From 2864fff2cf2caef5af28d386030076d7e95dd2b3 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Mon, 15 Apr 2024 12:23:28 -0500 Subject: [PATCH 01/61] implement offchain worker for OTC trades --- Cargo.lock | 34 ++ Cargo.toml | 2 + pallets/lbp/src/benchmarking.rs | 24 + pallets/lbp/src/weights.rs | 9 + pallets/omnipool/src/weights.rs | 9 + pallets/otc-settlements/Cargo.toml | 80 +++ pallets/otc-settlements/src/benchmarks.rs | 58 ++ pallets/otc-settlements/src/lib.rs | 500 +++++++++++++++ pallets/otc-settlements/src/mock.rs | 571 ++++++++++++++++++ pallets/otc-settlements/src/tests.rs | 569 +++++++++++++++++ pallets/otc-settlements/src/weights.rs | 71 +++ pallets/route-executor/src/lib.rs | 19 +- pallets/route-executor/src/weights.rs | 18 + pallets/stableswap/src/benchmarks.rs | 55 ++ pallets/stableswap/src/weights.rs | 9 + pallets/xyk/src/weights.rs | 9 + rococo-local/config.json | 55 +- runtime/hydradx/Cargo.toml | 4 + runtime/hydradx/src/assets.rs | 45 ++ runtime/hydradx/src/benchmarking/omnipool.rs | 45 ++ .../src/benchmarking/route_executor.rs | 42 +- runtime/hydradx/src/benchmarking/xyk.rs | 29 + runtime/hydradx/src/lib.rs | 11 + runtime/hydradx/src/weights/lbp.rs | 4 + runtime/hydradx/src/weights/mod.rs | 1 + runtime/hydradx/src/weights/omnipool.rs | 4 + .../hydradx/src/weights/otc_settlements.rs | 56 ++ runtime/hydradx/src/weights/route_executor.rs | 8 + runtime/hydradx/src/weights/stableswap.rs | 4 + runtime/hydradx/src/weights/xyk.rs | 4 + traits/src/router.rs | 8 + 31 files changed, 2325 insertions(+), 32 deletions(-) create mode 100644 pallets/otc-settlements/Cargo.toml create mode 100644 pallets/otc-settlements/src/benchmarks.rs create mode 100644 pallets/otc-settlements/src/lib.rs create mode 100644 pallets/otc-settlements/src/mock.rs create mode 100644 pallets/otc-settlements/src/tests.rs create mode 100644 pallets/otc-settlements/src/weights.rs create mode 100644 runtime/hydradx/src/weights/otc_settlements.rs diff --git a/Cargo.lock b/Cargo.lock index 674fa6350..73bca7702 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4695,6 +4695,7 @@ dependencies = [ "pallet-omnipool", "pallet-omnipool-liquidity-mining", "pallet-otc", + "pallet-otc-settlements", "pallet-preimage", "pallet-proxy", "pallet-referrals", @@ -8201,6 +8202,39 @@ dependencies = [ "test-utils", ] +[[package]] +name = "pallet-otc-settlements" +version = "1.1.0" +dependencies = [ + "env_logger 0.9.3", + "frame-benchmarking", + "frame-support", + "frame-system", + "hydra-dx-math", + "hydradx-traits", + "log", + "orml-tokens", + "orml-traits", + "pallet-balances", + "pallet-currencies", + "pallet-omnipool", + "pallet-otc", + "pallet-route-executor", + "pallet-xyk", + "parity-scale-codec", + "parking_lot 0.12.1", + "pretty_assertions", + "proptest", + "scale-info", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "test-utils", +] + [[package]] name = "pallet-preimage" version = "4.0.0-dev" diff --git a/Cargo.toml b/Cargo.toml index 96f425794..651693edf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ members = [ 'pallets/dynamic-fees', 'pallets/duster', 'pallets/otc', + 'pallets/otc-settlements', 'pallets/bonds', 'pallets/lbp', 'pallets/nft', @@ -72,6 +73,7 @@ pallet-nft = { path = "pallets/nft", default-features = false } pallet-omnipool = { path = "pallets/omnipool", default-features = false } pallet-omnipool-liquidity-mining = { path = "pallets/omnipool-liquidity-mining", default-features = false } pallet-otc = { path = "pallets/otc", default-features = false} +pallet-otc-settlements = { path = "pallets/otc-settlements", default-features = false} pallet-relaychain-info = { path = "pallets/relaychain-info", default-features = false } pallet-route-executor = { path = "pallets/route-executor", default-features = false } pallet-stableswap = { path = "pallets/stableswap", default-features = false } diff --git a/pallets/lbp/src/benchmarking.rs b/pallets/lbp/src/benchmarking.rs index d1826c906..9cc186000 100644 --- a/pallets/lbp/src/benchmarking.rs +++ b/pallets/lbp/src/benchmarking.rs @@ -257,6 +257,30 @@ benchmarks! { assert!( as TradeExecution>::calculate_buy(PoolType::LBP, asset_in, asset_out, amount).is_ok()); } verify{} + + calculate_spot_price { + let caller = funded_account::("caller", 0); + let fee_collector = funded_account::("fee_collector", 0); + let asset_in: AssetId = ASSET_A_ID; + let asset_out: AssetId = ASSET_B_ID; + let amount : Balance = 100_000_000; + let max_limit: Balance = 1_000_000_000; + + let pool_id = LBP::::pair_account_from_assets(ASSET_A_ID, ASSET_B_ID); + + LBP::::create_pool(RawOrigin::Root.into(), caller.clone(), ASSET_A_ID, ASSET_A_AMOUNT, ASSET_B_ID, ASSET_B_AMOUNT, INITIAL_WEIGHT, FINAL_WEIGHT, WeightCurveType::Linear, DEFAULT_FEE, fee_collector, 0)?; + ensure!(PoolData::::contains_key(&pool_id), "Pool does not exist."); + + let start = BlockNumberFor::::from(1u32); + let end = BlockNumberFor::::from(11u32); + + LBP::::update_pool_data(RawOrigin::Signed(caller).into(), pool_id, None, Some(start), Some(end), None, None, None, None, None)?; + + frame_system::Pallet::::set_block_number(BlockNumberFor::::from(2u32)); + + }: { + assert!( as TradeExecution>::calculate_spot_price(PoolType::LBP, asset_in, asset_out).is_ok()); + } } #[cfg(test)] diff --git a/pallets/lbp/src/weights.rs b/pallets/lbp/src/weights.rs index b43c189e4..310ebf53a 100644 --- a/pallets/lbp/src/weights.rs +++ b/pallets/lbp/src/weights.rs @@ -60,6 +60,7 @@ pub trait WeightInfo { fn router_execution_sell(c: u32, e: u32) -> Weight; fn router_execution_buy(c: u32, e: u32) -> Weight; fn calculate_buy() -> Weight; + fn calculate_spot_price() -> Weight; } /// Weights for pallet_lbp using the hydraDX node and recommended hardware. @@ -245,6 +246,10 @@ impl WeightInfo for HydraWeight { // Minimum execution time: 65_795_000 picoseconds. Weight::from_parts(66_370_000, 6156).saturating_add(T::DbWeight::get().reads(3_u64)) } + + fn calculate_spot_price() -> Weight { + Weight::zero() + } } // For backwards compatibility and tests @@ -428,4 +433,8 @@ impl WeightInfo for () { // Minimum execution time: 65_795_000 picoseconds. Weight::from_parts(66_370_000, 6156).saturating_add(RocksDbWeight::get().reads(3_u64)) } + + fn calculate_spot_price() -> Weight { + Weight::zero() + } } diff --git a/pallets/omnipool/src/weights.rs b/pallets/omnipool/src/weights.rs index 27d69e493..dc691a28b 100644 --- a/pallets/omnipool/src/weights.rs +++ b/pallets/omnipool/src/weights.rs @@ -62,6 +62,7 @@ pub trait WeightInfo { fn router_execution_buy(c: u32, e: u32) -> Weight; fn withdraw_protocol_liquidity() -> Weight; fn remove_token() -> Weight; + fn calculate_spot_price() -> Weight; } /// Weights for pallet_omnipool using the hydraDX node and recommended hardware. @@ -527,6 +528,10 @@ impl WeightInfo for HydraWeight { .saturating_add(T::DbWeight::get().reads(33)) .saturating_add(T::DbWeight::get().writes(22)) } + + fn calculate_spot_price() -> Weight { + Weight::zero() + } } // For backwards compatibility and tests @@ -990,4 +995,8 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(33)) .saturating_add(RocksDbWeight::get().writes(22)) } + + fn calculate_spot_price() -> Weight { + Weight::zero() + } } diff --git a/pallets/otc-settlements/Cargo.toml b/pallets/otc-settlements/Cargo.toml new file mode 100644 index 000000000..8415825e8 --- /dev/null +++ b/pallets/otc-settlements/Cargo.toml @@ -0,0 +1,80 @@ +[package] +name = 'pallet-otc-settlements' +version = '1.1.0' +description = 'A pallet with offchain worker closing OTC arbs' +authors = ['GalacticCouncil'] +edition = '2021' +license = 'Apache 2.0' +repository = "https://github.com/galacticcouncil/Hydradx-node" + +[dependencies] +# parity +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"] } +log = { version = "0.4.17", default-features = false } + +# primitives +sp-runtime = { workspace = true } +sp-std = { workspace = true } +sp-core = { workspace = true } +sp-io = { workspace = true } +sp-arithmetic = { workspace = true } + +# FRAME +frame-support = { workspace = true } +frame-system = { workspace = true } + +# HydraDX dependencies +hydradx-traits = { workspace = true } +pallet-otc = { workspace = true } +pallet-route-executor = { workspace = true } + +# ORML dependencies +orml-traits = { workspace = true } + +# Optional imports for benchmarking +frame-benchmarking = { workspace = true, optional = true } + +[dev-dependencies] +hydra-dx-math = { workspace = true } +pallet-omnipool = { workspace = true } +pallet-balances = { workspace = true } +pallet-xyk = { workspace = true } +pallet-currencies = { workspace = true } +sp-api = { workspace = true } +orml-tokens = { workspace = true, features=["std"] } +proptest = "1.0.0" +pretty_assertions = "1.2.1" +test-utils = { workspace = true } +parking_lot = "0.12.1" +env_logger = "*" + +[features] +default = ['std'] +std = [ + 'codec/std', + 'frame-support/std', + 'frame-system/std', + 'sp-runtime/std', + 'sp-core/std', + 'sp-io/std', + 'sp-std/std', + "scale-info/std", + "orml-tokens/std", + "hydradx-traits/std", + "hydra-dx-math/std", + "frame-benchmarking/std", + "pallet-otc/std", + "pallet-balances/std", + "pallet-currencies/std", + "pallet-route-executor/std", + "pallet-omnipool/std", + "pallet-xyk/std", +] + +runtime-benchmarks = [ + "frame-benchmarking", + "frame-system/runtime-benchmarks", + "frame-support/runtime-benchmarks", +] +try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/otc-settlements/src/benchmarks.rs b/pallets/otc-settlements/src/benchmarks.rs new file mode 100644 index 000000000..8d9272fc1 --- /dev/null +++ b/pallets/otc-settlements/src/benchmarks.rs @@ -0,0 +1,58 @@ +// Copyright (C) 2020-2023 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(feature = "runtime-benchmarks")] +use super::*; +use frame_benchmarking::{account, benchmarks}; +use frame_support::assert_ok; +use frame_system::RawOrigin; +use hydradx_traits::Create; +use orml_traits::MultiCurrency; + +pub const ONE: Balance = 1_000_000_000_000; +pub const HDX: u32 = 0; +pub const DOT: u32 = 2; + +benchmarks! { + where_clause { where + AssetIdOf: From, + ::Currency: MultiCurrency, + T: crate::Config, + T: pallet_otc::Config, + u32: From>, + ::AssetRegistry: Create> + } + settle_otc_order { + let account: T::AccountId = account("acc", 1, 1); + ::Currency::deposit(HDX.into(), &account, 1_000_000 * ONE)?; + ::Currency::deposit(DOT.into(), &account, 1_000_000 * ONE)?; + + assert_ok!( + pallet_otc::Pallet::::place_order(RawOrigin::Signed(account.clone()).into(), HDX.into(), DOT.into(), 100_000 * ONE, 200_001 * ONE, true) + ); + + let route = ::Router::get_route(AssetPair { + asset_in: DOT.into(), + asset_out: HDX.into(), + }); + }: _(RawOrigin::None, 0u32, 762_939_453_125, route) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::mock::*; + use frame_benchmarking::impl_benchmark_test_suite; + + impl_benchmark_test_suite!(Pallet, super::ExtBuilder::default().build().0, super::Test); +} diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs new file mode 100644 index 000000000..9ae14b226 --- /dev/null +++ b/pallets/otc-settlements/src/lib.rs @@ -0,0 +1,500 @@ +// This file is part of galacticcouncil/warehouse. +// Copyright (C) 2020-2023 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)] + +use frame_support::{pallet_prelude::*, PalletId}; +use frame_system::{ + ensure_none, + offchain::{SendTransactionTypes, SubmitTransaction}, + pallet_prelude::{BlockNumberFor, OriginFor}, + RawOrigin, +}; +use hydradx_traits::router::{AmmTradeWeights, AmountInAndOut, AssetPair, RouteProvider, RouteSpotPriceProvider, RouterT, Trade}; +use orml_traits::{GetByKey, MultiCurrency}; +pub use pallet_otc::OrderId; +use sp_arithmetic::traits::{CheckedMul, Saturating}; +use sp_arithmetic::{ArithmeticError, FixedPointNumber, FixedU128}; +use sp_runtime::offchain::storage::StorageValueRef; +use sp_runtime::offchain::storage_lock::{StorageLock, Time}; +use sp_runtime::offchain::Duration; +use sp_runtime::traits::AccountIdConversion; +use sp_std::vec; +use sp_std::vec::Vec; + +#[cfg(test)] +mod mock; +#[cfg(test)] +mod tests; + +#[cfg(feature = "runtime-benchmarks")] +mod benchmarks; + +pub mod weights; + +use weights::WeightInfo; + +// Re-export pallet items so that they can be accessed from the crate namespace. +pub use pallet::*; + +pub type Balance = u128; +pub type NamedReserveIdentifier = [u8; 8]; + +pub const PALLET_ID: PalletId = PalletId(*b"otcsettl"); + +pub const NAMED_RESERVE_ID: NamedReserveIdentifier = *b"otcorder"; + +// value taken from https://github.com/substrate-developer-hub/recipes/blob/master/pallets/ocw-demo/src/lib.rs +pub const UNSIGNED_TXS_PRIORITY: u64 = 100; + +pub const OFFCHAIN_WORKER_DATA: &[u8] = b"hydradx/otc-settlements/data/"; +pub const OFFCHAIN_WORKER_DATA_LAST_UPDATE: &[u8] = b"hydradx/otc-settlements/data-last-update/"; +pub const OFFCHAIN_WORKER_LOCK: &[u8] = b"hydradx/otc-settlements/lock/"; +pub const OFFCHAIN_WORKER_MAX_ITERATIONS: &[u8] = b"hydradx/otc-settlements/max-iterations/"; +pub const LOCK_DURATION: u64 = 5_000; // 5 seconds +pub const NUM_OF_ITERATIONS: u32 = 40; + +pub type AssetIdOf = ::AssetId; + +type SortedOtcsStorageType = (OrderId, FixedU128, FixedU128, FixedU128); + +#[frame_support::pallet] +pub mod pallet { + use super::*; + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::config] + pub trait Config: frame_system::Config + pallet_otc::Config + SendTransactionTypes> { + /// Named reservable multi currency + type Currency: MultiCurrency, Balance = Balance>; + + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + + type Router: RouteProvider> + + RouterT, Balance, Trade>, AmountInAndOut> + + RouteSpotPriceProvider>; + + type ExistentialDeposits: GetByKey, Balance>; + + /// Account who receives the profit. + #[pallet::constant] + type ProfitReceiver: Get; + + #[pallet::constant] + type ExistentialDepositMultiplier: Get; + + #[pallet::constant] + type PricePrecision: Get; + + /// Weight information for the extrinsics. + type WeightInfo: WeightInfo; + + /// Weight information for the extrinsics. + type RouterWeightInfo: AmmTradeWeights>>; + } + + #[pallet::hooks] + impl Hooks> for Pallet { + fn offchain_worker(block_number: BlockNumberFor) { + // limit the cases when the offchain worker run + if sp_io::offchain::is_validator() { + Self::sort_otcs(block_number); + Self::settle_otcs(); + } + } + } + + #[pallet::validate_unsigned] + impl ValidateUnsigned for Pallet { + type Call = Call; + + fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity { + match source { + TransactionSource::External => { + // receiving unsigned transaction from network - disallow + return InvalidTransaction::Call.into(); + } + TransactionSource::Local => {} // produced by off-chain worker + TransactionSource::InBlock => {} // some other node included it in a block + }; + + let valid_tx = |provide| { + ValidTransaction::with_tag_prefix("settle-otc-with-router") + .priority(UNSIGNED_TXS_PRIORITY) + .and_provides([&provide]) + .longevity(3) + .propagate(false) + .build() + }; + + match call { + Call::settle_otc_order { .. } => valid_tx(b"settle_otc_order".to_vec()), + _ => InvalidTransaction::Call.into(), + } + } + } + + #[pallet::event] + #[pallet::generate_deposit(pub(crate) fn deposit_event)] + pub enum Event { + /// An Order has been cancelled + Executed { + otc_id: OrderId, + otc_asset_in: AssetIdOf, + otc_asset_out: AssetIdOf, + otc_amount_in: Balance, + otc_amount_out: Balance, + trade_amount_in: Balance, + trade_amount_out: Balance, + }, + } + + #[pallet::error] + pub enum Error { + /// Order cannot be found + OrderNotFound, + PriceNotAvailable, + InvalidConditions, + TradeAmountTooHigh, + TradeAmountTooLow, + } + + #[pallet::call] + impl Pallet { + #[pallet::call_index(0)] + #[pallet::weight(::WeightInfo::settle_otc_order() + .saturating_add(::RouterWeightInfo::sell_weight(route)) + .saturating_add(::RouterWeightInfo::get_route_weight()) + .saturating_add(::RouterWeightInfo::calculate_spot_price_weight(route)) + )] + pub fn settle_otc_order(origin: OriginFor, otc_id: OrderId, amount: Balance, route: Vec>>) -> DispatchResult { + ensure_none(origin)?; + + Self::settle_otc(otc_id, amount, route) + } + } +} + +impl Pallet { + pub fn account_id() -> T::AccountId { + PALLET_ID.into_account_truncating() + } + + #[cfg(not(feature = "runtime-benchmarks"))] + fn ensure_min_profit_amount(asset: T::AssetId, amount: Balance) -> DispatchResult { + let min_amount = ::ExistentialDeposits::get(&asset) + .checked_mul(::ExistentialDepositMultiplier::get().into()) + .ok_or(ArithmeticError::Overflow)?; + + // tell the binary search algo to find higher values + ensure!(amount >= min_amount, Error::::TradeAmountTooLow); + + Ok(()) + } + + #[cfg(feature = "runtime-benchmarks")] + fn ensure_min_profit_amount(_asset: T::AssetId, _amount: Balance) -> DispatchResult { + Ok(()) + } + + // Executes two trades: asset_a -> OTC -> asset_b, and asset_b -> Router -> asset_a + pub fn settle_otc(otc_id: OrderId, amount: Balance, route: Vec>>) -> DispatchResult { + let pallet_acc = Self::account_id(); + + let otc = >::get(otc_id).ok_or(Error::::OrderNotFound)?; + let (asset_a, asset_b) = (otc.asset_in, otc.asset_out); + + // get initial account balances + let asset_a_balance_before = ::Currency::free_balance(asset_a, &pallet_acc); + let asset_b_balance_before = ::Currency::free_balance(asset_b, &pallet_acc); + + ::Currency::deposit(asset_a, &pallet_acc, amount)?; + + if !otc.partially_fillable { + ensure!(otc.amount_out == amount, Error::::InvalidConditions); + } + + ensure!(route == T::Router::get_route(AssetPair { + asset_in: asset_b, + asset_out: asset_a, + }), Error::::InvalidConditions); + + // get initial otc and router price + let otc_price = + FixedU128::checked_from_rational(otc.amount_out, otc.amount_in).ok_or(ArithmeticError::Overflow)?; + + // TODO: remove + // let router_price_before = T::Router::spot_price(&route).ok_or(Error::::PriceNotAvailable)?; + log::debug!( + target: "offchain_worker::settle_otc", + "initial router price: {:?} otc_price: {:?} ", + T::Router::spot_price(&route).ok_or(Error::::PriceNotAvailable)?, + otc_price + ); + + if otc.partially_fillable && amount != otc.amount_in { + log::debug!( + target: "offchain_worker::settle_otc", + "calling partial fill order: amount {:?} ", amount); + pallet_otc::Pallet::::partial_fill_order(RawOrigin::Signed(pallet_acc.clone()).into(), otc_id, amount)?; + } else { + log::debug!( + target: "offchain_worker::settle_otc", + "calling fill order"); + pallet_otc::Pallet::::fill_order(RawOrigin::Signed(pallet_acc.clone()).into(), otc_id)?; + }; + + let otc_amount_out = ::Currency::free_balance(asset_b, &pallet_acc) + .checked_sub(asset_b_balance_before) + .unwrap(); + + log::debug!( + target: "offchain_worker::settle_otc", + "calling router sell: amount_in {:?} ", otc_amount_out); + T::Router::sell( + RawOrigin::Signed(pallet_acc.clone()).into(), + asset_b, + asset_a, + otc_amount_out, + 1, + route.clone(), + ) + .map_err(|_| Error::::TradeAmountTooHigh)?; + // There are 3 possible types of error: + // min trade limit not reached - we start with the largest possible amount, so we can't increase it more. + // max trade limit reached - we are interested in this one. We can decrease the amount and try again. + // some other error - we can't handle this one properly. + + // // Compare OTC and Router price + let router_price_after = T::Router::spot_price(&route).unwrap(); + log::debug!( + target: "offchain_worker::settle_otc", + "final router price: {:?} otc_price: {:?} ", + router_price_after, + otc_price + ); + + // in the case of fully fillable orders, the resulting price is not important + if otc.partially_fillable { + let price_diff = { + if otc_price > router_price_after { + otc_price.saturating_sub(router_price_after) + } else { + router_price_after.saturating_sub(otc_price) + } + }; + + let price_precision = T::PricePrecision::get() + .checked_mul(&otc_price) + .ok_or(ArithmeticError::Overflow)?; + if price_diff > price_precision { + ensure!(router_price_after <= otc_price, Error::::TradeAmountTooHigh); + ensure!(router_price_after >= otc_price, Error::::TradeAmountTooLow); + } + } + + let asset_a_balance_after_router_trade = ::Currency::free_balance(asset_a, &pallet_acc); + + let profit = asset_a_balance_after_router_trade + .checked_sub(amount) + .ok_or(ArithmeticError::Overflow)?; + + Self::ensure_min_profit_amount(asset_a, profit)?; + + ::Currency::transfer(asset_a, &pallet_acc, &T::ProfitReceiver::get(), profit)?; + + ::Currency::withdraw(asset_a, &pallet_acc, amount)?; + + let asset_a_balance_after = ::Currency::free_balance(asset_a, &pallet_acc); + let asset_b_balance_after = ::Currency::free_balance(asset_b, &pallet_acc); + + ensure!( + asset_a_balance_after == asset_a_balance_before, + Error::::InvalidConditions + ); + ensure!( + asset_b_balance_after == asset_b_balance_before, + Error::::InvalidConditions + ); + + Self::deposit_event(Event::Executed { + otc_id, + otc_asset_in: asset_a, + otc_asset_out: asset_b, + otc_amount_in: amount, + otc_amount_out, + trade_amount_in: otc_amount_out, + trade_amount_out: amount + profit, + }); + + Ok(()) + } + + fn try_update_last_block_storage(block_number: BlockNumberFor) -> bool { + let last_update_storage = StorageValueRef::persistent(OFFCHAIN_WORKER_DATA_LAST_UPDATE); + let last_update = last_update_storage + .get::>() + .unwrap_or_default() + .unwrap_or_default(); + + if block_number > last_update { + last_update_storage.set(&block_number); + true + } else { + false + } + } + + fn sort_otcs(block_number: BlockNumberFor) { + log::debug!( + target: "offchain_worker::sort_otcs", + "sort_otcs()"); + + // acquire offchain worker lock. + let lock_expiration = Duration::from_millis(LOCK_DURATION); + let mut lock = StorageLock::<'_, Time>::with_deadline(OFFCHAIN_WORKER_LOCK, lock_expiration); + + if Self::try_update_last_block_storage(block_number) { + if let Ok(_guard) = lock.try_lock() { + let sorted_otcs = StorageValueRef::persistent(OFFCHAIN_WORKER_DATA); + + let mut list = vec![]; + for (otc_id, otc) in >::iter() { + let otc_price = FixedU128::checked_from_rational(otc.amount_out, otc.amount_in); + + let route = T::Router::get_route(AssetPair { + asset_in: otc.asset_out, + asset_out: otc.asset_in, + }); + let router_price_before = T::Router::spot_price(&route.clone()); + + if let (Some(otc_price), Some(router_price)) = (otc_price, router_price_before) { + // otc's with no arb opportunity are at the end of the list and are not sorted + let price_diff = otc_price.saturating_sub(router_price); + list.push((otc_id, otc_price, router_price, price_diff)); + } + } + + // sort the list by the price diff + list.sort_by(|a, b| b.3.partial_cmp(&a.3).unwrap()); + + sorted_otcs.set(&list); + }; + } + } + + fn settle_otcs() { + log::debug!( + target: "offchain_worker::settle_otcs", + "settle OTCs"); + // iterate over sorted OTCs + let sorted_otcs_storage = StorageValueRef::persistent(OFFCHAIN_WORKER_DATA); + let sorted_otcs = sorted_otcs_storage + .get::>() + .unwrap_or_default() + .unwrap_or_default(); + + for (otc_id, otc_price, router_price_before, _price_diff) in sorted_otcs.iter() { + log::debug!( + target: "offchain_worker::settle_otcs", + "test OTC id {:?} ", otc_id); + + if router_price_before > otc_price { + log::debug!( + target: "offchain_worker::settle_otcs", + "no arb, skipping OTC: {:?}", otc_id); + continue; + } + + let otc = >::get(otc_id).unwrap(); + let route = T::Router::get_route(AssetPair { + asset_in: otc.asset_out, + asset_out: otc.asset_in, + }); + let maybe_amount = Self::try_find_trade_amount(*otc_id, route.clone()); + if let Some(sell_amt) = maybe_amount { + log::debug!( + target: "offchain_worker::settle_otcs", + "Sending TX for OTC id: {:?} amount: {:?}", + otc_id, + sell_amt + ); + let call = Call::settle_otc_order { + otc_id: *otc_id, + amount: sell_amt, + route, + }; + let _ = SubmitTransaction::>::submit_unsigned_transaction(call.into()); + } + } + } + + fn try_find_trade_amount(otc_id: OrderId, route: Vec>>) -> Option { + let otc = >::get(otc_id).unwrap(); + + // use binary search to determine the correct sell amount + let mut sell_amt = otc.amount_in; // start by trying to fill the whole order + let mut sell_amt_up = sell_amt; + let mut sell_amt_down = 0; // TODO: set to some min trade amount + + let iters = if !otc.partially_fillable { 1 } else { NUM_OF_ITERATIONS }; + for i in 0..iters { + log::debug!( + target: "offchain_worker::settle_otcs", + "iteration: {:?}", i); + log::debug!( + target: "offchain_worker::settle_otcs::binary_search", + "\nsell_amt: {:?}\nsell_amt_up: {:?}\nsell_amt_down: {:?}", sell_amt, sell_amt_up, sell_amt_down); + match Self::settle_otc_order(RawOrigin::None.into(), otc_id, sell_amt, route.clone()) { + Ok(_) => { + log::debug!( + target: "offchain_worker::settle_otcs", + "Extrinsic executed successfully for OTC id: {:?} amount: {:?}", + otc_id, + sell_amt + ); + return Some(sell_amt); + } + Err(error) => { + if error == Error::::TradeAmountTooHigh.into() { + log::debug!( + target: "offchain_worker::settle_otcs", + "Extrinsic failed: trade amount too high for OTC id: {:?} amount: {:?}", otc_id, sell_amt); + + sell_amt_up = sell_amt; + } else if error == Error::::TradeAmountTooLow.into() { + log::debug!( + target: "offchain_worker::settle_otcs", + "Extrinsic failed: trade amount too low for OTC id: {:?} amount: {:?}", otc_id, sell_amt); + + sell_amt_down = sell_amt; + } else { + log::debug!( + target: "offchain_worker::settle_otcs", + "Extrinsic failed with error for OTC id: {:?} amount: {:?} error: {:?}", otc_id, sell_amt, error); + return None; + } + } + } + if sell_amt_down == sell_amt_up { + return None; + } + sell_amt = (sell_amt_up + sell_amt_down) / 2; + } + None + } +} diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs new file mode 100644 index 000000000..e4ba10e89 --- /dev/null +++ b/pallets/otc-settlements/src/mock.rs @@ -0,0 +1,571 @@ +// This file is part of galacticcouncil/warehouse. +// Copyright (C) 2020-2023 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_otc_settlements; +use crate::*; +use frame_support::traits::tokens::nonfungibles::{Create, Inspect, Mutate}; +use frame_support::{ + assert_ok, parameter_types, + traits::{Everything, Nothing}, +}; +use frame_system::EnsureRoot; +use hydra_dx_math::ema::EmaPrice; +use hydradx_traits::router::PoolType; +use hydradx_traits::AssetKind; +use orml_traits::parameter_type_with_key; +use pallet_currencies::fungibles::FungibleCurrencies; +use pallet_currencies::BasicCurrencyAdapter; +use pallet_omnipool::traits::ExternalPriceProvider; +use sp_core::offchain::{ + testing::PoolState, testing::TestOffchainExt, testing::TestTransactionPoolExt, OffchainDbExt, OffchainWorkerExt, + TransactionPoolExt, +}; +use sp_core::H256; +use sp_runtime::Permill; +use sp_runtime::{ + traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, +}; +use sp_std::sync::Arc; + +type Block = frame_system::mocking::MockBlock; + +pub type AccountId = u64; +pub type Amount = i128; +pub type AssetId = u32; +pub type Balance = u128; +pub type NamedReserveIdentifier = [u8; 8]; + +pub const HDX: AssetId = 0; +pub const LRNA: AssetId = 1; +pub const DAI: AssetId = 2; +pub const DOT: AssetId = 3; +pub const KSM: AssetId = 4; +pub const BTC: AssetId = 5; + +pub const ONE: Balance = 1_000_000_000_000; + +pub const ALICE: AccountId = 1; +pub const BOB: AccountId = 2; + +frame_support::construct_runtime!( + pub enum Test + { + System: frame_system, + Balances: pallet_balances, + Tokens: orml_tokens, + Currencies: pallet_currencies, + OtcSettlements: pallet_otc_settlements, + OTC: pallet_otc, + Omnipool: pallet_omnipool, + Router: pallet_route_executor, + XYK: pallet_xyk, + } +); + +parameter_types! { + pub ExistentialDepositMultiplier: u8 = 5; + pub MinProfitLimit: Balance = 10_000_000_000_000; + pub PricePrecision: FixedU128 = FixedU128::from_rational(1, 1_000_000); +} + +parameter_type_with_key! { + pub ExistentialDeposits: |_currency_id: AssetId| -> Balance { + 1 + }; +} + +impl pallet_otc_settlements::Config for Test { + type Currency = Currencies; + type RuntimeEvent = RuntimeEvent; + type Router = Router; + type ExistentialDeposits = ExistentialDeposits; + type ProfitReceiver = TreasuryAccount; + type ExistentialDepositMultiplier = ExistentialDepositMultiplier; + type PricePrecision = PricePrecision; + type WeightInfo = (); + type RouterWeightInfo = (); +} + +impl pallet_otc::Config for Test { + type AssetId = AssetId; + type AssetRegistry = MockedAssetRegistry; + type Currency = Currencies; + type RuntimeEvent = RuntimeEvent; + type ExistentialDeposits = ExistentialDeposits; + type ExistentialDepositMultiplier = ExistentialDepositMultiplier; + type WeightInfo = (); +} + +parameter_types! { + pub DefaultRoutePoolType: PoolType = PoolType::Omnipool; +} + +pub struct MockedAssetRegistry; + +impl hydradx_traits::registry::Inspect for MockedAssetRegistry { + type AssetId = AssetId; + type Location = (); + + fn is_sufficient(_id: Self::AssetId) -> bool { + true + } + + fn exists(_id: Self::AssetId) -> bool { + true + } + + fn decimals(_id: Self::AssetId) -> Option { + unimplemented!() + } + + fn asset_type(_id: Self::AssetId) -> Option { + unimplemented!() + } + + fn is_banned(_id: Self::AssetId) -> bool { + unimplemented!() + } + + fn asset_name(_id: Self::AssetId) -> Option> { + unimplemented!() + } + + fn asset_symbol(_id: Self::AssetId) -> Option> { + unimplemented!() + } + + fn existential_deposit(_id: Self::AssetId) -> Option { + unimplemented!() + } +} + +impl pallet_route_executor::Config for Test { + type RuntimeEvent = RuntimeEvent; + type AssetId = AssetId; + type Balance = Balance; + type NativeAssetId = HDXAssetId; + type Currency = FungibleCurrencies; + type AMM = (Omnipool, XYK); + type InspectRegistry = MockedAssetRegistry; + type DefaultRoutePoolType = DefaultRoutePoolType; + type WeightInfo = (); + type TechnicalOrigin = EnsureRoot; +} + +parameter_types! { + pub const BlockHashCount: u64 = 250; + pub const SS58Prefix: u8 = 63; + pub const MaxReserves: u32 = 50; +} + +impl frame_system::Config for Test { + type BaseCallFilter = Everything; + type BlockWeights = (); + type BlockLength = (); + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type Nonce = u64; + type Block = Block; + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = u64; + type Lookup = IdentityLookup; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = BlockHashCount; + type DbWeight = (); + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = SS58Prefix; + type OnSetCode = (); + type MaxConsumers = frame_support::traits::ConstU32<16>; +} + +impl orml_tokens::Config for Test { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type Amount = Amount; + type CurrencyId = AssetId; + type WeightInfo = (); + type ExistentialDeposits = ExistentialDeposits; + type MaxLocks = (); + type DustRemovalWhitelist = Nothing; + type ReserveIdentifier = NamedReserveIdentifier; + type MaxReserves = MaxReserves; + type CurrencyHooks = (); +} + +parameter_types! { + pub const HDXAssetId: AssetId = HDX; + pub const LRNAAssetId: AssetId = LRNA; + pub const PositionCollectionId: u32= 1000; + + pub const ExistentialDeposit: u128 = 500; + pub ProtocolFee: Permill = Permill::from_percent(0); + pub AssetFee: Permill = Permill::from_percent(0); + pub AssetWeightCap: Permill = Permill::from_percent(100); + pub MinAddedLiquidity: Balance = 1000u128; + pub MinTradeAmount: Balance = 1000u128; + pub MaxInRatio: Balance = 1u128; + pub MaxOutRatio: Balance = 1u128; + pub const TVLCap: Balance = Balance::MAX; + + pub const TransactionByteFee: Balance = 10 * ONE / 100_000; + + pub const TreasuryPalletId: PalletId = PalletId(*b"aca/trsy"); + pub TreasuryAccount: AccountId = TreasuryPalletId::get().into_account_truncating(); +} + +impl pallet_balances::Config for Test { + type MaxLocks = (); + type Balance = Balance; + type RuntimeEvent = RuntimeEvent; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = frame_system::Pallet; + type WeightInfo = (); + type MaxReserves = MaxReserves; + type ReserveIdentifier = NamedReserveIdentifier; + type FreezeIdentifier = (); + type MaxFreezes = (); + type MaxHolds = (); + type RuntimeHoldReason = (); +} + +impl pallet_currencies::Config for Test { + type RuntimeEvent = RuntimeEvent; + type MultiCurrency = Tokens; + type NativeCurrency = BasicCurrencyAdapter; + type GetNativeCurrencyId = HDXAssetId; + type WeightInfo = (); +} + +parameter_types! { + pub const MinTradingLimit: Balance = 1_000; + pub const MinPoolLiquidity: Balance = 1_000; + pub const OracleSourceIdentifier: hydradx_traits::Source = *b"hydraxyk"; + pub XYKExchangeFee: (u32, u32) = (3, 1_000); + pub const DiscountedFee: (u32, u32) = (7, 10_000); +} + +pub struct AllowPools; + +impl hydradx_traits::CanCreatePool for AllowPools { + fn can_create(_asset_a: AssetId, _asset_b: AssetId) -> bool { + true + } +} + +pub struct AssetPairAccountIdTest; +impl hydradx_traits::AssetPairAccountIdFor for AssetPairAccountIdTest { + fn from_assets(asset_a: AssetId, asset_b: AssetId, _: &str) -> u64 { + let mut a = asset_a as u128; + let mut b = asset_b as u128; + if a > b { + std::mem::swap(&mut a, &mut b) + } + (a * 1000 + b) as u64 + } +} + +impl hydradx_traits::Create for MockedAssetRegistry +where + AssetId: From, +{ + type Error = DispatchError; + type Name = BoundedVec>; + type Symbol = BoundedVec>; + + fn register_asset( + _asset_id: Option, + _name: Option, + _kind: AssetKind, + _existential_deposit: Option, + _symbol: Option, + _decimals: Option, + _location: Option, + _xcm_rate_limit: Option, + _is_sufficient: bool, + ) -> Result { + unimplemented!() + } + + fn register_insufficient_asset( + _asset_id: Option, + _name: Option, + _kind: AssetKind, + _existential_deposit: Option, + _symbol: Option, + _decimals: Option, + _location: Option, + _xcm_rate_limit: Option, + ) -> Result { + unimplemented!() + } + fn get_or_register_asset( + _name: Self::Name, + _kind: AssetKind, + _existential_deposit: Option, + _symbol: Option, + _decimals: Option, + _location: Option, + _xcm_rate_limit: Option, + _is_sufficient: bool, + ) -> Result { + Ok(AssetId::default()) + } +} + +pub struct DummyDuster; + +impl hydradx_traits::pools::DustRemovalAccountWhitelist for DummyDuster { + type Error = DispatchError; + + fn add_account(_account: &AccountId) -> Result<(), Self::Error> { + unimplemented!() + } + + fn remove_account(_account: &AccountId) -> Result<(), Self::Error> { + unimplemented!() + } +} + +impl pallet_xyk::Config for Test { + type RuntimeEvent = RuntimeEvent; + type AssetRegistry = MockedAssetRegistry; + type AssetPairAccountId = AssetPairAccountIdTest; + type Currency = Currencies; + type NativeAssetId = HDXAssetId; + type WeightInfo = (); + type GetExchangeFee = XYKExchangeFee; + type MinTradingLimit = MinTradingLimit; + type MinPoolLiquidity = MinPoolLiquidity; + type MaxInRatio = MaxInRatio; + type MaxOutRatio = MaxOutRatio; + type CanCreatePool = AllowPools; + type AMMHandler = (); + type DiscountedFee = DiscountedFee; + type NonDustableWhitelistHandler = DummyDuster; + type OracleSource = OracleSourceIdentifier; +} + +impl pallet_omnipool::Config for Test { + type RuntimeEvent = RuntimeEvent; + type AssetId = AssetId; + type PositionItemId = u32; + type Currency = Currencies; + type HubAssetId = LRNAAssetId; + type WeightInfo = (); + type HdxAssetId = HDXAssetId; + type NFTCollectionId = PositionCollectionId; + type NFTHandler = DummyNFT; + type AssetRegistry = MockedAssetRegistry; + type MinimumTradingLimit = MinTradeAmount; + type MinimumPoolLiquidity = MinAddedLiquidity; + type TechnicalOrigin = EnsureRoot; + type MaxInRatio = MaxInRatio; + type MaxOutRatio = MaxOutRatio; + type CollectionId = u32; + type AuthorityOrigin = EnsureRoot; + type OmnipoolHooks = (); + type PriceBarrier = (); + type MinWithdrawalFee = (); + type ExternalPriceOracle = WithdrawFeePriceOracle; + type Fee = FeeProvider; +} + +pub struct DummyNFT; + +impl> Inspect for DummyNFT { + type ItemId = u32; + type CollectionId = u32; + + fn owner(_class: &Self::CollectionId, _instance: &Self::ItemId) -> Option { + todo!() + } +} + +impl> Create for DummyNFT { + fn create_collection(_class: &Self::CollectionId, _who: &AccountId, _admin: &AccountId) -> DispatchResult { + Ok(()) + } +} + +impl + Into + Copy> Mutate for DummyNFT { + fn mint_into(_class: &Self::CollectionId, _instance: &Self::ItemId, _who: &AccountId) -> DispatchResult { + Ok(()) + } + + fn burn( + _class: &Self::CollectionId, + _instance: &Self::ItemId, + _maybe_check_owner: Option<&AccountId>, + ) -> DispatchResult { + Ok(()) + } +} + +pub struct WithdrawFeePriceOracle; + +impl ExternalPriceProvider for WithdrawFeePriceOracle { + type Error = DispatchError; + + fn get_price(_asset_a: AssetId, _asset_b: AssetId) -> Result { + todo!() + } + + fn get_price_weight() -> Weight { + todo!() + } +} + +pub struct FeeProvider; + +impl GetByKey for FeeProvider { + fn get(_: &AssetId) -> (Permill, Permill) { + (Permill::from_percent(0), Permill::from_percent(0)) + } +} + +pub(crate) type Extrinsic = sp_runtime::testing::TestXt; +impl frame_system::offchain::SendTransactionTypes for Test +where + RuntimeCall: From, +{ + type OverarchingCall = RuntimeCall; + type Extrinsic = Extrinsic; +} + +pub struct ExtBuilder { + endowed_accounts: Vec<(u64, AssetId, Balance)>, + init_pool: Option<(FixedU128, FixedU128)>, + omnipool_liquidity: Vec<(AccountId, AssetId, Balance)>, //who, asset, amount/ +} + +impl Default for ExtBuilder { + fn default() -> Self { + Self { + endowed_accounts: vec![ + (ALICE, HDX, 1_000_000_000_000 * ONE), + (ALICE, LRNA, 1_000_000_000_000 * ONE), + (ALICE, DAI, 1_000_000_000_000 * ONE), + (ALICE, DOT, 1_000_000_000_000 * ONE), + (ALICE, KSM, 1_000_000_000_000 * ONE), + (ALICE, BTC, 1_000_000_000_000 * ONE), + (BOB, HDX, 1_000_000_000 * ONE), + (BOB, DAI, 1_000_000_000 * ONE), + (Omnipool::protocol_account(), HDX, 1_000_000 * ONE), + (Omnipool::protocol_account(), LRNA, 1_000_000 * ONE), + (Omnipool::protocol_account(), DAI, 1_000_000 * ONE), + (Omnipool::protocol_account(), DOT, 1_000_000 * ONE), + (Omnipool::protocol_account(), KSM, 1_000_000 * ONE), + ], + init_pool: Some((FixedU128::from_float(0.5), FixedU128::from(1))), + omnipool_liquidity: vec![(ALICE, KSM, 5_000 * ONE)], + } + } +} + +impl ExtBuilder { + pub fn build(self) -> (sp_io::TestExternalities, Arc>) { + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); + + let mut initial_native_accounts: Vec<(AccountId, Balance)> = vec![]; + let additional_accounts: Vec<(AccountId, Balance)> = self + .endowed_accounts + .iter() + .filter(|a| a.1 == HDX) + .flat_map(|(x, _, amount)| vec![(*x, *amount)]) + .collect::<_>(); + + initial_native_accounts.extend(additional_accounts); + pallet_balances::GenesisConfig:: { + balances: initial_native_accounts, + } + .assimilate_storage(&mut t) + .unwrap(); + + orml_tokens::GenesisConfig:: { + balances: self.endowed_accounts, + } + .assimilate_storage(&mut t) + .unwrap(); + + let mut ext: sp_io::TestExternalities = t.into(); + + ext.execute_with(|| { + System::set_block_number(1); + }); + + if let Some((stable_price, native_price)) = self.init_pool { + ext.execute_with(|| { + assert_ok!(Omnipool::add_token( + RuntimeOrigin::root(), + HDXAssetId::get(), + native_price, + Permill::from_percent(100), + Omnipool::protocol_account(), + )); + assert_ok!(Omnipool::add_token( + RuntimeOrigin::root(), + DAI, + stable_price, + Permill::from_percent(100), + Omnipool::protocol_account(), + )); + assert_ok!(Omnipool::add_token( + RuntimeOrigin::root(), + DOT, + stable_price, + Permill::from_percent(100), + Omnipool::protocol_account(), + )); + assert_ok!(Omnipool::add_token( + RuntimeOrigin::root(), + KSM, + stable_price, + Permill::from_percent(100), + Omnipool::protocol_account(), + )); + + for p in self.omnipool_liquidity { + assert_ok!(Omnipool::add_liquidity(RuntimeOrigin::signed(p.0), p.1, p.2)); + } + }); + } + + let (offchain, _offchain_state) = TestOffchainExt::with_offchain_db(ext.offchain_db()); + ext.register_extension(OffchainDbExt::new(offchain.clone())); + ext.register_extension(OffchainWorkerExt::new(offchain)); + let (pool, pool_state) = TestTransactionPoolExt::new(); + ext.register_extension(TransactionPoolExt::new(pool)); + + ext.persist_offchain_overlay(); + + (ext, pool_state) + } +} + +pub fn expect_events(e: Vec) { + e.into_iter().for_each(frame_system::Pallet::::assert_has_event); +} + +pub fn calculate_otc_price(otc: &pallet_otc::Order) -> FixedU128 { + FixedU128::checked_from_rational(otc.amount_out, otc.amount_in).unwrap() +} diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs new file mode 100644 index 000000000..82f0bc30a --- /dev/null +++ b/pallets/otc-settlements/src/tests.rs @@ -0,0 +1,569 @@ +// 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. + +#![allow(clippy::bool_assert_comparison)] +use super::*; +pub use crate::mock::*; +use frame_support::{assert_ok, assert_storage_noop}; + +#[test] +fn offchain_worker_should_store_last_update_in_storage() { + let (mut ext, _) = ExtBuilder::default().build(); + ext.execute_with(|| { + frame_system::Pallet::::set_block_number(10); + + let last_update_storage = StorageValueRef::persistent(OFFCHAIN_WORKER_DATA_LAST_UPDATE); + let last_update = last_update_storage + .get::>() + .unwrap_or_default() + .unwrap_or_default(); + + assert!(last_update == 0); // not stored, default value + + frame_system::Pallet::::set_block_number(11); + + let block_num = frame_system::Pallet::::block_number(); + + >>::offchain_worker(block_num); + + let last_update = last_update_storage + .get::>() + .unwrap_or_default() + .unwrap_or_default(); + + assert!(last_update == block_num); + + frame_system::Pallet::::set_block_number(12); + + let block_num = frame_system::Pallet::::block_number(); + + >>::offchain_worker(block_num); + + let last_update = last_update_storage + .get::>() + .unwrap_or_default() + .unwrap_or_default(); + + assert!(last_update == block_num); + + // skip some blocks + frame_system::Pallet::::set_block_number(15); + + let block_num = frame_system::Pallet::::block_number(); + + >>::offchain_worker(block_num); + + let last_update = last_update_storage + .get::>() + .unwrap_or_default() + .unwrap_or_default(); + + assert!(last_update == block_num); + + // older block should not update the storage + frame_system::Pallet::::set_block_number(14); + + let last_updated_block = 15; + + >>::offchain_worker(block_num); + + let last_update = last_update_storage + .get::>() + .unwrap_or_default() + .unwrap_or_default(); + + assert!(last_update == last_updated_block); + }); +} + +#[test] +fn otcs_list_storage_should_be_sorted_on_new_block() { + let (mut ext, _) = ExtBuilder::default().build(); + ext.execute_with(|| { + place_orders(); + + let sorted_list_of_otcs_storage = StorageValueRef::persistent(OFFCHAIN_WORKER_DATA); + let sorted_list_of_otcs = sorted_list_of_otcs_storage + .get::>() + .unwrap_or_default() + .unwrap_or_default(); + + assert!(sorted_list_of_otcs.is_empty()); // not stored, default value + + frame_system::Pallet::::set_block_number(15); + let block_num = frame_system::Pallet::::block_number(); + + OtcSettlements::sort_otcs(block_num); + + let sorted_list_of_otcs = sorted_list_of_otcs_storage + .get::>() + .unwrap_or_default() + .unwrap_or_default(); + + assert!(!sorted_list_of_otcs.is_empty()); + + // the list should be sorted + let mut copy_of_list = sorted_list_of_otcs.clone(); + copy_of_list.sort_by(|a, b| b.3.partial_cmp(&a.3).unwrap()); + assert!(sorted_list_of_otcs == copy_of_list); + + // place new order and verify that the list is not updated again in the same block + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, + DAI, + 1_000_000_000, + 2_000_000_000, + true, + )); + + OtcSettlements::sort_otcs(block_num); + + let latest_sorted_list_of_otcs = sorted_list_of_otcs_storage + .get::>() + .unwrap_or_default() + .unwrap_or_default(); + + assert!(sorted_list_of_otcs == latest_sorted_list_of_otcs); + }); +} + +#[test] +fn profit_should_be_transferred_to_treasury() { + let (mut ext, _) = ExtBuilder::default().build(); + ext.execute_with(|| { + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, + DAI, + 100_000 * ONE, + 200_001 * ONE, + true, + )); + + let balance_before = Currencies::free_balance(HDX, &TreasuryAccount::get()); + + >>::offchain_worker(System::block_number()); + + let balance_after = Currencies::free_balance(HDX, &TreasuryAccount::get()); + assert!(balance_after > balance_before); + }); +} + +#[test] +fn existing_arb_opportunity_should_trigger_trade() { + let (mut ext, _) = ExtBuilder::default().build(); + ext.execute_with(|| { + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, // otc asset_in + DAI, // otc asset_out + 100_000 * ONE, + 200_001 * ONE, + true, + )); + + // get otc price + let otc_id = 0; + let otc = >::get(otc_id).unwrap(); + let otc_price = calculate_otc_price(&otc); + + // get trade price + let route = Router::get_route(AssetPair { + asset_in: otc.asset_out, + asset_out: otc.asset_in, + }); + let router_price = Router::spot_price(&route).unwrap(); + + // verify that there's an arb opportunity + assert!(otc_price > router_price); + + let hdx_total_issuance = Currencies::total_issuance(HDX); + let dai_total_issuance = Currencies::total_issuance(DAI); + + assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); + assert!(Currencies::free_balance(DAI, &OtcSettlements::account_id()) == 0); + + >>::offchain_worker(System::block_number()); + + assert_eq!(hdx_total_issuance, Currencies::total_issuance(HDX)); + assert_eq!(dai_total_issuance, Currencies::total_issuance(DAI)); + + // total issuance of tokens should not change + assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); + assert!(Currencies::free_balance(DAI, &OtcSettlements::account_id()) == 0); + + expect_events(vec![Event::Executed { + otc_id, + otc_asset_in: HDX, + otc_asset_out: DAI, + otc_amount_in: 762_939_453_125, + otc_amount_out: 1_525_886_535_644, + trade_amount_in: 1_525_886_535_644, + trade_amount_out: 762_941_521_577, + } + .into()]); + }); +} + +#[test] +fn multiple_arb_opportunities_should_trigger_trades() { + let (mut ext, _) = ExtBuilder::default().build(); + ext.execute_with(|| { + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, // otc asset_in + DAI, // otc asset_out + 100_000 * ONE, + 200_001 * ONE, + true, + )); + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + DOT, // otc asset_in + KSM, // otc asset_out + 100_000 * ONE, + 100_001 * ONE, + true, + )); + + >>::offchain_worker(System::block_number()); + + expect_events(vec![ + Event::Executed { + otc_id: 0, + otc_asset_in: HDX, + otc_asset_out: DAI, + otc_amount_in: 762_939_453_125, + otc_amount_out: 1_525_886_535_644, + trade_amount_in: 1_525_886_535_644, + trade_amount_out: 762_941_521_577, + } + .into(), + Event::Executed { + otc_id: 1, + otc_asset_in: DOT, + otc_asset_out: KSM, + otc_amount_in: 2288818359375, + otc_amount_out: 2288841247558, + trade_amount_in: 2288841247558, + trade_amount_out: 2288830796079, + } + .into(), + ]); + }); +} + +#[test] +fn trade_should_be_triggered_when_arb_opportunity_appears() { + let (mut ext, _) = ExtBuilder::default().build(); + ext.execute_with(|| { + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, // otc asset_in + DAI, // otc asset_out + 100_001 * ONE, + 200_000 * ONE, + true, + )); + + // get otc price + let otc_id = 0; + let otc = >::get(otc_id).unwrap(); + let otc_price = calculate_otc_price(&otc); + + // get trade price + let route = Router::get_route(AssetPair { + asset_in: otc.asset_out, + asset_out: otc.asset_in, + }); + let router_price = Router::spot_price(&route).unwrap(); + + // verify that there's no arb opportunity yet + assert!(otc_price < router_price); + + >>::offchain_worker(System::block_number()); + + // make a trade to move the price and create an arb opportunity + assert_ok!(Omnipool::sell(RuntimeOrigin::signed(ALICE), HDX, DAI, 10 * ONE, ONE,)); + + System::set_block_number(System::block_number() + 1); + + // get otc price + let otc_price = calculate_otc_price(&otc); + + // get trade price + let route = Router::get_route(AssetPair { + asset_in: otc.asset_out, + asset_out: otc.asset_in, + }); + let router_price = Router::spot_price(&route).unwrap(); + + // verify that there's an arb opportunity + assert!(otc_price > router_price); + + let hdx_total_issuance = Currencies::total_issuance(HDX); + let dai_total_issuance = Currencies::total_issuance(DAI); + + assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); + assert!(Currencies::free_balance(DAI, &OtcSettlements::account_id()) == 0); + + >>::offchain_worker(System::block_number()); + + assert_eq!(hdx_total_issuance, Currencies::total_issuance(HDX)); + assert_eq!(dai_total_issuance, Currencies::total_issuance(DAI)); + + // total issuance of tokens should not change + assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); + assert!(Currencies::free_balance(DAI, &OtcSettlements::account_id()) == 0); + + expect_events(vec![Event::Executed { + otc_id, + otc_asset_in: HDX, + otc_asset_out: DAI, + otc_amount_in: 8_392_417_907_714, + otc_amount_out: 16_784_667_968_748, + trade_amount_in: 16_784_667_968_748, + trade_amount_out: 8_392_626_224_459, + } + .into()]); + }); +} + +#[test] +fn trade_should_not_be_triggered_when_there_is_no_arb_opportunity() { + let (mut ext, _) = ExtBuilder::default().build(); + ext.execute_with(|| { + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, // otc asset_in + DAI, // otc asset_out + 100_001 * ONE, + 200_000 * ONE, + true, + )); + + // get otc price + let otc_id = 0; + let otc = >::get(otc_id).unwrap(); + let otc_price = calculate_otc_price(&otc); + + // get trade price + let route = Router::get_route(AssetPair { + asset_in: otc.asset_out, + asset_out: otc.asset_in, + }); + let router_price = Router::spot_price(&route).unwrap(); + + // verify that there's no arb opportunity + assert!(otc_price < router_price); + + let hdx_total_issuance = Currencies::total_issuance(HDX); + let dai_total_issuance = Currencies::total_issuance(DAI); + + assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); + assert!(Currencies::free_balance(DAI, &OtcSettlements::account_id()) == 0); + + assert_storage_noop!(>>::offchain_worker( + System::block_number() + )); + + assert_eq!(hdx_total_issuance, Currencies::total_issuance(HDX)); + assert_eq!(dai_total_issuance, Currencies::total_issuance(DAI)); + + // total issuance of tokens should not change + assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); + assert!(Currencies::free_balance(DAI, &OtcSettlements::account_id()) == 0); + }); +} + +#[test] +fn trade_should_not_be_triggered_when_optimal_amount_not_found() { + let (mut ext, _) = ExtBuilder::default().build(); + ext.execute_with(|| { + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, // otc asset_in + DAI, // otc asset_out + 1_000_000 * ONE, + 8_000_000_001 * ONE, + true, + )); + + // get otc price + let otc_id = 0; + let otc = >::get(otc_id).unwrap(); + let otc_price = calculate_otc_price(&otc); + + // get trade price + let route = Router::get_route(AssetPair { + asset_in: otc.asset_out, + asset_out: otc.asset_in, + }); + let router_price = Router::spot_price(&route).unwrap(); + + // verify that there's an arb opportunity + assert!(otc_price > router_price); + + let hdx_total_issuance = Currencies::total_issuance(HDX); + let dai_total_issuance = Currencies::total_issuance(DAI); + + assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); + assert!(Currencies::free_balance(DAI, &OtcSettlements::account_id()) == 0); + + assert_storage_noop!(>>::offchain_worker( + System::block_number() + )); + + assert_eq!(hdx_total_issuance, Currencies::total_issuance(HDX)); + assert_eq!(dai_total_issuance, Currencies::total_issuance(DAI)); + + // total issuance of tokens should not change + assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); + assert!(Currencies::free_balance(DAI, &OtcSettlements::account_id()) == 0); + }); +} + +#[test] +fn test_offchain_worker_unsigned_transaction_submission() { + let (mut ext, pool_state) = ExtBuilder::default().build(); + ext.execute_with(|| { + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, // otc asset_in + DAI, // otc asset_out + 100_000 * ONE, + 200_001 * ONE, + true, + )); + + let otc_id = 0; + let otc = >::get(otc_id).unwrap(); + let route = Router::get_route(AssetPair { + asset_in: otc.asset_out, + asset_out: otc.asset_in, + }); + + >>::offchain_worker(System::block_number()); + + // check that a transaction has been added to the pool + let tx = pool_state.write().transactions.pop().unwrap(); + assert!(pool_state.read().transactions.is_empty()); + let tx = Extrinsic::decode(&mut &*tx).unwrap(); + assert_eq!(tx.signature, None); // unsigned + assert_eq!( + tx.call, + crate::mock::RuntimeCall::OtcSettlements(crate::Call::settle_otc_order { + otc_id: 0, + amount: 762_939_453_125, + route, + }) + ); + }) +} + +fn place_orders() { + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, + DAI, + 1_000_000_000, + 2_000_000_000, + true, + )); + + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, + LRNA, + 1_000_000_000, + 3_000_000_000, + true, + )); + + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + LRNA, + HDX, + 4_000_000_000, + 3_000_000_000, + true, + )); + + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, + LRNA, + 7_000_000_000, + 3_000_000_000, + true, + )); + + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + KSM, + DAI, + 2_000_000_000, + 3_000_000_000, + true, + )); + + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, + DAI, + 2_000_000, + 3_000_000_000, + true, + )); + + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, + DAI, + 2_000_000_000, + 3_000_000_000_000, + true, + )); + + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + DAI, + DOT, + 2_000_000_000, + 3_000_000_000_000, + true, + )); + + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, + DOT, + 9_000_000_000, + 3_000_000_000, + true, + )); + + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + DAI, + DOT, + 2_000_000_000, + 13_000_000_000, + true, + )); +} diff --git a/pallets/otc-settlements/src/weights.rs b/pallets/otc-settlements/src/weights.rs new file mode 100644 index 000000000..16fa9838e --- /dev/null +++ b/pallets/otc-settlements/src/weights.rs @@ -0,0 +1,71 @@ +// This file is part of HydraDX. + +// Copyright (C) 2020-2023 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. + +//! Autogenerated weights for `pallet_otc` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-12, STEPS: `5`, 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` + +// Executed Command: +// target/release/hydradx +// benchmark +// pallet +// --pallet=pallet-otc +// --wasm-execution=compiled +// --heap-pages=4096 +// --chain=dev +// --extrinsic=* +// --steps=5 +// --repeat=20 +// --output +// ./weights-1.1.0/otc.rs +// --template +// .maintain/pallet-weight-template-no-back.hbs + +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(clippy::unnecessary_cast)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for pallet_otc. +pub trait WeightInfo { + fn settle_otc_order() -> Weight; +} + +/// Weights for pallet_otc using the hydraDX node and recommended hardware. +pub struct HydraWeight(PhantomData); + +impl WeightInfo for HydraWeight { + fn settle_otc_order() -> Weight { + Weight::zero() + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn settle_otc_order() -> Weight { + Weight::zero() + } +} diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index c5841dc0f..7c7e1c084 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}; use sp_core::U512; -use sp_runtime::traits::{AccountIdConversion, CheckedDiv}; +use sp_runtime::traits::{AccountIdConversion, CheckedDiv, One}; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128, TransactionOutcome}; use sp_std::{vec, vec::Vec}; @@ -819,6 +819,22 @@ impl RouterT RouteSpotPriceProvider for DummyRouter { + fn spot_price(_route: &[Trade]) -> Option { + Some(FixedU128::one()) + } +} + +impl RouteProvider for DummyRouter { + fn get_route(asset_pair: AssetPair) -> Vec> { + vec![Trade { + pool: T::DefaultRoutePoolType::get(), + asset_in: asset_pair.asset_in, + asset_out: asset_pair.asset_out, + }] + } +} + #[macro_export] macro_rules! handle_execution_error { ($execution_result:expr) => {{ @@ -853,6 +869,7 @@ impl RouteProvider for Pallet { } } } + impl RouteSpotPriceProvider for Pallet { fn spot_price(route: &[Trade]) -> Option { let mut prices: Vec = Vec::with_capacity(route.len()); diff --git a/pallets/route-executor/src/weights.rs b/pallets/route-executor/src/weights.rs index be4375720..fa74e6b83 100644 --- a/pallets/route-executor/src/weights.rs +++ b/pallets/route-executor/src/weights.rs @@ -52,6 +52,8 @@ pub trait WeightInfo { fn calculate_and_execute_buy_in_lbp(c: u32, b: u32, ) -> Weight; fn set_route_for_xyk() -> Weight; fn force_insert_route() -> Weight; + fn get_route() -> Weight; + fn calculate_spot_price_in_lbp() -> Weight; } /// Weights for `pallet_route_executor` using the HydraDX node and recommended hardware. @@ -155,6 +157,14 @@ impl WeightInfo for HydraWeight { Weight::from_parts(30_421_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } + + fn get_route() -> Weight { + Weight::zero() + } + + fn calculate_spot_price_in_lbp() -> Weight { + Weight::zero() + } } // For backwards compatibility and tests. @@ -257,4 +267,12 @@ impl WeightInfo for () { Weight::from_parts(30_421_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } + + fn get_route() -> Weight { + Weight::zero() + } + + fn calculate_spot_price_in_lbp() -> Weight { + Weight::zero() + } } diff --git a/pallets/stableswap/src/benchmarks.rs b/pallets/stableswap/src/benchmarks.rs index f0b6cf13d..216c7c38d 100644 --- a/pallets/stableswap/src/benchmarks.rs +++ b/pallets/stableswap/src/benchmarks.rs @@ -607,5 +607,60 @@ benchmarks! { } } + calculate_spot_price { + let c in 1..2; // number of times calculate_buy is executed + let e in 0..1; // if e == 1, execute_buy is executed + + let caller: T::AccountId = account("caller", 0, 1); + let lp_provider: T::AccountId = account("provider", 0, 1); + let initial_liquidity = 1_000_000_000_000_000_000u128; + let liquidity_added = 300_000_000_000_000u128; + + let mut initial: Vec> = vec![]; + let mut added_liquidity: Vec> = vec![]; + let mut asset_ids: Vec = Vec::new() ; + for idx in 0..MAX_ASSETS_IN_POOL { + let asset_id: T::AssetId = (idx + ASSET_ID_OFFSET).into(); + T::BenchmarkHelper::register_asset(asset_id, 12)?; + asset_ids.push(asset_id); + T::Currency::update_balance(asset_id, &caller, initial_liquidity as i128)?; + T::Currency::update_balance(asset_id, &lp_provider, liquidity_added as i128)?; + initial.push(AssetAmount::new(asset_id, initial_liquidity)); + added_liquidity.push(AssetAmount::new(asset_id, liquidity_added)); + } + let pool_id: T::AssetId = (1000u32).into(); + T::BenchmarkHelper::register_asset(pool_id, 18)?; + let amplification = 100u16; + let trade_fee = Permill::from_percent(1); + let asset_in: T::AssetId = *asset_ids.last().unwrap(); + let asset_out: T::AssetId = *asset_ids.first().unwrap(); + let successful_origin = T::AuthorityOrigin::try_successful_origin().unwrap(); + crate::Pallet::::create_pool(successful_origin, + pool_id, + asset_ids, + amplification, + trade_fee, + )?; + crate::Pallet::::add_liquidity(RawOrigin::Signed(caller).into(), + pool_id, + initial, + )?; + + let buyer: T::AccountId = account("buyer", 0, 1); + T::Currency::update_balance(asset_in, &buyer, 100_000_000_000_000i128)?; + let amount_buy = 10_000_000_000_000u128; + let sell_max_limit = 11_000_000_000_000u128; + // Worst case is when amplification is changing + crate::Pallet::::update_amplification(RawOrigin::Root.into(), + pool_id, + 1000, + 100u32.into(), + 1000u32.into(), + )?; + System::::set_block_number(500u32.into()); + }: { + assert!( as TradeExecution>::calculate_spot_price(PoolType::Stableswap(pool_id), asset_in, asset_out).is_ok()); + } + impl_benchmark_test_suite!(Pallet, crate::tests::mock::ExtBuilder::default().build(), crate::tests::mock::Test); } diff --git a/pallets/stableswap/src/weights.rs b/pallets/stableswap/src/weights.rs index ed47df426..cd2a88122 100644 --- a/pallets/stableswap/src/weights.rs +++ b/pallets/stableswap/src/weights.rs @@ -62,6 +62,7 @@ pub trait WeightInfo { fn update_amplification() -> Weight; fn router_execution_sell(c: u32, e: u32) -> Weight; fn router_execution_buy(c: u32, e: u32) -> Weight; + fn calculate_spot_price() -> Weight; } /// Weights for pallet_stableswap using the hydraDX node and recommended hardware. @@ -362,6 +363,10 @@ impl WeightInfo for HydraWeight { .saturating_add(T::DbWeight::get().writes((6_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 5797).saturating_mul(e.into())) } + + fn calculate_spot_price() -> Weight { + Weight::zero() + } } // For backwards compatibility and tests @@ -660,4 +665,8 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes((6_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 5797).saturating_mul(e.into())) } + + fn calculate_spot_price() -> Weight { + Weight::zero() + } } diff --git a/pallets/xyk/src/weights.rs b/pallets/xyk/src/weights.rs index e1cae9ea6..2e09876f4 100644 --- a/pallets/xyk/src/weights.rs +++ b/pallets/xyk/src/weights.rs @@ -58,6 +58,7 @@ pub trait WeightInfo { fn buy() -> Weight; fn router_execution_sell(c: u32, e: u32) -> Weight; fn router_execution_buy(c: u32, e: u32) -> Weight; + fn calculate_spot_price() -> Weight; } /// Weights for amm using the hydraDX node and recommended hardware. @@ -239,6 +240,10 @@ impl WeightInfo for HydraWeight { .saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 5166).saturating_mul(e.into())) } + + fn calculate_spot_price() -> Weight { + Weight::zero() + } } // For backwards compatibility and tests @@ -418,4 +423,8 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes((5_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 5166).saturating_mul(e.into())) } + + fn calculate_spot_price() -> Weight { + Weight::zero() + } } diff --git a/rococo-local/config.json b/rococo-local/config.json index 8613de4ce..194973837 100644 --- a/rococo-local/config.json +++ b/rococo-local/config.json @@ -1,62 +1,59 @@ { + "settings": { + "provider": "native" + }, "relaychain": { - "bin": "../../polkadot-sdk/target/release/polkadot", - "chain": "rococo-local", + "default_command": "../../polkadot-sdk/target/release/polkadot", + "chain": "rococo-dev", "nodes": [ { "name": "alice", - "wsPort": 9944, - "port": 30444 + "validator": true, + "args": ["--disable-worker-version-check"], + "wsPort": 9944 }, { "name": "bob", - "wsPort": 9955, - "port": 30555 + "validator": true, + "args": ["--disable-worker-version-check"], + "wsPort": 9955 }, { "name": "charlie", - "wsPort": 9966, - "port": 30666 + "validator": true, + "args": ["--disable-worker-version-check"], + "wsPort": 9966 }, { "name": "dave", - "wsPort": 9977, - "port": 30777 - } - ], - "genesis": { - "runtime": { - "runtime_genesis_config": { - "configuration": { - "config": { - "validation_upgrade_frequency": 1, - "validation_upgrade_delay": 10 - } - } - } + "validator": true, + "args": ["--disable-worker-version-check"], + "wsPort": 9977 } - } + ] }, "simpleParachains": [], "parachains": [ { - "bin": "../target/release/hydradx", + "id": 2032, + "cumulus_based": true, "chain":"local", - "balance": "1000000000000000000000", - "nodes": [ + "collators": [ { + "name": "alice", + "command": "../target/release/hydradx", "wsPort": 9988, - "port": 31200, "flags": ["--alice", "--rpc-cors=all", "--", "--execution=wasm"] }, { + "name": "bob", + "command": "../target/release/hydradx", "wsPort": 9989, - "port": 31201, "flags": ["--bob", "--rpc-cors=all", "--", "--execution=wasm"] } ] } ], - "hrmpChannels": [], + "hrmp_channels": [], "types": {} } diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index 02a2288e2..7925df118 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -76,6 +76,7 @@ pallet-transaction-pause = { workspace = true } pallet-duster = { workspace = true } warehouse-liquidity-mining = { workspace = true } pallet-otc = { workspace = true } +pallet-otc-settlements = { workspace = true } pallet-route-executor = { workspace = true } pallet-staking = { workspace = true } @@ -191,6 +192,7 @@ runtime-benchmarks = [ "pallet-duster/runtime-benchmarks", "pallet-omnipool-liquidity-mining/runtime-benchmarks", "pallet-otc/runtime-benchmarks", + "pallet-otc-settlements/runtime-benchmarks", "pallet-dca/runtime-benchmarks", "pallet-route-executor/runtime-benchmarks", "pallet-ethereum/runtime-benchmarks", @@ -265,6 +267,7 @@ std = [ "pallet-dca/std", "pallet-ema-oracle/std", "pallet-otc/std", + "pallet-otc-settlements/std", "pallet-route-executor/std", "pallet-omnipool-liquidity-mining/std", "pallet-dynamic-fees/std", @@ -357,6 +360,7 @@ try-runtime= [ "pallet-circuit-breaker/try-runtime", "pallet-xcm-rate-limiter/try-runtime", "pallet-otc/try-runtime", + "pallet-otc-settlements/try-runtime", "pallet-route-executor/try-runtime", "pallet-dynamic-fees/try-runtime", "pallet-staking/try-runtime", diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 97183c74b..76ed2e780 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -829,6 +829,13 @@ impl RouterWeightInfo { number_of_times_execute_sell_amounts_executed, )) } + + pub fn calculate_spot_price_overweight() -> Weight { + + weights::route_executor::HydraWeight::::calculate_spot_price_in_lbp() + .saturating_sub(weights::lbp::HydraWeight::::calculate_spot_price( + )) + } } impl AmmTradeWeights> for RouterWeightInfo { @@ -1019,6 +1026,27 @@ impl AmmTradeWeights> for RouterWeightInfo { //Since we don't have any AMM specific thing in the extrinsic, we just return the plain weight weights::route_executor::HydraWeight::::force_insert_route() } + + // Used in OtcSettlements::settle_otc_order extrinsic + fn calculate_spot_price_weight(route: &[Trade]) -> Weight { + let mut weight = Self::calculate_spot_price_overweight(); + + for trade in route { + let amm_weight = match trade.pool { + PoolType::Omnipool => weights::omnipool::HydraWeight::::calculate_spot_price(), + PoolType::LBP => weights::lbp::HydraWeight::::calculate_spot_price(), + PoolType::Stableswap(_) => weights::stableswap::HydraWeight::::calculate_spot_price(), + PoolType::XYK => weights::xyk::HydraWeight::::calculate_spot_price(), + }; + weight.saturating_accrue(amm_weight); + } + + weight + } + + fn get_route_weight() -> Weight { + weights::route_executor::HydraWeight::::get_route() + } } parameter_types! { @@ -1040,6 +1068,8 @@ impl pallet_route_executor::Config for Runtime { parameter_types! { pub const ExistentialDepositMultiplier: u8 = 5; + pub TreasuryAccount: AccountId = Treasury::account_id(); + pub const PricePrecision: FixedU128 = FixedU128::from_rational(1, 100); } impl pallet_otc::Config for Runtime { @@ -1052,6 +1082,21 @@ impl pallet_otc::Config for Runtime { type WeightInfo = weights::otc::HydraWeight; } +impl pallet_otc_settlements::Config for Runtime { + type Currency = Currencies; + type RuntimeEvent = RuntimeEvent; + type ExistentialDeposits = AssetRegistry; + #[cfg(not(feature = "runtime-benchmarks"))] + type Router = Router; + #[cfg(feature = "runtime-benchmarks")] + type Router = pallet_route_executor::DummyRouter; + type ProfitReceiver = TreasuryAccount; + type ExistentialDepositMultiplier = ExistentialDepositMultiplier; + type PricePrecision = PricePrecision; + type WeightInfo = weights::otc_settlements::HydraWeight; + type RouterWeightInfo = RouterWeightInfo; +} + // Dynamic fees parameter_types! { pub AssetFeeParams: FeeParams = FeeParams{ diff --git a/runtime/hydradx/src/benchmarking/omnipool.rs b/runtime/hydradx/src/benchmarking/omnipool.rs index d2eef93ef..66825dcba 100644 --- a/runtime/hydradx/src/benchmarking/omnipool.rs +++ b/runtime/hydradx/src/benchmarking/omnipool.rs @@ -515,6 +515,51 @@ runtime_benchmarks! { } } + calculate_spot_price { + let c in 1..2; // number of times calculate_buy is executed + let e in 0..1; // if e == 1, execute_buy is executed + init()?; + + let acc = Omnipool::protocol_account(); + // Register new asset in asset registry + let token_id = register_asset(b"FCK".to_vec(), 1_u128).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; + + // Create account for token provider and set balance + let owner: AccountId = account("owner", 0, 1); + + let token_price = FixedU128::from((1,5)); + let token_amount = 200_000_000_000_000_u128; + + update_balance(token_id, &acc, token_amount); + + // Add the token to the pool + Omnipool::add_token(RawOrigin::Root.into(), token_id, token_price, Permill::from_percent(100), owner)?; + + // Create LP provider account with correct balance aand add some liquidity + let lp_provider: AccountId = account("provider", 1, 1); + update_balance(token_id, &lp_provider, 500_000_000_000_000_u128); + + let liquidity_added = 1_000_000_000_000_u128; + + let current_position_id = Omnipool::next_position_id(); + + run_to_block(10); + Omnipool::add_liquidity(RawOrigin::Signed(lp_provider).into(), token_id, liquidity_added)?; + + let buyer: AccountId = account("buyer", 2, 1); + update_balance(DAI, &buyer, 500_000_000_000_000_u128); + Omnipool::buy(RawOrigin::Signed(buyer).into(), token_id, DAI, 30_000_000_000_000_u128, 100_000_000_000_000_u128)?; + + let seller: AccountId = account("seller", 3, 1); + update_balance(token_id, &seller, 500_000_000_000_000_u128); + + let amount_buy = 1_000_000_000_000_u128; + let sell_max_limit = 2_000_000_000_000_u128; + + }: { + assert!(>::calculate_spot_price(PoolType::Omnipool, token_id, DAI).is_ok()); + } + } #[cfg(test)] diff --git a/runtime/hydradx/src/benchmarking/route_executor.rs b/runtime/hydradx/src/benchmarking/route_executor.rs index f52a37884..fc4ddfb2e 100644 --- a/runtime/hydradx/src/benchmarking/route_executor.rs +++ b/runtime/hydradx/src/benchmarking/route_executor.rs @@ -21,13 +21,13 @@ use crate::{ }; use super::*; -use crate::benchmarking::dca::HDX; +use crate::benchmarking::dca::{HDX, DAI}; use frame_benchmarking::{account, BenchmarkError}; use frame_support::dispatch::DispatchResult; use frame_support::{assert_ok, ensure}; use frame_system::RawOrigin; use hydradx_traits::router::inverse_route; -use hydradx_traits::router::AssetPair; +use hydradx_traits::router::{AssetPair, RouteProvider, RouteSpotPriceProvider}; use hydradx_traits::router::{PoolType, RouterT, Trade}; use orml_benchmarking::runtime_benchmarks; use orml_traits::{MultiCurrency, MultiCurrencyExtended}; @@ -328,6 +328,44 @@ runtime_benchmarks! { let stored_route = Router::route(AssetPair::new(HDX, asset_6)).unwrap(); assert_eq!(inverse_route(stored_route.to_vec()), route); } + + get_route { + let route = vec![Trade { + pool: PoolType::XYK, + asset_in: HDX, + asset_out: DAI + }]; + + Router::force_insert_route( + RawOrigin::Root.into(), + AssetPair::new(HDX, DAI), + route.clone(), + )?; + }: { + Router::get_route(AssetPair::new(HDX, DAI)) + } + + // Calculates the weight of LBP spot price calculation. Used in the calculation to determine the weight of the overhead. + calculate_spot_price_in_lbp { + let asset_in = register_external_asset(b"FCA".to_vec()).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; + let asset_out = register_external_asset(b"FCB".to_vec()).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; + let caller: AccountId = funded_account("caller", 7, &[asset_in, asset_out]); + let seller: AccountId = funded_account("seller", 8, &[asset_in, asset_out]); + + setup_lbp(caller, asset_in, asset_out)?; + + let trades = vec![Trade { + pool: PoolType::LBP, + asset_in, + asset_out + }]; + + }: { + Router::spot_price(trades.as_slice()); + } + verify { + assert!(Router::spot_price(trades.as_slice()).is_some()); + } } #[cfg(test)] diff --git a/runtime/hydradx/src/benchmarking/xyk.rs b/runtime/hydradx/src/benchmarking/xyk.rs index 9c28e41e6..827135c23 100644 --- a/runtime/hydradx/src/benchmarking/xyk.rs +++ b/runtime/hydradx/src/benchmarking/xyk.rs @@ -264,6 +264,35 @@ runtime_benchmarks! { assert_eq!(frame_system::Pallet::::account(caller).sufficients, 1); } } + + calculate_spot_price { + let c in 1..3; // number of times calculate_buy is executed + let e in 0..1; // if e == 1, execute_buy is executed + + let asset_a = register_external_asset(b"TKNA".to_vec()).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; + let asset_b = register_external_asset(b"TKNB".to_vec()).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; + let fee_asset = register_asset(b"FEE".to_vec(), 1u128).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; + + let maker = funded_account::("maker", 0, &[asset_a, asset_b, fee_asset]); + let caller = funded_account::("caller", 1, &[asset_a, fee_asset]); + + + init_fee_asset(fee_asset)?; + MultiTransactionPayment::set_currency(RawOrigin::Signed(maker.clone()).into(), fee_asset)?; + MultiTransactionPayment::set_currency(RawOrigin::Signed(caller.clone()).into(), fee_asset)?; + + let discount = false; + let amount: Balance = 200_000_000_000_000; + let max_sold: Balance = INITIAL_BALANCE; + + XYK::create_pool(RawOrigin::Signed(maker.clone()).into(), asset_a, INITIAL_BALANCE, asset_b, INITIAL_BALANCE)?; + + >::transfer(asset_a, &caller, &maker, 749_249_999_999_999_u128)?; + + assert_eq!(frame_system::Pallet::::account(caller.clone()).sufficients, 1); + }: { + assert!(>::calculate_spot_price(PoolType::XYK, asset_a, asset_b).is_ok()); + } } #[cfg(test)] diff --git a/runtime/hydradx/src/lib.rs b/runtime/hydradx/src/lib.rs index 48bd3461c..ca908dffa 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -174,6 +174,7 @@ construct_runtime!( Staking: pallet_staking = 69, Stableswap: pallet_stableswap = 70, Bonds: pallet_bonds = 71, + OtcSettlements: pallet_otc_settlements = 72, LBP: pallet_lbp = 73, XYK: pallet_xyk = 74, Referrals: pallet_referrals = 75, @@ -266,6 +267,14 @@ pub type Executive = frame_executive::Executive< (migrations::OnRuntimeUpgradeMigration,), >; +impl frame_system::offchain::SendTransactionTypes for Runtime +where + RuntimeCall: From, +{ + type OverarchingCall = RuntimeCall; + type Extrinsic = UncheckedExtrinsic; +} + impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { @@ -725,6 +734,7 @@ impl_runtime_apis! { list_benchmark!(list, extra, pallet_transaction_pause, TransactionPause); list_benchmark!(list, extra, pallet_otc, OTC); + list_benchmark!(list, extra, pallet_otc_settlements, OtcSettlements); list_benchmark!(list, extra, pallet_xcm, PolkadotXcm); orml_list_benchmark!(list, extra, pallet_currencies, benchmarking::currencies); @@ -810,6 +820,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_transaction_pause, TransactionPause); add_benchmark!(params, batches, pallet_otc, OTC); + add_benchmark!(params, batches, pallet_otc_settlements, OtcSettlements); add_benchmark!(params, batches, pallet_xcm, PolkadotXcm); orml_add_benchmark!(params, batches, pallet_currencies, benchmarking::currencies); diff --git a/runtime/hydradx/src/weights/lbp.rs b/runtime/hydradx/src/weights/lbp.rs index 2a4238477..f0f14dd8d 100644 --- a/runtime/hydradx/src/weights/lbp.rs +++ b/runtime/hydradx/src/weights/lbp.rs @@ -258,4 +258,8 @@ impl WeightInfo for HydraWeight { Weight::from_parts(67_128_000, 6156) .saturating_add(T::DbWeight::get().reads(3)) } + + fn calculate_spot_price() -> Weight { + Weight::zero() + } } diff --git a/runtime/hydradx/src/weights/mod.rs b/runtime/hydradx/src/weights/mod.rs index c006d22b5..82c0441aa 100644 --- a/runtime/hydradx/src/weights/mod.rs +++ b/runtime/hydradx/src/weights/mod.rs @@ -17,6 +17,7 @@ pub mod lbp; pub mod omnipool; pub mod omnipool_lm; pub mod otc; +pub mod otc_settlements; pub mod payment; pub mod preimage; pub mod proxy; diff --git a/runtime/hydradx/src/weights/omnipool.rs b/runtime/hydradx/src/weights/omnipool.rs index 8cd6318d1..0884df74a 100644 --- a/runtime/hydradx/src/weights/omnipool.rs +++ b/runtime/hydradx/src/weights/omnipool.rs @@ -541,4 +541,8 @@ impl pallet_omnipool::WeightInfo for HydraWeight { .saturating_add(T::DbWeight::get().reads(36)) .saturating_add(T::DbWeight::get().writes(21)) } + + fn calculate_spot_price() -> Weight { + Weight::zero() + } } \ No newline at end of file diff --git a/runtime/hydradx/src/weights/otc_settlements.rs b/runtime/hydradx/src/weights/otc_settlements.rs new file mode 100644 index 000000000..79d19c2db --- /dev/null +++ b/runtime/hydradx/src/weights/otc_settlements.rs @@ -0,0 +1,56 @@ +// This file is part of HydraDX. + +// Copyright (C) 2020-2023 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. + +//! Autogenerated weights for `pallet_otc` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2024-02-15, STEPS: `10`, REPEAT: `30`, 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 + +// Executed Command: +// target/release/hydradx +// benchmark +// pallet +// --chain=dev +// --steps=10 +// --repeat=30 +// --wasm-execution=compiled +// --heap-pages=4096 +// --template=.maintain/pallet-weight-template-no-back.hbs +// --pallet=pallet_otc +// --output=./weights/otc.rs +// --extrinsic=* + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +use pallet_otc_settlements::weights::WeightInfo; + +/// Weight functions for `pallet_otc`. +pub struct HydraWeight(PhantomData); +impl WeightInfo for HydraWeight { + fn settle_otc_order() -> Weight { + Weight::zero() + } +} diff --git a/runtime/hydradx/src/weights/route_executor.rs b/runtime/hydradx/src/weights/route_executor.rs index 10f017e21..3f4908300 100644 --- a/runtime/hydradx/src/weights/route_executor.rs +++ b/runtime/hydradx/src/weights/route_executor.rs @@ -146,4 +146,12 @@ impl pallet_route_executor::weights::WeightInfo for Hyd Weight::from_parts(30_303_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } + + fn get_route() -> Weight { + Weight::zero() + } + + fn calculate_spot_price_in_lbp() -> Weight { + Weight::zero() + } } \ No newline at end of file diff --git a/runtime/hydradx/src/weights/stableswap.rs b/runtime/hydradx/src/weights/stableswap.rs index d507ae37e..31fb9fb28 100644 --- a/runtime/hydradx/src/weights/stableswap.rs +++ b/runtime/hydradx/src/weights/stableswap.rs @@ -362,4 +362,8 @@ impl WeightInfo for HydraWeight { .saturating_add(T::DbWeight::get().writes((6_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 5797).saturating_mul(e.into())) } + + fn calculate_spot_price() -> Weight { + Weight::zero() + } } diff --git a/runtime/hydradx/src/weights/xyk.rs b/runtime/hydradx/src/weights/xyk.rs index 7a8c24f45..756452c60 100644 --- a/runtime/hydradx/src/weights/xyk.rs +++ b/runtime/hydradx/src/weights/xyk.rs @@ -319,4 +319,8 @@ impl WeightInfo for HydraWeight { .saturating_add(T::DbWeight::get().writes((11_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 10332).saturating_mul(e.into())) } + + fn calculate_spot_price() -> Weight { + Weight::zero() + } } diff --git a/traits/src/router.rs b/traits/src/router.rs index c08dce014..ad9513132 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -311,6 +311,8 @@ pub trait AmmTradeWeights { fn buy_and_calculate_buy_trade_amounts_weight(route: &[Trade]) -> Weight; fn set_route_weight(route: &[Trade]) -> Weight; fn force_insert_route_weight() -> Weight; + fn get_route_weight() -> Weight; + fn calculate_spot_price_weight(route: &[Trade]) -> Weight; } impl AmmTradeWeights for () { @@ -335,4 +337,10 @@ impl AmmTradeWeights for () { fn force_insert_route_weight() -> Weight { Weight::zero() } + fn get_route_weight() -> Weight { + Weight::zero() + } + fn calculate_spot_price_weight(_route: &[Trade]) -> Weight { + Weight::zero() + } } From 1c215498d729c4ccee8625ea7e466c9fb123d80e Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Mon, 15 Apr 2024 13:43:18 -0500 Subject: [PATCH 02/61] rebenchmark AMMs --- pallets/lbp/src/weights.rs | 349 +++++++----- pallets/omnipool/src/weights.rs | 423 ++++++++------ pallets/stableswap/src/weights.rs | 412 ++++++++------ pallets/xyk/src/weights.rs | 647 ++++++++++++++-------- runtime/hydradx/src/benchmarking/xyk.rs | 3 - runtime/hydradx/src/weights/lbp.rs | 93 ++-- runtime/hydradx/src/weights/omnipool.rs | 135 +++-- runtime/hydradx/src/weights/stableswap.rs | 121 ++-- runtime/hydradx/src/weights/xyk.rs | 119 ++-- 9 files changed, 1398 insertions(+), 904 deletions(-) diff --git a/pallets/lbp/src/weights.rs b/pallets/lbp/src/weights.rs index 310ebf53a..559667886 100644 --- a/pallets/lbp/src/weights.rs +++ b/pallets/lbp/src/weights.rs @@ -18,26 +18,25 @@ //! Autogenerated weights for `pallet_lbp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-12, STEPS: `5`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-15, STEPS: `10`, REPEAT: `30`, 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: `Some("dev")`, DB CACHE: 1024 // Executed Command: // target/release/hydradx // benchmark // pallet -// --pallet=pallet-lbp +// --chain=dev +// --steps=10 +// --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --chain=dev +// --template=.maintain/pallet-weight-template-no-back.hbs +// --pallet=pallet-lbp +// --output=weights-1.1.0/lbp.rs // --extrinsic=* -// --steps=5 -// --repeat=20 -// --output -// ./weights-1.1.0/lbp.rs -// --template -// .maintain/pallet-weight-template-no-back.hbs +// --extra #![allow(unused_parens)] #![allow(unused_imports)] @@ -73,8 +72,12 @@ impl WeightInfo for HydraWeight { /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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) @@ -83,12 +86,12 @@ impl 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: `992` + // Measured: `1278` // Estimated: `11322` - // Minimum execution time: 144_386_000 picoseconds. - Weight::from_parts(145_196_000, 11322) - .saturating_add(T::DbWeight::get().reads(12_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) + // Minimum execution time: 167_421_000 picoseconds. + Weight::from_parts(168_793_000, 11322) + .saturating_add(T::DbWeight::get().reads(15)) + .saturating_add(T::DbWeight::get().writes(8)) } /// Storage: `LBP::PoolData` (r:1 w:1) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) @@ -96,36 +99,44 @@ impl WeightInfo for HydraWeight { /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) fn update_pool_data() -> Weight { // Proof Size summary in bytes: - // Measured: `351` + // Measured: `384` // Estimated: `3628` - // Minimum execution time: 30_461_000 picoseconds. - Weight::from_parts(30_686_000, 3628) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Minimum execution time: 30_510_000 picoseconds. + Weight::from_parts(30_907_000, 3628) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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: `1180` + // Measured: `1539` // Estimated: `11322` - // Minimum execution time: 100_583_000 picoseconds. - Weight::from_parts(101_592_000, 11322) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Minimum execution time: 121_701_000 picoseconds. + Weight::from_parts(123_000_000, 11322) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().writes(4)) } /// Storage: `LBP::PoolData` (r:1 w:1) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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) @@ -136,12 +147,12 @@ impl 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: `1368` + // Measured: `1654` // Estimated: `11322` - // Minimum execution time: 133_274_000 picoseconds. - Weight::from_parts(134_648_000, 11322) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) + // Minimum execution time: 155_630_000 picoseconds. + Weight::from_parts(156_726_000, 11322) + .saturating_add(T::DbWeight::get().reads(13)) + .saturating_add(T::DbWeight::get().writes(8)) } /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) @@ -149,18 +160,22 @@ impl WeightInfo for HydraWeight { /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `1585` + // Measured: `1944` // Estimated: `13905` - // Minimum execution time: 218_344_000 picoseconds. - Weight::from_parts(220_109_000, 13905) - .saturating_add(T::DbWeight::get().reads(12_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + // Minimum execution time: 245_392_000 picoseconds. + Weight::from_parts(247_320_000, 13905) + .saturating_add(T::DbWeight::get().reads(16)) + .saturating_add(T::DbWeight::get().writes(7)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) @@ -168,18 +183,22 @@ impl WeightInfo for HydraWeight { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `1585` + // Measured: `1944` // Estimated: `13905` - // Minimum execution time: 219_060_000 picoseconds. - Weight::from_parts(220_516_000, 13905) - .saturating_add(T::DbWeight::get().reads(12_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + // Minimum execution time: 247_168_000 picoseconds. + Weight::from_parts(248_543_000, 13905) + .saturating_add(T::DbWeight::get().reads(16)) + .saturating_add(T::DbWeight::get().writes(7)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) @@ -187,24 +206,28 @@ impl WeightInfo for HydraWeight { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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`) /// 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: `756 + e * (829 ±0)` - // Estimated: `6156 + e * (7749 ±0)` - // Minimum execution time: 65_722_000 picoseconds. - Weight::from_parts(66_193_000, 6156) - // Standard Error: 1_355_364 - .saturating_add(Weight::from_parts(3_961_882, 0).saturating_mul(c.into())) - // Standard Error: 2_927_921 - .saturating_add(Weight::from_parts(163_724_923, 0).saturating_mul(e.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().reads((9_u64).saturating_mul(e.into()))) + // Measured: `789 + e * (1155 ±0)` + // Estimated: `6156 + e * (7749 ±245_709_589_663_843_264)` + // Minimum execution time: 66_501_000 picoseconds. + Weight::from_parts(67_000_000, 6156) + // Standard Error: 582_591 + .saturating_add(Weight::from_parts(2_266_784, 0).saturating_mul(c.into())) + // Standard Error: 1_278_955 + .saturating_add(Weight::from_parts(186_170_573, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .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())) } @@ -214,24 +237,28 @@ impl WeightInfo for HydraWeight { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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`) /// 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 { + fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `756 + e * (829 ±0)` + // Measured: `789 + e * (1155 ±0)` // Estimated: `6156 + e * (7749 ±0)` - // Minimum execution time: 116_733_000 picoseconds. - Weight::from_parts(117_433_000, 6156) - // Standard Error: 1_509_020 - .saturating_add(Weight::from_parts(5_197_432, 0).saturating_mul(c.into())) - // Standard Error: 4_928_439 - .saturating_add(Weight::from_parts(141_782_318, 0).saturating_mul(e.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().reads((9_u64).saturating_mul(e.into()))) + // Minimum execution time: 117_257_000 picoseconds. + Weight::from_parts(118_182_000, 6156) + // Standard Error: 747_210 + .saturating_add(Weight::from_parts(3_788_250, 0).saturating_mul(c.into())) + // Standard Error: 2_467_334 + .saturating_add(Weight::from_parts(157_907_441, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .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())) } @@ -241,14 +268,25 @@ impl WeightInfo for HydraWeight { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_buy() -> Weight { // Proof Size summary in bytes: - // Measured: `756` + // Measured: `789` // Estimated: `6156` - // Minimum execution time: 65_795_000 picoseconds. - Weight::from_parts(66_370_000, 6156).saturating_add(T::DbWeight::get().reads(3_u64)) + // Minimum execution time: 67_298_000 picoseconds. + Weight::from_parts(68_051_000, 6156) + .saturating_add(T::DbWeight::get().reads(3)) } - + /// Storage: `LBP::PoolData` (r:1 w:0) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:2 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Locks` (r:1 w:0) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) fn calculate_spot_price() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `789` + // Estimated: `6156` + // Minimum execution time: 33_145_000 picoseconds. + Weight::from_parts(33_774_000, 6156) + .saturating_add(T::DbWeight::get().reads(4)) } } @@ -260,8 +298,12 @@ impl WeightInfo for () { /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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) @@ -270,12 +312,12 @@ impl WeightInfo for () { /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) fn create_pool() -> Weight { // Proof Size summary in bytes: - // Measured: `992` + // Measured: `1278` // Estimated: `11322` - // Minimum execution time: 144_386_000 picoseconds. - Weight::from_parts(145_196_000, 11322) - .saturating_add(RocksDbWeight::get().reads(12_u64)) - .saturating_add(RocksDbWeight::get().writes(8_u64)) + // Minimum execution time: 167_421_000 picoseconds. + Weight::from_parts(168_793_000, 11322) + .saturating_add(RocksDbWeight::get().reads(15)) + .saturating_add(RocksDbWeight::get().writes(8)) } /// Storage: `LBP::PoolData` (r:1 w:1) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) @@ -283,36 +325,44 @@ impl WeightInfo for () { /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) fn update_pool_data() -> Weight { // Proof Size summary in bytes: - // Measured: `351` + // Measured: `384` // Estimated: `3628` - // Minimum execution time: 30_461_000 picoseconds. - Weight::from_parts(30_686_000, 3628) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) + // Minimum execution time: 30_510_000 picoseconds. + Weight::from_parts(30_907_000, 3628) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(3)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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: `1180` + // Measured: `1539` // Estimated: `11322` - // Minimum execution time: 100_583_000 picoseconds. - Weight::from_parts(101_592_000, 11322) - .saturating_add(RocksDbWeight::get().reads(8_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) + // Minimum execution time: 121_701_000 picoseconds. + Weight::from_parts(123_000_000, 11322) + .saturating_add(RocksDbWeight::get().reads(11)) + .saturating_add(RocksDbWeight::get().writes(4)) } /// Storage: `LBP::PoolData` (r:1 w:1) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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) @@ -323,12 +373,12 @@ impl WeightInfo for () { /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `1368` + // Measured: `1654` // Estimated: `11322` - // Minimum execution time: 133_274_000 picoseconds. - Weight::from_parts(134_648_000, 11322) - .saturating_add(RocksDbWeight::get().reads(10_u64)) - .saturating_add(RocksDbWeight::get().writes(8_u64)) + // Minimum execution time: 155_630_000 picoseconds. + Weight::from_parts(156_726_000, 11322) + .saturating_add(RocksDbWeight::get().reads(13)) + .saturating_add(RocksDbWeight::get().writes(8)) } /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) @@ -336,18 +386,22 @@ impl WeightInfo for () { /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `1585` + // Measured: `1944` // Estimated: `13905` - // Minimum execution time: 218_344_000 picoseconds. - Weight::from_parts(220_109_000, 13905) - .saturating_add(RocksDbWeight::get().reads(12_u64)) - .saturating_add(RocksDbWeight::get().writes(7_u64)) + // Minimum execution time: 245_392_000 picoseconds. + Weight::from_parts(247_320_000, 13905) + .saturating_add(RocksDbWeight::get().reads(16)) + .saturating_add(RocksDbWeight::get().writes(7)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) @@ -355,18 +409,22 @@ impl WeightInfo for () { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `1585` + // Measured: `1944` // Estimated: `13905` - // Minimum execution time: 219_060_000 picoseconds. - Weight::from_parts(220_516_000, 13905) - .saturating_add(RocksDbWeight::get().reads(12_u64)) - .saturating_add(RocksDbWeight::get().writes(7_u64)) + // Minimum execution time: 247_168_000 picoseconds. + Weight::from_parts(248_543_000, 13905) + .saturating_add(RocksDbWeight::get().reads(16)) + .saturating_add(RocksDbWeight::get().writes(7)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) @@ -374,24 +432,28 @@ impl WeightInfo for () { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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`) /// 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: `756 + e * (829 ±0)` - // Estimated: `6156 + e * (7749 ±0)` - // Minimum execution time: 65_722_000 picoseconds. - Weight::from_parts(66_193_000, 6156) - // Standard Error: 1_355_364 - .saturating_add(Weight::from_parts(3_961_882, 0).saturating_mul(c.into())) - // Standard Error: 2_927_921 - .saturating_add(Weight::from_parts(163_724_923, 0).saturating_mul(e.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().reads((9_u64).saturating_mul(e.into()))) + // Measured: `789 + e * (1155 ±0)` + // Estimated: `6156 + e * (7749 ±245_709_589_663_843_264)` + // Minimum execution time: 66_501_000 picoseconds. + Weight::from_parts(67_000_000, 6156) + // Standard Error: 582_591 + .saturating_add(Weight::from_parts(2_266_784, 0).saturating_mul(c.into())) + // Standard Error: 1_278_955 + .saturating_add(Weight::from_parts(186_170_573, 0).saturating_mul(e.into())) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().reads((13_u64).saturating_mul(e.into()))) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 7749).saturating_mul(e.into())) } @@ -401,24 +463,28 @@ impl WeightInfo for () { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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`) /// 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 { + fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `756 + e * (829 ±0)` + // Measured: `789 + e * (1155 ±0)` // Estimated: `6156 + e * (7749 ±0)` - // Minimum execution time: 116_733_000 picoseconds. - Weight::from_parts(117_433_000, 6156) - // Standard Error: 1_509_020 - .saturating_add(Weight::from_parts(5_197_432, 0).saturating_mul(c.into())) - // Standard Error: 4_928_439 - .saturating_add(Weight::from_parts(141_782_318, 0).saturating_mul(e.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().reads((9_u64).saturating_mul(e.into()))) + // Minimum execution time: 117_257_000 picoseconds. + Weight::from_parts(118_182_000, 6156) + // Standard Error: 747_210 + .saturating_add(Weight::from_parts(3_788_250, 0).saturating_mul(c.into())) + // Standard Error: 2_467_334 + .saturating_add(Weight::from_parts(157_907_441, 0).saturating_mul(e.into())) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().reads((13_u64).saturating_mul(e.into()))) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 7749).saturating_mul(e.into())) } @@ -428,13 +494,24 @@ impl WeightInfo for () { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_buy() -> Weight { // Proof Size summary in bytes: - // Measured: `756` + // Measured: `789` // Estimated: `6156` - // Minimum execution time: 65_795_000 picoseconds. - Weight::from_parts(66_370_000, 6156).saturating_add(RocksDbWeight::get().reads(3_u64)) + // Minimum execution time: 67_298_000 picoseconds. + Weight::from_parts(68_051_000, 6156) + .saturating_add(RocksDbWeight::get().reads(3)) } - + /// Storage: `LBP::PoolData` (r:1 w:0) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:2 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Locks` (r:1 w:0) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) fn calculate_spot_price() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `789` + // Estimated: `6156` + // Minimum execution time: 33_145_000 picoseconds. + Weight::from_parts(33_774_000, 6156) + .saturating_add(RocksDbWeight::get().reads(4)) } } diff --git a/pallets/omnipool/src/weights.rs b/pallets/omnipool/src/weights.rs index dc691a28b..0c5fd8d3e 100644 --- a/pallets/omnipool/src/weights.rs +++ b/pallets/omnipool/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for `pallet_omnipool` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-01-09, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-15, STEPS: `10`, REPEAT: `30`, 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 @@ -36,6 +36,7 @@ // --pallet=pallet-omnipool // --output=weights-1.1.0/omnipool.rs // --extrinsic=* +// --extra #![allow(unused_parens)] #![allow(unused_imports)] @@ -72,7 +73,7 @@ impl WeightInfo for HydraWeight { /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Uniques::Class` (r:1 w:1) /// Proof: `Uniques::Class` (`max_values`: None, `max_size`: Some(190), added: 2665, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:2 w:1) @@ -85,6 +86,8 @@ impl WeightInfo for HydraWeight { /// Proof: `Uniques::CollectionMaxSupply` (`max_values`: None, `max_size`: Some(36), added: 2511, 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::BannedAssets` (r:1 w:0) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) /// Storage: `Tokens::TotalIssuance` (r:1 w:1) /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Accumulator` (r:1 w:1) @@ -95,11 +98,11 @@ impl 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: `3004` + // Measured: `3095` // Estimated: `7406` - // Minimum execution time: 141_394_000 picoseconds. - Weight::from_parts(142_349_000, 7406) - .saturating_add(T::DbWeight::get().reads(12)) + // Minimum execution time: 153_937_000 picoseconds. + Weight::from_parts(155_022_000, 7406) + .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(10)) } /// Storage: `Tokens::Accounts` (r:3 w:3) @@ -118,8 +121,12 @@ impl WeightInfo for HydraWeight { /// Proof: `Uniques::Class` (`max_values`: None, `max_size`: Some(190), added: 2665, mode: `MaxEncodedLen`) /// Storage: `Uniques::CollectionMaxSupply` (r:1 w:0) /// Proof: `Uniques::CollectionMaxSupply` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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) @@ -140,11 +147,11 @@ impl 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: `3919` + // Measured: `4311` // Estimated: `8739` - // Minimum execution time: 220_969_000 picoseconds. - Weight::from_parts(222_574_000, 8739) - .saturating_add(T::DbWeight::get().reads(20)) + // Minimum execution time: 244_032_000 picoseconds. + Weight::from_parts(245_243_000, 8739) + .saturating_add(T::DbWeight::get().reads(23)) .saturating_add(T::DbWeight::get().writes(14)) } /// Storage: `Uniques::Asset` (r:1 w:1) @@ -159,8 +166,12 @@ impl WeightInfo for HydraWeight { /// Proof: `EmaOracle::Oracles` (`max_values`: None, `max_size`: Some(177), added: 2652, 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: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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) @@ -187,11 +198,11 @@ impl 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: `6903` + // Measured: `7222` // Estimated: `11322` - // Minimum execution time: 297_780_000 picoseconds. - Weight::from_parts(299_506_000, 11322) - .saturating_add(T::DbWeight::get().reads(23)) + // Minimum execution time: 326_920_000 picoseconds. + Weight::from_parts(329_009_000, 11322) + .saturating_add(T::DbWeight::get().reads(26)) .saturating_add(T::DbWeight::get().writes(16)) } /// Storage: `Tokens::Accounts` (r:5 w:5) @@ -202,8 +213,12 @@ impl WeightInfo for HydraWeight { /// Proof: `Omnipool::HubAssetImbalance` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`) /// Storage: `DynamicFees::AssetFee` (r:2 w:0) /// Proof: `DynamicFees::AssetFee` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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) + /// 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,11 +255,11 @@ impl WeightInfo for HydraWeight { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `7179` + // Measured: `7548` // Estimated: `13905` - // Minimum execution time: 333_598_000 picoseconds. - Weight::from_parts(336_465_000, 13905) - .saturating_add(T::DbWeight::get().reads(35)) + // Minimum execution time: 379_374_000 picoseconds. + Weight::from_parts(381_767_000, 13905) + .saturating_add(T::DbWeight::get().reads(41)) .saturating_add(T::DbWeight::get().writes(23)) } /// Storage: `Omnipool::Assets` (r:3 w:3) @@ -255,8 +270,12 @@ impl WeightInfo for HydraWeight { /// Proof: `Omnipool::HubAssetImbalance` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`) /// Storage: `DynamicFees::AssetFee` (r:2 w:0) /// Proof: `DynamicFees::AssetFee` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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) + /// 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) @@ -293,11 +312,11 @@ impl WeightInfo for HydraWeight { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `7179` + // Measured: `7548` // Estimated: `13905` - // Minimum execution time: 333_688_000 picoseconds. - Weight::from_parts(335_133_000, 13905) - .saturating_add(T::DbWeight::get().reads(35)) + // Minimum execution time: 388_979_000 picoseconds. + Weight::from_parts(391_112_000, 13905) + .saturating_add(T::DbWeight::get().reads(41)) .saturating_add(T::DbWeight::get().writes(23)) } /// Storage: `Omnipool::Assets` (r:1 w:1) @@ -306,8 +325,8 @@ impl WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `1305` // Estimated: `3550` - // Minimum execution time: 32_634_000 picoseconds. - Weight::from_parts(33_024_000, 3550) + // Minimum execution time: 33_126_000 picoseconds. + Weight::from_parts(33_573_000, 3550) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -315,8 +334,12 @@ impl WeightInfo for HydraWeight { /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:2 w:2) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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) @@ -325,11 +348,11 @@ impl 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: `2336` + // Measured: `2609` // Estimated: `6196` - // Minimum execution time: 107_435_000 picoseconds. - Weight::from_parts(108_211_000, 6196) - .saturating_add(T::DbWeight::get().reads(8)) + // Minimum execution time: 122_204_000 picoseconds. + Weight::from_parts(123_430_000, 6196) + .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().writes(5)) } /// Storage: `Omnipool::Positions` (r:1 w:1) @@ -346,10 +369,10 @@ impl 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: `2876` + // Measured: `2910` // Estimated: `3655` - // Minimum execution time: 75_289_000 picoseconds. - Weight::from_parts(76_090_000, 3655) + // Minimum execution time: 76_811_000 picoseconds. + Weight::from_parts(77_357_000, 3655) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -359,8 +382,8 @@ impl WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `1305` // Estimated: `3550` - // Minimum execution time: 32_857_000 picoseconds. - Weight::from_parts(33_349_000, 3550) + // Minimum execution time: 33_231_000 picoseconds. + Weight::from_parts(33_601_000, 3550) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -370,8 +393,12 @@ impl WeightInfo for HydraWeight { /// 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: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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) @@ -384,11 +411,11 @@ impl 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: `4019` + // Measured: `4304` // Estimated: `8739` - // Minimum execution time: 161_313_000 picoseconds. - Weight::from_parts(162_354_000, 8739) - .saturating_add(T::DbWeight::get().reads(13)) + // Minimum execution time: 180_374_000 picoseconds. + Weight::from_parts(181_092_000, 8739) + .saturating_add(T::DbWeight::get().reads(15)) .saturating_add(T::DbWeight::get().writes(8)) } /// Storage: `Omnipool::Assets` (r:1 w:1) @@ -398,9 +425,13 @@ impl WeightInfo for HydraWeight { /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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: `Duster::AccountBlacklist` (r:1 w:0) + /// 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: `System::Account` (r:2 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:2 w:0) @@ -409,11 +440,11 @@ impl 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: `3110` + // Measured: `3395` // Estimated: `11322` - // Minimum execution time: 160_104_000 picoseconds. - Weight::from_parts(161_947_000, 11322) - .saturating_add(T::DbWeight::get().reads(14)) + // Minimum execution time: 177_186_000 picoseconds. + Weight::from_parts(178_099_000, 11322) + .saturating_add(T::DbWeight::get().reads(16)) .saturating_add(T::DbWeight::get().writes(8)) } /// Storage: `Omnipool::Assets` (r:3 w:3) @@ -424,8 +455,12 @@ impl WeightInfo for HydraWeight { /// Proof: `Omnipool::HubAssetImbalance` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`) /// Storage: `DynamicFees::AssetFee` (r:2 w:0) /// Proof: `DynamicFees::AssetFee` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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) + /// 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) @@ -450,7 +485,7 @@ impl WeightInfo for HydraWeight { /// Proof: `Referrals::AssetRewards` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) /// Storage: `Referrals::TotalShares` (r:1 w:1) /// Proof: `Referrals::TotalShares` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) - /// Storage: `Referrals::TraderShares` (r:2 w:2) + /// Storage: `Referrals::TraderShares` (r:1 w:1) /// Proof: `Referrals::TraderShares` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) /// Storage: `Referrals::PendingConversions` (r:1 w:1) /// Proof: `Referrals::PendingConversions` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) @@ -458,20 +493,20 @@ impl WeightInfo for HydraWeight { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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 * (4788 ±0)` - // Estimated: `6156 + e * (7749 ±0)` - // Minimum execution time: 48_705_000 picoseconds. - Weight::from_parts(49_088_855, 6156) - // Standard Error: 97_412 - .saturating_add(Weight::from_parts(321_546, 0).saturating_mul(c.into())) - // Standard Error: 97_412 - .saturating_add(Weight::from_parts(291_861_384, 0).saturating_mul(e.into())) + // Measured: `1974 + e * (5073 ±0)` + // Estimated: `6156 + e * (8517 ±354_661_923_497_307_072)` + // Minimum execution time: 49_765_000 picoseconds. + Weight::from_parts(50_359_109, 6156) + // Standard Error: 127_532 + .saturating_add(Weight::from_parts(121_941, 0).saturating_mul(c.into())) + // Standard Error: 127_532 + .saturating_add(Weight::from_parts(336_435_574, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().reads((26_u64).saturating_mul(e.into()))) - .saturating_add(T::DbWeight::get().writes((22_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 7749).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads((31_u64).saturating_mul(e.into()))) + .saturating_add(T::DbWeight::get().writes((21_u64).saturating_mul(e.into()))) + .saturating_add(Weight::from_parts(0, 8517).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`) @@ -481,8 +516,12 @@ impl WeightInfo for HydraWeight { /// Proof: `Omnipool::HubAssetImbalance` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`) /// Storage: `DynamicFees::AssetFee` (r:2 w:0) /// Proof: `DynamicFees::AssetFee` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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) + /// 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) @@ -507,7 +546,7 @@ impl WeightInfo for HydraWeight { /// Proof: `Referrals::AssetRewards` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) /// Storage: `Referrals::TotalShares` (r:1 w:1) /// Proof: `Referrals::TotalShares` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) - /// Storage: `Referrals::TraderShares` (r:2 w:2) + /// Storage: `Referrals::TraderShares` (r:1 w:1) /// Proof: `Referrals::TraderShares` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) /// Storage: `Referrals::PendingConversions` (r:1 w:1) /// Proof: `Referrals::PendingConversions` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) @@ -515,22 +554,36 @@ impl WeightInfo for HydraWeight { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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 { + fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `6762` + // Measured: `7047` // Estimated: `13905` - // Minimum execution time: 325_047_000 picoseconds. - Weight::from_parts(309_584_818, 13905) - // Standard Error: 196_245 - .saturating_add(Weight::from_parts(16_694_995, 0).saturating_mul(c.into())) - // Standard Error: 196_245 - .saturating_add(Weight::from_parts(1_594_024, 0).saturating_mul(e.into())) - .saturating_add(T::DbWeight::get().reads(33)) - .saturating_add(T::DbWeight::get().writes(22)) + // Minimum execution time: 367_889_000 picoseconds. + Weight::from_parts(355_257_176, 13905) + // Standard Error: 169_485 + .saturating_add(Weight::from_parts(15_912_492, 0).saturating_mul(c.into())) + // Standard Error: 169_485 + .saturating_add(Weight::from_parts(1_094_838, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(38)) + .saturating_add(T::DbWeight::get().writes(21)) } - + /// 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: `Tokens::Accounts` (r:2 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_spot_price() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `1933` + // Estimated: `6156` + // Minimum execution time: 46_902_000 picoseconds. + Weight::from_parts(47_432_765, 6156) + // Standard Error: 25_604 + .saturating_add(Weight::from_parts(198_058, 0)) + // Standard Error: 25_604 + .saturating_add(Weight::from_parts(135_550, 0)) + .saturating_add(T::DbWeight::get().reads(6)) } } @@ -539,7 +592,7 @@ impl WeightInfo for () { /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Uniques::Class` (r:1 w:1) /// Proof: `Uniques::Class` (`max_values`: None, `max_size`: Some(190), added: 2665, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:2 w:1) @@ -552,6 +605,8 @@ impl WeightInfo for () { /// Proof: `Uniques::CollectionMaxSupply` (`max_values`: None, `max_size`: Some(36), added: 2511, 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::BannedAssets` (r:1 w:0) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) /// Storage: `Tokens::TotalIssuance` (r:1 w:1) /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Accumulator` (r:1 w:1) @@ -562,11 +617,11 @@ impl WeightInfo for () { /// Proof: `Omnipool::Positions` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) fn add_token() -> Weight { // Proof Size summary in bytes: - // Measured: `3004` + // Measured: `3095` // Estimated: `7406` - // Minimum execution time: 141_394_000 picoseconds. - Weight::from_parts(142_349_000, 7406) - .saturating_add(RocksDbWeight::get().reads(12)) + // Minimum execution time: 153_937_000 picoseconds. + Weight::from_parts(155_022_000, 7406) + .saturating_add(RocksDbWeight::get().reads(13)) .saturating_add(RocksDbWeight::get().writes(10)) } /// Storage: `Tokens::Accounts` (r:3 w:3) @@ -585,8 +640,12 @@ impl WeightInfo for () { /// Proof: `Uniques::Class` (`max_values`: None, `max_size`: Some(190), added: 2665, mode: `MaxEncodedLen`) /// Storage: `Uniques::CollectionMaxSupply` (r:1 w:0) /// Proof: `Uniques::CollectionMaxSupply` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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) @@ -607,11 +666,11 @@ impl WeightInfo for () { /// Proof: `Omnipool::Positions` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `3919` + // Measured: `4311` // Estimated: `8739` - // Minimum execution time: 220_969_000 picoseconds. - Weight::from_parts(222_574_000, 8739) - .saturating_add(RocksDbWeight::get().reads(20)) + // Minimum execution time: 244_032_000 picoseconds. + Weight::from_parts(245_243_000, 8739) + .saturating_add(RocksDbWeight::get().reads(23)) .saturating_add(RocksDbWeight::get().writes(14)) } /// Storage: `Uniques::Asset` (r:1 w:1) @@ -626,8 +685,12 @@ impl WeightInfo for () { /// Proof: `EmaOracle::Oracles` (`max_values`: None, `max_size`: Some(177), added: 2652, 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: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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) @@ -654,11 +717,11 @@ impl WeightInfo for () { /// Proof: `Uniques::ItemPriceOf` (`max_values`: None, `max_size`: Some(113), added: 2588, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `6903` + // Measured: `7222` // Estimated: `11322` - // Minimum execution time: 297_780_000 picoseconds. - Weight::from_parts(299_506_000, 11322) - .saturating_add(RocksDbWeight::get().reads(23)) + // Minimum execution time: 326_920_000 picoseconds. + Weight::from_parts(329_009_000, 11322) + .saturating_add(RocksDbWeight::get().reads(26)) .saturating_add(RocksDbWeight::get().writes(16)) } /// Storage: `Tokens::Accounts` (r:5 w:5) @@ -669,8 +732,12 @@ impl WeightInfo for () { /// Proof: `Omnipool::HubAssetImbalance` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`) /// Storage: `DynamicFees::AssetFee` (r:2 w:0) /// Proof: `DynamicFees::AssetFee` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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) + /// 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) @@ -707,11 +774,11 @@ impl WeightInfo for () { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `7179` + // Measured: `7548` // Estimated: `13905` - // Minimum execution time: 333_598_000 picoseconds. - Weight::from_parts(336_465_000, 13905) - .saturating_add(RocksDbWeight::get().reads(35)) + // Minimum execution time: 379_374_000 picoseconds. + Weight::from_parts(381_767_000, 13905) + .saturating_add(RocksDbWeight::get().reads(41)) .saturating_add(RocksDbWeight::get().writes(23)) } /// Storage: `Omnipool::Assets` (r:3 w:3) @@ -722,8 +789,12 @@ impl WeightInfo for () { /// Proof: `Omnipool::HubAssetImbalance` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`) /// Storage: `DynamicFees::AssetFee` (r:2 w:0) /// Proof: `DynamicFees::AssetFee` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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) + /// 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) @@ -760,11 +831,11 @@ impl WeightInfo for () { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `7179` + // Measured: `7548` // Estimated: `13905` - // Minimum execution time: 333_688_000 picoseconds. - Weight::from_parts(335_133_000, 13905) - .saturating_add(RocksDbWeight::get().reads(35)) + // Minimum execution time: 388_979_000 picoseconds. + Weight::from_parts(391_112_000, 13905) + .saturating_add(RocksDbWeight::get().reads(41)) .saturating_add(RocksDbWeight::get().writes(23)) } /// Storage: `Omnipool::Assets` (r:1 w:1) @@ -773,8 +844,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1305` // Estimated: `3550` - // Minimum execution time: 32_634_000 picoseconds. - Weight::from_parts(33_024_000, 3550) + // Minimum execution time: 33_126_000 picoseconds. + Weight::from_parts(33_573_000, 3550) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -782,8 +853,12 @@ impl WeightInfo for () { /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:2 w:2) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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) @@ -792,11 +867,11 @@ impl WeightInfo for () { /// 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: `2336` + // Measured: `2609` // Estimated: `6196` - // Minimum execution time: 107_435_000 picoseconds. - Weight::from_parts(108_211_000, 6196) - .saturating_add(RocksDbWeight::get().reads(8)) + // Minimum execution time: 122_204_000 picoseconds. + Weight::from_parts(123_430_000, 6196) + .saturating_add(RocksDbWeight::get().reads(10)) .saturating_add(RocksDbWeight::get().writes(5)) } /// Storage: `Omnipool::Positions` (r:1 w:1) @@ -813,10 +888,10 @@ impl WeightInfo for () { /// Proof: `Uniques::ItemPriceOf` (`max_values`: None, `max_size`: Some(113), added: 2588, mode: `MaxEncodedLen`) fn sacrifice_position() -> Weight { // Proof Size summary in bytes: - // Measured: `2876` + // Measured: `2910` // Estimated: `3655` - // Minimum execution time: 75_289_000 picoseconds. - Weight::from_parts(76_090_000, 3655) + // Minimum execution time: 76_811_000 picoseconds. + Weight::from_parts(77_357_000, 3655) .saturating_add(RocksDbWeight::get().reads(4)) .saturating_add(RocksDbWeight::get().writes(6)) } @@ -826,8 +901,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1305` // Estimated: `3550` - // Minimum execution time: 32_857_000 picoseconds. - Weight::from_parts(33_349_000, 3550) + // Minimum execution time: 33_231_000 picoseconds. + Weight::from_parts(33_601_000, 3550) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -837,8 +912,12 @@ impl WeightInfo for () { /// 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: `Duster::AccountBlacklist` (r:1 w:0) + /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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) @@ -851,11 +930,11 @@ impl WeightInfo for () { /// 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: `4019` + // Measured: `4304` // Estimated: `8739` - // Minimum execution time: 161_313_000 picoseconds. - Weight::from_parts(162_354_000, 8739) - .saturating_add(RocksDbWeight::get().reads(13)) + // Minimum execution time: 180_374_000 picoseconds. + Weight::from_parts(181_092_000, 8739) + .saturating_add(RocksDbWeight::get().reads(15)) .saturating_add(RocksDbWeight::get().writes(8)) } /// Storage: `Omnipool::Assets` (r:1 w:1) @@ -865,9 +944,13 @@ impl WeightInfo for () { /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// 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: `Duster::AccountBlacklist` (r:1 w:0) + /// 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: `System::Account` (r:2 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:2 w:0) @@ -876,11 +959,11 @@ impl WeightInfo for () { /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) fn remove_token() -> Weight { // Proof Size summary in bytes: - // Measured: `3110` + // Measured: `3395` // Estimated: `11322` - // Minimum execution time: 160_104_000 picoseconds. - Weight::from_parts(161_947_000, 11322) - .saturating_add(RocksDbWeight::get().reads(14)) + // Minimum execution time: 177_186_000 picoseconds. + Weight::from_parts(178_099_000, 11322) + .saturating_add(RocksDbWeight::get().reads(16)) .saturating_add(RocksDbWeight::get().writes(8)) } /// Storage: `Omnipool::Assets` (r:3 w:3) @@ -891,8 +974,12 @@ impl WeightInfo for () { /// Proof: `Omnipool::HubAssetImbalance` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`) /// Storage: `DynamicFees::AssetFee` (r:2 w:0) /// Proof: `DynamicFees::AssetFee` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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) + /// 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) @@ -917,7 +1004,7 @@ impl WeightInfo for () { /// Proof: `Referrals::AssetRewards` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) /// Storage: `Referrals::TotalShares` (r:1 w:1) /// Proof: `Referrals::TotalShares` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) - /// Storage: `Referrals::TraderShares` (r:2 w:2) + /// Storage: `Referrals::TraderShares` (r:1 w:1) /// Proof: `Referrals::TraderShares` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) /// Storage: `Referrals::PendingConversions` (r:1 w:1) /// Proof: `Referrals::PendingConversions` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) @@ -925,20 +1012,20 @@ impl WeightInfo for () { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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 * (4788 ±0)` - // Estimated: `6156 + e * (7749 ±0)` - // Minimum execution time: 48_705_000 picoseconds. - Weight::from_parts(49_088_855, 6156) - // Standard Error: 97_412 - .saturating_add(Weight::from_parts(321_546, 0).saturating_mul(c.into())) - // Standard Error: 97_412 - .saturating_add(Weight::from_parts(291_861_384, 0).saturating_mul(e.into())) + // Measured: `1974 + e * (5073 ±0)` + // Estimated: `6156 + e * (8517 ±354_661_923_497_307_072)` + // Minimum execution time: 49_765_000 picoseconds. + Weight::from_parts(50_359_109, 6156) + // Standard Error: 127_532 + .saturating_add(Weight::from_parts(121_941, 0).saturating_mul(c.into())) + // Standard Error: 127_532 + .saturating_add(Weight::from_parts(336_435_574, 0).saturating_mul(e.into())) .saturating_add(RocksDbWeight::get().reads(7)) - .saturating_add(RocksDbWeight::get().reads((26_u64).saturating_mul(e.into()))) - .saturating_add(RocksDbWeight::get().writes((22_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 7749).saturating_mul(e.into())) + .saturating_add(RocksDbWeight::get().reads((31_u64).saturating_mul(e.into()))) + .saturating_add(RocksDbWeight::get().writes((21_u64).saturating_mul(e.into()))) + .saturating_add(Weight::from_parts(0, 8517).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`) @@ -948,8 +1035,12 @@ impl WeightInfo for () { /// Proof: `Omnipool::HubAssetImbalance` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`) /// Storage: `DynamicFees::AssetFee` (r:2 w:0) /// Proof: `DynamicFees::AssetFee` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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) + /// 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) @@ -974,7 +1065,7 @@ impl WeightInfo for () { /// Proof: `Referrals::AssetRewards` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) /// Storage: `Referrals::TotalShares` (r:1 w:1) /// Proof: `Referrals::TotalShares` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) - /// Storage: `Referrals::TraderShares` (r:2 w:2) + /// Storage: `Referrals::TraderShares` (r:1 w:1) /// Proof: `Referrals::TraderShares` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) /// Storage: `Referrals::PendingConversions` (r:1 w:1) /// Proof: `Referrals::PendingConversions` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) @@ -982,21 +1073,35 @@ impl WeightInfo for () { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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 { + fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `6762` + // Measured: `7047` // Estimated: `13905` - // Minimum execution time: 325_047_000 picoseconds. - Weight::from_parts(309_584_818, 13905) - // Standard Error: 196_245 - .saturating_add(Weight::from_parts(16_694_995, 0).saturating_mul(c.into())) - // Standard Error: 196_245 - .saturating_add(Weight::from_parts(1_594_024, 0).saturating_mul(e.into())) - .saturating_add(RocksDbWeight::get().reads(33)) - .saturating_add(RocksDbWeight::get().writes(22)) + // Minimum execution time: 367_889_000 picoseconds. + Weight::from_parts(355_257_176, 13905) + // Standard Error: 169_485 + .saturating_add(Weight::from_parts(15_912_492, 0).saturating_mul(c.into())) + // Standard Error: 169_485 + .saturating_add(Weight::from_parts(1_094_838, 0).saturating_mul(e.into())) + .saturating_add(RocksDbWeight::get().reads(38)) + .saturating_add(RocksDbWeight::get().writes(21)) } - + /// 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: `Tokens::Accounts` (r:2 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_spot_price() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `1933` + // Estimated: `6156` + // Minimum execution time: 46_902_000 picoseconds. + Weight::from_parts(47_432_765, 6156) + // Standard Error: 25_604 + .saturating_add(Weight::from_parts(198_058, 0)) + // Standard Error: 25_604 + .saturating_add(Weight::from_parts(135_550, 0)) + .saturating_add(RocksDbWeight::get().reads(6)) } } diff --git a/pallets/stableswap/src/weights.rs b/pallets/stableswap/src/weights.rs index cd2a88122..1ae22f9b7 100644 --- a/pallets/stableswap/src/weights.rs +++ b/pallets/stableswap/src/weights.rs @@ -1,5 +1,4 @@ // This file is part of HydraDX. -// This file is part of HydraDX. // Copyright (C) 2020-2023 Intergalactic, Limited (GIB). // SPDX-License-Identifier: Apache-2.0 @@ -19,7 +18,7 @@ //! Autogenerated weights for `pallet_stableswap` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-18, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-15, STEPS: `10`, REPEAT: `30`, 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 @@ -37,6 +36,7 @@ // --pallet=pallet-stableswap // --output=weights-1.1.0/stableswap.rs // --extrinsic=* +// --extra #![allow(unused_parens)] #![allow(unused_imports)] @@ -72,15 +72,15 @@ impl WeightInfo for HydraWeight { /// Storage: `Stableswap::Pools` (r:1 w:1) /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::Assets` (r:6 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Duster::AccountBlacklist` (r:0 w:1) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) fn create_pool() -> Weight { // Proof Size summary in bytes: - // Measured: `717` - // Estimated: `16362` - // Minimum execution time: 52_498_000 picoseconds. - Weight::from_parts(52_992_000, 16362) + // Measured: `822` + // Estimated: `16590` + // Minimum execution time: 52_261_000 picoseconds. + Weight::from_parts(52_961_000, 16590) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -90,54 +90,60 @@ impl WeightInfo for HydraWeight { /// Proof: `Stableswap::AssetTradability` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:11 w:11) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, 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::TotalIssuance` (r:1 w:1) /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:6 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::BannedAssets` (r:6 w:0) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, 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:0) /// 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: `Duster::AccountBlacklist` (r:1 w:0) + /// 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`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `3168` + // Measured: `3438` // Estimated: `29403` - // Minimum execution time: 1_087_109_000 picoseconds. - Weight::from_parts(1_090_256_000, 29403) - .saturating_add(T::DbWeight::get().reads(33)) + // Minimum execution time: 1_206_204_000 picoseconds. + Weight::from_parts(1_209_964_000, 29403) + .saturating_add(T::DbWeight::get().reads(35)) .saturating_add(T::DbWeight::get().writes(14)) } + /// Storage: `Stableswap::AssetTradability` (r:1 w:0) + /// Proof: `Stableswap::AssetTradability` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`) /// Storage: `Stableswap::Pools` (r:1 w:0) /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `Tokens::TotalIssuance` (r:1 w:1) /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:3) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, 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:0) /// 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: `Duster::AccountBlacklist` (r:1 w:0) + /// 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`) fn add_liquidity_shares() -> Weight { // Proof Size summary in bytes: - // Measured: `3014` + // Measured: `3306` // Estimated: `19071` - // Minimum execution time: 739_668_000 picoseconds. - Weight::from_parts(743_517_000, 19071) - .saturating_add(T::DbWeight::get().reads(20)) + // Minimum execution time: 823_372_000 picoseconds. + Weight::from_parts(827_372_000, 19071) + .saturating_add(T::DbWeight::get().reads(23)) .saturating_add(T::DbWeight::get().writes(6)) } /// Storage: `Stableswap::AssetTradability` (r:1 w:0) @@ -146,14 +152,16 @@ impl WeightInfo for HydraWeight { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Stableswap::Pools` (r:1 w:0) /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, 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::TotalIssuance` (r:1 w:1) /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:2 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Accumulator` (r:1 w:1) @@ -162,11 +170,11 @@ impl WeightInfo for HydraWeight { /// 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: `3017` + // Measured: `3330` // Estimated: `19071` - // Minimum execution time: 777_557_000 picoseconds. - Weight::from_parts(781_094_000, 19071) - .saturating_add(T::DbWeight::get().reads(21)) + // Minimum execution time: 868_702_000 picoseconds. + Weight::from_parts(876_117_000, 19071) + .saturating_add(T::DbWeight::get().reads(22)) .saturating_add(T::DbWeight::get().writes(7)) } /// Storage: `Stableswap::AssetTradability` (r:1 w:0) @@ -175,12 +183,14 @@ impl WeightInfo for HydraWeight { /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:3) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, 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::TotalIssuance` (r:1 w:1) /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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: `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) @@ -191,11 +201,11 @@ impl WeightInfo for HydraWeight { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) fn withdraw_asset_amount() -> Weight { // Proof Size summary in bytes: - // Measured: `3017` + // Measured: `3330` // Estimated: `19071` - // Minimum execution time: 1_041_027_000 picoseconds. - Weight::from_parts(1_050_193_000, 19071) - .saturating_add(T::DbWeight::get().reads(22)) + // Minimum execution time: 1_174_979_000 picoseconds. + Weight::from_parts(1_185_049_000, 19071) + .saturating_add(T::DbWeight::get().reads(23)) .saturating_add(T::DbWeight::get().writes(6)) } /// Storage: `Stableswap::AssetTradability` (r:2 w:0) @@ -204,10 +214,12 @@ impl WeightInfo for HydraWeight { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Stableswap::Pools` (r:1 w:0) /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, 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) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, 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::AcceptedCurrencies` (r:1 w:0) @@ -220,11 +232,11 @@ impl WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `3043` + // Measured: `3393` // Estimated: `19071` - // Minimum execution time: 730_301_000 picoseconds. - Weight::from_parts(735_887_000, 19071) - .saturating_add(T::DbWeight::get().reads(22)) + // Minimum execution time: 824_523_000 picoseconds. + Weight::from_parts(829_011_000, 19071) + .saturating_add(T::DbWeight::get().reads(25)) .saturating_add(T::DbWeight::get().writes(7)) } /// Storage: `Stableswap::AssetTradability` (r:2 w:0) @@ -233,10 +245,12 @@ impl WeightInfo for HydraWeight { /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, 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) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, 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) @@ -249,11 +263,11 @@ impl WeightInfo for HydraWeight { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `3013` + // Measured: `3363` // Estimated: `19071` - // Minimum execution time: 710_874_000 picoseconds. - Weight::from_parts(714_006_000, 19071) - .saturating_add(T::DbWeight::get().reads(23)) + // Minimum execution time: 801_509_000 picoseconds. + Weight::from_parts(806_894_000, 19071) + .saturating_add(T::DbWeight::get().reads(26)) .saturating_add(T::DbWeight::get().writes(6)) } /// Storage: `Stableswap::Pools` (r:1 w:0) @@ -264,8 +278,8 @@ impl WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 25_547_000 picoseconds. - Weight::from_parts(25_951_000, 3522) + // Minimum execution time: 24_683_000 picoseconds. + Weight::from_parts(25_068_000, 3522) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -275,8 +289,8 @@ impl WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 23_026_000 picoseconds. - Weight::from_parts(23_457_000, 3522) + // Minimum execution time: 22_077_000 picoseconds. + Weight::from_parts(22_521_000, 3522) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -286,8 +300,8 @@ impl WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 24_839_000 picoseconds. - Weight::from_parts(25_332_000, 3522) + // Minimum execution time: 24_223_000 picoseconds. + Weight::from_parts(24_594_000, 3522) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -295,12 +309,14 @@ impl WeightInfo for HydraWeight { /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Stableswap::AssetTradability` (r:2 w:0) /// Proof: `Stableswap::AssetTradability` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, 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::AcceptedCurrencies` (r:1 w:0) @@ -313,16 +329,16 @@ impl WeightInfo for HydraWeight { /// 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: `1276 + e * (1767 ±0)` - // Estimated: `13905 + e * (5797 ±124_823_812_913_251_024)` - // Minimum execution time: 305_934_000 picoseconds. - Weight::from_parts(312_030_194, 13905) - // Standard Error: 324_777 - .saturating_add(Weight::from_parts(704_923_524, 0).saturating_mul(e.into())) + // Measured: `1588 + e * (1805 ±0)` + // Estimated: `13990 + e * (5797 ±0)` + // Minimum execution time: 327_792_000 picoseconds. + Weight::from_parts(331_553_194, 13990) + // Standard Error: 419_520 + .saturating_add(Weight::from_parts(791_547_476, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().reads((11_u64).saturating_mul(e.into()))) + .saturating_add(T::DbWeight::get().reads((14_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 5797).saturating_mul(e.into())) } @@ -330,12 +346,14 @@ impl WeightInfo for HydraWeight { /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Stableswap::AssetTradability` (r:2 w:0) /// Proof: `Stableswap::AssetTradability` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, 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) @@ -348,24 +366,36 @@ impl WeightInfo for HydraWeight { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, 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 { + fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1275 + e * (1738 ±0)` - // Estimated: `13905 + e * (5797 ±201_913_854_157_949_888)` - // Minimum execution time: 304_954_000 picoseconds. - Weight::from_parts(306_226_000, 13905) - // Standard Error: 3_224_854 - .saturating_add(Weight::from_parts(12_176_535, 0).saturating_mul(c.into())) - // Standard Error: 7_079_475 - .saturating_add(Weight::from_parts(445_329_428, 0).saturating_mul(e.into())) + // Measured: `1587 + e * (1776 ±0)` + // Estimated: `13990 + e * (5797 ±245_709_589_663_843_264)` + // Minimum execution time: 328_597_000 picoseconds. + Weight::from_parts(330_295_000, 13990) + // Standard Error: 3_450_424 + .saturating_add(Weight::from_parts(13_109_908, 0).saturating_mul(c.into())) + // Standard Error: 7_574_666 + .saturating_add(Weight::from_parts(510_661_078, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().reads((12_u64).saturating_mul(e.into()))) + .saturating_add(T::DbWeight::get().reads((15_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((6_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 5797).saturating_mul(e.into())) } - + /// Storage: `Stableswap::Pools` (r:1 w:0) + /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:5 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:5 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) fn calculate_spot_price() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `1587` + // Estimated: `13990` + // Minimum execution time: 260_302_000 picoseconds. + Weight::from_parts(262_839_643, 13990) + // Standard Error: 74_388 + .saturating_add(Weight::from_parts(8_090, 0)) + .saturating_add(T::DbWeight::get().reads(11)) } } @@ -374,15 +404,15 @@ impl WeightInfo for () { /// Storage: `Stableswap::Pools` (r:1 w:1) /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::Assets` (r:6 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Duster::AccountBlacklist` (r:0 w:1) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) fn create_pool() -> Weight { // Proof Size summary in bytes: - // Measured: `717` - // Estimated: `16362` - // Minimum execution time: 52_498_000 picoseconds. - Weight::from_parts(52_992_000, 16362) + // Measured: `822` + // Estimated: `16590` + // Minimum execution time: 52_261_000 picoseconds. + Weight::from_parts(52_961_000, 16590) .saturating_add(RocksDbWeight::get().reads(7)) .saturating_add(RocksDbWeight::get().writes(2)) } @@ -392,54 +422,60 @@ impl WeightInfo for () { /// Proof: `Stableswap::AssetTradability` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:11 w:11) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, 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::TotalIssuance` (r:1 w:1) /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:6 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::BannedAssets` (r:6 w:0) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, 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:0) /// 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: `Duster::AccountBlacklist` (r:1 w:0) + /// 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`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `3168` + // Measured: `3438` // Estimated: `29403` - // Minimum execution time: 1_087_109_000 picoseconds. - Weight::from_parts(1_090_256_000, 29403) - .saturating_add(RocksDbWeight::get().reads(33)) + // Minimum execution time: 1_206_204_000 picoseconds. + Weight::from_parts(1_209_964_000, 29403) + .saturating_add(RocksDbWeight::get().reads(35)) .saturating_add(RocksDbWeight::get().writes(14)) } + /// Storage: `Stableswap::AssetTradability` (r:1 w:0) + /// Proof: `Stableswap::AssetTradability` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`) /// Storage: `Stableswap::Pools` (r:1 w:0) /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `Tokens::TotalIssuance` (r:1 w:1) /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:3) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, 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:0) /// 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: `Duster::AccountBlacklist` (r:1 w:0) + /// 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`) fn add_liquidity_shares() -> Weight { // Proof Size summary in bytes: - // Measured: `3014` + // Measured: `3306` // Estimated: `19071` - // Minimum execution time: 739_668_000 picoseconds. - Weight::from_parts(743_517_000, 19071) - .saturating_add(RocksDbWeight::get().reads(20)) + // Minimum execution time: 823_372_000 picoseconds. + Weight::from_parts(827_372_000, 19071) + .saturating_add(RocksDbWeight::get().reads(23)) .saturating_add(RocksDbWeight::get().writes(6)) } /// Storage: `Stableswap::AssetTradability` (r:1 w:0) @@ -448,14 +484,16 @@ impl WeightInfo for () { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Stableswap::Pools` (r:1 w:0) /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, 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::TotalIssuance` (r:1 w:1) /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:2 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Accumulator` (r:1 w:1) @@ -464,11 +502,11 @@ impl WeightInfo for () { /// 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: `3017` + // Measured: `3330` // Estimated: `19071` - // Minimum execution time: 777_557_000 picoseconds. - Weight::from_parts(781_094_000, 19071) - .saturating_add(RocksDbWeight::get().reads(21)) + // Minimum execution time: 868_702_000 picoseconds. + Weight::from_parts(876_117_000, 19071) + .saturating_add(RocksDbWeight::get().reads(22)) .saturating_add(RocksDbWeight::get().writes(7)) } /// Storage: `Stableswap::AssetTradability` (r:1 w:0) @@ -477,12 +515,14 @@ impl WeightInfo for () { /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:3) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, 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::TotalIssuance` (r:1 w:1) /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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: `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) @@ -493,11 +533,11 @@ impl WeightInfo for () { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) fn withdraw_asset_amount() -> Weight { // Proof Size summary in bytes: - // Measured: `3017` + // Measured: `3330` // Estimated: `19071` - // Minimum execution time: 1_041_027_000 picoseconds. - Weight::from_parts(1_050_193_000, 19071) - .saturating_add(RocksDbWeight::get().reads(22)) + // Minimum execution time: 1_174_979_000 picoseconds. + Weight::from_parts(1_185_049_000, 19071) + .saturating_add(RocksDbWeight::get().reads(23)) .saturating_add(RocksDbWeight::get().writes(6)) } /// Storage: `Stableswap::AssetTradability` (r:2 w:0) @@ -506,10 +546,12 @@ impl WeightInfo for () { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Stableswap::Pools` (r:1 w:0) /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, 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) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, 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::AcceptedCurrencies` (r:1 w:0) @@ -522,11 +564,11 @@ impl WeightInfo for () { /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `3043` + // Measured: `3393` // Estimated: `19071` - // Minimum execution time: 730_301_000 picoseconds. - Weight::from_parts(735_887_000, 19071) - .saturating_add(RocksDbWeight::get().reads(22)) + // Minimum execution time: 824_523_000 picoseconds. + Weight::from_parts(829_011_000, 19071) + .saturating_add(RocksDbWeight::get().reads(25)) .saturating_add(RocksDbWeight::get().writes(7)) } /// Storage: `Stableswap::AssetTradability` (r:2 w:0) @@ -535,10 +577,12 @@ impl WeightInfo for () { /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, 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) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, 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) @@ -551,11 +595,11 @@ impl WeightInfo for () { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `3013` + // Measured: `3363` // Estimated: `19071` - // Minimum execution time: 710_874_000 picoseconds. - Weight::from_parts(714_006_000, 19071) - .saturating_add(RocksDbWeight::get().reads(23)) + // Minimum execution time: 801_509_000 picoseconds. + Weight::from_parts(806_894_000, 19071) + .saturating_add(RocksDbWeight::get().reads(26)) .saturating_add(RocksDbWeight::get().writes(6)) } /// Storage: `Stableswap::Pools` (r:1 w:0) @@ -566,8 +610,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 25_547_000 picoseconds. - Weight::from_parts(25_951_000, 3522) + // Minimum execution time: 24_683_000 picoseconds. + Weight::from_parts(25_068_000, 3522) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -577,8 +621,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 23_026_000 picoseconds. - Weight::from_parts(23_457_000, 3522) + // Minimum execution time: 22_077_000 picoseconds. + Weight::from_parts(22_521_000, 3522) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -588,8 +632,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 24_839_000 picoseconds. - Weight::from_parts(25_332_000, 3522) + // Minimum execution time: 24_223_000 picoseconds. + Weight::from_parts(24_594_000, 3522) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -597,12 +641,14 @@ impl WeightInfo for () { /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Stableswap::AssetTradability` (r:2 w:0) /// Proof: `Stableswap::AssetTradability` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, 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::AcceptedCurrencies` (r:1 w:0) @@ -615,16 +661,16 @@ impl WeightInfo for () { /// 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: `1276 + e * (1767 ±0)` - // Estimated: `13905 + e * (5797 ±124_823_812_913_251_024)` - // Minimum execution time: 305_934_000 picoseconds. - Weight::from_parts(312_030_194, 13905) - // Standard Error: 324_777 - .saturating_add(Weight::from_parts(704_923_524, 0).saturating_mul(e.into())) + // Measured: `1588 + e * (1805 ±0)` + // Estimated: `13990 + e * (5797 ±0)` + // Minimum execution time: 327_792_000 picoseconds. + Weight::from_parts(331_553_194, 13990) + // Standard Error: 419_520 + .saturating_add(Weight::from_parts(791_547_476, 0).saturating_mul(e.into())) .saturating_add(RocksDbWeight::get().reads(11)) - .saturating_add(RocksDbWeight::get().reads((11_u64).saturating_mul(e.into()))) + .saturating_add(RocksDbWeight::get().reads((14_u64).saturating_mul(e.into()))) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 5797).saturating_mul(e.into())) } @@ -632,12 +678,14 @@ impl WeightInfo for () { /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetMetadataMap` (r:5 w:0) - /// Proof: `AssetRegistry::AssetMetadataMap` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Stableswap::AssetTradability` (r:2 w:0) /// Proof: `Stableswap::AssetTradability` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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) + /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, 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) @@ -650,23 +698,35 @@ impl WeightInfo for () { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, 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 { + fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1275 + e * (1738 ±0)` - // Estimated: `13905 + e * (5797 ±201_913_854_157_949_888)` - // Minimum execution time: 304_954_000 picoseconds. - Weight::from_parts(306_226_000, 13905) - // Standard Error: 3_224_854 - .saturating_add(Weight::from_parts(12_176_535, 0).saturating_mul(c.into())) - // Standard Error: 7_079_475 - .saturating_add(Weight::from_parts(445_329_428, 0).saturating_mul(e.into())) + // Measured: `1587 + e * (1776 ±0)` + // Estimated: `13990 + e * (5797 ±245_709_589_663_843_264)` + // Minimum execution time: 328_597_000 picoseconds. + Weight::from_parts(330_295_000, 13990) + // Standard Error: 3_450_424 + .saturating_add(Weight::from_parts(13_109_908, 0).saturating_mul(c.into())) + // Standard Error: 7_574_666 + .saturating_add(Weight::from_parts(510_661_078, 0).saturating_mul(e.into())) .saturating_add(RocksDbWeight::get().reads(11)) - .saturating_add(RocksDbWeight::get().reads((12_u64).saturating_mul(e.into()))) + .saturating_add(RocksDbWeight::get().reads((15_u64).saturating_mul(e.into()))) .saturating_add(RocksDbWeight::get().writes((6_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 5797).saturating_mul(e.into())) } - + /// Storage: `Stableswap::Pools` (r:1 w:0) + /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:5 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:5 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) fn calculate_spot_price() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `1587` + // Estimated: `13990` + // Minimum execution time: 260_302_000 picoseconds. + Weight::from_parts(262_839_643, 13990) + // Standard Error: 74_388 + .saturating_add(Weight::from_parts(8_090, 0)) + .saturating_add(RocksDbWeight::get().reads(11)) } } diff --git a/pallets/xyk/src/weights.rs b/pallets/xyk/src/weights.rs index 2e09876f4..f8db2cfe2 100644 --- a/pallets/xyk/src/weights.rs +++ b/pallets/xyk/src/weights.rs @@ -18,26 +18,25 @@ //! Autogenerated weights for `pallet_xyk` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-12, STEPS: `5`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-15, STEPS: `10`, REPEAT: `30`, 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: `Some("dev")`, DB CACHE: 1024 // Executed Command: // target/release/hydradx // benchmark // pallet -// --pallet=pallet-xyk +// --chain=dev +// --steps=10 +// --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --chain=dev +// --template=.maintain/pallet-weight-template-no-back.hbs +// --pallet=pallet-xyk +// --output=weights-1.1.0/xyk.rs // --extrinsic=* -// --steps=5 -// --repeat=20 -// --output -// ./weights-1.1.0/xyk.rs -// --template -// .maintain/pallet-weight-template-no-back.hbs +// --extra #![allow(unused_parens)] #![allow(unused_imports)] @@ -65,366 +64,570 @@ pub trait WeightInfo { pub struct HydraWeight(PhantomData); impl WeightInfo for HydraWeight { + /// Storage: `AssetRegistry::Assets` (r:3 w:1) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) /// Storage: `XYK::ShareToken` (r:1 w:1) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:5 w:5) + /// Storage: `Tokens::Accounts` (r:7 w:7) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::AssetIds` (r:1 w:1) /// Proof: `AssetRegistry::AssetIds` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::NextAssetId` (r:1 w:1) /// Proof: `AssetRegistry::NextAssetId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:1) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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:2 w:1) + /// Storage: `Duster::AccountBlacklist` (r:1 w:1) + /// 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: `MultiTransactionPayment::AccountCurrencyMap` (r:3 w:0) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:3) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:3 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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: `Duster::AccountBlacklist` (r:0 w:1) - /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// 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: `1140` - // Estimated: `13905` - // Minimum execution time: 202_507_000 picoseconds. - Weight::from_parts(203_717_000, 13905) - .saturating_add(T::DbWeight::get().reads(17_u64)) - .saturating_add(T::DbWeight::get().writes(16_u64)) + // Measured: `3622` + // Estimated: `19071` + // Minimum execution time: 594_360_000 picoseconds. + Weight::from_parts(597_529_000, 19071) + .saturating_add(T::DbWeight::get().reads(33)) + .saturating_add(T::DbWeight::get().writes(20)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:5 w:5) + /// 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) /// Proof: `XYK::TotalLiquidity` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:3 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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: `Tokens::TotalIssuance` (r:1 w:1) - /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, 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: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`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`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `1803` - // Estimated: `13905` - // Minimum execution time: 176_176_000 picoseconds. - Weight::from_parts(177_422_000, 13905) - .saturating_add(T::DbWeight::get().reads(14_u64)) - .saturating_add(T::DbWeight::get().writes(9_u64)) + // Measured: `4258` + // Estimated: `19071` + // Minimum execution time: 355_154_000 picoseconds. + Weight::from_parts(357_271_000, 19071) + .saturating_add(T::DbWeight::get().reads(27)) + .saturating_add(T::DbWeight::get().writes(13)) } - /// Storage: `XYK::ShareToken` (r:1 w:0) + /// Storage: `XYK::ShareToken` (r:1 w:1) /// 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: `Tokens::Accounts` (r:5 w:5) + /// Storage: `Tokens::Accounts` (r:7 w:7) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:3 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:0) + /// Storage: `Duster::AccountBlacklist` (r:2 w:1) + /// 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) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:3) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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: `EmaOracle::Accumulator` (r:1 w:1) - /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, 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: `XYK::PoolAssets` (r:0 w:1) + /// Proof: `XYK::PoolAssets` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `1749` - // Estimated: `13905` - // Minimum execution time: 168_176_000 picoseconds. - Weight::from_parts(169_296_000, 13905) - .saturating_add(T::DbWeight::get().reads(13_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) + // Measured: `4308` + // Estimated: `19071` + // Minimum execution time: 525_290_000 picoseconds. + Weight::from_parts(529_273_000, 19071) + .saturating_add(T::DbWeight::get().reads(29)) + .saturating_add(T::DbWeight::get().writes(17)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:4 w:4) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// 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(87), added: 2562, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:0) + /// 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: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: `EmaOracle::Accumulator` (r:1 w:1) - /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// 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`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `1492` - // Estimated: `11322` - // Minimum execution time: 127_203_000 picoseconds. - Weight::from_parts(127_918_000, 11322) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) + // Measured: `4157` + // Estimated: `16488` + // Minimum execution time: 308_285_000 picoseconds. + Weight::from_parts(309_799_000, 16488) + .saturating_add(T::DbWeight::get().reads(24)) + .saturating_add(T::DbWeight::get().writes(10)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:4 w:4) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// 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(87), added: 2562, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:0) + /// 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: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) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `1492` - // Estimated: `11322` - // Minimum execution time: 126_846_000 picoseconds. - Weight::from_parts(127_737_000, 11322) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) + // Measured: `4157` + // Estimated: `16488` + // Minimum execution time: 305_868_000 picoseconds. + Weight::from_parts(307_731_000, 16488) + .saturating_add(T::DbWeight::get().reads(24)) + .saturating_add(T::DbWeight::get().writes(10)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:4 w:4) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// 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(87), added: 2562, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:0) + /// 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: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: `EmaOracle::Accumulator` (r:1 w:1) - /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// 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`) /// 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: `583 + e * (909 ±0)` - // Estimated: `6156 + e * (5166 ±0)` - // Minimum execution time: 22_072_000 picoseconds. - Weight::from_parts(5_201_125, 6156) - // Standard Error: 56_711 - .saturating_add(Weight::from_parts(8_630_075, 0).saturating_mul(c.into())) - // Standard Error: 56_711 - .saturating_add(Weight::from_parts(113_479_825, 0).saturating_mul(e.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(e.into()))) - .saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 5166).saturating_mul(e.into())) + // Measured: `1187 + e * (2970 ±0)` + // Estimated: `6156 + e * (10332 ±124_823_812_913_251_024)` + // Minimum execution time: 26_105_000 picoseconds. + Weight::from_parts(10_046_707, 6156) + // Standard Error: 68_331 + .saturating_add(Weight::from_parts(8_342_738, 0).saturating_mul(c.into())) + // Standard Error: 68_331 + .saturating_add(Weight::from_parts(290_434_716, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .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: `Tokens::Accounts` (r:4 w:4) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// 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(87), added: 2562, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:0) + /// 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: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) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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`) /// 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 { + fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `583 + e * (909 ±0)` - // Estimated: `6156 + e * (5166 ±0)` - // Minimum execution time: 30_065_000 picoseconds. - Weight::from_parts(6_816_200, 6156) - // Standard Error: 42_652 - .saturating_add(Weight::from_parts(7_927_825, 0).saturating_mul(c.into())) - // Standard Error: 69_651 - .saturating_add(Weight::from_parts(112_378_650, 0).saturating_mul(e.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(e.into()))) - .saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 5166).saturating_mul(e.into())) + // Measured: `1187 + e * (2970 ±0)` + // Estimated: `6156 + e * (10332 ±0)` + // Minimum execution time: 34_243_000 picoseconds. + Weight::from_parts(9_537_362, 6156) + // Standard Error: 44_250 + .saturating_add(Weight::from_parts(8_444_305, 0).saturating_mul(c.into())) + // Standard Error: 75_076 + .saturating_add(Weight::from_parts(289_395_556, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .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: `Tokens::Accounts` (r:2 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_spot_price() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `1187` + // Estimated: `6156` + // Minimum execution time: 26_159_000 picoseconds. + Weight::from_parts(26_805_702, 6156) + .saturating_add(T::DbWeight::get().reads(3)) } } // For backwards compatibility and tests impl WeightInfo for () { + /// Storage: `AssetRegistry::Assets` (r:3 w:1) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) /// Storage: `XYK::ShareToken` (r:1 w:1) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:5 w:5) + /// Storage: `Tokens::Accounts` (r:7 w:7) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::AssetIds` (r:1 w:1) /// Proof: `AssetRegistry::AssetIds` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::NextAssetId` (r:1 w:1) /// Proof: `AssetRegistry::NextAssetId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:1) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, 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:2 w:1) + /// Storage: `Duster::AccountBlacklist` (r:1 w:1) + /// 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: `MultiTransactionPayment::AccountCurrencyMap` (r:3 w:0) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:3) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:3 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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: `Duster::AccountBlacklist` (r:0 w:1) - /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// 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: `1140` - // Estimated: `13905` - // Minimum execution time: 202_507_000 picoseconds. - Weight::from_parts(203_717_000, 13905) - .saturating_add(RocksDbWeight::get().reads(17_u64)) - .saturating_add(RocksDbWeight::get().writes(16_u64)) + // Measured: `3622` + // Estimated: `19071` + // Minimum execution time: 594_360_000 picoseconds. + Weight::from_parts(597_529_000, 19071) + .saturating_add(RocksDbWeight::get().reads(33)) + .saturating_add(RocksDbWeight::get().writes(20)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:5 w:5) + /// 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) /// Proof: `XYK::TotalLiquidity` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:3 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// 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: `Tokens::TotalIssuance` (r:1 w:1) - /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, 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: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`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`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `1803` - // Estimated: `13905` - // Minimum execution time: 176_176_000 picoseconds. - Weight::from_parts(177_422_000, 13905) - .saturating_add(RocksDbWeight::get().reads(14_u64)) - .saturating_add(RocksDbWeight::get().writes(9_u64)) + // Measured: `4258` + // Estimated: `19071` + // Minimum execution time: 355_154_000 picoseconds. + Weight::from_parts(357_271_000, 19071) + .saturating_add(RocksDbWeight::get().reads(27)) + .saturating_add(RocksDbWeight::get().writes(13)) } - /// Storage: `XYK::ShareToken` (r:1 w:0) + /// Storage: `XYK::ShareToken` (r:1 w:1) /// 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: `Tokens::Accounts` (r:5 w:5) + /// Storage: `Tokens::Accounts` (r:7 w:7) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:3 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:0) + /// Storage: `Duster::AccountBlacklist` (r:2 w:1) + /// 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) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:3) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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: `EmaOracle::Accumulator` (r:1 w:1) - /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, 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: `XYK::PoolAssets` (r:0 w:1) + /// Proof: `XYK::PoolAssets` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `1749` - // Estimated: `13905` - // Minimum execution time: 168_176_000 picoseconds. - Weight::from_parts(169_296_000, 13905) - .saturating_add(RocksDbWeight::get().reads(13_u64)) - .saturating_add(RocksDbWeight::get().writes(8_u64)) + // Measured: `4308` + // Estimated: `19071` + // Minimum execution time: 525_290_000 picoseconds. + Weight::from_parts(529_273_000, 19071) + .saturating_add(RocksDbWeight::get().reads(29)) + .saturating_add(RocksDbWeight::get().writes(17)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:4 w:4) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// 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(87), added: 2562, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:0) + /// 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: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: `EmaOracle::Accumulator` (r:1 w:1) - /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// 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`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `1492` - // Estimated: `11322` - // Minimum execution time: 127_203_000 picoseconds. - Weight::from_parts(127_918_000, 11322) - .saturating_add(RocksDbWeight::get().reads(10_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) + // Measured: `4157` + // Estimated: `16488` + // Minimum execution time: 308_285_000 picoseconds. + Weight::from_parts(309_799_000, 16488) + .saturating_add(RocksDbWeight::get().reads(24)) + .saturating_add(RocksDbWeight::get().writes(10)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:4 w:4) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// 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(87), added: 2562, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:0) + /// 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: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) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `1492` - // Estimated: `11322` - // Minimum execution time: 126_846_000 picoseconds. - Weight::from_parts(127_737_000, 11322) - .saturating_add(RocksDbWeight::get().reads(10_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) + // Measured: `4157` + // Estimated: `16488` + // Minimum execution time: 305_868_000 picoseconds. + Weight::from_parts(307_731_000, 16488) + .saturating_add(RocksDbWeight::get().reads(24)) + .saturating_add(RocksDbWeight::get().writes(10)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:4 w:4) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// 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(87), added: 2562, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:0) + /// 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: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: `EmaOracle::Accumulator` (r:1 w:1) - /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// 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`) /// 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: `583 + e * (909 ±0)` - // Estimated: `6156 + e * (5166 ±0)` - // Minimum execution time: 22_072_000 picoseconds. - Weight::from_parts(5_201_125, 6156) - // Standard Error: 56_711 - .saturating_add(Weight::from_parts(8_630_075, 0).saturating_mul(c.into())) - // Standard Error: 56_711 - .saturating_add(Weight::from_parts(113_479_825, 0).saturating_mul(e.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(e.into()))) - .saturating_add(RocksDbWeight::get().writes((5_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 5166).saturating_mul(e.into())) + // Measured: `1187 + e * (2970 ±0)` + // Estimated: `6156 + e * (10332 ±124_823_812_913_251_024)` + // Minimum execution time: 26_105_000 picoseconds. + Weight::from_parts(10_046_707, 6156) + // Standard Error: 68_331 + .saturating_add(Weight::from_parts(8_342_738, 0).saturating_mul(c.into())) + // Standard Error: 68_331 + .saturating_add(Weight::from_parts(290_434_716, 0).saturating_mul(e.into())) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().reads((21_u64).saturating_mul(e.into()))) + .saturating_add(RocksDbWeight::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: `Tokens::Accounts` (r:4 w:4) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// 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(87), added: 2562, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:0) + /// 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: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) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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`) /// 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 { + fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `583 + e * (909 ±0)` - // Estimated: `6156 + e * (5166 ±0)` - // Minimum execution time: 30_065_000 picoseconds. - Weight::from_parts(6_816_200, 6156) - // Standard Error: 42_652 - .saturating_add(Weight::from_parts(7_927_825, 0).saturating_mul(c.into())) - // Standard Error: 69_651 - .saturating_add(Weight::from_parts(112_378_650, 0).saturating_mul(e.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(e.into()))) - .saturating_add(RocksDbWeight::get().writes((5_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 5166).saturating_mul(e.into())) + // Measured: `1187 + e * (2970 ±0)` + // Estimated: `6156 + e * (10332 ±0)` + // Minimum execution time: 34_243_000 picoseconds. + Weight::from_parts(9_537_362, 6156) + // Standard Error: 44_250 + .saturating_add(Weight::from_parts(8_444_305, 0).saturating_mul(c.into())) + // Standard Error: 75_076 + .saturating_add(Weight::from_parts(289_395_556, 0).saturating_mul(e.into())) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().reads((21_u64).saturating_mul(e.into()))) + .saturating_add(RocksDbWeight::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: `Tokens::Accounts` (r:2 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_spot_price() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `1187` + // Estimated: `6156` + // Minimum execution time: 26_159_000 picoseconds. + Weight::from_parts(26_805_702, 6156) + .saturating_add(RocksDbWeight::get().reads(3)) } } diff --git a/runtime/hydradx/src/benchmarking/xyk.rs b/runtime/hydradx/src/benchmarking/xyk.rs index 827135c23..50380a2f5 100644 --- a/runtime/hydradx/src/benchmarking/xyk.rs +++ b/runtime/hydradx/src/benchmarking/xyk.rs @@ -266,9 +266,6 @@ runtime_benchmarks! { } calculate_spot_price { - let c in 1..3; // number of times calculate_buy is executed - let e in 0..1; // if e == 1, execute_buy is executed - let asset_a = register_external_asset(b"TKNA".to_vec()).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; let asset_b = register_external_asset(b"TKNB".to_vec()).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; let fee_asset = register_asset(b"FEE".to_vec(), 1u128).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; diff --git a/runtime/hydradx/src/weights/lbp.rs b/runtime/hydradx/src/weights/lbp.rs index f0f14dd8d..abb67d1bd 100644 --- a/runtime/hydradx/src/weights/lbp.rs +++ b/runtime/hydradx/src/weights/lbp.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for `pallet_lbp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-15, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-15, STEPS: `10`, REPEAT: `30`, 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 @@ -33,9 +33,10 @@ // --wasm-execution=compiled // --heap-pages=4096 // --template=.maintain/pallet-weight-template-no-back.hbs -// --pallet=pallet_lbp -// --output=./weights/lbp.rs +// --pallet=pallet-lbp +// --output=weights-1.1.0/lbp.rs // --extrinsic=* +// --extra #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -70,10 +71,10 @@ impl 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: `1178` + // Measured: `1278` // Estimated: `11322` - // Minimum execution time: 162_938_000 picoseconds. - Weight::from_parts(164_251_000, 11322) + // Minimum execution time: 167_421_000 picoseconds. + Weight::from_parts(168_793_000, 11322) .saturating_add(T::DbWeight::get().reads(15)) .saturating_add(T::DbWeight::get().writes(8)) } @@ -83,10 +84,10 @@ impl WeightInfo for HydraWeight { /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) fn update_pool_data() -> Weight { // Proof Size summary in bytes: - // Measured: `351` + // Measured: `384` // Estimated: `3628` - // Minimum execution time: 30_041_000 picoseconds. - Weight::from_parts(30_468_000, 3628) + // Minimum execution time: 30_510_000 picoseconds. + Weight::from_parts(30_907_000, 3628) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -104,10 +105,10 @@ impl WeightInfo for HydraWeight { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `1439` + // Measured: `1539` // Estimated: `11322` - // Minimum execution time: 118_411_000 picoseconds. - Weight::from_parts(119_467_000, 11322) + // Minimum execution time: 121_701_000 picoseconds. + Weight::from_parts(123_000_000, 11322) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -131,10 +132,10 @@ impl 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: `1554` + // Measured: `1654` // Estimated: `11322` - // Minimum execution time: 153_550_000 picoseconds. - Weight::from_parts(154_890_000, 11322) + // Minimum execution time: 155_630_000 picoseconds. + Weight::from_parts(156_726_000, 11322) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(8)) } @@ -154,10 +155,10 @@ impl WeightInfo for HydraWeight { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `1844` + // Measured: `1944` // Estimated: `13905` - // Minimum execution time: 243_058_000 picoseconds. - Weight::from_parts(244_292_000, 13905) + // Minimum execution time: 245_392_000 picoseconds. + Weight::from_parts(247_320_000, 13905) .saturating_add(T::DbWeight::get().reads(16)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -177,10 +178,10 @@ impl WeightInfo for HydraWeight { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `1844` + // Measured: `1944` // Estimated: `13905` - // Minimum execution time: 242_758_000 picoseconds. - Weight::from_parts(244_140_000, 13905) + // Minimum execution time: 247_168_000 picoseconds. + Weight::from_parts(248_543_000, 13905) .saturating_add(T::DbWeight::get().reads(16)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -202,14 +203,14 @@ impl WeightInfo for HydraWeight { /// The range of component `e` is `[0, 1]`. fn router_execution_sell(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `756 + e * (1088 ±0)` - // Estimated: `6156 + e * (7749 ±251_795_645_551_580_832)` - // Minimum execution time: 66_583_000 picoseconds. - Weight::from_parts(67_060_000, 6156) - // Standard Error: 587_908 - .saturating_add(Weight::from_parts(2_276_829, 0).saturating_mul(c.into())) - // Standard Error: 1_290_627 - .saturating_add(Weight::from_parts(183_046_701, 0).saturating_mul(e.into())) + // Measured: `789 + e * (1155 ±0)` + // Estimated: `6156 + e * (7749 ±245_709_589_663_843_264)` + // Minimum execution time: 66_501_000 picoseconds. + Weight::from_parts(67_000_000, 6156) + // Standard Error: 582_591 + .saturating_add(Weight::from_parts(2_266_784, 0).saturating_mul(c.into())) + // Standard Error: 1_278_955 + .saturating_add(Weight::from_parts(186_170_573, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads((13_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(e.into()))) @@ -233,14 +234,14 @@ impl WeightInfo for HydraWeight { /// The range of component `e` is `[0, 1]`. fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `756 + e * (1088 ±0)` + // Measured: `789 + e * (1155 ±0)` // Estimated: `6156 + e * (7749 ±0)` - // Minimum execution time: 117_561_000 picoseconds. - Weight::from_parts(118_264_000, 6156) - // Standard Error: 751_682 - .saturating_add(Weight::from_parts(3_708_043, 0).saturating_mul(c.into())) - // Standard Error: 2_482_101 - .saturating_add(Weight::from_parts(155_294_743, 0).saturating_mul(e.into())) + // Minimum execution time: 117_257_000 picoseconds. + Weight::from_parts(118_182_000, 6156) + // Standard Error: 747_210 + .saturating_add(Weight::from_parts(3_788_250, 0).saturating_mul(c.into())) + // Standard Error: 2_467_334 + .saturating_add(Weight::from_parts(157_907_441, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads((13_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(e.into()))) @@ -252,14 +253,24 @@ impl WeightInfo for HydraWeight { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_buy() -> Weight { // Proof Size summary in bytes: - // Measured: `756` + // Measured: `789` // Estimated: `6156` - // Minimum execution time: 66_616_000 picoseconds. - Weight::from_parts(67_128_000, 6156) + // Minimum execution time: 67_298_000 picoseconds. + Weight::from_parts(68_051_000, 6156) .saturating_add(T::DbWeight::get().reads(3)) } - + /// Storage: `LBP::PoolData` (r:1 w:0) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:2 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Locks` (r:1 w:0) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) fn calculate_spot_price() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `789` + // Estimated: `6156` + // Minimum execution time: 33_145_000 picoseconds. + Weight::from_parts(33_774_000, 6156) + .saturating_add(T::DbWeight::get().reads(4)) } } diff --git a/runtime/hydradx/src/weights/omnipool.rs b/runtime/hydradx/src/weights/omnipool.rs index 0884df74a..1d4e2f50e 100644 --- a/runtime/hydradx/src/weights/omnipool.rs +++ b/runtime/hydradx/src/weights/omnipool.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for `pallet_omnipool` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-15, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-15, STEPS: `10`, REPEAT: `30`, 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 @@ -33,9 +33,10 @@ // --wasm-execution=compiled // --heap-pages=4096 // --template=.maintain/pallet-weight-template-no-back.hbs -// --pallet=pallet_omnipool -// --output=./weights/omnipool.rs +// --pallet=pallet-omnipool +// --output=weights-1.1.0/omnipool.rs // --extrinsic=* +// --extra #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -76,10 +77,10 @@ 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: `3028` + // Measured: `3095` // Estimated: `7406` - // Minimum execution time: 146_309_000 picoseconds. - Weight::from_parts(147_552_000, 7406) + // Minimum execution time: 153_937_000 picoseconds. + Weight::from_parts(155_022_000, 7406) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(10)) } @@ -125,10 +126,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: `4178` + // Measured: `4311` // Estimated: `8739` - // Minimum execution time: 236_030_000 picoseconds. - Weight::from_parts(237_610_000, 8739) + // Minimum execution time: 244_032_000 picoseconds. + Weight::from_parts(245_243_000, 8739) .saturating_add(T::DbWeight::get().reads(23)) .saturating_add(T::DbWeight::get().writes(14)) } @@ -176,10 +177,10 @@ 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: `7089` + // Measured: `7222` // Estimated: `11322` - // Minimum execution time: 316_738_000 picoseconds. - Weight::from_parts(319_501_000, 11322) + // Minimum execution time: 326_920_000 picoseconds. + Weight::from_parts(329_009_000, 11322) .saturating_add(T::DbWeight::get().reads(26)) .saturating_add(T::DbWeight::get().writes(16)) } @@ -195,7 +196,7 @@ 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) + /// 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`) @@ -233,11 +234,11 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `7327` + // Measured: `7548` // Estimated: `13905` - // Minimum execution time: 360_954_000 picoseconds. - Weight::from_parts(362_880_000, 13905) - .saturating_add(T::DbWeight::get().reads(39)) + // Minimum execution time: 379_374_000 picoseconds. + Weight::from_parts(381_767_000, 13905) + .saturating_add(T::DbWeight::get().reads(41)) .saturating_add(T::DbWeight::get().writes(23)) } /// Storage: `Omnipool::Assets` (r:3 w:3) @@ -252,7 +253,7 @@ 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) + /// 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`) @@ -290,11 +291,11 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `7327` + // Measured: `7548` // Estimated: `13905` - // Minimum execution time: 364_573_000 picoseconds. - Weight::from_parts(365_989_000, 13905) - .saturating_add(T::DbWeight::get().reads(39)) + // Minimum execution time: 388_979_000 picoseconds. + Weight::from_parts(391_112_000, 13905) + .saturating_add(T::DbWeight::get().reads(41)) .saturating_add(T::DbWeight::get().writes(23)) } /// Storage: `Omnipool::Assets` (r:1 w:1) @@ -303,8 +304,8 @@ impl pallet_omnipool::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `1305` // Estimated: `3550` - // Minimum execution time: 32_736_000 picoseconds. - Weight::from_parts(33_138_000, 3550) + // Minimum execution time: 33_126_000 picoseconds. + Weight::from_parts(33_573_000, 3550) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -326,10 +327,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: `2510` + // Measured: `2609` // Estimated: `6196` - // Minimum execution time: 122_163_000 picoseconds. - Weight::from_parts(123_392_000, 6196) + // Minimum execution time: 122_204_000 picoseconds. + Weight::from_parts(123_430_000, 6196) .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -347,10 +348,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: `2876` + // Measured: `2910` // Estimated: `3655` - // Minimum execution time: 75_629_000 picoseconds. - Weight::from_parts(76_582_000, 3655) + // Minimum execution time: 76_811_000 picoseconds. + Weight::from_parts(77_357_000, 3655) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -360,8 +361,8 @@ impl pallet_omnipool::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `1305` // Estimated: `3550` - // Minimum execution time: 32_944_000 picoseconds. - Weight::from_parts(33_586_000, 3550) + // Minimum execution time: 33_231_000 picoseconds. + Weight::from_parts(33_601_000, 3550) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -389,10 +390,10 @@ 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: `4205` + // Measured: `4304` // Estimated: `8739` - // Minimum execution time: 174_415_000 picoseconds. - Weight::from_parts(174_998_000, 8739) + // Minimum execution time: 180_374_000 picoseconds. + Weight::from_parts(181_092_000, 8739) .saturating_add(T::DbWeight::get().reads(15)) .saturating_add(T::DbWeight::get().writes(8)) } @@ -418,10 +419,10 @@ 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: `3296` + // Measured: `3395` // Estimated: `11322` - // Minimum execution time: 175_638_000 picoseconds. - Weight::from_parts(176_841_000, 11322) + // Minimum execution time: 177_186_000 picoseconds. + Weight::from_parts(178_099_000, 11322) .saturating_add(T::DbWeight::get().reads(16)) .saturating_add(T::DbWeight::get().writes(8)) } @@ -437,7 +438,7 @@ 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) + /// 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`) @@ -471,18 +472,20 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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 * (4936 ±0)` - // Estimated: `6156 + e * (7749 ±201_913_854_157_949_888)` - // Minimum execution time: 48_921_000 picoseconds. - Weight::from_parts(51_507_911, 6156) - // Standard Error: 122_017 - .saturating_add(Weight::from_parts(316_472_235, 0).saturating_mul(e.into())) + // Measured: `1974 + e * (5073 ±0)` + // Estimated: `6156 + e * (8517 ±354_661_923_497_307_072)` + // Minimum execution time: 49_765_000 picoseconds. + Weight::from_parts(50_359_109, 6156) + // Standard Error: 127_532 + .saturating_add(Weight::from_parts(121_941, 0).saturating_mul(c.into())) + // Standard Error: 127_532 + .saturating_add(Weight::from_parts(336_435_574, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().reads((29_u64).saturating_mul(e.into()))) + .saturating_add(T::DbWeight::get().reads((31_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((21_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 7749).saturating_mul(e.into())) + .saturating_add(Weight::from_parts(0, 8517).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`) @@ -496,7 +499,7 @@ 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) + /// 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`) @@ -530,19 +533,35 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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 { + fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `6910` + // Measured: `7047` // Estimated: `13905` - // Minimum execution time: 350_132_000 picoseconds. - Weight::from_parts(340_475_478, 13905) - // Standard Error: 178_513 - .saturating_add(Weight::from_parts(13_719_977, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(36)) + // Minimum execution time: 367_889_000 picoseconds. + Weight::from_parts(355_257_176, 13905) + // Standard Error: 169_485 + .saturating_add(Weight::from_parts(15_912_492, 0).saturating_mul(c.into())) + // Standard Error: 169_485 + .saturating_add(Weight::from_parts(1_094_838, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(38)) .saturating_add(T::DbWeight::get().writes(21)) } - + /// 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: `Tokens::Accounts` (r:2 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_spot_price() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `1933` + // Estimated: `6156` + // Minimum execution time: 46_902_000 picoseconds. + Weight::from_parts(47_432_765, 6156) + // Standard Error: 25_604 + .saturating_add(Weight::from_parts(198_058, 0)) + // Standard Error: 25_604 + .saturating_add(Weight::from_parts(135_550, 0)) + .saturating_add(T::DbWeight::get().reads(6)) } } \ No newline at end of file diff --git a/runtime/hydradx/src/weights/stableswap.rs b/runtime/hydradx/src/weights/stableswap.rs index 31fb9fb28..26b598e88 100644 --- a/runtime/hydradx/src/weights/stableswap.rs +++ b/runtime/hydradx/src/weights/stableswap.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for `pallet_stableswap` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-15, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-15, STEPS: `10`, REPEAT: `30`, 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 @@ -33,9 +33,10 @@ // --wasm-execution=compiled // --heap-pages=4096 // --template=.maintain/pallet-weight-template-no-back.hbs -// --pallet=pallet_stableswap -// --output=./weights/stableswap.rs +// --pallet=pallet-stableswap +// --output=weights-1.1.0/stableswap.rs // --extrinsic=* +// --extra #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -58,10 +59,10 @@ impl WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) fn create_pool() -> Weight { // Proof Size summary in bytes: - // Measured: `789` + // Measured: `822` // Estimated: `16590` - // Minimum execution time: 53_155_000 picoseconds. - Weight::from_parts(53_722_000, 16590) + // Minimum execution time: 52_261_000 picoseconds. + Weight::from_parts(52_961_000, 16590) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -89,10 +90,10 @@ impl WeightInfo for HydraWeight { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `3339` + // Measured: `3438` // Estimated: `29403` - // Minimum execution time: 1_155_933_000 picoseconds. - Weight::from_parts(1_159_202_000, 29403) + // Minimum execution time: 1_206_204_000 picoseconds. + Weight::from_parts(1_209_964_000, 29403) .saturating_add(T::DbWeight::get().reads(35)) .saturating_add(T::DbWeight::get().writes(14)) } @@ -120,10 +121,10 @@ impl WeightInfo for HydraWeight { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) fn add_liquidity_shares() -> Weight { // Proof Size summary in bytes: - // Measured: `3207` + // Measured: `3306` // Estimated: `19071` - // Minimum execution time: 775_198_000 picoseconds. - Weight::from_parts(779_737_000, 19071) + // Minimum execution time: 823_372_000 picoseconds. + Weight::from_parts(827_372_000, 19071) .saturating_add(T::DbWeight::get().reads(23)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -151,10 +152,10 @@ impl WeightInfo for HydraWeight { /// 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: `3231` + // Measured: `3330` // Estimated: `19071` - // Minimum execution time: 807_519_000 picoseconds. - Weight::from_parts(811_614_000, 19071) + // Minimum execution time: 868_702_000 picoseconds. + Weight::from_parts(876_117_000, 19071) .saturating_add(T::DbWeight::get().reads(22)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -182,10 +183,10 @@ impl WeightInfo for HydraWeight { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) fn withdraw_asset_amount() -> Weight { // Proof Size summary in bytes: - // Measured: `3231` + // Measured: `3330` // Estimated: `19071` - // Minimum execution time: 1_061_520_000 picoseconds. - Weight::from_parts(1_068_689_000, 19071) + // Minimum execution time: 1_174_979_000 picoseconds. + Weight::from_parts(1_185_049_000, 19071) .saturating_add(T::DbWeight::get().reads(23)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -195,7 +196,7 @@ impl WeightInfo for HydraWeight { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Stableswap::Pools` (r:1 w:0) /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:5 w:0) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Duster::AccountBlacklist` (r:2 w:0) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) @@ -213,11 +214,11 @@ impl WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `3269` + // Measured: `3393` // Estimated: `19071` - // Minimum execution time: 767_301_000 picoseconds. - Weight::from_parts(771_963_000, 19071) - .saturating_add(T::DbWeight::get().reads(24)) + // Minimum execution time: 824_523_000 picoseconds. + Weight::from_parts(829_011_000, 19071) + .saturating_add(T::DbWeight::get().reads(25)) .saturating_add(T::DbWeight::get().writes(7)) } /// Storage: `Stableswap::AssetTradability` (r:2 w:0) @@ -226,7 +227,7 @@ impl WeightInfo for HydraWeight { /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:5 w:0) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Duster::AccountBlacklist` (r:2 w:0) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) @@ -244,11 +245,11 @@ impl WeightInfo for HydraWeight { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `3239` + // Measured: `3363` // Estimated: `19071` - // Minimum execution time: 745_716_000 picoseconds. - Weight::from_parts(748_811_000, 19071) - .saturating_add(T::DbWeight::get().reads(25)) + // Minimum execution time: 801_509_000 picoseconds. + Weight::from_parts(806_894_000, 19071) + .saturating_add(T::DbWeight::get().reads(26)) .saturating_add(T::DbWeight::get().writes(6)) } /// Storage: `Stableswap::Pools` (r:1 w:0) @@ -259,8 +260,8 @@ impl WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 25_044_000 picoseconds. - Weight::from_parts(25_584_000, 3522) + // Minimum execution time: 24_683_000 picoseconds. + Weight::from_parts(25_068_000, 3522) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -270,8 +271,8 @@ impl WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 22_703_000 picoseconds. - Weight::from_parts(23_093_000, 3522) + // Minimum execution time: 22_077_000 picoseconds. + Weight::from_parts(22_521_000, 3522) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -281,8 +282,8 @@ impl WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 24_632_000 picoseconds. - Weight::from_parts(24_919_000, 3522) + // Minimum execution time: 24_223_000 picoseconds. + Weight::from_parts(24_594_000, 3522) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -290,7 +291,7 @@ impl WeightInfo for HydraWeight { /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:5 w:0) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Stableswap::AssetTradability` (r:2 w:0) /// Proof: `Stableswap::AssetTradability` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`) @@ -312,14 +313,14 @@ impl WeightInfo for HydraWeight { /// The range of component `e` is `[0, 1]`. fn router_execution_sell(_c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1555 + e * (1714 ±0)` - // Estimated: `13990 + e * (5797 ±245_709_589_663_843_264)` - // Minimum execution time: 314_654_000 picoseconds. - Weight::from_parts(321_208_138, 13990) - // Standard Error: 305_814 - .saturating_add(Weight::from_parts(731_985_555, 0).saturating_mul(e.into())) + // Measured: `1588 + e * (1805 ±0)` + // Estimated: `13990 + e * (5797 ±0)` + // Minimum execution time: 327_792_000 picoseconds. + Weight::from_parts(331_553_194, 13990) + // Standard Error: 419_520 + .saturating_add(Weight::from_parts(791_547_476, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().reads((13_u64).saturating_mul(e.into()))) + .saturating_add(T::DbWeight::get().reads((14_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 5797).saturating_mul(e.into())) } @@ -327,7 +328,7 @@ impl WeightInfo for HydraWeight { /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:5 w:0) + /// Storage: `AssetRegistry::Assets` (r:6 w:0) /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Stableswap::AssetTradability` (r:2 w:0) /// Proof: `Stableswap::AssetTradability` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`) @@ -349,21 +350,33 @@ impl WeightInfo for HydraWeight { /// The range of component `e` is `[0, 1]`. fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1554 + e * (1685 ±0)` - // Estimated: `13990 + e * (5797 ±201_913_854_157_949_888)` - // Minimum execution time: 312_997_000 picoseconds. - Weight::from_parts(314_359_000, 13990) - // Standard Error: 3_248_945 - .saturating_add(Weight::from_parts(12_345_948, 0).saturating_mul(c.into())) - // Standard Error: 7_132_362 - .saturating_add(Weight::from_parts(468_057_036, 0).saturating_mul(e.into())) + // Measured: `1587 + e * (1776 ±0)` + // Estimated: `13990 + e * (5797 ±245_709_589_663_843_264)` + // Minimum execution time: 328_597_000 picoseconds. + Weight::from_parts(330_295_000, 13990) + // Standard Error: 3_450_424 + .saturating_add(Weight::from_parts(13_109_908, 0).saturating_mul(c.into())) + // Standard Error: 7_574_666 + .saturating_add(Weight::from_parts(510_661_078, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().reads((14_u64).saturating_mul(e.into()))) + .saturating_add(T::DbWeight::get().reads((15_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((6_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 5797).saturating_mul(e.into())) } - + /// Storage: `Stableswap::Pools` (r:1 w:0) + /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:5 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:5 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) fn calculate_spot_price() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `1587` + // Estimated: `13990` + // Minimum execution time: 260_302_000 picoseconds. + Weight::from_parts(262_839_643, 13990) + // Standard Error: 74_388 + .saturating_add(Weight::from_parts(8_090, 0)) + .saturating_add(T::DbWeight::get().reads(11)) } } diff --git a/runtime/hydradx/src/weights/xyk.rs b/runtime/hydradx/src/weights/xyk.rs index 756452c60..dc97a224a 100644 --- a/runtime/hydradx/src/weights/xyk.rs +++ b/runtime/hydradx/src/weights/xyk.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for `pallet_xyk` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-15, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-15, STEPS: `10`, REPEAT: `30`, 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 @@ -33,9 +33,10 @@ // --wasm-execution=compiled // --heap-pages=4096 // --template=.maintain/pallet-weight-template-no-back.hbs -// --pallet=pallet_xyk -// --output=./weights/xyk.rs +// --pallet=pallet-xyk +// --output=weights-1.1.0/xyk.rs // --extrinsic=* +// --extra #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -50,6 +51,8 @@ use pallet_xyk::weights::WeightInfo; /// Weight functions for `pallet_xyk`. pub struct HydraWeight(PhantomData); impl WeightInfo for HydraWeight { + /// Storage: `AssetRegistry::Assets` (r:3 w:1) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) /// Storage: `XYK::ShareToken` (r:1 w:1) @@ -64,8 +67,6 @@ impl 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:3 w:1) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:3 w:0) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) @@ -88,10 +89,10 @@ impl WeightInfo for HydraWeight { /// Proof: `XYK::PoolAssets` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) fn create_pool() -> Weight { // Proof Size summary in bytes: - // Measured: `3522` + // Measured: `3622` // Estimated: `19071` - // Minimum execution time: 588_643_000 picoseconds. - Weight::from_parts(592_313_000, 19071) + // Minimum execution time: 594_360_000 picoseconds. + Weight::from_parts(597_529_000, 19071) .saturating_add(T::DbWeight::get().reads(33)) .saturating_add(T::DbWeight::get().writes(20)) } @@ -121,16 +122,16 @@ impl WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `Tokens::TotalIssuance` (r:1 w:1) /// 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: `EmaOracle::WhitelistedAssets` (r:1 w:0) + /// 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: `4159` + // Measured: `4258` // Estimated: `19071` - // Minimum execution time: 353_004_000 picoseconds. - Weight::from_parts(354_898_000, 19071) + // Minimum execution time: 355_154_000 picoseconds. + Weight::from_parts(357_271_000, 19071) .saturating_add(T::DbWeight::get().reads(27)) - .saturating_add(T::DbWeight::get().writes(14)) + .saturating_add(T::DbWeight::get().writes(13)) } /// Storage: `XYK::ShareToken` (r:1 w:1) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) @@ -158,18 +159,18 @@ impl 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: `EmaOracle::Accumulator` (r:1 w:1) - /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, 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: `XYK::PoolAssets` (r:0 w:1) /// Proof: `XYK::PoolAssets` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `4208` + // Measured: `4308` // Estimated: `19071` - // Minimum execution time: 523_229_000 picoseconds. - Weight::from_parts(525_459_000, 19071) + // Minimum execution time: 525_290_000 picoseconds. + Weight::from_parts(529_273_000, 19071) .saturating_add(T::DbWeight::get().reads(29)) - .saturating_add(T::DbWeight::get().writes(18)) + .saturating_add(T::DbWeight::get().writes(17)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) @@ -193,16 +194,16 @@ impl WeightInfo for HydraWeight { /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`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: `EmaOracle::WhitelistedAssets` (r:1 w:0) + /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `4057` + // Measured: `4157` // Estimated: `16488` - // Minimum execution time: 306_824_000 picoseconds. - Weight::from_parts(308_832_000, 16488) + // Minimum execution time: 308_285_000 picoseconds. + Weight::from_parts(309_799_000, 16488) .saturating_add(T::DbWeight::get().reads(24)) - .saturating_add(T::DbWeight::get().writes(11)) + .saturating_add(T::DbWeight::get().writes(10)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) @@ -226,16 +227,16 @@ impl WeightInfo for HydraWeight { /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, 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: `EmaOracle::WhitelistedAssets` (r:1 w:0) + /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `4057` + // Measured: `4157` // Estimated: `16488` - // Minimum execution time: 305_679_000 picoseconds. - Weight::from_parts(306_896_000, 16488) + // Minimum execution time: 305_868_000 picoseconds. + Weight::from_parts(307_731_000, 16488) .saturating_add(T::DbWeight::get().reads(24)) - .saturating_add(T::DbWeight::get().writes(11)) + .saturating_add(T::DbWeight::get().writes(10)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) @@ -259,23 +260,23 @@ impl WeightInfo for HydraWeight { /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`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: `EmaOracle::WhitelistedAssets` (r:1 w:0) + /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, 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: `1187 + e * (2870 ±0)` - // Estimated: `6156 + e * (10332 ±52_268_479_977_062_104)` - // Minimum execution time: 25_878_000 picoseconds. - Weight::from_parts(9_649_436, 6156) - // Standard Error: 80_766 - .saturating_add(Weight::from_parts(8_443_704, 0).saturating_mul(c.into())) - // Standard Error: 80_766 - .saturating_add(Weight::from_parts(289_624_454, 0).saturating_mul(e.into())) + // Measured: `1187 + e * (2970 ±0)` + // Estimated: `6156 + e * (10332 ±124_823_812_913_251_024)` + // Minimum execution time: 26_105_000 picoseconds. + Weight::from_parts(10_046_707, 6156) + // Standard Error: 68_331 + .saturating_add(Weight::from_parts(8_342_738, 0).saturating_mul(c.into())) + // Standard Error: 68_331 + .saturating_add(Weight::from_parts(290_434_716, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads((21_u64).saturating_mul(e.into()))) - .saturating_add(T::DbWeight::get().writes((11_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) @@ -300,27 +301,35 @@ impl WeightInfo for HydraWeight { /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, 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: `EmaOracle::WhitelistedAssets` (r:1 w:0) + /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, 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: `1187 + e * (2870 ±0)` + // Measured: `1187 + e * (2970 ±0)` // Estimated: `6156 + e * (10332 ±0)` - // Minimum execution time: 33_714_000 picoseconds. - Weight::from_parts(11_014_445, 6156) - // Standard Error: 41_799 - .saturating_add(Weight::from_parts(7_776_697, 0).saturating_mul(c.into())) - // Standard Error: 70_916 - .saturating_add(Weight::from_parts(287_790_853, 0).saturating_mul(e.into())) + // Minimum execution time: 34_243_000 picoseconds. + Weight::from_parts(9_537_362, 6156) + // Standard Error: 44_250 + .saturating_add(Weight::from_parts(8_444_305, 0).saturating_mul(c.into())) + // Standard Error: 75_076 + .saturating_add(Weight::from_parts(289_395_556, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads((21_u64).saturating_mul(e.into()))) - .saturating_add(T::DbWeight::get().writes((11_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: `Tokens::Accounts` (r:2 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_spot_price() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `1187` + // Estimated: `6156` + // Minimum execution time: 26_159_000 picoseconds. + Weight::from_parts(26_805_702, 6156) + .saturating_add(T::DbWeight::get().reads(3)) } } From 69eec15c686ab8cbbe9b23c862444344c4e0acc0 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Mon, 15 Apr 2024 13:48:36 -0500 Subject: [PATCH 03/61] remove params from benchmarks --- pallets/stableswap/src/benchmarks.rs | 3 --- runtime/hydradx/src/benchmarking/omnipool.rs | 2 -- 2 files changed, 5 deletions(-) diff --git a/pallets/stableswap/src/benchmarks.rs b/pallets/stableswap/src/benchmarks.rs index 216c7c38d..a6a5ce8c4 100644 --- a/pallets/stableswap/src/benchmarks.rs +++ b/pallets/stableswap/src/benchmarks.rs @@ -608,9 +608,6 @@ benchmarks! { } calculate_spot_price { - let c in 1..2; // number of times calculate_buy is executed - let e in 0..1; // if e == 1, execute_buy is executed - let caller: T::AccountId = account("caller", 0, 1); let lp_provider: T::AccountId = account("provider", 0, 1); let initial_liquidity = 1_000_000_000_000_000_000u128; diff --git a/runtime/hydradx/src/benchmarking/omnipool.rs b/runtime/hydradx/src/benchmarking/omnipool.rs index 66825dcba..7eacf2807 100644 --- a/runtime/hydradx/src/benchmarking/omnipool.rs +++ b/runtime/hydradx/src/benchmarking/omnipool.rs @@ -516,8 +516,6 @@ runtime_benchmarks! { } calculate_spot_price { - let c in 1..2; // number of times calculate_buy is executed - let e in 0..1; // if e == 1, execute_buy is executed init()?; let acc = Omnipool::protocol_account(); From 8946299d1a714e39dbca73ae18bd67dcad5e06c2 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Mon, 15 Apr 2024 13:59:21 -0500 Subject: [PATCH 04/61] rebenchmark AMMs --- pallets/omnipool/src/weights.rs | 16 ++++------------ pallets/stableswap/src/weights.rs | 12 ++++-------- runtime/hydradx/src/weights/omnipool.rs | 8 ++------ runtime/hydradx/src/weights/stableswap.rs | 6 ++---- 4 files changed, 12 insertions(+), 30 deletions(-) diff --git a/pallets/omnipool/src/weights.rs b/pallets/omnipool/src/weights.rs index 0c5fd8d3e..820a8cb66 100644 --- a/pallets/omnipool/src/weights.rs +++ b/pallets/omnipool/src/weights.rs @@ -577,12 +577,8 @@ impl WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `1933` // Estimated: `6156` - // Minimum execution time: 46_902_000 picoseconds. - Weight::from_parts(47_432_765, 6156) - // Standard Error: 25_604 - .saturating_add(Weight::from_parts(198_058, 0)) - // Standard Error: 25_604 - .saturating_add(Weight::from_parts(135_550, 0)) + // Minimum execution time: 47_828_000 picoseconds. + Weight::from_parts(48_456_000, 6156) .saturating_add(T::DbWeight::get().reads(6)) } } @@ -1096,12 +1092,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1933` // Estimated: `6156` - // Minimum execution time: 46_902_000 picoseconds. - Weight::from_parts(47_432_765, 6156) - // Standard Error: 25_604 - .saturating_add(Weight::from_parts(198_058, 0)) - // Standard Error: 25_604 - .saturating_add(Weight::from_parts(135_550, 0)) + // Minimum execution time: 47_828_000 picoseconds. + Weight::from_parts(48_456_000, 6156) .saturating_add(RocksDbWeight::get().reads(6)) } } diff --git a/pallets/stableswap/src/weights.rs b/pallets/stableswap/src/weights.rs index 1ae22f9b7..4bd3cfd8f 100644 --- a/pallets/stableswap/src/weights.rs +++ b/pallets/stableswap/src/weights.rs @@ -391,10 +391,8 @@ impl WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `1587` // Estimated: `13990` - // Minimum execution time: 260_302_000 picoseconds. - Weight::from_parts(262_839_643, 13990) - // Standard Error: 74_388 - .saturating_add(Weight::from_parts(8_090, 0)) + // Minimum execution time: 263_924_000 picoseconds. + Weight::from_parts(264_905_000, 13990) .saturating_add(T::DbWeight::get().reads(11)) } } @@ -723,10 +721,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1587` // Estimated: `13990` - // Minimum execution time: 260_302_000 picoseconds. - Weight::from_parts(262_839_643, 13990) - // Standard Error: 74_388 - .saturating_add(Weight::from_parts(8_090, 0)) + // Minimum execution time: 263_924_000 picoseconds. + Weight::from_parts(264_905_000, 13990) .saturating_add(RocksDbWeight::get().reads(11)) } } diff --git a/runtime/hydradx/src/weights/omnipool.rs b/runtime/hydradx/src/weights/omnipool.rs index 1d4e2f50e..5de05cf92 100644 --- a/runtime/hydradx/src/weights/omnipool.rs +++ b/runtime/hydradx/src/weights/omnipool.rs @@ -556,12 +556,8 @@ impl pallet_omnipool::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `1933` // Estimated: `6156` - // Minimum execution time: 46_902_000 picoseconds. - Weight::from_parts(47_432_765, 6156) - // Standard Error: 25_604 - .saturating_add(Weight::from_parts(198_058, 0)) - // Standard Error: 25_604 - .saturating_add(Weight::from_parts(135_550, 0)) + // Minimum execution time: 47_828_000 picoseconds. + Weight::from_parts(48_456_000, 6156) .saturating_add(T::DbWeight::get().reads(6)) } } \ No newline at end of file diff --git a/runtime/hydradx/src/weights/stableswap.rs b/runtime/hydradx/src/weights/stableswap.rs index 26b598e88..e5c80265a 100644 --- a/runtime/hydradx/src/weights/stableswap.rs +++ b/runtime/hydradx/src/weights/stableswap.rs @@ -373,10 +373,8 @@ impl WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `1587` // Estimated: `13990` - // Minimum execution time: 260_302_000 picoseconds. - Weight::from_parts(262_839_643, 13990) - // Standard Error: 74_388 - .saturating_add(Weight::from_parts(8_090, 0)) + // Minimum execution time: 263_924_000 picoseconds. + Weight::from_parts(264_905_000, 13990) .saturating_add(T::DbWeight::get().reads(11)) } } From 391b3d3dfb280d0c3e25a3db750be53e9e644dd0 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Mon, 15 Apr 2024 14:06:37 -0500 Subject: [PATCH 05/61] rebenchmark router --- pallets/route-executor/src/weights.rs | 156 +++++++++++------- runtime/hydradx/src/weights/route_executor.rs | 67 +++++--- 2 files changed, 136 insertions(+), 87 deletions(-) diff --git a/pallets/route-executor/src/weights.rs b/pallets/route-executor/src/weights.rs index fa74e6b83..e0fb0b5a1 100644 --- a/pallets/route-executor/src/weights.rs +++ b/pallets/route-executor/src/weights.rs @@ -15,14 +15,13 @@ // See the License for the specific language governing permissions and // limitations under the License. - //! Autogenerated weights for `pallet_route_executor` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-03-18, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-15, STEPS: `10`, REPEAT: `30`, 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: `Some("dev")`, DB CACHE: 1024 // Executed Command: // target/release/hydradx @@ -33,10 +32,11 @@ // --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --template=.maintain/pallet-weight-template.hbs -// --pallet=pallet_route-executor -// --output=re2.rs +// --template=.maintain/pallet-weight-template-no-back.hbs +// --pallet=pallet-route-executor +// --output=weights-1.1.0/router.rs // --extrinsic=* +// --extra #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -76,14 +76,14 @@ impl 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: `3436` + // Measured: `3502` // Estimated: `13905` - // Minimum execution time: 342_467_000 picoseconds. - Weight::from_parts(346_028_529, 13905) - // Standard Error: 185_098 - .saturating_add(Weight::from_parts(50_586_970, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(16_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + // Minimum execution time: 350_123_000 picoseconds. + Weight::from_parts(353_120_014, 13905) + // Standard Error: 196_262 + .saturating_add(Weight::from_parts(53_190_547, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(16)) + .saturating_add(T::DbWeight::get().writes(7)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) @@ -103,15 +103,15 @@ impl 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: `1604 + b * (1837 ±0)` - // Estimated: `6156 + b * (7749 ±0)` - // Minimum execution time: 75_256_000 picoseconds. - Weight::from_parts(76_245_000, 6156) - // Standard Error: 604_587 - .saturating_add(Weight::from_parts(2_376_809, 0).saturating_mul(c.into())) - // Standard Error: 1_327_242 - .saturating_add(Weight::from_parts(273_173_826, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Measured: `1604 + b * (1923 ±0)` + // Estimated: `6156 + b * (7749 ±99_524_913_928_918_768)` + // Minimum execution time: 76_629_000 picoseconds. + Weight::from_parts(77_524_000, 6156) + // Standard Error: 643_893 + .saturating_add(Weight::from_parts(2_575_705, 0).saturating_mul(c.into())) + // Standard Error: 1_413_530 + .saturating_add(Weight::from_parts(279_458_895, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads((13_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(b.into()))) .saturating_add(Weight::from_parts(0, 7749).saturating_mul(b.into())) @@ -140,12 +140,12 @@ impl 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: `6326` + // Measured: `6393` // Estimated: `39735` - // Minimum execution time: 2_275_922_000 picoseconds. - Weight::from_parts(2_284_697_000, 39735) - .saturating_add(T::DbWeight::get().reads(55_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 2_322_739_000 picoseconds. + Weight::from_parts(2_333_287_000, 39735) + .saturating_add(T::DbWeight::get().reads(55)) + .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: `Router::Routes` (r:0 w:1) /// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`) @@ -153,17 +153,33 @@ impl WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `1012` // Estimated: `0` - // Minimum execution time: 30_072_000 picoseconds. - Weight::from_parts(30_421_000, 0) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 30_683_000 picoseconds. + Weight::from_parts(31_106_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) } - + /// Storage: `Router::Routes` (r:1 w:0) + /// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`) fn get_route() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `800` + // Estimated: `3555` + // Minimum execution time: 8_542_000 picoseconds. + Weight::from_parts(8_764_000, 3555) + .saturating_add(T::DbWeight::get().reads(1)) } - + /// Storage: `LBP::PoolData` (r:1 w:0) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:2 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Locks` (r:1 w:0) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) fn calculate_spot_price_in_lbp() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `1641` + // Estimated: `6156` + // Minimum execution time: 44_947_000 picoseconds. + Weight::from_parts(45_510_000, 6156) + .saturating_add(T::DbWeight::get().reads(4)) } } @@ -186,14 +202,14 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 1]`. fn calculate_and_execute_sell_in_lbp(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3436` + // Measured: `3502` // Estimated: `13905` - // Minimum execution time: 342_467_000 picoseconds. - Weight::from_parts(346_028_529, 13905) - // Standard Error: 185_098 - .saturating_add(Weight::from_parts(50_586_970, 0).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(16_u64)) - .saturating_add(RocksDbWeight::get().writes(7_u64)) + // Minimum execution time: 350_123_000 picoseconds. + Weight::from_parts(353_120_014, 13905) + // Standard Error: 196_262 + .saturating_add(Weight::from_parts(53_190_547, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(16)) + .saturating_add(RocksDbWeight::get().writes(7)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) @@ -213,15 +229,15 @@ impl WeightInfo for () { /// 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: `1604 + b * (1837 ±0)` - // Estimated: `6156 + b * (7749 ±0)` - // Minimum execution time: 75_256_000 picoseconds. - Weight::from_parts(76_245_000, 6156) - // Standard Error: 604_587 - .saturating_add(Weight::from_parts(2_376_809, 0).saturating_mul(c.into())) - // Standard Error: 1_327_242 - .saturating_add(Weight::from_parts(273_173_826, 0).saturating_mul(b.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + // Measured: `1604 + b * (1923 ±0)` + // Estimated: `6156 + b * (7749 ±99_524_913_928_918_768)` + // Minimum execution time: 76_629_000 picoseconds. + Weight::from_parts(77_524_000, 6156) + // Standard Error: 643_893 + .saturating_add(Weight::from_parts(2_575_705, 0).saturating_mul(c.into())) + // Standard Error: 1_413_530 + .saturating_add(Weight::from_parts(279_458_895, 0).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().reads((13_u64).saturating_mul(b.into()))) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(b.into()))) .saturating_add(Weight::from_parts(0, 7749).saturating_mul(b.into())) @@ -250,12 +266,12 @@ impl WeightInfo for () { /// 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: `6326` + // Measured: `6393` // Estimated: `39735` - // Minimum execution time: 2_275_922_000 picoseconds. - Weight::from_parts(2_284_697_000, 39735) - .saturating_add(RocksDbWeight::get().reads(55_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + // Minimum execution time: 2_322_739_000 picoseconds. + Weight::from_parts(2_333_287_000, 39735) + .saturating_add(RocksDbWeight::get().reads(55)) + .saturating_add(RocksDbWeight::get().writes(1)) } /// Storage: `Router::Routes` (r:0 w:1) /// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`) @@ -263,16 +279,32 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1012` // Estimated: `0` - // Minimum execution time: 30_072_000 picoseconds. - Weight::from_parts(30_421_000, 0) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + // Minimum execution time: 30_683_000 picoseconds. + Weight::from_parts(31_106_000, 0) + .saturating_add(RocksDbWeight::get().writes(1)) } - + /// Storage: `Router::Routes` (r:1 w:0) + /// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`) fn get_route() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `800` + // Estimated: `3555` + // Minimum execution time: 8_542_000 picoseconds. + Weight::from_parts(8_764_000, 3555) + .saturating_add(RocksDbWeight::get().reads(1)) } - + /// Storage: `LBP::PoolData` (r:1 w:0) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:2 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Locks` (r:1 w:0) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) fn calculate_spot_price_in_lbp() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `1641` + // Estimated: `6156` + // Minimum execution time: 44_947_000 picoseconds. + Weight::from_parts(45_510_000, 6156) + .saturating_add(RocksDbWeight::get().reads(4)) } } diff --git a/runtime/hydradx/src/weights/route_executor.rs b/runtime/hydradx/src/weights/route_executor.rs index 3f4908300..53877f518 100644 --- a/runtime/hydradx/src/weights/route_executor.rs +++ b/runtime/hydradx/src/weights/route_executor.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for `pallet_route_executor` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-03-18, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-15, STEPS: `10`, REPEAT: `30`, 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 @@ -33,9 +33,10 @@ // --wasm-execution=compiled // --heap-pages=4096 // --template=.maintain/pallet-weight-template-no-back.hbs -// --pallet=pallet_route-executor -// --output=re2.rs +// --pallet=pallet-route-executor +// --output=weights-1.1.0/router.rs // --extrinsic=* +// --extra #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -65,12 +66,12 @@ impl pallet_route_executor::weights::WeightInfo for Hyd /// The range of component `c` is `[0, 1]`. fn calculate_and_execute_sell_in_lbp(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3436` + // Measured: `3502` // Estimated: `13905` - // Minimum execution time: 344_173_000 picoseconds. - Weight::from_parts(347_378_169, 13905) - // Standard Error: 131_839 - .saturating_add(Weight::from_parts(49_213_080, 0).saturating_mul(c.into())) + // Minimum execution time: 350_123_000 picoseconds. + Weight::from_parts(353_120_014, 13905) + // Standard Error: 196_262 + .saturating_add(Weight::from_parts(53_190_547, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(16)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -92,14 +93,14 @@ impl pallet_route_executor::weights::WeightInfo for Hyd /// 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: `1604 + b * (1837 ±0)` - // Estimated: `6156 + b * (7749 ±251_795_645_551_580_832)` - // Minimum execution time: 75_692_000 picoseconds. - Weight::from_parts(76_409_000, 6156) - // Standard Error: 611_234 - .saturating_add(Weight::from_parts(2_382_471, 0).saturating_mul(c.into())) - // Standard Error: 1_341_833 - .saturating_add(Weight::from_parts(272_805_599, 0).saturating_mul(b.into())) + // Measured: `1604 + b * (1923 ±0)` + // Estimated: `6156 + b * (7749 ±99_524_913_928_918_768)` + // Minimum execution time: 76_629_000 picoseconds. + Weight::from_parts(77_524_000, 6156) + // Standard Error: 643_893 + .saturating_add(Weight::from_parts(2_575_705, 0).saturating_mul(c.into())) + // Standard Error: 1_413_530 + .saturating_add(Weight::from_parts(279_458_895, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads((13_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(b.into()))) @@ -129,10 +130,10 @@ impl pallet_route_executor::weights::WeightInfo for Hyd /// 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: `6326` + // Measured: `6393` // Estimated: `39735` - // Minimum execution time: 2_263_303_000 picoseconds. - Weight::from_parts(2_275_623_000, 39735) + // Minimum execution time: 2_322_739_000 picoseconds. + Weight::from_parts(2_333_287_000, 39735) .saturating_add(T::DbWeight::get().reads(55)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -142,16 +143,32 @@ impl pallet_route_executor::weights::WeightInfo for Hyd // Proof Size summary in bytes: // Measured: `1012` // Estimated: `0` - // Minimum execution time: 29_861_000 picoseconds. - Weight::from_parts(30_303_000, 0) + // Minimum execution time: 30_683_000 picoseconds. + Weight::from_parts(31_106_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } - + /// Storage: `Router::Routes` (r:1 w:0) + /// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`) fn get_route() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `800` + // Estimated: `3555` + // Minimum execution time: 8_542_000 picoseconds. + Weight::from_parts(8_764_000, 3555) + .saturating_add(T::DbWeight::get().reads(1)) } - + /// Storage: `LBP::PoolData` (r:1 w:0) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:2 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Locks` (r:1 w:0) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) fn calculate_spot_price_in_lbp() -> Weight { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `1641` + // Estimated: `6156` + // Minimum execution time: 44_947_000 picoseconds. + Weight::from_parts(45_510_000, 6156) + .saturating_add(T::DbWeight::get().reads(4)) } } \ No newline at end of file From 2ecb60d7ea60f242704447f3a433ad33bebefe23 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Mon, 15 Apr 2024 14:13:13 -0500 Subject: [PATCH 06/61] rebenchmark dca --- pallets/dca/src/weights.rs | 69 ++++++++++++++++-------------- runtime/hydradx/src/weights/dca.rs | 37 ++++++++-------- 2 files changed, 55 insertions(+), 51 deletions(-) diff --git a/pallets/dca/src/weights.rs b/pallets/dca/src/weights.rs index bccefb04d..f1100adcf 100644 --- a/pallets/dca/src/weights.rs +++ b/pallets/dca/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for `pallet_dca` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-27, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-15, STEPS: `10`, REPEAT: `30`, 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 @@ -36,6 +36,7 @@ // --pallet=pallet-dca // --output=weights-1.1.0/dca.rs // --extrinsic=* +// --extra #![allow(unused_parens)] #![allow(unused_imports)] @@ -74,10 +75,10 @@ impl WeightInfo for HydraWeight { /// 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: `54411` + // Measured: `54557` // Estimated: `31902` - // Minimum execution time: 244_530_000 picoseconds. - Weight::from_parts(249_044_000, 31902) + // Minimum execution time: 245_760_000 picoseconds. + Weight::from_parts(250_305_000, 31902) .saturating_add(T::DbWeight::get().reads(17)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -95,10 +96,10 @@ impl WeightInfo for HydraWeight { /// 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: `54411` + // Measured: `54665` // Estimated: `31902` - // Minimum execution time: 244_929_000 picoseconds. - Weight::from_parts(249_576_000, 31902) + // Minimum execution time: 246_294_000 picoseconds. + Weight::from_parts(255_918_000, 31902) .saturating_add(T::DbWeight::get().reads(17)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -106,10 +107,11 @@ impl WeightInfo for HydraWeight { /// Proof: `DCA::ScheduleIdsPerBlock` (`max_values`: None, `max_size`: Some(101), added: 2576, mode: `MaxEncodedLen`) fn on_initialize_with_empty_block() -> Weight { // Proof Size summary in bytes: - // Measured: `1075` + // Measured: `1113` // Estimated: `3566` - // Minimum execution time: 17_904_000 picoseconds. - Weight::from_parts(18_177_000, 3566).saturating_add(T::DbWeight::get().reads(1)) + // Minimum execution time: 19_342_000 picoseconds. + Weight::from_parts(19_876_000, 3566) + .saturating_add(T::DbWeight::get().reads(1)) } /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) @@ -122,7 +124,7 @@ impl WeightInfo for HydraWeight { /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `DCA::ScheduleIdsPerBlock` (r:11 w:1) /// Proof: `DCA::ScheduleIdsPerBlock` (`max_values`: None, `max_size`: Some(101), added: 2576, mode: `MaxEncodedLen`) /// Storage: `DCA::RetriesOnError` (r:0 w:1) @@ -135,10 +137,10 @@ impl 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: `52577` + // Measured: `52623` // Estimated: `29326` - // Minimum execution time: 175_288_000 picoseconds. - Weight::from_parts(178_961_000, 29326) + // Minimum execution time: 178_372_000 picoseconds. + Weight::from_parts(180_669_000, 29326) .saturating_add(T::DbWeight::get().reads(17)) .saturating_add(T::DbWeight::get().writes(8)) } @@ -158,10 +160,10 @@ impl WeightInfo for HydraWeight { /// Proof: `DCA::ScheduleOwnership` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`) fn terminate() -> Weight { // Proof Size summary in bytes: - // Measured: `2526` + // Measured: `2564` // Estimated: `4714` - // Minimum execution time: 82_404_000 picoseconds. - Weight::from_parts(83_099_000, 4714) + // Minimum execution time: 82_773_000 picoseconds. + Weight::from_parts(83_722_000, 4714) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -183,10 +185,10 @@ impl WeightInfo for () { /// 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: `54411` + // Measured: `54557` // Estimated: `31902` - // Minimum execution time: 244_530_000 picoseconds. - Weight::from_parts(249_044_000, 31902) + // Minimum execution time: 245_760_000 picoseconds. + Weight::from_parts(250_305_000, 31902) .saturating_add(RocksDbWeight::get().reads(17)) .saturating_add(RocksDbWeight::get().writes(7)) } @@ -204,10 +206,10 @@ impl WeightInfo for () { /// 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: `54411` + // Measured: `54665` // Estimated: `31902` - // Minimum execution time: 244_929_000 picoseconds. - Weight::from_parts(249_576_000, 31902) + // Minimum execution time: 246_294_000 picoseconds. + Weight::from_parts(255_918_000, 31902) .saturating_add(RocksDbWeight::get().reads(17)) .saturating_add(RocksDbWeight::get().writes(7)) } @@ -215,10 +217,11 @@ impl WeightInfo for () { /// Proof: `DCA::ScheduleIdsPerBlock` (`max_values`: None, `max_size`: Some(101), added: 2576, mode: `MaxEncodedLen`) fn on_initialize_with_empty_block() -> Weight { // Proof Size summary in bytes: - // Measured: `1075` + // Measured: `1113` // Estimated: `3566` - // Minimum execution time: 17_904_000 picoseconds. - Weight::from_parts(18_177_000, 3566).saturating_add(RocksDbWeight::get().reads(1)) + // Minimum execution time: 19_342_000 picoseconds. + Weight::from_parts(19_876_000, 3566) + .saturating_add(RocksDbWeight::get().reads(1)) } /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) @@ -231,7 +234,7 @@ impl WeightInfo for () { /// 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(87), added: 2562, mode: `MaxEncodedLen`) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `DCA::ScheduleIdsPerBlock` (r:11 w:1) /// Proof: `DCA::ScheduleIdsPerBlock` (`max_values`: None, `max_size`: Some(101), added: 2576, mode: `MaxEncodedLen`) /// Storage: `DCA::RetriesOnError` (r:0 w:1) @@ -244,10 +247,10 @@ impl WeightInfo for () { /// Proof: `DCA::RemainingAmounts` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) fn schedule() -> Weight { // Proof Size summary in bytes: - // Measured: `52577` + // Measured: `52623` // Estimated: `29326` - // Minimum execution time: 175_288_000 picoseconds. - Weight::from_parts(178_961_000, 29326) + // Minimum execution time: 178_372_000 picoseconds. + Weight::from_parts(180_669_000, 29326) .saturating_add(RocksDbWeight::get().reads(17)) .saturating_add(RocksDbWeight::get().writes(8)) } @@ -267,10 +270,10 @@ impl WeightInfo for () { /// Proof: `DCA::ScheduleOwnership` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`) fn terminate() -> Weight { // Proof Size summary in bytes: - // Measured: `2526` + // Measured: `2564` // Estimated: `4714` - // Minimum execution time: 82_404_000 picoseconds. - Weight::from_parts(83_099_000, 4714) + // Minimum execution time: 82_773_000 picoseconds. + Weight::from_parts(83_722_000, 4714) .saturating_add(RocksDbWeight::get().reads(5)) .saturating_add(RocksDbWeight::get().writes(7)) } diff --git a/runtime/hydradx/src/weights/dca.rs b/runtime/hydradx/src/weights/dca.rs index 143e19da8..b599005e2 100644 --- a/runtime/hydradx/src/weights/dca.rs +++ b/runtime/hydradx/src/weights/dca.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for `pallet_dca` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-15, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-15, STEPS: `10`, REPEAT: `30`, 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 @@ -33,9 +33,10 @@ // --wasm-execution=compiled // --heap-pages=4096 // --template=.maintain/pallet-weight-template-no-back.hbs -// --pallet=pallet_dca -// --output=./weights/dca.rs +// --pallet=pallet-dca +// --output=weights-1.1.0/dca.rs // --extrinsic=* +// --extra* #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -64,10 +65,10 @@ impl WeightInfo for HydraWeight { /// 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: `54411` + // Measured: `54557` // Estimated: `31902` - // Minimum execution time: 237_105_000 picoseconds. - Weight::from_parts(240_959_000, 31902) + // Minimum execution time: 245_760_000 picoseconds. + Weight::from_parts(250_305_000, 31902) .saturating_add(T::DbWeight::get().reads(17)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -85,10 +86,10 @@ impl WeightInfo for HydraWeight { /// 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: `54411` + // Measured: `54665` // Estimated: `31902` - // Minimum execution time: 238_379_000 picoseconds. - Weight::from_parts(241_004_000, 31902) + // Minimum execution time: 246_294_000 picoseconds. + Weight::from_parts(255_918_000, 31902) .saturating_add(T::DbWeight::get().reads(17)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -96,10 +97,10 @@ impl WeightInfo for HydraWeight { /// Proof: `DCA::ScheduleIdsPerBlock` (`max_values`: None, `max_size`: Some(101), added: 2576, mode: `MaxEncodedLen`) fn on_initialize_with_empty_block() -> Weight { // Proof Size summary in bytes: - // Measured: `1075` + // Measured: `1113` // Estimated: `3566` - // Minimum execution time: 17_306_000 picoseconds. - Weight::from_parts(17_642_000, 3566) + // Minimum execution time: 19_342_000 picoseconds. + Weight::from_parts(19_876_000, 3566) .saturating_add(T::DbWeight::get().reads(1)) } /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) @@ -126,10 +127,10 @@ impl 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: `52552` + // Measured: `52623` // Estimated: `29326` - // Minimum execution time: 174_494_000 picoseconds. - Weight::from_parts(176_197_000, 29326) + // Minimum execution time: 178_372_000 picoseconds. + Weight::from_parts(180_669_000, 29326) .saturating_add(T::DbWeight::get().reads(17)) .saturating_add(T::DbWeight::get().writes(8)) } @@ -149,10 +150,10 @@ impl WeightInfo for HydraWeight { /// Proof: `DCA::ScheduleOwnership` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`) fn terminate() -> Weight { // Proof Size summary in bytes: - // Measured: `2526` + // Measured: `2564` // Estimated: `4714` - // Minimum execution time: 80_303_000 picoseconds. - Weight::from_parts(81_183_000, 4714) + // Minimum execution time: 82_773_000 picoseconds. + Weight::from_parts(83_722_000, 4714) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(7)) } From c587394c5b0fa510c8d058c752020334fef310dc Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Mon, 15 Apr 2024 14:29:28 -0500 Subject: [PATCH 07/61] fix benchmark test --- pallets/dca/src/tests/mock.rs | 8 ++++---- pallets/dca/src/tests/on_initialize.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index 3454b897c..9da6b45b5 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -54,10 +54,10 @@ pub type BlockNumber = u64; pub type AssetId = u32; type NamedReserveIdentifier = [u8; 8]; -pub const BUY_DCA_FEE_IN_NATIVE: Balance = 1374044000; -pub const BUY_DCA_FEE_IN_DAI: Balance = 1209158720; -pub const SELL_DCA_FEE_IN_NATIVE: Balance = 1374576000; -pub const SELL_DCA_FEE_IN_DAI: Balance = 1209626880; +pub const BUY_DCA_FEE_IN_NATIVE: Balance = 1375305000; +pub const BUY_DCA_FEE_IN_DAI: Balance = 1210268400; +pub const SELL_DCA_FEE_IN_NATIVE: Balance = 1380918000; +pub const SELL_DCA_FEE_IN_DAI: Balance = 1215207840; pub const HDX: AssetId = 0; pub const LRNA: AssetId = 1; diff --git a/pallets/dca/src/tests/on_initialize.rs b/pallets/dca/src/tests/on_initialize.rs index d1f793a33..8e39e3eac 100644 --- a/pallets/dca/src/tests/on_initialize.rs +++ b/pallets/dca/src/tests/on_initialize.rs @@ -865,7 +865,7 @@ fn full_buy_dca_should_be_completed_when_some_execution_is_successful_but_not_en assert_number_of_executed_buy_trades!(4); assert_eq!(0, Currencies::reserved_balance(HDX, &ALICE)); - let left_over_which_is_not_enough_for_last_trade = 9994503824000; + let left_over_which_is_not_enough_for_last_trade = 9994498780000; assert_balance!( ALICE, From 2525c15b95602f68c9d6ee40fd1b15ee921fb765 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 16 Apr 2024 15:02:19 -0500 Subject: [PATCH 08/61] fix benchmarks --- pallets/otc-settlements/src/benchmarks.rs | 20 +++++++------ pallets/otc-settlements/src/lib.rs | 14 ++++----- pallets/otc-settlements/src/mock.rs | 35 ++++++++++++++++------- pallets/otc-settlements/src/tests.rs | 11 +++++++ pallets/route-executor/src/lib.rs | 4 +-- 5 files changed, 55 insertions(+), 29 deletions(-) diff --git a/pallets/otc-settlements/src/benchmarks.rs b/pallets/otc-settlements/src/benchmarks.rs index 8d9272fc1..ac9780627 100644 --- a/pallets/otc-settlements/src/benchmarks.rs +++ b/pallets/otc-settlements/src/benchmarks.rs @@ -21,7 +21,7 @@ use orml_traits::MultiCurrency; pub const ONE: Balance = 1_000_000_000_000; pub const HDX: u32 = 0; -pub const DOT: u32 = 2; +pub const DAI: u32 = 2; benchmarks! { where_clause { where @@ -30,22 +30,26 @@ benchmarks! { T: crate::Config, T: pallet_otc::Config, u32: From>, - ::AssetRegistry: Create> + ::AssetRegistry: Create>, } settle_otc_order { + let (dot, dai) = (HDX, DAI); let account: T::AccountId = account("acc", 1, 1); - ::Currency::deposit(HDX.into(), &account, 1_000_000 * ONE)?; - ::Currency::deposit(DOT.into(), &account, 1_000_000 * ONE)?; + + + ::Currency::deposit(dot.into(), &account, 1_000_000_000 * ONE)?; + ::Currency::deposit(dai.into(), &account, 1_000_000_000 * ONE)?; assert_ok!( - pallet_otc::Pallet::::place_order(RawOrigin::Signed(account.clone()).into(), HDX.into(), DOT.into(), 100_000 * ONE, 200_001 * ONE, true) + pallet_otc::Pallet::::place_order(RawOrigin::Signed(account.clone()).into(), dot.into(), dai.into(), 100_000_000 * ONE, 200_000_001 * ONE, true) ); let route = ::Router::get_route(AssetPair { - asset_in: DOT.into(), - asset_out: HDX.into(), + asset_in: dai.into(), + asset_out: dot.into(), }); - }: _(RawOrigin::None, 0u32, 762_939_453_125, route) + + }: _(RawOrigin::None, 0u32, 2 * ONE, route) } #[cfg(test)] diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 9ae14b226..bf168c52b 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -25,6 +25,7 @@ use frame_system::{ use hydradx_traits::router::{AmmTradeWeights, AmountInAndOut, AssetPair, RouteProvider, RouteSpotPriceProvider, RouterT, Trade}; use orml_traits::{GetByKey, MultiCurrency}; pub use pallet_otc::OrderId; +use pallet_otc::weights::WeightInfo as OtcWeightInfo; use sp_arithmetic::traits::{CheckedMul, Saturating}; use sp_arithmetic::{ArithmeticError, FixedPointNumber, FixedU128}; use sp_runtime::offchain::storage::StorageValueRef; @@ -180,6 +181,7 @@ pub mod pallet { .saturating_add(::RouterWeightInfo::sell_weight(route)) .saturating_add(::RouterWeightInfo::get_route_weight()) .saturating_add(::RouterWeightInfo::calculate_spot_price_weight(route)) + .saturating_add(::WeightInfo::fill_order().max(::WeightInfo::partial_fill_order())) )] pub fn settle_otc_order(origin: OriginFor, otc_id: OrderId, amount: Balance, route: Vec>>) -> DispatchResult { ensure_none(origin)?; @@ -237,15 +239,7 @@ impl Pallet { let otc_price = FixedU128::checked_from_rational(otc.amount_out, otc.amount_in).ok_or(ArithmeticError::Overflow)?; - // TODO: remove - // let router_price_before = T::Router::spot_price(&route).ok_or(Error::::PriceNotAvailable)?; - log::debug!( - target: "offchain_worker::settle_otc", - "initial router price: {:?} otc_price: {:?} ", - T::Router::spot_price(&route).ok_or(Error::::PriceNotAvailable)?, - otc_price - ); - + #[cfg(not(feature = "runtime-benchmarks"))] if otc.partially_fillable && amount != otc.amount_in { log::debug!( target: "offchain_worker::settle_otc", @@ -265,6 +259,8 @@ impl Pallet { log::debug!( target: "offchain_worker::settle_otc", "calling router sell: amount_in {:?} ", otc_amount_out); + + #[cfg(not(feature = "runtime-benchmarks"))] T::Router::sell( RawOrigin::Signed(pallet_acc.clone()).into(), asset_b, diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index e4ba10e89..9b5fa93b1 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -39,6 +39,7 @@ use sp_runtime::{ BuildStorage, }; use sp_std::sync::Arc; +use std::{cell::RefCell, collections::HashMap}; type Block = frame_system::mocking::MockBlock; @@ -60,6 +61,10 @@ pub const ONE: Balance = 1_000_000_000_000; pub const ALICE: AccountId = 1; pub const BOB: AccountId = 2; +thread_local! { + pub static REGISTERED_ASSETS: RefCell> = RefCell::new(HashMap::default()); +} + frame_support::construct_runtime!( pub enum Test { @@ -123,7 +128,7 @@ impl hydradx_traits::registry::Inspect for MockedAssetRegistry { true } - fn exists(_id: Self::AssetId) -> bool { + fn exists(_asset_id: Self::AssetId) -> bool { true } @@ -303,7 +308,17 @@ where _xcm_rate_limit: Option, _is_sufficient: bool, ) -> Result { - unimplemented!() + let assigned = REGISTERED_ASSETS.with(|v| { + //NOTE: This is to have same ids as real AssetRegistry which is used in the benchmarks. + //1_000_000 - offset of the reals AssetRegistry + // - 5 - remove assets reagistered by default for the vec.len() + // + 1 - first reg asset start with 1 not 0 + // => 1st asset id == 1_000_001 + let l = 1_000_000 - 4 + v.borrow().len(); + v.borrow_mut().insert(l as u32, l as u32); + l as u32 + }); + Ok(assigned) } fn register_insufficient_asset( @@ -486,6 +501,14 @@ impl ExtBuilder { pub fn build(self) -> (sp_io::TestExternalities, Arc>) { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); + REGISTERED_ASSETS.with(|v| { + v.borrow_mut().insert(HDX, HDX); + v.borrow_mut().insert(LRNA, LRNA); + v.borrow_mut().insert(DAI, DAI); + v.borrow_mut().insert(DOT, DOT); + v.borrow_mut().insert(KSM, KSM); + }); + let mut initial_native_accounts: Vec<(AccountId, Balance)> = vec![]; let additional_accounts: Vec<(AccountId, Balance)> = self .endowed_accounts @@ -561,11 +584,3 @@ impl ExtBuilder { (ext, pool_state) } } - -pub fn expect_events(e: Vec) { - e.into_iter().for_each(frame_system::Pallet::::assert_has_event); -} - -pub fn calculate_otc_price(otc: &pallet_otc::Order) -> FixedU128 { - FixedU128::checked_from_rational(otc.amount_out, otc.amount_in).unwrap() -} diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 82f0bc30a..99f50efd1 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -15,11 +15,22 @@ // See the License for the specific language governing permissions and // limitations under the License. +// we don't need to run tests with benchmarking feature +#![cfg(not(feature = "runtime-benchmarks"))] + #![allow(clippy::bool_assert_comparison)] use super::*; pub use crate::mock::*; use frame_support::{assert_ok, assert_storage_noop}; +pub fn expect_events(e: Vec) { + e.into_iter().for_each(frame_system::Pallet::::assert_has_event); +} + +pub fn calculate_otc_price(otc: &pallet_otc::Order) -> FixedU128 { + FixedU128::checked_from_rational(otc.amount_out, otc.amount_in).unwrap() +} + #[test] fn offchain_worker_should_store_last_update_in_storage() { let (mut ext, _) = ExtBuilder::default().build(); diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index 7c7e1c084..3e5a8f113 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}; use sp_core::U512; -use sp_runtime::traits::{AccountIdConversion, CheckedDiv, One}; +use sp_runtime::traits::{AccountIdConversion, CheckedDiv}; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128, TransactionOutcome}; use sp_std::{vec, vec::Vec}; @@ -821,7 +821,7 @@ impl RouterT RouteSpotPriceProvider for DummyRouter { fn spot_price(_route: &[Trade]) -> Option { - Some(FixedU128::one()) + Some(FixedU128::from_u32(2)) } } From 28041e4f5247f930c1abba1da720f85f89585831 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 16 Apr 2024 15:10:10 -0500 Subject: [PATCH 09/61] rebenchmark otc settlements pallet --- pallets/otc-settlements/src/weights.rs | 49 ++++++++++++++----- .../hydradx/src/weights/otc_settlements.rs | 23 +++++++-- 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/pallets/otc-settlements/src/weights.rs b/pallets/otc-settlements/src/weights.rs index 16fa9838e..7fcbc989f 100644 --- a/pallets/otc-settlements/src/weights.rs +++ b/pallets/otc-settlements/src/weights.rs @@ -15,29 +15,28 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Autogenerated weights for `pallet_otc` +//! Autogenerated weights for `pallet_otc_settlements` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-12, STEPS: `5`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-16, STEPS: `10`, REPEAT: `30`, 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: `Some("dev")`, DB CACHE: 1024 // Executed Command: // target/release/hydradx // benchmark // pallet -// --pallet=pallet-otc +// --chain=dev +// --steps=10 +// --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --chain=dev +// --template=.maintain/pallet-weight-template-no-back.hbs +// --pallet=pallet-otc-settlements +// --output=weights-1.1.0/otc_settlements.rs // --extrinsic=* -// --steps=5 -// --repeat=20 -// --output -// ./weights-1.1.0/otc.rs -// --template -// .maintain/pallet-weight-template-no-back.hbs +// --extra #![allow(unused_parens)] #![allow(unused_imports)] @@ -58,14 +57,38 @@ pub trait WeightInfo { pub struct HydraWeight(PhantomData); impl 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:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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 { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `644` + // Estimated: `3593` + // Minimum execution time: 96_068_000 picoseconds. + Weight::from_parts(96_704_000, 3593) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) } } // For backwards compatibility and tests impl WeightInfo for () { + /// 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:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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 { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `644` + // Estimated: `3593` + // Minimum execution time: 96_068_000 picoseconds. + Weight::from_parts(96_704_000, 3593) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(1)) } } diff --git a/runtime/hydradx/src/weights/otc_settlements.rs b/runtime/hydradx/src/weights/otc_settlements.rs index 79d19c2db..f1681c343 100644 --- a/runtime/hydradx/src/weights/otc_settlements.rs +++ b/runtime/hydradx/src/weights/otc_settlements.rs @@ -15,10 +15,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Autogenerated weights for `pallet_otc` +//! Autogenerated weights for `pallet_otc_settlements` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-15, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-04-16, STEPS: `10`, REPEAT: `30`, 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 @@ -33,9 +33,10 @@ // --wasm-execution=compiled // --heap-pages=4096 // --template=.maintain/pallet-weight-template-no-back.hbs -// --pallet=pallet_otc -// --output=./weights/otc.rs +// --pallet=pallet-otc-settlements +// --output=weights-1.1.0/otc_settlements.rs // --extrinsic=* +// --extra #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -50,7 +51,19 @@ use pallet_otc_settlements::weights::WeightInfo; /// Weight functions for `pallet_otc`. pub struct HydraWeight(PhantomData); impl 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:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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 { - Weight::zero() + // Proof Size summary in bytes: + // Measured: `644` + // Estimated: `3593` + // Minimum execution time: 96_068_000 picoseconds. + Weight::from_parts(96_704_000, 3593) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) } } From a47a864237dd55e29283255aa553fe943dded802 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 16 Apr 2024 15:45:56 -0500 Subject: [PATCH 10/61] update comments --- pallets/otc-settlements/src/lib.rs | 48 +++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index bf168c52b..513d178d0 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -80,32 +80,37 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_otc::Config + SendTransactionTypes> { + /// The overarching event type. + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + /// Named reservable multi currency type Currency: MultiCurrency, Balance = Balance>; - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - + ///Router implementation type Router: RouteProvider> + RouterT, Balance, Trade>, AmountInAndOut> + RouteSpotPriceProvider>; + /// Provider of existential deposits. type ExistentialDeposits: GetByKey, Balance>; - /// Account who receives the profit. + /// Determines the minimum profit #[pallet::constant] - type ProfitReceiver: Get; + type ExistentialDepositMultiplier: Get; + /// Account who receives the profit. #[pallet::constant] - type ExistentialDepositMultiplier: Get; + type ProfitReceiver: Get; + /// Determines when we consider an arbitrage as closed. #[pallet::constant] type PricePrecision: Get; - /// Weight information for the extrinsics. - type WeightInfo: WeightInfo; + /// Router weight information. + type RouterWeightInfo: AmmTradeWeights>>; /// Weight information for the extrinsics. - type RouterWeightInfo: AmmTradeWeights>>; + type WeightInfo: WeightInfo; } #[pallet::hooks] @@ -152,7 +157,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] pub enum Event { - /// An Order has been cancelled + /// A trade has been executed Executed { otc_id: OrderId, otc_asset_in: AssetIdOf, @@ -166,16 +171,37 @@ pub mod pallet { #[pallet::error] pub enum Error { - /// Order cannot be found + /// Otc order not found OrderNotFound, - PriceNotAvailable, + /// Execution requirements not met InvalidConditions, + /// Trade amount higher than necessary TradeAmountTooHigh, + /// Trade amount lower than necessary TradeAmountTooLow, } #[pallet::call] impl Pallet { + /// Close an existing OTC arbitrage opportunity. + /// + /// Executes a trade between an OTC order and some route. + /// If the OTC order is partially fillable, the extrinsic fails if the existing arbitrage + /// opportunity is not closed af the trade. + /// If the OTC order is not partially fillable, fails if there is no profit af the trade. + /// + /// `Origin` calling this extrinsic is not paying or receiving anything. + /// + /// The profit made by closing the arbitrage is transferred to `FeeReceiver`. + /// + /// Parameters: + /// - `origin`: Unsigned origin. + /// - `otc_id`: ID of the OTC order with existing arbitrage opportunity. + /// - `amount`: Amount necessary to clone the arb. + /// - `route`: The route we trade against. Required for the fee calculation. + /// + /// Emits `Executed` event when successful. + /// #[pallet::call_index(0)] #[pallet::weight(::WeightInfo::settle_otc_order() .saturating_add(::RouterWeightInfo::sell_weight(route)) From 8b6660665f04188336d9cb72db46550018210f90 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 16 Apr 2024 15:46:45 -0500 Subject: [PATCH 11/61] bump crate version --- Cargo.lock | 2 +- pallets/otc/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 73bca7702..c302e28a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8182,7 +8182,7 @@ dependencies = [ [[package]] name = "pallet-otc" -version = "1.1.1" +version = "1.1.2" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/pallets/otc/Cargo.toml b/pallets/otc/Cargo.toml index 3eba0e9f0..f565ba074 100644 --- a/pallets/otc/Cargo.toml +++ b/pallets/otc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-otc' -version = '1.1.1' +version = '1.1.2' description = 'A pallet for trustless over-the-counter trading' authors = ['GalacticCouncil'] edition = '2021' From 5b949d06719e76e36fe6ca5a3d31905b3800b214 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 16 Apr 2024 15:48:32 -0500 Subject: [PATCH 12/61] formatting --- pallets/dca/src/weights.rs | 6 ++--- pallets/lbp/src/benchmarking.rs | 2 +- pallets/lbp/src/weights.rs | 20 ++++++--------- pallets/omnipool/src/weights.rs | 14 +++++------ pallets/otc-settlements/src/lib.rs | 25 +++++++++++++------ pallets/otc-settlements/src/tests.rs | 1 - pallets/stableswap/src/benchmarks.rs | 2 +- pallets/stableswap/src/weights.rs | 14 +++++------ pallets/xyk/src/weights.rs | 14 +++++------ runtime/hydradx/src/assets.rs | 4 +-- runtime/hydradx/src/benchmarking/omnipool.rs | 2 +- .../src/benchmarking/route_executor.rs | 6 ++--- 12 files changed, 53 insertions(+), 57 deletions(-) diff --git a/pallets/dca/src/weights.rs b/pallets/dca/src/weights.rs index f1100adcf..00c12b084 100644 --- a/pallets/dca/src/weights.rs +++ b/pallets/dca/src/weights.rs @@ -110,8 +110,7 @@ impl WeightInfo for HydraWeight { // Measured: `1113` // Estimated: `3566` // Minimum execution time: 19_342_000 picoseconds. - Weight::from_parts(19_876_000, 3566) - .saturating_add(T::DbWeight::get().reads(1)) + Weight::from_parts(19_876_000, 3566).saturating_add(T::DbWeight::get().reads(1)) } /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) @@ -220,8 +219,7 @@ impl WeightInfo for () { // Measured: `1113` // Estimated: `3566` // Minimum execution time: 19_342_000 picoseconds. - Weight::from_parts(19_876_000, 3566) - .saturating_add(RocksDbWeight::get().reads(1)) + Weight::from_parts(19_876_000, 3566).saturating_add(RocksDbWeight::get().reads(1)) } /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) diff --git a/pallets/lbp/src/benchmarking.rs b/pallets/lbp/src/benchmarking.rs index 9cc186000..37a47fbd4 100644 --- a/pallets/lbp/src/benchmarking.rs +++ b/pallets/lbp/src/benchmarking.rs @@ -258,7 +258,7 @@ benchmarks! { } verify{} - calculate_spot_price { + calculate_spot_price { let caller = funded_account::("caller", 0); let fee_collector = funded_account::("fee_collector", 0); let asset_in: AssetId = ASSET_A_ID; diff --git a/pallets/lbp/src/weights.rs b/pallets/lbp/src/weights.rs index 559667886..24f173812 100644 --- a/pallets/lbp/src/weights.rs +++ b/pallets/lbp/src/weights.rs @@ -216,7 +216,7 @@ impl WeightInfo for HydraWeight { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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: `789 + e * (1155 ±0)` // Estimated: `6156 + e * (7749 ±245_709_589_663_843_264)` @@ -247,7 +247,7 @@ impl WeightInfo for HydraWeight { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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 { + fn router_execution_buy(c: u32, e: u32) -> Weight { // Proof Size summary in bytes: // Measured: `789 + e * (1155 ±0)` // Estimated: `6156 + e * (7749 ±0)` @@ -271,8 +271,7 @@ impl WeightInfo for HydraWeight { // Measured: `789` // Estimated: `6156` // Minimum execution time: 67_298_000 picoseconds. - Weight::from_parts(68_051_000, 6156) - .saturating_add(T::DbWeight::get().reads(3)) + Weight::from_parts(68_051_000, 6156).saturating_add(T::DbWeight::get().reads(3)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) @@ -285,8 +284,7 @@ impl WeightInfo for HydraWeight { // Measured: `789` // Estimated: `6156` // Minimum execution time: 33_145_000 picoseconds. - Weight::from_parts(33_774_000, 6156) - .saturating_add(T::DbWeight::get().reads(4)) + Weight::from_parts(33_774_000, 6156).saturating_add(T::DbWeight::get().reads(4)) } } @@ -442,7 +440,7 @@ impl WeightInfo for () { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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: `789 + e * (1155 ±0)` // Estimated: `6156 + e * (7749 ±245_709_589_663_843_264)` @@ -473,7 +471,7 @@ impl WeightInfo for () { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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 { + fn router_execution_buy(c: u32, e: u32) -> Weight { // Proof Size summary in bytes: // Measured: `789 + e * (1155 ±0)` // Estimated: `6156 + e * (7749 ±0)` @@ -497,8 +495,7 @@ impl WeightInfo for () { // Measured: `789` // Estimated: `6156` // Minimum execution time: 67_298_000 picoseconds. - Weight::from_parts(68_051_000, 6156) - .saturating_add(RocksDbWeight::get().reads(3)) + Weight::from_parts(68_051_000, 6156).saturating_add(RocksDbWeight::get().reads(3)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) @@ -511,7 +508,6 @@ impl WeightInfo for () { // Measured: `789` // Estimated: `6156` // Minimum execution time: 33_145_000 picoseconds. - Weight::from_parts(33_774_000, 6156) - .saturating_add(RocksDbWeight::get().reads(4)) + Weight::from_parts(33_774_000, 6156).saturating_add(RocksDbWeight::get().reads(4)) } } diff --git a/pallets/omnipool/src/weights.rs b/pallets/omnipool/src/weights.rs index 820a8cb66..800a6fd76 100644 --- a/pallets/omnipool/src/weights.rs +++ b/pallets/omnipool/src/weights.rs @@ -493,7 +493,7 @@ impl WeightInfo for HydraWeight { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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 * (5073 ±0)` // Estimated: `6156 + e * (8517 ±354_661_923_497_307_072)` @@ -554,7 +554,7 @@ impl WeightInfo for HydraWeight { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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 { + fn router_execution_buy(c: u32, e: u32) -> Weight { // Proof Size summary in bytes: // Measured: `7047` // Estimated: `13905` @@ -578,8 +578,7 @@ impl WeightInfo for HydraWeight { // Measured: `1933` // Estimated: `6156` // Minimum execution time: 47_828_000 picoseconds. - Weight::from_parts(48_456_000, 6156) - .saturating_add(T::DbWeight::get().reads(6)) + Weight::from_parts(48_456_000, 6156).saturating_add(T::DbWeight::get().reads(6)) } } @@ -1008,7 +1007,7 @@ impl WeightInfo for () { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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 * (5073 ±0)` // Estimated: `6156 + e * (8517 ±354_661_923_497_307_072)` @@ -1069,7 +1068,7 @@ impl WeightInfo for () { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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 { + fn router_execution_buy(c: u32, e: u32) -> Weight { // Proof Size summary in bytes: // Measured: `7047` // Estimated: `13905` @@ -1093,7 +1092,6 @@ impl WeightInfo for () { // Measured: `1933` // Estimated: `6156` // Minimum execution time: 47_828_000 picoseconds. - Weight::from_parts(48_456_000, 6156) - .saturating_add(RocksDbWeight::get().reads(6)) + Weight::from_parts(48_456_000, 6156).saturating_add(RocksDbWeight::get().reads(6)) } } diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 513d178d0..34470e892 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -22,10 +22,12 @@ use frame_system::{ pallet_prelude::{BlockNumberFor, OriginFor}, RawOrigin, }; -use hydradx_traits::router::{AmmTradeWeights, AmountInAndOut, AssetPair, RouteProvider, RouteSpotPriceProvider, RouterT, Trade}; +use hydradx_traits::router::{ + AmmTradeWeights, AmountInAndOut, AssetPair, RouteProvider, RouteSpotPriceProvider, RouterT, Trade, +}; use orml_traits::{GetByKey, MultiCurrency}; -pub use pallet_otc::OrderId; use pallet_otc::weights::WeightInfo as OtcWeightInfo; +pub use pallet_otc::OrderId; use sp_arithmetic::traits::{CheckedMul, Saturating}; use sp_arithmetic::{ArithmeticError, FixedPointNumber, FixedU128}; use sp_runtime::offchain::storage::StorageValueRef; @@ -209,7 +211,12 @@ pub mod pallet { .saturating_add(::RouterWeightInfo::calculate_spot_price_weight(route)) .saturating_add(::WeightInfo::fill_order().max(::WeightInfo::partial_fill_order())) )] - pub fn settle_otc_order(origin: OriginFor, otc_id: OrderId, amount: Balance, route: Vec>>) -> DispatchResult { + pub fn settle_otc_order( + origin: OriginFor, + otc_id: OrderId, + amount: Balance, + route: Vec>>, + ) -> DispatchResult { ensure_none(origin)?; Self::settle_otc(otc_id, amount, route) @@ -256,10 +263,14 @@ impl Pallet { ensure!(otc.amount_out == amount, Error::::InvalidConditions); } - ensure!(route == T::Router::get_route(AssetPair { - asset_in: asset_b, - asset_out: asset_a, - }), Error::::InvalidConditions); + ensure!( + route + == T::Router::get_route(AssetPair { + asset_in: asset_b, + asset_out: asset_a, + }), + Error::::InvalidConditions + ); // get initial otc and router price let otc_price = diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 99f50efd1..77fe14d57 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -17,7 +17,6 @@ // we don't need to run tests with benchmarking feature #![cfg(not(feature = "runtime-benchmarks"))] - #![allow(clippy::bool_assert_comparison)] use super::*; pub use crate::mock::*; diff --git a/pallets/stableswap/src/benchmarks.rs b/pallets/stableswap/src/benchmarks.rs index a6a5ce8c4..f43f5cb8c 100644 --- a/pallets/stableswap/src/benchmarks.rs +++ b/pallets/stableswap/src/benchmarks.rs @@ -607,7 +607,7 @@ benchmarks! { } } - calculate_spot_price { + calculate_spot_price { let caller: T::AccountId = account("caller", 0, 1); let lp_provider: T::AccountId = account("provider", 0, 1); let initial_liquidity = 1_000_000_000_000_000_000u128; diff --git a/pallets/stableswap/src/weights.rs b/pallets/stableswap/src/weights.rs index 4bd3cfd8f..e87c7b13c 100644 --- a/pallets/stableswap/src/weights.rs +++ b/pallets/stableswap/src/weights.rs @@ -329,7 +329,7 @@ impl WeightInfo for HydraWeight { /// 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: `1588 + e * (1805 ±0)` // Estimated: `13990 + e * (5797 ±0)` @@ -366,7 +366,7 @@ impl WeightInfo for HydraWeight { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, 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 { + fn router_execution_buy(c: u32, e: u32) -> Weight { // Proof Size summary in bytes: // Measured: `1587 + e * (1776 ±0)` // Estimated: `13990 + e * (5797 ±245_709_589_663_843_264)` @@ -392,8 +392,7 @@ impl WeightInfo for HydraWeight { // Measured: `1587` // Estimated: `13990` // Minimum execution time: 263_924_000 picoseconds. - Weight::from_parts(264_905_000, 13990) - .saturating_add(T::DbWeight::get().reads(11)) + Weight::from_parts(264_905_000, 13990).saturating_add(T::DbWeight::get().reads(11)) } } @@ -659,7 +658,7 @@ impl WeightInfo for () { /// 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: `1588 + e * (1805 ±0)` // Estimated: `13990 + e * (5797 ±0)` @@ -696,7 +695,7 @@ impl WeightInfo for () { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, 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 { + fn router_execution_buy(c: u32, e: u32) -> Weight { // Proof Size summary in bytes: // Measured: `1587 + e * (1776 ±0)` // Estimated: `13990 + e * (5797 ±245_709_589_663_843_264)` @@ -722,7 +721,6 @@ impl WeightInfo for () { // Measured: `1587` // Estimated: `13990` // Minimum execution time: 263_924_000 picoseconds. - Weight::from_parts(264_905_000, 13990) - .saturating_add(RocksDbWeight::get().reads(11)) + Weight::from_parts(264_905_000, 13990).saturating_add(RocksDbWeight::get().reads(11)) } } diff --git a/pallets/xyk/src/weights.rs b/pallets/xyk/src/weights.rs index f8db2cfe2..788dfeee4 100644 --- a/pallets/xyk/src/weights.rs +++ b/pallets/xyk/src/weights.rs @@ -277,7 +277,7 @@ impl WeightInfo for HydraWeight { /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, 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: `1187 + e * (2970 ±0)` // Estimated: `6156 + e * (10332 ±124_823_812_913_251_024)` @@ -318,7 +318,7 @@ impl WeightInfo for HydraWeight { /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, 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 { + fn router_execution_buy(c: u32, e: u32) -> Weight { // Proof Size summary in bytes: // Measured: `1187 + e * (2970 ±0)` // Estimated: `6156 + e * (10332 ±0)` @@ -342,8 +342,7 @@ impl WeightInfo for HydraWeight { // Measured: `1187` // Estimated: `6156` // Minimum execution time: 26_159_000 picoseconds. - Weight::from_parts(26_805_702, 6156) - .saturating_add(T::DbWeight::get().reads(3)) + Weight::from_parts(26_805_702, 6156).saturating_add(T::DbWeight::get().reads(3)) } } @@ -562,7 +561,7 @@ impl WeightInfo for () { /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, 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: `1187 + e * (2970 ±0)` // Estimated: `6156 + e * (10332 ±124_823_812_913_251_024)` @@ -603,7 +602,7 @@ impl WeightInfo for () { /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, 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 { + fn router_execution_buy(c: u32, e: u32) -> Weight { // Proof Size summary in bytes: // Measured: `1187 + e * (2970 ±0)` // Estimated: `6156 + e * (10332 ±0)` @@ -627,7 +626,6 @@ impl WeightInfo for () { // Measured: `1187` // Estimated: `6156` // Minimum execution time: 26_159_000 picoseconds. - Weight::from_parts(26_805_702, 6156) - .saturating_add(RocksDbWeight::get().reads(3)) + Weight::from_parts(26_805_702, 6156).saturating_add(RocksDbWeight::get().reads(3)) } } diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 76ed2e780..aa63d9d97 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -831,10 +831,8 @@ impl RouterWeightInfo { } pub fn calculate_spot_price_overweight() -> Weight { - weights::route_executor::HydraWeight::::calculate_spot_price_in_lbp() - .saturating_sub(weights::lbp::HydraWeight::::calculate_spot_price( - )) + .saturating_sub(weights::lbp::HydraWeight::::calculate_spot_price()) } } diff --git a/runtime/hydradx/src/benchmarking/omnipool.rs b/runtime/hydradx/src/benchmarking/omnipool.rs index 7eacf2807..f03212427 100644 --- a/runtime/hydradx/src/benchmarking/omnipool.rs +++ b/runtime/hydradx/src/benchmarking/omnipool.rs @@ -515,7 +515,7 @@ runtime_benchmarks! { } } - calculate_spot_price { + calculate_spot_price { init()?; let acc = Omnipool::protocol_account(); diff --git a/runtime/hydradx/src/benchmarking/route_executor.rs b/runtime/hydradx/src/benchmarking/route_executor.rs index fc4ddfb2e..a2d4d2ea7 100644 --- a/runtime/hydradx/src/benchmarking/route_executor.rs +++ b/runtime/hydradx/src/benchmarking/route_executor.rs @@ -21,7 +21,7 @@ use crate::{ }; use super::*; -use crate::benchmarking::dca::{HDX, DAI}; +use crate::benchmarking::dca::{DAI, HDX}; use frame_benchmarking::{account, BenchmarkError}; use frame_support::dispatch::DispatchResult; use frame_support::{assert_ok, ensure}; @@ -342,8 +342,8 @@ runtime_benchmarks! { route.clone(), )?; }: { - Router::get_route(AssetPair::new(HDX, DAI)) - } + Router::get_route(AssetPair::new(HDX, DAI)) + } // Calculates the weight of LBP spot price calculation. Used in the calculation to determine the weight of the overhead. calculate_spot_price_in_lbp { From a10ef80e04c0c675b1ee2259e874ab0f66200301 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 16 Apr 2024 19:41:26 -0500 Subject: [PATCH 13/61] satisfy clippy --- pallets/otc-settlements/src/benchmarks.rs | 2 +- runtime/hydradx/src/benchmarking/route_executor.rs | 2 +- runtime/hydradx/src/benchmarking/xyk.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/otc-settlements/src/benchmarks.rs b/pallets/otc-settlements/src/benchmarks.rs index ac9780627..7187bafb4 100644 --- a/pallets/otc-settlements/src/benchmarks.rs +++ b/pallets/otc-settlements/src/benchmarks.rs @@ -41,7 +41,7 @@ benchmarks! { ::Currency::deposit(dai.into(), &account, 1_000_000_000 * ONE)?; assert_ok!( - pallet_otc::Pallet::::place_order(RawOrigin::Signed(account.clone()).into(), dot.into(), dai.into(), 100_000_000 * ONE, 200_000_001 * ONE, true) + pallet_otc::Pallet::::place_order(RawOrigin::Signed(account).into(), dot.into(), dai.into(), 100_000_000 * ONE, 200_000_001 * ONE, true) ); let route = ::Router::get_route(AssetPair { diff --git a/runtime/hydradx/src/benchmarking/route_executor.rs b/runtime/hydradx/src/benchmarking/route_executor.rs index a2d4d2ea7..f92ae465d 100644 --- a/runtime/hydradx/src/benchmarking/route_executor.rs +++ b/runtime/hydradx/src/benchmarking/route_executor.rs @@ -339,7 +339,7 @@ runtime_benchmarks! { Router::force_insert_route( RawOrigin::Root.into(), AssetPair::new(HDX, DAI), - route.clone(), + route, )?; }: { Router::get_route(AssetPair::new(HDX, DAI)) diff --git a/runtime/hydradx/src/benchmarking/xyk.rs b/runtime/hydradx/src/benchmarking/xyk.rs index 50380a2f5..bd977d64c 100644 --- a/runtime/hydradx/src/benchmarking/xyk.rs +++ b/runtime/hydradx/src/benchmarking/xyk.rs @@ -286,7 +286,7 @@ runtime_benchmarks! { >::transfer(asset_a, &caller, &maker, 749_249_999_999_999_u128)?; - assert_eq!(frame_system::Pallet::::account(caller.clone()).sufficients, 1); + assert_eq!(frame_system::Pallet::::account(caller).sufficients, 1); }: { assert!(>::calculate_spot_price(PoolType::XYK, asset_a, asset_b).is_ok()); } From 125b14ce39153c6dbc0d6fb6e1413e19daf43d3b Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 17 Apr 2024 10:40:31 -0500 Subject: [PATCH 14/61] update crate versions and remove unused param --- Cargo.lock | 8 ++++---- integration-tests/Cargo.toml | 2 +- pallets/otc-settlements/Cargo.toml | 2 +- pallets/otc/Cargo.toml | 2 +- runtime/hydradx/Cargo.toml | 2 +- runtime/hydradx/src/assets.rs | 1 - runtime/hydradx/src/lib.rs | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3dcbeeac2..28cf13c94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4621,7 +4621,7 @@ dependencies = [ [[package]] name = "hydradx-runtime" -version = "228.0.0" +version = "229.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -8182,7 +8182,7 @@ dependencies = [ [[package]] name = "pallet-otc" -version = "1.1.2" +version = "1.1.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -8204,7 +8204,7 @@ dependencies = [ [[package]] name = "pallet-otc-settlements" -version = "1.1.0" +version = "1.0.0" dependencies = [ "env_logger 0.9.3", "frame-benchmarking", @@ -11428,7 +11428,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "1.20.2" +version = "1.20.3" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 22825e2a1..9f5f40be8 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-integration-tests" -version = "1.20.2" +version = "1.20.3" description = "Integration tests" authors = ["GalacticCouncil"] edition = "2021" diff --git a/pallets/otc-settlements/Cargo.toml b/pallets/otc-settlements/Cargo.toml index 8415825e8..0ac16bba8 100644 --- a/pallets/otc-settlements/Cargo.toml +++ b/pallets/otc-settlements/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-otc-settlements' -version = '1.1.0' +version = '1.0.0' description = 'A pallet with offchain worker closing OTC arbs' authors = ['GalacticCouncil'] edition = '2021' diff --git a/pallets/otc/Cargo.toml b/pallets/otc/Cargo.toml index f565ba074..3eba0e9f0 100644 --- a/pallets/otc/Cargo.toml +++ b/pallets/otc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-otc' -version = '1.1.2' +version = '1.1.1' description = 'A pallet for trustless over-the-counter trading' authors = ['GalacticCouncil'] edition = '2021' diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index 7925df118..4a3d121b0 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-runtime" -version = "228.0.0" +version = "229.0.0" authors = ["GalacticCouncil"] edition = "2021" license = "Apache 2.0" diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index aa63d9d97..f6810fa3f 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -1066,7 +1066,6 @@ impl pallet_route_executor::Config for Runtime { parameter_types! { pub const ExistentialDepositMultiplier: u8 = 5; - pub TreasuryAccount: AccountId = Treasury::account_id(); pub const PricePrecision: FixedU128 = FixedU128::from_rational(1, 100); } diff --git a/runtime/hydradx/src/lib.rs b/runtime/hydradx/src/lib.rs index ca908dffa..16a708aae 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -109,7 +109,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("hydradx"), impl_name: create_runtime_str!("hydradx"), authoring_version: 1, - spec_version: 228, + spec_version: 229, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 0cb3695bdea1be97704235fee322120d3f248a1a Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 17 Apr 2024 11:04:11 -0500 Subject: [PATCH 15/61] satisfy clippy --- integration-tests/src/evm.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/integration-tests/src/evm.rs b/integration-tests/src/evm.rs index 8c1c24060..5a42ad27c 100644 --- a/integration-tests/src/evm.rs +++ b/integration-tests/src/evm.rs @@ -1157,12 +1157,11 @@ fn dispatch_should_work_with_buying_insufficient_asset() { .unwrap(); create_xyk_pool_with_amounts(shitcoin, 1000000 * UNITS, HDX, 1000000 * UNITS); - let evm_address = EVMAccounts::evm_address(&Into::::into(ALICE)); init_omnipool_with_oracle_for_block_10(); assert_ok!(hydradx_runtime::Currencies::update_balance( hydradx_runtime::RuntimeOrigin::root(), - currency_precompile::alice_substrate_evm_addr().into(), + currency_precompile::alice_substrate_evm_addr(), WETH, (100 * UNITS * 1_000_000) as i128, )); @@ -1186,9 +1185,9 @@ fn dispatch_should_work_with_buying_insufficient_asset() { let router_swap = RuntimeCall::Router(pallet_route_executor::Call::buy { asset_in: WETH, asset_out: shitcoin, - amount_out: 1 * UNITS, + amount_out: UNITS, max_amount_in: u128::MAX, - route: swap_route.clone(), + route: swap_route, }); //Arrange @@ -1217,7 +1216,7 @@ fn dispatch_should_work_with_buying_insufficient_asset() { //EVM call passes even when the substrate tx fails, so we need to check if the tx is executed expect_hydra_events(vec![pallet_evm::Event::Executed { address: DISPATCH_ADDR }.into()]); let new_balance = Tokens::free_balance(shitcoin, ¤cy_precompile::alice_substrate_evm_addr()); - assert_eq!(new_balance, 1 * UNITS); + assert_eq!(new_balance, UNITS); }); } From 03ccd18601eca10d6535c6328b7cdc54225e67e9 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 17 Apr 2024 11:48:04 -0500 Subject: [PATCH 16/61] remove unused code from benchmarks --- pallets/otc-settlements/src/benchmarks.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/pallets/otc-settlements/src/benchmarks.rs b/pallets/otc-settlements/src/benchmarks.rs index 7187bafb4..08fe77863 100644 --- a/pallets/otc-settlements/src/benchmarks.rs +++ b/pallets/otc-settlements/src/benchmarks.rs @@ -16,7 +16,6 @@ use super::*; use frame_benchmarking::{account, benchmarks}; use frame_support::assert_ok; use frame_system::RawOrigin; -use hydradx_traits::Create; use orml_traits::MultiCurrency; pub const ONE: Balance = 1_000_000_000_000; @@ -27,26 +26,21 @@ benchmarks! { where_clause { where AssetIdOf: From, ::Currency: MultiCurrency, - T: crate::Config, - T: pallet_otc::Config, - u32: From>, - ::AssetRegistry: Create>, + T: crate::Config + pallet_otc::Config, } settle_otc_order { - let (dot, dai) = (HDX, DAI); let account: T::AccountId = account("acc", 1, 1); - - ::Currency::deposit(dot.into(), &account, 1_000_000_000 * ONE)?; - ::Currency::deposit(dai.into(), &account, 1_000_000_000 * ONE)?; + ::Currency::deposit(HDX.into(), &account, 1_000_000_000 * ONE)?; + ::Currency::deposit(DAI.into(), &account, 1_000_000_000 * ONE)?; assert_ok!( - pallet_otc::Pallet::::place_order(RawOrigin::Signed(account).into(), dot.into(), dai.into(), 100_000_000 * ONE, 200_000_001 * ONE, true) + pallet_otc::Pallet::::place_order(RawOrigin::Signed(account).into(), HDX.into(), DAI.into(), 100_000_000 * ONE, 200_000_001 * ONE, true) ); let route = ::Router::get_route(AssetPair { - asset_in: dai.into(), - asset_out: dot.into(), + asset_in: DAI.into(), + asset_out: HDX.into(), }); }: _(RawOrigin::None, 0u32, 2 * ONE, route) From 1722038192a816cbd793504b867e27bcd3ed2934 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 17 Apr 2024 12:04:15 -0500 Subject: [PATCH 17/61] include pov size in weight calculation --- runtime/hydradx/src/assets.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index f6810fa3f..92be6ff37 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -831,8 +831,12 @@ impl RouterWeightInfo { } pub fn calculate_spot_price_overweight() -> Weight { - weights::route_executor::HydraWeight::::calculate_spot_price_in_lbp() - .saturating_sub(weights::lbp::HydraWeight::::calculate_spot_price()) + Weight::from_parts( + weights::route_executor::HydraWeight::::calculate_spot_price_in_lbp() + .ref_time() + .saturating_sub(weights::lbp::HydraWeight::::calculate_spot_price().ref_time()), + weights::route_executor::HydraWeight::::calculate_spot_price_in_lbp().proof_size(), + ) } } From 1b6af341d8b1a04d2774f8314d3e9d0430a4b6b0 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 17 Apr 2024 12:18:01 -0500 Subject: [PATCH 18/61] update comments --- pallets/otc-settlements/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 34470e892..36a6deffa 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -246,7 +246,7 @@ impl Pallet { Ok(()) } - // Executes two trades: asset_a -> OTC -> asset_b, and asset_b -> Router -> asset_a + /// Executes two trades: asset_a -> OTC -> asset_b, and asset_b -> Router -> asset_a pub fn settle_otc(otc_id: OrderId, amount: Balance, route: Vec>>) -> DispatchResult { let pallet_acc = Self::account_id(); @@ -377,6 +377,8 @@ impl Pallet { Ok(()) } + /// Store the latest block number in the offchain storage. + /// Returns `true` if `block_number` is newer than the block number stored in the storage. fn try_update_last_block_storage(block_number: BlockNumberFor) -> bool { let last_update_storage = StorageValueRef::persistent(OFFCHAIN_WORKER_DATA_LAST_UPDATE); let last_update = last_update_storage @@ -392,6 +394,7 @@ impl Pallet { } } + /// Sort open OTCs orders and save a list in the offchain storage. fn sort_otcs(block_number: BlockNumberFor) { log::debug!( target: "offchain_worker::sort_otcs", @@ -430,6 +433,7 @@ impl Pallet { } } + /// Iterate over sorted list of OTCs and try to find arbitrage opportunities. fn settle_otcs() { log::debug!( target: "offchain_worker::settle_otcs", @@ -476,6 +480,7 @@ impl Pallet { } } + /// Try to find the correct amount to close the arbitrage opportunity. fn try_find_trade_amount(otc_id: OrderId, route: Vec>>) -> Option { let otc = >::get(otc_id).unwrap(); From f34c26ed8a98a3e13442f72726b5245a3852e4de Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 17 Apr 2024 13:34:36 -0500 Subject: [PATCH 19/61] update comments --- pallets/otc-settlements/src/lib.rs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 36a6deffa..ded67b1cb 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -189,8 +189,8 @@ pub mod pallet { /// /// Executes a trade between an OTC order and some route. /// If the OTC order is partially fillable, the extrinsic fails if the existing arbitrage - /// opportunity is not closed af the trade. - /// If the OTC order is not partially fillable, fails if there is no profit af the trade. + /// opportunity is not closed after the trade. + /// If the OTC order is not partially fillable, fails if there is no profit after the trade. /// /// `Origin` calling this extrinsic is not paying or receiving anything. /// @@ -229,24 +229,25 @@ impl Pallet { PALLET_ID.into_account_truncating() } - #[cfg(not(feature = "runtime-benchmarks"))] - fn ensure_min_profit_amount(asset: T::AssetId, amount: Balance) -> DispatchResult { + /// Ensure that the profit is more than some minimum amount. + fn ensure_min_profit(asset: T::AssetId, profit: Balance) -> DispatchResult { let min_amount = ::ExistentialDeposits::get(&asset) .checked_mul(::ExistentialDepositMultiplier::get().into()) .ok_or(ArithmeticError::Overflow)?; - // tell the binary search algo to find higher values - ensure!(amount >= min_amount, Error::::TradeAmountTooLow); - - Ok(()) - } + // In the benchmark we doesn't make any trade, so this check would fail. + #[cfg(not(feature = "runtime-benchmarks"))] + // tell the binary search algorithm to find higher values + ensure!(profit >= min_amount, Error::::TradeAmountTooLow); - #[cfg(feature = "runtime-benchmarks")] - fn ensure_min_profit_amount(_asset: T::AssetId, _amount: Balance) -> DispatchResult { Ok(()) } - /// Executes two trades: asset_a -> OTC -> asset_b, and asset_b -> Router -> asset_a + /// Executes two trades: asset_a -> OTC -> asset_b, and asset_b -> Router -> asset_a. + /// + /// If the OTC order is partially fillable, the extrinsic fails if the existing arbitrage + /// opportunity is not closed after the trade. + /// If the OTC order is not partially fillable, fails if there is no profit after the trade. pub fn settle_otc(otc_id: OrderId, amount: Balance, route: Vec>>) -> DispatchResult { let pallet_acc = Self::account_id(); @@ -276,6 +277,8 @@ impl Pallet { let otc_price = FixedU128::checked_from_rational(otc.amount_out, otc.amount_in).ok_or(ArithmeticError::Overflow)?; + // Router trade is disabled in the benchmarks, so disable this one as well. + // Without disabling it, the requirements for the extrinsic cannot be met (e.g. profit). #[cfg(not(feature = "runtime-benchmarks"))] if otc.partially_fillable && amount != otc.amount_in { log::debug!( @@ -297,6 +300,7 @@ impl Pallet { target: "offchain_worker::settle_otc", "calling router sell: amount_in {:?} ", otc_amount_out); + // Disable in the benchmarks and use existing weight from the router pallet. #[cfg(not(feature = "runtime-benchmarks"))] T::Router::sell( RawOrigin::Signed(pallet_acc.clone()).into(), @@ -346,7 +350,7 @@ impl Pallet { .checked_sub(amount) .ok_or(ArithmeticError::Overflow)?; - Self::ensure_min_profit_amount(asset_a, profit)?; + Self::ensure_min_profit(asset_a, profit)?; ::Currency::transfer(asset_a, &pallet_acc, &T::ProfitReceiver::get(), profit)?; From 58088dc4dfd3e2c5754620934b3b4b9e253db6b3 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 17 Apr 2024 14:29:53 -0500 Subject: [PATCH 20/61] satisfy clippy --- pallets/otc-settlements/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index ded67b1cb..986d0f1e5 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -230,15 +230,15 @@ impl Pallet { } /// Ensure that the profit is more than some minimum amount. - fn ensure_min_profit(asset: T::AssetId, profit: Balance) -> DispatchResult { - let min_amount = ::ExistentialDeposits::get(&asset) + fn ensure_min_profit(asset: T::AssetId, _profit: Balance) -> DispatchResult { + let _min_amount = ::ExistentialDeposits::get(&asset) .checked_mul(::ExistentialDepositMultiplier::get().into()) .ok_or(ArithmeticError::Overflow)?; // In the benchmark we doesn't make any trade, so this check would fail. #[cfg(not(feature = "runtime-benchmarks"))] // tell the binary search algorithm to find higher values - ensure!(profit >= min_amount, Error::::TradeAmountTooLow); + ensure!(_profit >= _min_amount, Error::::TradeAmountTooLow); Ok(()) } From 979f8161e86e155dfe815ab4aefe5b6cdf2cbdbc Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 25 Apr 2024 14:51:26 +0200 Subject: [PATCH 21/61] resolve comments --- Cargo.lock | 2 +- pallets/otc-settlements/Cargo.toml | 6 +- pallets/otc-settlements/src/lib.rs | 60 ++++--- pallets/otc-settlements/src/mock.rs | 226 +++++++++++---------------- pallets/otc-settlements/src/tests.rs | 99 ++++++++---- 5 files changed, 191 insertions(+), 202 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b044d0a37..54cbc7d46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8219,12 +8219,12 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-asset-registry", "pallet-balances", "pallet-currencies", "pallet-omnipool", "pallet-otc", "pallet-route-executor", - "pallet-xyk", "parity-scale-codec", "parking_lot 0.12.1", "pretty_assertions", diff --git a/pallets/otc-settlements/Cargo.toml b/pallets/otc-settlements/Cargo.toml index 0ac16bba8..027a83678 100644 --- a/pallets/otc-settlements/Cargo.toml +++ b/pallets/otc-settlements/Cargo.toml @@ -27,7 +27,6 @@ frame-system = { workspace = true } # HydraDX dependencies hydradx-traits = { workspace = true } pallet-otc = { workspace = true } -pallet-route-executor = { workspace = true } # ORML dependencies orml-traits = { workspace = true } @@ -38,8 +37,9 @@ frame-benchmarking = { workspace = true, optional = true } [dev-dependencies] hydra-dx-math = { workspace = true } pallet-omnipool = { workspace = true } +pallet-asset-registry = { workspace = true } +pallet-route-executor = { workspace = true } pallet-balances = { workspace = true } -pallet-xyk = { workspace = true } pallet-currencies = { workspace = true } sp-api = { workspace = true } orml-tokens = { workspace = true, features=["std"] } @@ -69,7 +69,7 @@ std = [ "pallet-currencies/std", "pallet-route-executor/std", "pallet-omnipool/std", - "pallet-xyk/std", + "pallet-asset-registry/std", ] runtime-benchmarks = [ diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 986d0f1e5..6d68c4f52 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -57,20 +57,19 @@ pub type NamedReserveIdentifier = [u8; 8]; pub const PALLET_ID: PalletId = PalletId(*b"otcsettl"); -pub const NAMED_RESERVE_ID: NamedReserveIdentifier = *b"otcorder"; - // value taken from https://github.com/substrate-developer-hub/recipes/blob/master/pallets/ocw-demo/src/lib.rs pub const UNSIGNED_TXS_PRIORITY: u64 = 100; +/// Vector of `SortedOtcsStorageType` pub const OFFCHAIN_WORKER_DATA: &[u8] = b"hydradx/otc-settlements/data/"; +/// Last block number when we updated the `OFFCHAIN_WORKER_DATA` pub const OFFCHAIN_WORKER_DATA_LAST_UPDATE: &[u8] = b"hydradx/otc-settlements/data-last-update/"; -pub const OFFCHAIN_WORKER_LOCK: &[u8] = b"hydradx/otc-settlements/lock/"; -pub const OFFCHAIN_WORKER_MAX_ITERATIONS: &[u8] = b"hydradx/otc-settlements/max-iterations/"; -pub const LOCK_DURATION: u64 = 5_000; // 5 seconds -pub const NUM_OF_ITERATIONS: u32 = 40; +pub const SORTED_ORDERS_LOCK: &[u8] = b"hydradx/otc-settlements/lock/"; +pub const LOCK_TIMEOUT_EXPIRATION: u64 = 5_000; // 5 seconds +/// The number of iterations in the binary search algorithm +pub const FILL_SEARCH_ITERATIONS: u32 = 40; pub type AssetIdOf = ::AssetId; - type SortedOtcsStorageType = (OrderId, FixedU128, FixedU128, FixedU128); #[frame_support::pallet] @@ -88,7 +87,7 @@ pub mod pallet { /// Named reservable multi currency type Currency: MultiCurrency, Balance = Balance>; - ///Router implementation + /// Router implementation type Router: RouteProvider> + RouterT, Balance, Trade>, AmountInAndOut> + RouteSpotPriceProvider>; @@ -160,23 +159,19 @@ pub mod pallet { #[pallet::generate_deposit(pub(crate) fn deposit_event)] pub enum Event { /// A trade has been executed - Executed { - otc_id: OrderId, - otc_asset_in: AssetIdOf, - otc_asset_out: AssetIdOf, - otc_amount_in: Balance, - otc_amount_out: Balance, - trade_amount_in: Balance, - trade_amount_out: Balance, - }, + Executed { asset_id: AssetIdOf, profit: Balance }, } #[pallet::error] pub enum Error { /// Otc order not found OrderNotFound, - /// Execution requirements not met - InvalidConditions, + /// OTC order is not partially fillable + NotPartiallyFillable, + /// Provided route doesn't match the existing route + InvalidRoute, + /// Initial and final balance are different + BalanceInconsistency, /// Trade amount higher than necessary TradeAmountTooHigh, /// Trade amount lower than necessary @@ -261,7 +256,7 @@ impl Pallet { ::Currency::deposit(asset_a, &pallet_acc, amount)?; if !otc.partially_fillable { - ensure!(otc.amount_out == amount, Error::::InvalidConditions); + ensure!(otc.amount_out == amount, Error::::NotPartiallyFillable); } ensure!( @@ -270,7 +265,7 @@ impl Pallet { asset_in: asset_b, asset_out: asset_a, }), - Error::::InvalidConditions + Error::::InvalidRoute ); // get initial otc and router price @@ -361,21 +356,16 @@ impl Pallet { ensure!( asset_a_balance_after == asset_a_balance_before, - Error::::InvalidConditions + Error::::BalanceInconsistency ); ensure!( asset_b_balance_after == asset_b_balance_before, - Error::::InvalidConditions + Error::::BalanceInconsistency ); Self::deposit_event(Event::Executed { - otc_id, - otc_asset_in: asset_a, - otc_asset_out: asset_b, - otc_amount_in: amount, - otc_amount_out, - trade_amount_in: otc_amount_out, - trade_amount_out: amount + profit, + asset_id: asset_a, + profit, }); Ok(()) @@ -405,8 +395,8 @@ impl Pallet { "sort_otcs()"); // acquire offchain worker lock. - let lock_expiration = Duration::from_millis(LOCK_DURATION); - let mut lock = StorageLock::<'_, Time>::with_deadline(OFFCHAIN_WORKER_LOCK, lock_expiration); + let lock_expiration = Duration::from_millis(LOCK_TIMEOUT_EXPIRATION); + let mut lock = StorageLock::<'_, Time>::with_deadline(SORTED_ORDERS_LOCK, lock_expiration); if Self::try_update_last_block_storage(block_number) { if let Ok(_guard) = lock.try_lock() { @@ -493,7 +483,11 @@ impl Pallet { let mut sell_amt_up = sell_amt; let mut sell_amt_down = 0; // TODO: set to some min trade amount - let iters = if !otc.partially_fillable { 1 } else { NUM_OF_ITERATIONS }; + let iters = if otc.partially_fillable { + FILL_SEARCH_ITERATIONS + } else { + 1 + }; for i in 0..iters { log::debug!( target: "offchain_worker::settle_otcs", diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index 9b5fa93b1..75afceb98 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -20,10 +20,9 @@ use frame_support::{ assert_ok, parameter_types, traits::{Everything, Nothing}, }; -use frame_system::EnsureRoot; +use frame_system::{EnsureRoot, EnsureSigned}; use hydra_dx_math::ema::EmaPrice; use hydradx_traits::router::PoolType; -use hydradx_traits::AssetKind; use orml_traits::parameter_type_with_key; use pallet_currencies::fungibles::FungibleCurrencies; use pallet_currencies::BasicCurrencyAdapter; @@ -39,7 +38,6 @@ use sp_runtime::{ BuildStorage, }; use sp_std::sync::Arc; -use std::{cell::RefCell, collections::HashMap}; type Block = frame_system::mocking::MockBlock; @@ -61,10 +59,6 @@ pub const ONE: Balance = 1_000_000_000_000; pub const ALICE: AccountId = 1; pub const BOB: AccountId = 2; -thread_local! { - pub static REGISTERED_ASSETS: RefCell> = RefCell::new(HashMap::default()); -} - frame_support::construct_runtime!( pub enum Test { @@ -72,11 +66,11 @@ frame_support::construct_runtime!( Balances: pallet_balances, Tokens: orml_tokens, Currencies: pallet_currencies, - OtcSettlements: pallet_otc_settlements, + AssetRegistry: pallet_asset_registry, OTC: pallet_otc, Omnipool: pallet_omnipool, Router: pallet_route_executor, - XYK: pallet_xyk, + OtcSettlements: pallet_otc_settlements, } ); @@ -106,7 +100,7 @@ impl pallet_otc_settlements::Config for Test { impl pallet_otc::Config for Test { type AssetId = AssetId; - type AssetRegistry = MockedAssetRegistry; + type AssetRegistry = AssetRegistry; type Currency = Currencies; type RuntimeEvent = RuntimeEvent; type ExistentialDeposits = ExistentialDeposits; @@ -118,53 +112,14 @@ parameter_types! { pub DefaultRoutePoolType: PoolType = PoolType::Omnipool; } -pub struct MockedAssetRegistry; - -impl hydradx_traits::registry::Inspect for MockedAssetRegistry { - type AssetId = AssetId; - type Location = (); - - fn is_sufficient(_id: Self::AssetId) -> bool { - true - } - - fn exists(_asset_id: Self::AssetId) -> bool { - true - } - - fn decimals(_id: Self::AssetId) -> Option { - unimplemented!() - } - - fn asset_type(_id: Self::AssetId) -> Option { - unimplemented!() - } - - fn is_banned(_id: Self::AssetId) -> bool { - unimplemented!() - } - - fn asset_name(_id: Self::AssetId) -> Option> { - unimplemented!() - } - - fn asset_symbol(_id: Self::AssetId) -> Option> { - unimplemented!() - } - - fn existential_deposit(_id: Self::AssetId) -> Option { - unimplemented!() - } -} - impl pallet_route_executor::Config for Test { type RuntimeEvent = RuntimeEvent; type AssetId = AssetId; type Balance = Balance; type NativeAssetId = HDXAssetId; type Currency = FungibleCurrencies; - type AMM = (Omnipool, XYK); - type InspectRegistry = MockedAssetRegistry; + type AMM = Omnipool; + type InspectRegistry = AssetRegistry; type DefaultRoutePoolType = DefaultRoutePoolType; type WeightInfo = (); type TechnicalOrigin = EnsureRoot; @@ -264,8 +219,6 @@ impl pallet_currencies::Config for Test { parameter_types! { pub const MinTradingLimit: Balance = 1_000; pub const MinPoolLiquidity: Balance = 1_000; - pub const OracleSourceIdentifier: hydradx_traits::Source = *b"hydraxyk"; - pub XYKExchangeFee: (u32, u32) = (3, 1_000); pub const DiscountedFee: (u32, u32) = (7, 10_000); } @@ -289,62 +242,28 @@ impl hydradx_traits::AssetPairAccountIdFor for AssetPairAccountIdT } } -impl hydradx_traits::Create for MockedAssetRegistry -where - AssetId: From, -{ - type Error = DispatchError; - type Name = BoundedVec>; - type Symbol = BoundedVec>; - - fn register_asset( - _asset_id: Option, - _name: Option, - _kind: AssetKind, - _existential_deposit: Option, - _symbol: Option, - _decimals: Option, - _location: Option, - _xcm_rate_limit: Option, - _is_sufficient: bool, - ) -> Result { - let assigned = REGISTERED_ASSETS.with(|v| { - //NOTE: This is to have same ids as real AssetRegistry which is used in the benchmarks. - //1_000_000 - offset of the reals AssetRegistry - // - 5 - remove assets reagistered by default for the vec.len() - // + 1 - first reg asset start with 1 not 0 - // => 1st asset id == 1_000_001 - let l = 1_000_000 - 4 + v.borrow().len(); - v.borrow_mut().insert(l as u32, l as u32); - l as u32 - }); - Ok(assigned) - } +parameter_types! { + #[derive(PartialEq, Debug)] + pub RegistryStringLimit: u32 = 100; + #[derive(PartialEq, Debug)] + pub MinRegistryStringLimit: u32 = 2; + pub const SequentialIdOffset: u32 = 1_000_000; +} - fn register_insufficient_asset( - _asset_id: Option, - _name: Option, - _kind: AssetKind, - _existential_deposit: Option, - _symbol: Option, - _decimals: Option, - _location: Option, - _xcm_rate_limit: Option, - ) -> Result { - unimplemented!() - } - fn get_or_register_asset( - _name: Self::Name, - _kind: AssetKind, - _existential_deposit: Option, - _symbol: Option, - _decimals: Option, - _location: Option, - _xcm_rate_limit: Option, - _is_sufficient: bool, - ) -> Result { - Ok(AssetId::default()) - } +type AssetLocation = u8; + +impl pallet_asset_registry::Config for Test { + type RuntimeEvent = RuntimeEvent; + type RegistryOrigin = EnsureRoot; + type Currency = Tokens; + type UpdateOrigin = EnsureSigned; + type AssetId = AssetId; + type AssetNativeLocation = AssetLocation; + type StringLimit = RegistryStringLimit; + type MinStringLimit = MinRegistryStringLimit; + type SequentialIdStartAt = SequentialIdOffset; + type RegExternalWeightMultiplier = frame_support::traits::ConstU64<1>; + type WeightInfo = (); } pub struct DummyDuster; @@ -361,25 +280,6 @@ impl hydradx_traits::pools::DustRemovalAccountWhitelist for DummyDust } } -impl pallet_xyk::Config for Test { - type RuntimeEvent = RuntimeEvent; - type AssetRegistry = MockedAssetRegistry; - type AssetPairAccountId = AssetPairAccountIdTest; - type Currency = Currencies; - type NativeAssetId = HDXAssetId; - type WeightInfo = (); - type GetExchangeFee = XYKExchangeFee; - type MinTradingLimit = MinTradingLimit; - type MinPoolLiquidity = MinPoolLiquidity; - type MaxInRatio = MaxInRatio; - type MaxOutRatio = MaxOutRatio; - type CanCreatePool = AllowPools; - type AMMHandler = (); - type DiscountedFee = DiscountedFee; - type NonDustableWhitelistHandler = DummyDuster; - type OracleSource = OracleSourceIdentifier; -} - impl pallet_omnipool::Config for Test { type RuntimeEvent = RuntimeEvent; type AssetId = AssetId; @@ -390,7 +290,7 @@ impl pallet_omnipool::Config for Test { type HdxAssetId = HDXAssetId; type NFTCollectionId = PositionCollectionId; type NFTHandler = DummyNFT; - type AssetRegistry = MockedAssetRegistry; + type AssetRegistry = AssetRegistry; type MinimumTradingLimit = MinTradeAmount; type MinimumPoolLiquidity = MinAddedLiquidity; type TechnicalOrigin = EnsureRoot; @@ -490,6 +390,7 @@ impl Default for ExtBuilder { (Omnipool::protocol_account(), DAI, 1_000_000 * ONE), (Omnipool::protocol_account(), DOT, 1_000_000 * ONE), (Omnipool::protocol_account(), KSM, 1_000_000 * ONE), + (Omnipool::protocol_account(), BTC, 1_000_000 * ONE), ], init_pool: Some((FixedU128::from_float(0.5), FixedU128::from(1))), omnipool_liquidity: vec![(ALICE, KSM, 5_000 * ONE)], @@ -501,13 +402,53 @@ impl ExtBuilder { pub fn build(self) -> (sp_io::TestExternalities, Arc>) { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - REGISTERED_ASSETS.with(|v| { - v.borrow_mut().insert(HDX, HDX); - v.borrow_mut().insert(LRNA, LRNA); - v.borrow_mut().insert(DAI, DAI); - v.borrow_mut().insert(DOT, DOT); - v.borrow_mut().insert(KSM, KSM); - }); + let registered_assets = vec![ + ( + Some(LRNA), + Some::>(b"LRNA".to_vec().try_into().unwrap()), + 10_000, + Some::>(b"LRNA".to_vec().try_into().unwrap()), + Some(12), + None::, + true, + ), + ( + Some(DAI), + Some::>(b"DAI".to_vec().try_into().unwrap()), + 10_000, + Some::>(b"DAI".to_vec().try_into().unwrap()), + Some(12), + None::, + true, + ), + ( + Some(DOT), + Some::>(b"DOT".to_vec().try_into().unwrap()), + 10_000, + Some::>(b"DOT".to_vec().try_into().unwrap()), + Some(12), + None::, + true, + ), + ( + Some(KSM), + Some::>(b"KSM".to_vec().try_into().unwrap()), + 10_000, + Some::>(b"KSM".to_vec().try_into().unwrap()), + Some(12), + None::, + true, + ), + ( + Some(BTC), + Some::>(b"BTC".to_vec().try_into().unwrap()), + 10_000, + Some::>(b"BTC".to_vec().try_into().unwrap()), + Some(12), + None::, + false, + ), + ]; let mut initial_native_accounts: Vec<(AccountId, Balance)> = vec![]; let additional_accounts: Vec<(AccountId, Balance)> = self @@ -518,6 +459,14 @@ impl ExtBuilder { .collect::<_>(); initial_native_accounts.extend(additional_accounts); + + pallet_asset_registry::GenesisConfig:: { + registered_assets, + ..Default::default() + } + .assimilate_storage(&mut t) + .unwrap(); + pallet_balances::GenesisConfig:: { balances: initial_native_accounts, } @@ -566,6 +515,13 @@ impl ExtBuilder { Permill::from_percent(100), Omnipool::protocol_account(), )); + assert_ok!(Omnipool::add_token( + RuntimeOrigin::root(), + BTC, + stable_price, + Permill::from_percent(100), + Omnipool::protocol_account(), + )); for p in self.omnipool_liquidity { assert_ok!(Omnipool::add_liquidity(RuntimeOrigin::signed(p.0), p.1, p.2)); diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 77fe14d57..ef9573389 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -21,11 +21,16 @@ use super::*; pub use crate::mock::*; use frame_support::{assert_ok, assert_storage_noop}; +use hydradx_traits::Inspect; pub 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 fn calculate_otc_price(otc: &pallet_otc::Order) -> FixedU128 { FixedU128::checked_from_rational(otc.amount_out, otc.amount_in).unwrap() } @@ -217,14 +222,63 @@ fn existing_arb_opportunity_should_trigger_trade() { assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); assert!(Currencies::free_balance(DAI, &OtcSettlements::account_id()) == 0); - expect_events(vec![Event::Executed { - otc_id, - otc_asset_in: HDX, - otc_asset_out: DAI, - otc_amount_in: 762_939_453_125, - otc_amount_out: 1_525_886_535_644, - trade_amount_in: 1_525_886_535_644, - trade_amount_out: 762_941_521_577, + expect_last_events(vec![Event::Executed { + asset_id: HDX, + profit: 2_068_452, + } + .into()]); + }); +} + +#[test] +fn existing_arb_opportunity_of_insufficient_asset_should_trigger_trade() { + let (mut ext, _) = ExtBuilder::default().build(); + ext.execute_with(|| { + // ensure that BTC is configured as insufficient asset + assert!(!AssetRegistry::is_sufficient(BTC)); + + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + BTC, // otc asset_in + HDX, // otc asset_out + 200_000 * ONE, + 100_001 * ONE, + true, + )); + + // get otc price + let otc_id = 0; + let otc = >::get(otc_id).unwrap(); + let otc_price = calculate_otc_price(&otc); + + // get trade price + let route = Router::get_route(AssetPair { + asset_in: otc.asset_out, + asset_out: otc.asset_in, + }); + let router_price = Router::spot_price(&route).unwrap(); + + // verify that there's an arb opportunity + assert!(otc_price > router_price); + + let hdx_total_issuance = Currencies::total_issuance(HDX); + let btc_total_issuance = Currencies::total_issuance(BTC); + + assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); + assert!(Currencies::free_balance(BTC, &OtcSettlements::account_id()) == 0); + + >>::offchain_worker(System::block_number()); + + assert_eq!(hdx_total_issuance, Currencies::total_issuance(HDX)); + assert_eq!(btc_total_issuance, Currencies::total_issuance(BTC)); + + // total issuance of tokens should not change + assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); + assert!(Currencies::free_balance(BTC, &OtcSettlements::account_id()) == 0); + + expect_last_events(vec![Event::Executed { + asset_id: BTC, + profit: 16_547_522, } .into()]); }); @@ -255,23 +309,13 @@ fn multiple_arb_opportunities_should_trigger_trades() { expect_events(vec![ Event::Executed { - otc_id: 0, - otc_asset_in: HDX, - otc_asset_out: DAI, - otc_amount_in: 762_939_453_125, - otc_amount_out: 1_525_886_535_644, - trade_amount_in: 1_525_886_535_644, - trade_amount_out: 762_941_521_577, + asset_id: HDX, + profit: 2_068_452, } .into(), Event::Executed { - otc_id: 1, - otc_asset_in: DOT, - otc_asset_out: KSM, - otc_amount_in: 2288818359375, - otc_amount_out: 2288841247558, - trade_amount_in: 2288841247558, - trade_amount_out: 2288830796079, + asset_id: DOT, + profit: 12_436_704, } .into(), ]); @@ -341,14 +385,9 @@ fn trade_should_be_triggered_when_arb_opportunity_appears() { assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); assert!(Currencies::free_balance(DAI, &OtcSettlements::account_id()) == 0); - expect_events(vec![Event::Executed { - otc_id, - otc_asset_in: HDX, - otc_asset_out: DAI, - otc_amount_in: 8_392_417_907_714, - otc_amount_out: 16_784_667_968_748, - trade_amount_in: 16_784_667_968_748, - trade_amount_out: 8_392_626_224_459, + expect_last_events(vec![Event::Executed { + asset_id: HDX, + profit: 208_316_745, } .into()]); }); From 4619264b3bfa1f7cac8094d820abff993667beee Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 25 Apr 2024 15:02:42 +0200 Subject: [PATCH 22/61] bump crate versions --- Cargo.lock | 14 +++++++------- pallets/dca/Cargo.toml | 2 +- pallets/lbp/Cargo.toml | 2 +- pallets/omnipool/Cargo.toml | 2 +- pallets/route-executor/Cargo.toml | 2 +- pallets/stableswap/Cargo.toml | 2 +- pallets/xyk/Cargo.toml | 2 +- traits/Cargo.toml | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54cbc7d46..c9726f304 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4753,7 +4753,7 @@ dependencies = [ [[package]] name = "hydradx-traits" -version = "3.2.1" +version = "3.2.2" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -7409,7 +7409,7 @@ dependencies = [ [[package]] name = "pallet-dca" -version = "1.4.4" +version = "1.4.5" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -7885,7 +7885,7 @@ dependencies = [ [[package]] name = "pallet-lbp" -version = "4.8.0" +version = "4.8.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -8132,7 +8132,7 @@ dependencies = [ [[package]] name = "pallet-omnipool" -version = "4.1.6" +version = "4.1.7" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -8361,7 +8361,7 @@ dependencies = [ [[package]] name = "pallet-route-executor" -version = "2.3.0" +version = "2.3.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -8461,7 +8461,7 @@ dependencies = [ [[package]] name = "pallet-stableswap" -version = "3.6.0" +version = "3.6.1" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -8869,7 +8869,7 @@ dependencies = [ [[package]] name = "pallet-xyk" -version = "6.4.2" +version = "6.4.3" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/pallets/dca/Cargo.toml b/pallets/dca/Cargo.toml index 1ca106707..7ce6bd3fd 100644 --- a/pallets/dca/Cargo.toml +++ b/pallets/dca/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-dca' -version = "1.4.4" +version = "1.4.5" description = 'A pallet to manage DCA scheduling' authors = ['GalacticCouncil'] edition = '2021' diff --git a/pallets/lbp/Cargo.toml b/pallets/lbp/Cargo.toml index 84b7da2ff..7732b96f7 100644 --- a/pallets/lbp/Cargo.toml +++ b/pallets/lbp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-lbp" -version = "4.8.0" +version = "4.8.1" description = "HydraDX Liquidity Bootstrapping Pool Pallet" authors = ["GalacticCouncil"] edition = "2021" diff --git a/pallets/omnipool/Cargo.toml b/pallets/omnipool/Cargo.toml index 42031605b..b6145826a 100644 --- a/pallets/omnipool/Cargo.toml +++ b/pallets/omnipool/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-omnipool" -version = "4.1.6" +version = "4.1.7" authors = ['GalacticCouncil'] edition = "2021" license = "Apache-2.0" diff --git a/pallets/route-executor/Cargo.toml b/pallets/route-executor/Cargo.toml index 727f84d08..574a144be 100644 --- a/pallets/route-executor/Cargo.toml +++ b/pallets/route-executor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-route-executor' -version = '2.3.0' +version = '2.3.1' description = 'A pallet to execute a route containing a sequence of trades' authors = ['GalacticCouncil'] edition = '2021' diff --git a/pallets/stableswap/Cargo.toml b/pallets/stableswap/Cargo.toml index c6117c771..0eb65d7e1 100644 --- a/pallets/stableswap/Cargo.toml +++ b/pallets/stableswap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-stableswap' -version = '3.6.0' +version = '3.6.1' description = 'AMM for correlated assets' authors = ['GalacticCouncil'] edition = '2021' diff --git a/pallets/xyk/Cargo.toml b/pallets/xyk/Cargo.toml index 040c37124..68c6df36f 100644 --- a/pallets/xyk/Cargo.toml +++ b/pallets/xyk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-xyk' -version = "6.4.2" +version = "6.4.3" description = 'XYK automated market maker' authors = ['GalacticCouncil'] edition = '2021' diff --git a/traits/Cargo.toml b/traits/Cargo.toml index 963e7acd2..82025f19b 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-traits" -version = "3.2.1" +version = "3.2.2" description = "Shared traits" authors = ["GalacticCouncil"] edition = "2021" From b913f2972b6292e9ad245a213d2067c087860b14 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 9 May 2024 11:54:53 +0200 Subject: [PATCH 23/61] fix build --- integration-tests/src/evm_permit.rs | 2 +- pallets/lbp/src/benchmarking.rs | 4 ++-- pallets/lbp/src/weights.rs | 6 +++--- pallets/omnipool/src/weights.rs | 6 +++--- pallets/otc-settlements/src/lib.rs | 6 +++--- pallets/otc-settlements/src/tests.rs | 12 ++++++------ pallets/route-executor/src/lib.rs | 2 +- pallets/stableswap/src/benchmarks.rs | 4 ++-- pallets/stableswap/src/weights.rs | 6 +++--- pallets/xyk/src/weights.rs | 6 +++--- runtime/hydradx/src/assets.rs | 12 ++++++------ runtime/hydradx/src/benchmarking/omnipool.rs | 4 ++-- runtime/hydradx/src/benchmarking/route_executor.rs | 8 ++++---- runtime/hydradx/src/benchmarking/xyk.rs | 4 ++-- runtime/hydradx/src/weights/lbp.rs | 2 +- runtime/hydradx/src/weights/omnipool.rs | 2 +- runtime/hydradx/src/weights/stableswap.rs | 2 +- runtime/hydradx/src/weights/xyk.rs | 2 +- traits/src/router.rs | 4 ++-- 19 files changed, 47 insertions(+), 47 deletions(-) diff --git a/integration-tests/src/evm_permit.rs b/integration-tests/src/evm_permit.rs index 06e87d45f..2fdb7bd4f 100644 --- a/integration-tests/src/evm_permit.rs +++ b/integration-tests/src/evm_permit.rs @@ -1141,7 +1141,7 @@ fn dispatch_permit_should_increase_account_nonce_correctly() { let hdx_balance = user_acc.balance(HDX); let tx_fee = initial_user_hdx_balance - hdx_balance; - assert_eq!(tx_fee, 1_798_512_789_698); + assert_eq!(tx_fee, 1_816_997_321_901); }) } diff --git a/pallets/lbp/src/benchmarking.rs b/pallets/lbp/src/benchmarking.rs index 37a47fbd4..94a98caa2 100644 --- a/pallets/lbp/src/benchmarking.rs +++ b/pallets/lbp/src/benchmarking.rs @@ -258,7 +258,7 @@ benchmarks! { } verify{} - calculate_spot_price { + calculate_spot_price_with_fee { let caller = funded_account::("caller", 0); let fee_collector = funded_account::("fee_collector", 0); let asset_in: AssetId = ASSET_A_ID; @@ -279,7 +279,7 @@ benchmarks! { frame_system::Pallet::::set_block_number(BlockNumberFor::::from(2u32)); }: { - assert!( as TradeExecution>::calculate_spot_price(PoolType::LBP, asset_in, asset_out).is_ok()); + assert!( as TradeExecution>::calculate_spot_price_with_fee(PoolType::LBP, asset_in, asset_out).is_ok()); } } diff --git a/pallets/lbp/src/weights.rs b/pallets/lbp/src/weights.rs index 24f173812..f9aaba689 100644 --- a/pallets/lbp/src/weights.rs +++ b/pallets/lbp/src/weights.rs @@ -59,7 +59,7 @@ pub trait WeightInfo { fn router_execution_sell(c: u32, e: u32) -> Weight; fn router_execution_buy(c: u32, e: u32) -> Weight; fn calculate_buy() -> Weight; - fn calculate_spot_price() -> Weight; + fn calculate_spot_price_with_fee() -> Weight; } /// Weights for pallet_lbp using the hydraDX node and recommended hardware. @@ -279,7 +279,7 @@ impl WeightInfo for HydraWeight { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:0) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) - fn calculate_spot_price() -> Weight { + fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: // Measured: `789` // Estimated: `6156` @@ -503,7 +503,7 @@ impl WeightInfo for () { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:0) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) - fn calculate_spot_price() -> Weight { + fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: // Measured: `789` // Estimated: `6156` diff --git a/pallets/omnipool/src/weights.rs b/pallets/omnipool/src/weights.rs index 800a6fd76..9b97a685e 100644 --- a/pallets/omnipool/src/weights.rs +++ b/pallets/omnipool/src/weights.rs @@ -63,7 +63,7 @@ pub trait WeightInfo { fn router_execution_buy(c: u32, e: u32) -> Weight; fn withdraw_protocol_liquidity() -> Weight; fn remove_token() -> Weight; - fn calculate_spot_price() -> Weight; + fn calculate_spot_price_with_fee() -> Weight; } /// Weights for pallet_omnipool using the hydraDX node and recommended hardware. @@ -573,7 +573,7 @@ impl WeightInfo for HydraWeight { /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, 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() -> Weight { + fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: // Measured: `1933` // Estimated: `6156` @@ -1087,7 +1087,7 @@ impl WeightInfo for () { /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, 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() -> Weight { + fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: // Measured: `1933` // Estimated: `6156` diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 6d68c4f52..9596f1e96 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -203,7 +203,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::settle_otc_order() .saturating_add(::RouterWeightInfo::sell_weight(route)) .saturating_add(::RouterWeightInfo::get_route_weight()) - .saturating_add(::RouterWeightInfo::calculate_spot_price_weight(route)) + .saturating_add(::RouterWeightInfo::calculate_spot_price_with_fee_weight(route)) .saturating_add(::WeightInfo::fill_order().max(::WeightInfo::partial_fill_order())) )] pub fn settle_otc_order( @@ -312,7 +312,7 @@ impl Pallet { // some other error - we can't handle this one properly. // // Compare OTC and Router price - let router_price_after = T::Router::spot_price(&route).unwrap(); + let router_price_after = T::Router::spot_price_with_fee(&route).unwrap(); log::debug!( target: "offchain_worker::settle_otc", "final router price: {:?} otc_price: {:?} ", @@ -410,7 +410,7 @@ impl Pallet { asset_in: otc.asset_out, asset_out: otc.asset_in, }); - let router_price_before = T::Router::spot_price(&route.clone()); + let router_price_before = T::Router::spot_price_with_fee(&route.clone()); if let (Some(otc_price), Some(router_price)) = (otc_price, router_price_before) { // otc's with no arb opportunity are at the end of the list and are not sorted diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index ef9573389..7199bff2d 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -202,7 +202,7 @@ fn existing_arb_opportunity_should_trigger_trade() { asset_in: otc.asset_out, asset_out: otc.asset_in, }); - let router_price = Router::spot_price(&route).unwrap(); + let router_price = Router::spot_price_with_fee(&route).unwrap(); // verify that there's an arb opportunity assert!(otc_price > router_price); @@ -256,7 +256,7 @@ fn existing_arb_opportunity_of_insufficient_asset_should_trigger_trade() { asset_in: otc.asset_out, asset_out: otc.asset_in, }); - let router_price = Router::spot_price(&route).unwrap(); + let router_price = Router::spot_price_with_fee(&route).unwrap(); // verify that there's an arb opportunity assert!(otc_price > router_price); @@ -345,7 +345,7 @@ fn trade_should_be_triggered_when_arb_opportunity_appears() { asset_in: otc.asset_out, asset_out: otc.asset_in, }); - let router_price = Router::spot_price(&route).unwrap(); + let router_price = Router::spot_price_with_fee(&route).unwrap(); // verify that there's no arb opportunity yet assert!(otc_price < router_price); @@ -365,7 +365,7 @@ fn trade_should_be_triggered_when_arb_opportunity_appears() { asset_in: otc.asset_out, asset_out: otc.asset_in, }); - let router_price = Router::spot_price(&route).unwrap(); + let router_price = Router::spot_price_with_fee(&route).unwrap(); // verify that there's an arb opportunity assert!(otc_price > router_price); @@ -416,7 +416,7 @@ fn trade_should_not_be_triggered_when_there_is_no_arb_opportunity() { asset_in: otc.asset_out, asset_out: otc.asset_in, }); - let router_price = Router::spot_price(&route).unwrap(); + let router_price = Router::spot_price_with_fee(&route).unwrap(); // verify that there's no arb opportunity assert!(otc_price < router_price); @@ -463,7 +463,7 @@ fn trade_should_not_be_triggered_when_optimal_amount_not_found() { asset_in: otc.asset_out, asset_out: otc.asset_in, }); - let router_price = Router::spot_price(&route).unwrap(); + let router_price = Router::spot_price_with_fee(&route).unwrap(); // verify that there's an arb opportunity assert!(otc_price > router_price); diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index 1f41b5288..91604744b 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -820,7 +820,7 @@ impl RouterT RouteSpotPriceProvider for DummyRouter { - fn spot_price(_route: &[Trade]) -> Option { + fn spot_price_with_fee(_route: &[Trade]) -> Option { Some(FixedU128::from_u32(2)) } } diff --git a/pallets/stableswap/src/benchmarks.rs b/pallets/stableswap/src/benchmarks.rs index a2045ac17..b41ab251c 100644 --- a/pallets/stableswap/src/benchmarks.rs +++ b/pallets/stableswap/src/benchmarks.rs @@ -609,7 +609,7 @@ benchmarks! { } } - calculate_spot_price { + calculate_spot_price_with_fee { let caller: T::AccountId = account("caller", 0, 1); let lp_provider: T::AccountId = account("provider", 0, 1); let initial_liquidity = 1_000_000_000_000_000_000u128; @@ -658,7 +658,7 @@ benchmarks! { )?; System::::set_block_number(500u32.into()); }: { - assert!( as TradeExecution>::calculate_spot_price(PoolType::Stableswap(pool_id), asset_in, asset_out).is_ok()); + assert!( as TradeExecution>::calculate_spot_price_with_fee(PoolType::Stableswap(pool_id), asset_in, asset_out).is_ok()); } impl_benchmark_test_suite!(Pallet, crate::tests::mock::ExtBuilder::default().build(), crate::tests::mock::Test); diff --git a/pallets/stableswap/src/weights.rs b/pallets/stableswap/src/weights.rs index e87c7b13c..a2da60c43 100644 --- a/pallets/stableswap/src/weights.rs +++ b/pallets/stableswap/src/weights.rs @@ -62,7 +62,7 @@ pub trait WeightInfo { fn update_amplification() -> Weight; fn router_execution_sell(c: u32, e: u32) -> Weight; fn router_execution_buy(c: u32, e: u32) -> Weight; - fn calculate_spot_price() -> Weight; + fn calculate_spot_price_with_fee() -> Weight; } /// Weights for pallet_stableswap using the hydraDX node and recommended hardware. @@ -387,7 +387,7 @@ impl WeightInfo for HydraWeight { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::Assets` (r:5 w:0) /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) - fn calculate_spot_price() -> Weight { + fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: // Measured: `1587` // Estimated: `13990` @@ -716,7 +716,7 @@ impl WeightInfo for () { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::Assets` (r:5 w:0) /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) - fn calculate_spot_price() -> Weight { + fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: // Measured: `1587` // Estimated: `13990` diff --git a/pallets/xyk/src/weights.rs b/pallets/xyk/src/weights.rs index 788dfeee4..f802798e2 100644 --- a/pallets/xyk/src/weights.rs +++ b/pallets/xyk/src/weights.rs @@ -57,7 +57,7 @@ pub trait WeightInfo { fn buy() -> Weight; fn router_execution_sell(c: u32, e: u32) -> Weight; fn router_execution_buy(c: u32, e: u32) -> Weight; - fn calculate_spot_price() -> Weight; + fn calculate_spot_price_with_fee() -> Weight; } /// Weights for amm using the hydraDX node and recommended hardware. @@ -337,7 +337,7 @@ impl WeightInfo for HydraWeight { /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, 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() -> Weight { + fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: // Measured: `1187` // Estimated: `6156` @@ -621,7 +621,7 @@ impl WeightInfo for () { /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, 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() -> Weight { + fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: // Measured: `1187` // Estimated: `6156` diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 92be6ff37..6db34b4cd 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -834,7 +834,7 @@ impl RouterWeightInfo { Weight::from_parts( weights::route_executor::HydraWeight::::calculate_spot_price_in_lbp() .ref_time() - .saturating_sub(weights::lbp::HydraWeight::::calculate_spot_price().ref_time()), + .saturating_sub(weights::lbp::HydraWeight::::calculate_spot_price_with_fee().ref_time()), weights::route_executor::HydraWeight::::calculate_spot_price_in_lbp().proof_size(), ) } @@ -1030,15 +1030,15 @@ impl AmmTradeWeights> for RouterWeightInfo { } // Used in OtcSettlements::settle_otc_order extrinsic - fn calculate_spot_price_weight(route: &[Trade]) -> Weight { + fn calculate_spot_price_with_fee_weight(route: &[Trade]) -> Weight { let mut weight = Self::calculate_spot_price_overweight(); for trade in route { let amm_weight = match trade.pool { - PoolType::Omnipool => weights::omnipool::HydraWeight::::calculate_spot_price(), - PoolType::LBP => weights::lbp::HydraWeight::::calculate_spot_price(), - PoolType::Stableswap(_) => weights::stableswap::HydraWeight::::calculate_spot_price(), - PoolType::XYK => weights::xyk::HydraWeight::::calculate_spot_price(), + PoolType::Omnipool => weights::omnipool::HydraWeight::::calculate_spot_price_with_fee(), + PoolType::LBP => weights::lbp::HydraWeight::::calculate_spot_price_with_fee(), + PoolType::Stableswap(_) => weights::stableswap::HydraWeight::::calculate_spot_price_with_fee(), + PoolType::XYK => weights::xyk::HydraWeight::::calculate_spot_price_with_fee(), }; weight.saturating_accrue(amm_weight); } diff --git a/runtime/hydradx/src/benchmarking/omnipool.rs b/runtime/hydradx/src/benchmarking/omnipool.rs index f03212427..de26b072c 100644 --- a/runtime/hydradx/src/benchmarking/omnipool.rs +++ b/runtime/hydradx/src/benchmarking/omnipool.rs @@ -515,7 +515,7 @@ runtime_benchmarks! { } } - calculate_spot_price { + calculate_spot_price_with_fee { init()?; let acc = Omnipool::protocol_account(); @@ -555,7 +555,7 @@ runtime_benchmarks! { let sell_max_limit = 2_000_000_000_000_u128; }: { - assert!(>::calculate_spot_price(PoolType::Omnipool, token_id, DAI).is_ok()); + assert!(>::calculate_spot_price_with_fee(PoolType::Omnipool, token_id, DAI).is_ok()); } } diff --git a/runtime/hydradx/src/benchmarking/route_executor.rs b/runtime/hydradx/src/benchmarking/route_executor.rs index f92ae465d..b23494c85 100644 --- a/runtime/hydradx/src/benchmarking/route_executor.rs +++ b/runtime/hydradx/src/benchmarking/route_executor.rs @@ -345,8 +345,8 @@ runtime_benchmarks! { Router::get_route(AssetPair::new(HDX, DAI)) } - // Calculates the weight of LBP spot price calculation. Used in the calculation to determine the weight of the overhead. - calculate_spot_price_in_lbp { + // Calculates the weight of LBP spot price with fee calculation. Used in the calculation to determine the weight of the overhead. + calculate_spot_price_with_fee_in_lbp { let asset_in = register_external_asset(b"FCA".to_vec()).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; let asset_out = register_external_asset(b"FCB".to_vec()).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; let caller: AccountId = funded_account("caller", 7, &[asset_in, asset_out]); @@ -361,10 +361,10 @@ runtime_benchmarks! { }]; }: { - Router::spot_price(trades.as_slice()); + Router::spot_price_with_fee(trades.as_slice()); } verify { - assert!(Router::spot_price(trades.as_slice()).is_some()); + assert!(Router::spot_price_with_fee(trades.as_slice()).is_some()); } } diff --git a/runtime/hydradx/src/benchmarking/xyk.rs b/runtime/hydradx/src/benchmarking/xyk.rs index bd977d64c..59dbffc47 100644 --- a/runtime/hydradx/src/benchmarking/xyk.rs +++ b/runtime/hydradx/src/benchmarking/xyk.rs @@ -265,7 +265,7 @@ runtime_benchmarks! { } } - calculate_spot_price { + calculate_spot_price_with_fee { let asset_a = register_external_asset(b"TKNA".to_vec()).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; let asset_b = register_external_asset(b"TKNB".to_vec()).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; let fee_asset = register_asset(b"FEE".to_vec(), 1u128).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; @@ -288,7 +288,7 @@ runtime_benchmarks! { assert_eq!(frame_system::Pallet::::account(caller).sufficients, 1); }: { - assert!(>::calculate_spot_price(PoolType::XYK, asset_a, asset_b).is_ok()); + assert!(>::calculate_spot_price_with_fee(PoolType::XYK, asset_a, asset_b).is_ok()); } } diff --git a/runtime/hydradx/src/weights/lbp.rs b/runtime/hydradx/src/weights/lbp.rs index abb67d1bd..955dadf92 100644 --- a/runtime/hydradx/src/weights/lbp.rs +++ b/runtime/hydradx/src/weights/lbp.rs @@ -265,7 +265,7 @@ impl WeightInfo for HydraWeight { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:0) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) - fn calculate_spot_price() -> Weight { + fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: // Measured: `789` // Estimated: `6156` diff --git a/runtime/hydradx/src/weights/omnipool.rs b/runtime/hydradx/src/weights/omnipool.rs index 5de05cf92..950d10f3b 100644 --- a/runtime/hydradx/src/weights/omnipool.rs +++ b/runtime/hydradx/src/weights/omnipool.rs @@ -552,7 +552,7 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, 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() -> Weight { + fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: // Measured: `1933` // Estimated: `6156` diff --git a/runtime/hydradx/src/weights/stableswap.rs b/runtime/hydradx/src/weights/stableswap.rs index e5c80265a..4c5729fd7 100644 --- a/runtime/hydradx/src/weights/stableswap.rs +++ b/runtime/hydradx/src/weights/stableswap.rs @@ -369,7 +369,7 @@ impl WeightInfo for HydraWeight { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::Assets` (r:5 w:0) /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) - fn calculate_spot_price() -> Weight { + fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: // Measured: `1587` // Estimated: `13990` diff --git a/runtime/hydradx/src/weights/xyk.rs b/runtime/hydradx/src/weights/xyk.rs index dc97a224a..deaa4cd6a 100644 --- a/runtime/hydradx/src/weights/xyk.rs +++ b/runtime/hydradx/src/weights/xyk.rs @@ -324,7 +324,7 @@ impl WeightInfo for HydraWeight { /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, 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() -> Weight { + fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: // Measured: `1187` // Estimated: `6156` diff --git a/traits/src/router.rs b/traits/src/router.rs index 2ff31459f..b2e812e3b 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -312,7 +312,7 @@ pub trait AmmTradeWeights { fn set_route_weight(route: &[Trade]) -> Weight; fn force_insert_route_weight() -> Weight; fn get_route_weight() -> Weight; - fn calculate_spot_price_weight(route: &[Trade]) -> Weight; + fn calculate_spot_price_with_fee_weight(route: &[Trade]) -> Weight; } impl AmmTradeWeights for () { @@ -340,7 +340,7 @@ impl AmmTradeWeights for () { fn get_route_weight() -> Weight { Weight::zero() } - fn calculate_spot_price_weight(_route: &[Trade]) -> Weight { + fn calculate_spot_price_with_fee_weight(_route: &[Trade]) -> Weight { Weight::zero() } } From 4d0ae34c93d23576ef4f245bf1b6ed5ccf6f186f Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Mon, 13 May 2024 12:41:26 +0200 Subject: [PATCH 24/61] remove origin check --- Cargo.lock | 1 + integration-tests/Cargo.toml | 1 + pallets/otc-settlements/Cargo.toml | 25 +++++++++++++---------- pallets/otc-settlements/src/lib.rs | 8 +++----- pallets/otc-settlements/src/tests.rs | 30 ++++++++++++++++++++++++++++ pallets/otc/Cargo.toml | 9 +++++---- 6 files changed, 54 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 014d22d24..f4639897b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11636,6 +11636,7 @@ dependencies = [ "pallet-omnipool", "pallet-omnipool-liquidity-mining", "pallet-otc", + "pallet-otc-settlements", "pallet-referrals", "pallet-relaychain-info", "pallet-route-executor", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 1b3a1a9e9..5d2959393 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -30,6 +30,7 @@ pallet-duster = { workspace = true } pallet-ema-oracle = { workspace = true } warehouse-liquidity-mining = { workspace = true } pallet-otc = { workspace = true } +pallet-otc-settlements = { workspace = true } pallet-relaychain-info = { workspace = true } pallet-route-executor = { workspace = true} pallet-dca = { workspace = true} diff --git a/pallets/otc-settlements/Cargo.toml b/pallets/otc-settlements/Cargo.toml index 027a83678..8b032794d 100644 --- a/pallets/otc-settlements/Cargo.toml +++ b/pallets/otc-settlements/Cargo.toml @@ -59,17 +59,20 @@ std = [ 'sp-core/std', 'sp-io/std', 'sp-std/std', - "scale-info/std", - "orml-tokens/std", - "hydradx-traits/std", - "hydra-dx-math/std", - "frame-benchmarking/std", - "pallet-otc/std", - "pallet-balances/std", - "pallet-currencies/std", - "pallet-route-executor/std", - "pallet-omnipool/std", - "pallet-asset-registry/std", + 'sp-arithmetic/std', + 'sp-api/std', + 'scale-info/std', + 'orml-tokens/std', + 'orml-traits/std', + 'hydradx-traits/std', + 'hydra-dx-math/std', + 'frame-benchmarking/std', + 'pallet-otc/std', + 'pallet-balances/std', + 'pallet-currencies/std', + 'pallet-route-executor/std', + 'pallet-omnipool/std', + 'pallet-asset-registry/std', ] runtime-benchmarks = [ diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 9596f1e96..2e31e9ae7 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -17,7 +17,6 @@ use frame_support::{pallet_prelude::*, PalletId}; use frame_system::{ - ensure_none, offchain::{SendTransactionTypes, SubmitTransaction}, pallet_prelude::{BlockNumberFor, OriginFor}, RawOrigin, @@ -192,7 +191,8 @@ pub mod pallet { /// The profit made by closing the arbitrage is transferred to `FeeReceiver`. /// /// Parameters: - /// - `origin`: Unsigned origin. + /// - `origin`: Signed or unsigned origin. Unsigned origin doesn't pay the TX fee, + /// but can be submitted only by a collator. /// - `otc_id`: ID of the OTC order with existing arbitrage opportunity. /// - `amount`: Amount necessary to clone the arb. /// - `route`: The route we trade against. Required for the fee calculation. @@ -207,13 +207,11 @@ pub mod pallet { .saturating_add(::WeightInfo::fill_order().max(::WeightInfo::partial_fill_order())) )] pub fn settle_otc_order( - origin: OriginFor, + _origin: OriginFor, otc_id: OrderId, amount: Balance, route: Vec>>, ) -> DispatchResult { - ensure_none(origin)?; - Self::settle_otc(otc_id, amount, route) } } diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 7199bff2d..830c6081f 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -18,6 +18,7 @@ // we don't need to run tests with benchmarking feature #![cfg(not(feature = "runtime-benchmarks"))] #![allow(clippy::bool_assert_comparison)] + use super::*; pub use crate::mock::*; use frame_support::{assert_ok, assert_storage_noop}; @@ -525,6 +526,35 @@ fn test_offchain_worker_unsigned_transaction_submission() { }) } +#[test] +fn test_offchain_worker_signed_transaction_submission() { + let (mut ext, _pool_state) = ExtBuilder::default().build(); + ext.execute_with(|| { + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, // otc asset_in + DAI, // otc asset_out + 100_000 * ONE, + 200_001 * ONE, + true, + )); + + let otc_id = 0; + let otc = >::get(otc_id).unwrap(); + let route = Router::get_route(AssetPair { + asset_in: otc.asset_out, + asset_out: otc.asset_in, + }); + + assert_ok!(OtcSettlements::settle_otc_order( + RuntimeOrigin::signed(ALICE), + 0, + 762_939_453_125, + route, + )); + }) +} + fn place_orders() { assert_ok!(OTC::place_order( RuntimeOrigin::signed(ALICE), diff --git a/pallets/otc/Cargo.toml b/pallets/otc/Cargo.toml index f565ba074..0e005f27b 100644 --- a/pallets/otc/Cargo.toml +++ b/pallets/otc/Cargo.toml @@ -48,10 +48,11 @@ std = [ 'sp-core/std', 'sp-io/std', 'sp-std/std', - "scale-info/std", - "orml-tokens/std", - "hydradx-traits/std", - "frame-benchmarking/std" + 'scale-info/std', + 'orml-tokens/std', + 'orml-traits/std', + 'hydradx-traits/std', + 'frame-benchmarking/std' ] runtime-benchmarks = [ From 6e333fb6c78859544c8eed9471c95d0e1ce77ba1 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 14 May 2024 10:46:20 +0200 Subject: [PATCH 25/61] add MinTradingLimit --- integration-tests/src/router.rs | 8 ++++---- pallets/otc-settlements/src/lib.rs | 8 ++++++-- pallets/otc-settlements/src/mock.rs | 30 ++++++++++++++++++---------- pallets/otc-settlements/src/tests.rs | 12 +++++------ runtime/hydradx/src/assets.rs | 1 + 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 6f0ff3f8b..4c9c11b05 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -1305,12 +1305,12 @@ mod omnipool_router_tests { //We need to do this because this setup leads to different behaviour of reducable_balance in the post balance check in router hydradx_runtime::System::inc_consumers(&AccountId::from(ALICE)).unwrap(); - let acc = hydradx_runtime::System::account(&AccountId::from(ALICE)); + let acc = hydradx_runtime::System::account(AccountId::from(ALICE)); assert_eq!(acc.consumers, 1); hydradx_runtime::System::dec_providers(&AccountId::from(ALICE)).unwrap(); hydradx_runtime::System::dec_providers(&AccountId::from(ALICE)).unwrap(); hydradx_runtime::System::dec_providers(&AccountId::from(ALICE)).unwrap(); - let acc = hydradx_runtime::System::account(&AccountId::from(ALICE)); + let acc = hydradx_runtime::System::account(AccountId::from(ALICE)); assert_eq!(acc.providers, 1); //Act and assert @@ -1381,12 +1381,12 @@ mod omnipool_router_tests { //We need to do this because this setup leads to different behaviour of reducable_balance in the post balance check in router hydradx_runtime::System::inc_consumers(&AccountId::from(ALICE)).unwrap(); - let acc = hydradx_runtime::System::account(&AccountId::from(ALICE)); + let acc = hydradx_runtime::System::account(AccountId::from(ALICE)); assert_eq!(acc.consumers, 1); hydradx_runtime::System::dec_providers(&AccountId::from(ALICE)).unwrap(); hydradx_runtime::System::dec_providers(&AccountId::from(ALICE)).unwrap(); hydradx_runtime::System::dec_providers(&AccountId::from(ALICE)).unwrap(); - let acc = hydradx_runtime::System::account(&AccountId::from(ALICE)); + let acc = hydradx_runtime::System::account(AccountId::from(ALICE)); assert_eq!(acc.providers, 1); //Act and assert diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 2e31e9ae7..f6d9eaada 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -1,4 +1,4 @@ -// This file is part of galacticcouncil/warehouse. +// This file is part of HydraDX. // Copyright (C) 2020-2023 Intergalactic, Limited (GIB). SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -106,6 +106,10 @@ pub mod pallet { #[pallet::constant] type PricePrecision: Get; + /// Minimum trading limit + #[pallet::constant] + type MinTradingLimit: Get; + /// Router weight information. type RouterWeightInfo: AmmTradeWeights>>; @@ -479,7 +483,7 @@ impl Pallet { // use binary search to determine the correct sell amount let mut sell_amt = otc.amount_in; // start by trying to fill the whole order let mut sell_amt_up = sell_amt; - let mut sell_amt_down = 0; // TODO: set to some min trade amount + let mut sell_amt_down = T::MinTradingLimit::get(); let iters = if otc.partially_fillable { FILL_SEARCH_ITERATIONS diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index 75afceb98..a6a2d3c83 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -15,28 +15,28 @@ use crate as pallet_otc_settlements; use crate::*; -use frame_support::traits::tokens::nonfungibles::{Create, Inspect, Mutate}; use frame_support::{ assert_ok, parameter_types, - traits::{Everything, Nothing}, + sp_runtime::{ + traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, Permill, + }, + traits::{ + tokens::nonfungibles::{Create, Inspect, Mutate}, + Everything, Nothing, + }, }; use frame_system::{EnsureRoot, EnsureSigned}; use hydra_dx_math::ema::EmaPrice; -use hydradx_traits::router::PoolType; +use hydradx_traits::router::{PoolType, RefundEdCalculator}; use orml_traits::parameter_type_with_key; -use pallet_currencies::fungibles::FungibleCurrencies; -use pallet_currencies::BasicCurrencyAdapter; +use pallet_currencies::{fungibles::FungibleCurrencies, BasicCurrencyAdapter}; use pallet_omnipool::traits::ExternalPriceProvider; use sp_core::offchain::{ testing::PoolState, testing::TestOffchainExt, testing::TestTransactionPoolExt, OffchainDbExt, OffchainWorkerExt, TransactionPoolExt, }; use sp_core::H256; -use sp_runtime::Permill; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, - BuildStorage, -}; use sp_std::sync::Arc; type Block = frame_system::mocking::MockBlock; @@ -94,6 +94,7 @@ impl pallet_otc_settlements::Config for Test { type ProfitReceiver = TreasuryAccount; type ExistentialDepositMultiplier = ExistentialDepositMultiplier; type PricePrecision = PricePrecision; + type MinTradingLimit = MinTradingLimit; type WeightInfo = (); type RouterWeightInfo = (); } @@ -112,6 +113,14 @@ parameter_types! { pub DefaultRoutePoolType: PoolType = PoolType::Omnipool; } +pub struct MockedEdCalculator; + +impl RefundEdCalculator for MockedEdCalculator { + fn calculate() -> Balance { + 1_000_000_000_000 + } +} + impl pallet_route_executor::Config for Test { type RuntimeEvent = RuntimeEvent; type AssetId = AssetId; @@ -123,6 +132,7 @@ impl pallet_route_executor::Config for Test { type DefaultRoutePoolType = DefaultRoutePoolType; type WeightInfo = (); type TechnicalOrigin = EnsureRoot; + type EdToRefundCalculator = MockedEdCalculator; } parameter_types! { diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 830c6081f..ea0fb21e7 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -279,7 +279,7 @@ fn existing_arb_opportunity_of_insufficient_asset_should_trigger_trade() { expect_last_events(vec![Event::Executed { asset_id: BTC, - profit: 16_547_522, + profit: 16_547_521, } .into()]); }); @@ -316,7 +316,7 @@ fn multiple_arb_opportunities_should_trigger_trades() { .into(), Event::Executed { asset_id: DOT, - profit: 12_436_704, + profit: 12_436_705, } .into(), ]); @@ -519,7 +519,7 @@ fn test_offchain_worker_unsigned_transaction_submission() { tx.call, crate::mock::RuntimeCall::OtcSettlements(crate::Call::settle_otc_order { otc_id: 0, - amount: 762_939_453_125, + amount: 762_939_454_124, route, }) ); @@ -548,9 +548,9 @@ fn test_offchain_worker_signed_transaction_submission() { assert_ok!(OtcSettlements::settle_otc_order( RuntimeOrigin::signed(ALICE), - 0, - 762_939_453_125, - route, + 0, + 762_939_453_125, + route, )); }) } diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 886c4a880..b21798144 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -1114,6 +1114,7 @@ impl pallet_otc_settlements::Config for Runtime { type ProfitReceiver = TreasuryAccount; type ExistentialDepositMultiplier = ExistentialDepositMultiplier; type PricePrecision = PricePrecision; + type MinTradingLimit = MinTradingLimit; type WeightInfo = weights::otc_settlements::HydraWeight; type RouterWeightInfo = RouterWeightInfo; } From 495c3068c0df5a00a43df56664c9d8feb8f558d7 Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 14 May 2024 14:12:36 +0200 Subject: [PATCH 26/61] fixed unsafe math --- math/src/stableswap/math.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math/src/stableswap/math.rs b/math/src/stableswap/math.rs index 4124cab8f..a8c2a6458 100644 --- a/math/src/stableswap/math.rs +++ b/math/src/stableswap/math.rs @@ -799,7 +799,7 @@ pub fn calculate_spot_price( let mut updated_reserves = asset_reserves.clone(); for reserve in updated_reserves.iter_mut() { if reserve.0 == added_asset.0 { - reserve.1.amount += added_asset.1; + reserve.1.amount.checked_add(added_asset.1)?; } } From a3a85dd5ebb2dc5bfc185f41668659dfc49102d7 Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 14 May 2024 14:17:46 +0200 Subject: [PATCH 27/61] bump math version --- Cargo.lock | 2 +- math/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c46cc112b..8759d192f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4508,7 +4508,7 @@ dependencies = [ [[package]] name = "hydra-dx-math" -version = "8.1.1" +version = "8.1.2" dependencies = [ "approx", "criterion", diff --git a/math/Cargo.toml b/math/Cargo.toml index 392320a23..9447c3454 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.1.1" +version = "8.1.2" [dependencies] primitive-types = {default-features = false, version = '0.12.0'} From adff99207b22e1f3dbcf71ae72fd1969c815cd4d Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 14 May 2024 15:24:45 +0200 Subject: [PATCH 28/61] fix bug as checked math returns a new instance --- math/src/stableswap/math.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math/src/stableswap/math.rs b/math/src/stableswap/math.rs index a8c2a6458..b6d67c418 100644 --- a/math/src/stableswap/math.rs +++ b/math/src/stableswap/math.rs @@ -799,7 +799,7 @@ pub fn calculate_spot_price( let mut updated_reserves = asset_reserves.clone(); for reserve in updated_reserves.iter_mut() { if reserve.0 == added_asset.0 { - reserve.1.amount.checked_add(added_asset.1)?; + reserve.1.amount = reserve.1.amount.checked_add(added_asset.1)?; } } From 8f6d4eb969dabc5febe0f02b5f1194f1606eb413 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 14 May 2024 15:32:36 +0200 Subject: [PATCH 29/61] add readme file --- math/src/stableswap/math.rs | 2 +- pallets/otc-settlements/README.md | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 pallets/otc-settlements/README.md diff --git a/math/src/stableswap/math.rs b/math/src/stableswap/math.rs index b6d67c418..d9597abbe 100644 --- a/math/src/stableswap/math.rs +++ b/math/src/stableswap/math.rs @@ -799,7 +799,7 @@ pub fn calculate_spot_price( let mut updated_reserves = asset_reserves.clone(); for reserve in updated_reserves.iter_mut() { if reserve.0 == added_asset.0 { - reserve.1.amount = reserve.1.amount.checked_add(added_asset.1)?; + reserve.1.amount = reserve.1.amount.checked_add(added_asset.1)?; } } diff --git a/pallets/otc-settlements/README.md b/pallets/otc-settlements/README.md new file mode 100644 index 000000000..c21178bbc --- /dev/null +++ b/pallets/otc-settlements/README.md @@ -0,0 +1,16 @@ +# OTC Settlements pallet +## Description +The pallet provides implementation of the offchain worker for closing existing arbitrage opportunities between OTC +orders and the Omnipool. +Two main parts of this pallet are methods to find the correct amount in order to close an existing arbitrage opportunity +and an extrinsic. The extrinsic is mainly called by the offchain worker as unsigned extrinsic, but can by also called +by any user using signed origin. In the former case, the block producer doesn't pay the fee. + +## Notes +If the OTC order is partially fillable, the pallet tries to close the arbitrage opportunity by finding the amount that +aligns the OTC and the Omnipool prices. Executing this trade needs to be profitable, but we are not trying to maximize +the profit. +In the case of not partially fillable OTC orders, the pallet tries to maximize the profit. + +## Dispatachable functions +* `settle_otc_order` - Executes a trade between an OTC order and some route. \ No newline at end of file From b6431feea6c88e63f270af8c18b7bc5a9b732ad9 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 14 May 2024 15:45:21 +0200 Subject: [PATCH 30/61] move MaxIterations to the config --- pallets/otc-settlements/src/lib.rs | 15 +++++++++------ pallets/otc-settlements/src/mock.rs | 1 + runtime/hydradx/src/assets.rs | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index f6d9eaada..80c9d62fe 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -65,7 +65,6 @@ pub const OFFCHAIN_WORKER_DATA: &[u8] = b"hydradx/otc-settlements/data/"; pub const OFFCHAIN_WORKER_DATA_LAST_UPDATE: &[u8] = b"hydradx/otc-settlements/data-last-update/"; pub const SORTED_ORDERS_LOCK: &[u8] = b"hydradx/otc-settlements/lock/"; pub const LOCK_TIMEOUT_EXPIRATION: u64 = 5_000; // 5 seconds -/// The number of iterations in the binary search algorithm pub const FILL_SEARCH_ITERATIONS: u32 = 40; pub type AssetIdOf = ::AssetId; @@ -83,10 +82,10 @@ pub mod pallet { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; - /// Named reservable multi currency + /// Named reservable multi currency. type Currency: MultiCurrency, Balance = Balance>; - /// Router implementation + /// Router implementation. type Router: RouteProvider> + RouterT, Balance, Trade>, AmountInAndOut> + RouteSpotPriceProvider>; @@ -94,7 +93,7 @@ pub mod pallet { /// Provider of existential deposits. type ExistentialDeposits: GetByKey, Balance>; - /// Determines the minimum profit + /// Determines the minimum profit. #[pallet::constant] type ExistentialDepositMultiplier: Get; @@ -106,10 +105,14 @@ pub mod pallet { #[pallet::constant] type PricePrecision: Get; - /// Minimum trading limit + /// Minimum trading limit. #[pallet::constant] type MinTradingLimit: Get; + /// Maximum number of iterations used in the binary search algorithm to find the trade amount. + #[pallet::constant] + type MaxIterations: Get; + /// Router weight information. type RouterWeightInfo: AmmTradeWeights>>; @@ -486,7 +489,7 @@ impl Pallet { let mut sell_amt_down = T::MinTradingLimit::get(); let iters = if otc.partially_fillable { - FILL_SEARCH_ITERATIONS + T::MaxIterations::get() } else { 1 }; diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index a6a2d3c83..7749bda79 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -95,6 +95,7 @@ impl pallet_otc_settlements::Config for Test { type ExistentialDepositMultiplier = ExistentialDepositMultiplier; type PricePrecision = PricePrecision; type MinTradingLimit = MinTradingLimit; + type MaxIterations = ConstU32<40>; type WeightInfo = (); type RouterWeightInfo = (); } diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index b21798144..a466dfe0f 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -1115,6 +1115,7 @@ impl pallet_otc_settlements::Config for Runtime { type ExistentialDepositMultiplier = ExistentialDepositMultiplier; type PricePrecision = PricePrecision; type MinTradingLimit = MinTradingLimit; + type MaxIterations = ConstU32<40>; type WeightInfo = weights::otc_settlements::HydraWeight; type RouterWeightInfo = RouterWeightInfo; } From d8381d8ad091c5d38ceea95f2bc007050dd2b9df Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 14 May 2024 15:47:26 +0200 Subject: [PATCH 31/61] bump crate versions --- Cargo.lock | 4 ++-- pallets/lbp/Cargo.toml | 2 +- pallets/stableswap/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8759d192f..8bf42278a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7979,7 +7979,7 @@ dependencies = [ [[package]] name = "pallet-lbp" -version = "4.8.1" +version = "4.8.2" dependencies = [ "frame-benchmarking", "frame-support", @@ -8555,7 +8555,7 @@ dependencies = [ [[package]] name = "pallet-stableswap" -version = "3.6.1" +version = "3.6.2" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", diff --git a/pallets/lbp/Cargo.toml b/pallets/lbp/Cargo.toml index 7732b96f7..42c82080a 100644 --- a/pallets/lbp/Cargo.toml +++ b/pallets/lbp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-lbp" -version = "4.8.1" +version = "4.8.2" description = "HydraDX Liquidity Bootstrapping Pool Pallet" authors = ["GalacticCouncil"] edition = "2021" diff --git a/pallets/stableswap/Cargo.toml b/pallets/stableswap/Cargo.toml index 0eb65d7e1..5c4ab38bd 100644 --- a/pallets/stableswap/Cargo.toml +++ b/pallets/stableswap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-stableswap' -version = '3.6.1' +version = '3.6.2' description = 'AMM for correlated assets' authors = ['GalacticCouncil'] edition = '2021' From fa0366d826497dcca93dca83e888465a7b8d36e3 Mon Sep 17 00:00:00 2001 From: Richard Roznovjak Date: Wed, 15 May 2024 07:11:34 -0500 Subject: [PATCH 32/61] Update pallets/otc-settlements/README.md Co-authored-by: Daniel Moka --- pallets/otc-settlements/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/otc-settlements/README.md b/pallets/otc-settlements/README.md index c21178bbc..91b5364f9 100644 --- a/pallets/otc-settlements/README.md +++ b/pallets/otc-settlements/README.md @@ -3,7 +3,7 @@ The pallet provides implementation of the offchain worker for closing existing arbitrage opportunities between OTC orders and the Omnipool. Two main parts of this pallet are methods to find the correct amount in order to close an existing arbitrage opportunity -and an extrinsic. The extrinsic is mainly called by the offchain worker as unsigned extrinsic, but can by also called +and an extrinsic. The extrinsic is mainly called by the offchain worker as unsigned extrinsic, but can be also called by any user using signed origin. In the former case, the block producer doesn't pay the fee. ## Notes From 11a36c2959987aa43e0730b3096b9c29e6a50f4c Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 15 May 2024 16:00:52 +0200 Subject: [PATCH 33/61] use otc order percentage to calculate min profit --- pallets/otc-settlements/src/lib.rs | 42 +++++++++++++++------------- pallets/otc-settlements/src/mock.rs | 6 ++-- pallets/otc-settlements/src/tests.rs | 32 ++++++++++----------- runtime/hydradx/src/assets.rs | 4 +-- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 80c9d62fe..be8e821de 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -24,15 +24,22 @@ use frame_system::{ use hydradx_traits::router::{ AmmTradeWeights, AmountInAndOut, AssetPair, RouteProvider, RouteSpotPriceProvider, RouterT, Trade, }; -use orml_traits::{GetByKey, MultiCurrency}; +use orml_traits::MultiCurrency; use pallet_otc::weights::WeightInfo as OtcWeightInfo; pub use pallet_otc::OrderId; -use sp_arithmetic::traits::{CheckedMul, Saturating}; -use sp_arithmetic::{ArithmeticError, FixedPointNumber, FixedU128}; -use sp_runtime::offchain::storage::StorageValueRef; -use sp_runtime::offchain::storage_lock::{StorageLock, Time}; -use sp_runtime::offchain::Duration; -use sp_runtime::traits::AccountIdConversion; +use sp_arithmetic::{ + traits::{CheckedMul, Saturating}, + ArithmeticError, FixedPointNumber, FixedU128, +}; +use sp_runtime::{ + offchain::{ + storage::StorageValueRef, + storage_lock::{StorageLock, Time}, + Duration, + }, + traits::AccountIdConversion, + Perbill, +}; use sp_std::vec; use sp_std::vec::Vec; @@ -90,17 +97,14 @@ pub mod pallet { + RouterT, Balance, Trade>, AmountInAndOut> + RouteSpotPriceProvider>; - /// Provider of existential deposits. - type ExistentialDeposits: GetByKey, Balance>; - - /// Determines the minimum profit. - #[pallet::constant] - type ExistentialDepositMultiplier: Get; - /// Account who receives the profit. #[pallet::constant] type ProfitReceiver: Get; + /// Minimum profit in terms of percentage. + #[pallet::constant] + type MinProfitPercentage: Get; + /// Determines when we consider an arbitrage as closed. #[pallet::constant] type PricePrecision: Get; @@ -230,15 +234,13 @@ impl Pallet { } /// Ensure that the profit is more than some minimum amount. - fn ensure_min_profit(asset: T::AssetId, _profit: Balance) -> DispatchResult { - let _min_amount = ::ExistentialDeposits::get(&asset) - .checked_mul(::ExistentialDepositMultiplier::get().into()) - .ok_or(ArithmeticError::Overflow)?; + fn ensure_min_profit(otc_amount_in: Balance, _profit: Balance) -> DispatchResult { + let _min_expected_profit = T::MinProfitPercentage::get().mul_floor(otc_amount_in); // In the benchmark we doesn't make any trade, so this check would fail. #[cfg(not(feature = "runtime-benchmarks"))] // tell the binary search algorithm to find higher values - ensure!(_profit >= _min_amount, Error::::TradeAmountTooLow); + ensure!(_profit >= _min_expected_profit, Error::::TradeAmountTooLow); Ok(()) } @@ -350,7 +352,7 @@ impl Pallet { .checked_sub(amount) .ok_or(ArithmeticError::Overflow)?; - Self::ensure_min_profit(asset_a, profit)?; + Self::ensure_min_profit(otc.amount_in, profit)?; ::Currency::transfer(asset_a, &pallet_acc, &T::ProfitReceiver::get(), profit)?; diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index 7749bda79..ff041aea0 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -29,7 +29,7 @@ use frame_support::{ use frame_system::{EnsureRoot, EnsureSigned}; use hydra_dx_math::ema::EmaPrice; use hydradx_traits::router::{PoolType, RefundEdCalculator}; -use orml_traits::parameter_type_with_key; +use orml_traits::{parameter_type_with_key, GetByKey}; use pallet_currencies::{fungibles::FungibleCurrencies, BasicCurrencyAdapter}; use pallet_omnipool::traits::ExternalPriceProvider; use sp_core::offchain::{ @@ -78,6 +78,7 @@ parameter_types! { pub ExistentialDepositMultiplier: u8 = 5; pub MinProfitLimit: Balance = 10_000_000_000_000; pub PricePrecision: FixedU128 = FixedU128::from_rational(1, 1_000_000); + pub MinProfitPercentage: Perbill = Perbill::from_rational(1u32, 1_000_00u32); // 0.001% } parameter_type_with_key! { @@ -90,9 +91,8 @@ impl pallet_otc_settlements::Config for Test { type Currency = Currencies; type RuntimeEvent = RuntimeEvent; type Router = Router; - type ExistentialDeposits = ExistentialDeposits; type ProfitReceiver = TreasuryAccount; - type ExistentialDepositMultiplier = ExistentialDepositMultiplier; + type MinProfitPercentage = MinProfitPercentage; type PricePrecision = PricePrecision; type MinTradingLimit = MinTradingLimit; type MaxIterations = ConstU32<40>; diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index ea0fb21e7..0f45d4197 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -167,7 +167,7 @@ fn profit_should_be_transferred_to_treasury() { HDX, DAI, 100_000 * ONE, - 200_001 * ONE, + 201_000 * ONE, true, )); @@ -189,7 +189,7 @@ fn existing_arb_opportunity_should_trigger_trade() { HDX, // otc asset_in DAI, // otc asset_out 100_000 * ONE, - 200_001 * ONE, + 201_000 * ONE, true, )); @@ -225,7 +225,7 @@ fn existing_arb_opportunity_should_trigger_trade() { expect_last_events(vec![Event::Executed { asset_id: HDX, - profit: 2_068_452, + profit: 2_067_802_207_347, } .into()]); }); @@ -243,7 +243,7 @@ fn existing_arb_opportunity_of_insufficient_asset_should_trigger_trade() { BTC, // otc asset_in HDX, // otc asset_out 200_000 * ONE, - 100_001 * ONE, + 101_000 * ONE, true, )); @@ -279,7 +279,7 @@ fn existing_arb_opportunity_of_insufficient_asset_should_trigger_trade() { expect_last_events(vec![Event::Executed { asset_id: BTC, - profit: 16_547_521, + profit: 16_419_654_005_878, } .into()]); }); @@ -294,7 +294,7 @@ fn multiple_arb_opportunities_should_trigger_trades() { HDX, // otc asset_in DAI, // otc asset_out 100_000 * ONE, - 200_001 * ONE, + 201_000 * ONE, true, )); assert_ok!(OTC::place_order( @@ -302,7 +302,7 @@ fn multiple_arb_opportunities_should_trigger_trades() { DOT, // otc asset_in KSM, // otc asset_out 100_000 * ONE, - 100_001 * ONE, + 101_000 * ONE, true, )); @@ -311,12 +311,12 @@ fn multiple_arb_opportunities_should_trigger_trades() { expect_events(vec![ Event::Executed { asset_id: HDX, - profit: 2_068_452, + profit: 2_067_802_207_347, } .into(), Event::Executed { asset_id: DOT, - profit: 12_436_705, + profit: 12_345_450_557_916, } .into(), ]); @@ -354,7 +354,7 @@ fn trade_should_be_triggered_when_arb_opportunity_appears() { >>::offchain_worker(System::block_number()); // make a trade to move the price and create an arb opportunity - assert_ok!(Omnipool::sell(RuntimeOrigin::signed(ALICE), HDX, DAI, 10 * ONE, ONE,)); + assert_ok!(Omnipool::sell(RuntimeOrigin::signed(ALICE), HDX, DAI, 1_000 * ONE, ONE,)); System::set_block_number(System::block_number() + 1); @@ -388,7 +388,7 @@ fn trade_should_be_triggered_when_arb_opportunity_appears() { expect_last_events(vec![Event::Executed { asset_id: HDX, - profit: 208_316_745, + profit: 2_981_065_139_674, } .into()]); }); @@ -497,7 +497,7 @@ fn test_offchain_worker_unsigned_transaction_submission() { HDX, // otc asset_in DAI, // otc asset_out 100_000 * ONE, - 200_001 * ONE, + 201_000 * ONE, true, )); @@ -519,7 +519,7 @@ fn test_offchain_worker_unsigned_transaction_submission() { tx.call, crate::mock::RuntimeCall::OtcSettlements(crate::Call::settle_otc_order { otc_id: 0, - amount: 762_939_454_124, + amount: 828_170_776_368_178, route, }) ); @@ -535,7 +535,7 @@ fn test_offchain_worker_signed_transaction_submission() { HDX, // otc asset_in DAI, // otc asset_out 100_000 * ONE, - 200_001 * ONE, + 201_000 * ONE, true, )); @@ -548,8 +548,8 @@ fn test_offchain_worker_signed_transaction_submission() { assert_ok!(OtcSettlements::settle_otc_order( RuntimeOrigin::signed(ALICE), - 0, - 762_939_453_125, + otc_id, + 828_170_776_368_178, route, )); }) diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index a466dfe0f..289b586c1 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -1091,6 +1091,7 @@ impl pallet_route_executor::Config for Runtime { parameter_types! { pub const ExistentialDepositMultiplier: u8 = 5; pub const PricePrecision: FixedU128 = FixedU128::from_rational(1, 100); + pub MinProfitPercentage: Perbill = Perbill::from_rational(1u32, 1_000_00u32); // 0.001% } impl pallet_otc::Config for Runtime { @@ -1106,13 +1107,12 @@ impl pallet_otc::Config for Runtime { impl pallet_otc_settlements::Config for Runtime { type Currency = Currencies; type RuntimeEvent = RuntimeEvent; - type ExistentialDeposits = AssetRegistry; #[cfg(not(feature = "runtime-benchmarks"))] type Router = Router; #[cfg(feature = "runtime-benchmarks")] type Router = pallet_route_executor::DummyRouter; type ProfitReceiver = TreasuryAccount; - type ExistentialDepositMultiplier = ExistentialDepositMultiplier; + type MinProfitPercentage = MinProfitPercentage; type PricePrecision = PricePrecision; type MinTradingLimit = MinTradingLimit; type MaxIterations = ConstU32<40>; From e5f56599bbc22822798139274e774746ec66b7aa Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 15 May 2024 16:09:01 +0200 Subject: [PATCH 34/61] satisfy clippy --- pallets/otc-settlements/src/mock.rs | 2 +- runtime/hydradx/src/assets.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index ff041aea0..150dba96d 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -78,7 +78,7 @@ parameter_types! { pub ExistentialDepositMultiplier: u8 = 5; pub MinProfitLimit: Balance = 10_000_000_000_000; pub PricePrecision: FixedU128 = FixedU128::from_rational(1, 1_000_000); - pub MinProfitPercentage: Perbill = Perbill::from_rational(1u32, 1_000_00u32); // 0.001% + pub MinProfitPercentage: Perbill = Perbill::from_rational(1u32, 100_000_u32); // 0.001% } parameter_type_with_key! { diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 289b586c1..d2b99e7fe 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -1091,7 +1091,7 @@ impl pallet_route_executor::Config for Runtime { parameter_types! { pub const ExistentialDepositMultiplier: u8 = 5; pub const PricePrecision: FixedU128 = FixedU128::from_rational(1, 100); - pub MinProfitPercentage: Perbill = Perbill::from_rational(1u32, 1_000_00u32); // 0.001% + pub MinProfitPercentage: Perbill = Perbill::from_rational(1u32, 100_000_u32); // 0.001% } impl pallet_otc::Config for Runtime { From 3622848ff712724422834b0849dce74f86bde0f3 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 15 May 2024 16:20:49 +0200 Subject: [PATCH 35/61] bump crate version --- Cargo.lock | 2 +- pallets/otc/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8bf42278a..bdf64a9ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8280,7 +8280,7 @@ dependencies = [ [[package]] name = "pallet-otc" -version = "1.1.2" +version = "1.1.3" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/pallets/otc/Cargo.toml b/pallets/otc/Cargo.toml index 0e005f27b..f62c741f7 100644 --- a/pallets/otc/Cargo.toml +++ b/pallets/otc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-otc' -version = '1.1.2' +version = '1.1.3' description = 'A pallet for trustless over-the-counter trading' authors = ['GalacticCouncil'] edition = '2021' From fc26bdcf69c5c61daa777f5c601ca371c59de646 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 24 May 2024 13:59:57 +0200 Subject: [PATCH 36/61] bump crate versions --- Cargo.lock | 12 ++++++------ integration-tests/Cargo.toml | 2 +- pallets/dca/Cargo.toml | 2 +- pallets/omnipool/Cargo.toml | 2 +- pallets/route-executor/Cargo.toml | 2 +- runtime/hydradx/Cargo.toml | 2 +- runtime/hydradx/src/lib.rs | 2 +- traits/Cargo.toml | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 403c78688..727092c38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4671,7 +4671,7 @@ dependencies = [ [[package]] name = "hydradx-runtime" -version = "236.0.0" +version = "237.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -4802,7 +4802,7 @@ dependencies = [ [[package]] name = "hydradx-traits" -version = "3.3.1" +version = "3.4.0" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -7474,7 +7474,7 @@ dependencies = [ [[package]] name = "pallet-dca" -version = "1.4.7" +version = "1.4.8" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -8226,7 +8226,7 @@ dependencies = [ [[package]] name = "pallet-omnipool" -version = "4.2.1" +version = "4.2.2" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -8455,7 +8455,7 @@ dependencies = [ [[package]] name = "pallet-route-executor" -version = "2.3.2" +version = "2.4.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -11578,7 +11578,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "1.21.6" +version = "1.21.7" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 8214fc112..21e550ab3 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-integration-tests" -version = "1.21.6" +version = "1.21.7" description = "Integration tests" authors = ["GalacticCouncil"] edition = "2021" diff --git a/pallets/dca/Cargo.toml b/pallets/dca/Cargo.toml index dfac51357..c7634b80c 100644 --- a/pallets/dca/Cargo.toml +++ b/pallets/dca/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-dca' -version = "1.4.7" +version = "1.4.8" description = 'A pallet to manage DCA scheduling' authors = ['GalacticCouncil'] edition = '2021' diff --git a/pallets/omnipool/Cargo.toml b/pallets/omnipool/Cargo.toml index e225f654c..e108fd6aa 100644 --- a/pallets/omnipool/Cargo.toml +++ b/pallets/omnipool/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-omnipool" -version = "4.2.1" +version = "4.2.2" authors = ['GalacticCouncil'] edition = "2021" license = "Apache-2.0" diff --git a/pallets/route-executor/Cargo.toml b/pallets/route-executor/Cargo.toml index ccf6826f9..62f609323 100644 --- a/pallets/route-executor/Cargo.toml +++ b/pallets/route-executor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-route-executor' -version = '2.3.2' +version = '2.4.0' description = 'A pallet to execute a route containing a sequence of trades' authors = ['GalacticCouncil'] edition = '2021' diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index 160a310a3..e111f1442 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-runtime" -version = "236.0.0" +version = "237.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 569b25e77..6428d94a8 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -109,7 +109,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("hydradx"), impl_name: create_runtime_str!("hydradx"), authoring_version: 1, - spec_version: 236, + spec_version: 237, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/traits/Cargo.toml b/traits/Cargo.toml index 7b55955e9..d162a8230 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-traits" -version = "3.3.1" +version = "3.4.0" description = "Shared traits" authors = ["GalacticCouncil"] edition = "2021" From 26c96c32ae33dbb2fae6de968ed27c4a04cc0861 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Mon, 27 May 2024 10:54:06 +0200 Subject: [PATCH 37/61] bump crate versions --- Cargo.lock | 10 +++++----- pallets/lbp/Cargo.toml | 2 +- pallets/omnipool/Cargo.toml | 2 +- pallets/otc/Cargo.toml | 2 +- pallets/stableswap/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 c58bc2558..f95638f0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4671,7 +4671,7 @@ dependencies = [ [[package]] name = "hydradx-runtime" -version = "237.0.0" +version = "238.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -7980,7 +7980,7 @@ dependencies = [ [[package]] name = "pallet-lbp" -version = "4.8.2" +version = "4.8.3" dependencies = [ "frame-benchmarking", "frame-support", @@ -8227,7 +8227,7 @@ dependencies = [ [[package]] name = "pallet-omnipool" -version = "4.2.2" +version = "4.2.3" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -8281,7 +8281,7 @@ dependencies = [ [[package]] name = "pallet-otc" -version = "1.1.3" +version = "1.1.4" dependencies = [ "frame-benchmarking", "frame-support", @@ -8556,7 +8556,7 @@ dependencies = [ [[package]] name = "pallet-stableswap" -version = "3.6.2" +version = "3.6.3" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", diff --git a/pallets/lbp/Cargo.toml b/pallets/lbp/Cargo.toml index 42c82080a..68726ad06 100644 --- a/pallets/lbp/Cargo.toml +++ b/pallets/lbp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-lbp" -version = "4.8.2" +version = "4.8.3" description = "HydraDX Liquidity Bootstrapping Pool Pallet" authors = ["GalacticCouncil"] edition = "2021" diff --git a/pallets/omnipool/Cargo.toml b/pallets/omnipool/Cargo.toml index e108fd6aa..709bcc360 100644 --- a/pallets/omnipool/Cargo.toml +++ b/pallets/omnipool/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-omnipool" -version = "4.2.2" +version = "4.2.3" authors = ['GalacticCouncil'] edition = "2021" license = "Apache-2.0" diff --git a/pallets/otc/Cargo.toml b/pallets/otc/Cargo.toml index f62c741f7..398e38058 100644 --- a/pallets/otc/Cargo.toml +++ b/pallets/otc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-otc' -version = '1.1.3' +version = '1.1.4' description = 'A pallet for trustless over-the-counter trading' authors = ['GalacticCouncil'] edition = '2021' diff --git a/pallets/stableswap/Cargo.toml b/pallets/stableswap/Cargo.toml index 5c4ab38bd..dcbbdfd98 100644 --- a/pallets/stableswap/Cargo.toml +++ b/pallets/stableswap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-stableswap' -version = '3.6.2' +version = '3.6.3' description = 'AMM for correlated assets' authors = ['GalacticCouncil'] edition = '2021' diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index bbb18a04c..b76e23ba8 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-runtime" -version = "237.0.0" +version = "238.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 6428d94a8..898ce3406 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -109,7 +109,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("hydradx"), impl_name: create_runtime_str!("hydradx"), authoring_version: 1, - spec_version: 237, + spec_version: 238, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 46730d4765cba5764dbb9b1b37df8099b9725de3 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Mon, 27 May 2024 13:35:20 +0200 Subject: [PATCH 38/61] bump crate versions --- Cargo.lock | 4 ++-- integration-tests/Cargo.toml | 2 +- runtime/hydradx/Cargo.toml | 2 +- runtime/hydradx/src/lib.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index beb742a3c..a4f628ee6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4671,7 +4671,7 @@ dependencies = [ [[package]] name = "hydradx-runtime" -version = "238.0.0" +version = "239.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -11579,7 +11579,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "1.21.7" +version = "1.21.8" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 21e550ab3..b806761a5 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-integration-tests" -version = "1.21.7" +version = "1.21.8" description = "Integration tests" authors = ["GalacticCouncil"] edition = "2021" diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index b76e23ba8..9efff2d10 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-runtime" -version = "238.0.0" +version = "239.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 898ce3406..04b195645 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -109,7 +109,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("hydradx"), impl_name: create_runtime_str!("hydradx"), authoring_version: 1, - spec_version: 238, + spec_version: 239, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From bebcbde6879d39c97b3a6b02b985704367ef5113 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 28 May 2024 12:46:44 +0200 Subject: [PATCH 39/61] update comments --- pallets/otc-settlements/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index be8e821de..1f34a5ae1 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -237,7 +237,8 @@ impl Pallet { fn ensure_min_profit(otc_amount_in: Balance, _profit: Balance) -> DispatchResult { let _min_expected_profit = T::MinProfitPercentage::get().mul_floor(otc_amount_in); - // In the benchmark we doesn't make any trade, so this check would fail. + // In the benchmark we calculate the overhead of extrinsic and we doesn't make any trade. + // We disable this check because otherwise it would fail. #[cfg(not(feature = "runtime-benchmarks"))] // tell the binary search algorithm to find higher values ensure!(_profit >= _min_expected_profit, Error::::TradeAmountTooLow); @@ -248,8 +249,8 @@ impl Pallet { /// Executes two trades: asset_a -> OTC -> asset_b, and asset_b -> Router -> asset_a. /// /// If the OTC order is partially fillable, the extrinsic fails if the existing arbitrage - /// opportunity is not closed after the trade. - /// If the OTC order is not partially fillable, fails if there is no profit after the trade. + /// opportunity is not closed after the trade and if there is no profit after the trade. + /// If the OTC order is not partially fillable, fails only if there is no profit after the trade. pub fn settle_otc(otc_id: OrderId, amount: Balance, route: Vec>>) -> DispatchResult { let pallet_acc = Self::account_id(); From 52516f733d06cc77a9d21331fd0cbcff50edf608 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 29 May 2024 19:39:39 +0200 Subject: [PATCH 40/61] resolve comments from the review --- pallets/otc-settlements/Cargo.toml | 3 +- pallets/otc-settlements/src/lib.rs | 92 ++++++++++++++++------------ pallets/otc-settlements/src/mock.rs | 2 +- pallets/otc-settlements/src/tests.rs | 35 ++++++++++- runtime/hydradx/src/assets.rs | 2 +- 5 files changed, 87 insertions(+), 47 deletions(-) diff --git a/pallets/otc-settlements/Cargo.toml b/pallets/otc-settlements/Cargo.toml index 8b032794d..4b86c3c7b 100644 --- a/pallets/otc-settlements/Cargo.toml +++ b/pallets/otc-settlements/Cargo.toml @@ -28,8 +28,6 @@ frame-system = { workspace = true } hydradx-traits = { workspace = true } pallet-otc = { workspace = true } -# ORML dependencies -orml-traits = { workspace = true } # Optional imports for benchmarking frame-benchmarking = { workspace = true, optional = true } @@ -42,6 +40,7 @@ pallet-route-executor = { workspace = true } pallet-balances = { workspace = true } pallet-currencies = { workspace = true } sp-api = { workspace = true } +orml-traits = { workspace = true } orml-tokens = { workspace = true, features=["std"] } proptest = "1.0.0" pretty_assertions = "1.2.1" diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 1f34a5ae1..dffac8117 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -15,7 +15,12 @@ #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::{pallet_prelude::*, PalletId}; +use frame_support::{pallet_prelude::*, PalletId, + traits::{ + fungibles::{Inspect, Mutate}, + tokens::{Fortitude, Preservation, Precision}, + }, +}; use frame_system::{ offchain::{SendTransactionTypes, SubmitTransaction}, pallet_prelude::{BlockNumberFor, OriginFor}, @@ -24,7 +29,6 @@ use frame_system::{ use hydradx_traits::router::{ AmmTradeWeights, AmountInAndOut, AssetPair, RouteProvider, RouteSpotPriceProvider, RouterT, Trade, }; -use orml_traits::MultiCurrency; use pallet_otc::weights::WeightInfo as OtcWeightInfo; pub use pallet_otc::OrderId; use sp_arithmetic::{ @@ -57,6 +61,7 @@ use weights::WeightInfo; // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; +use pallet_otc::Order; pub type Balance = u128; pub type NamedReserveIdentifier = [u8; 8]; @@ -75,7 +80,7 @@ pub const LOCK_TIMEOUT_EXPIRATION: u64 = 5_000; // 5 seconds pub const FILL_SEARCH_ITERATIONS: u32 = 40; pub type AssetIdOf = ::AssetId; -type SortedOtcsStorageType = (OrderId, FixedU128, FixedU128, FixedU128); +type SortedOtcsStorageType = OrderId; #[frame_support::pallet] pub mod pallet { @@ -90,7 +95,7 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Named reservable multi currency. - type Currency: MultiCurrency, Balance = Balance>; + type Currency: Mutate, Balance = Balance>; /// Router implementation. type Router: RouteProvider> @@ -186,6 +191,8 @@ pub mod pallet { TradeAmountTooHigh, /// Trade amount lower than necessary TradeAmountTooLow, + /// Price for a route is not available + PriceNotAvailable, } #[pallet::call] @@ -234,15 +241,16 @@ impl Pallet { } /// Ensure that the profit is more than some minimum amount. - fn ensure_min_profit(otc_amount_in: Balance, _profit: Balance) -> DispatchResult { - let _min_expected_profit = T::MinProfitPercentage::get().mul_floor(otc_amount_in); - + fn ensure_min_profit(otc_amount_in: Balance, profit: Balance) -> DispatchResult { // In the benchmark we calculate the overhead of extrinsic and we doesn't make any trade. // We disable this check because otherwise it would fail. - #[cfg(not(feature = "runtime-benchmarks"))] - // tell the binary search algorithm to find higher values - ensure!(_profit >= _min_expected_profit, Error::::TradeAmountTooLow); + if cfg!(feature = "runtime-benchmarks") { + return Ok(()); + } + let min_expected_profit = T::MinProfitPercentage::get().mul_floor(otc_amount_in); + // tell the binary search algorithm to find higher values + ensure!(profit >= min_expected_profit, Error::::TradeAmountTooLow); Ok(()) } @@ -257,12 +265,6 @@ impl Pallet { let otc = >::get(otc_id).ok_or(Error::::OrderNotFound)?; let (asset_a, asset_b) = (otc.asset_in, otc.asset_out); - // get initial account balances - let asset_a_balance_before = ::Currency::free_balance(asset_a, &pallet_acc); - let asset_b_balance_before = ::Currency::free_balance(asset_b, &pallet_acc); - - ::Currency::deposit(asset_a, &pallet_acc, amount)?; - if !otc.partially_fillable { ensure!(otc.amount_out == amount, Error::::NotPartiallyFillable); } @@ -276,6 +278,12 @@ impl Pallet { Error::::InvalidRoute ); + // get initial account balances + let asset_a_balance_before = ::Currency::balance(asset_a, &pallet_acc); + let asset_b_balance_before = ::Currency::balance(asset_b, &pallet_acc); + + ::Currency::mint_into(asset_a, &pallet_acc, amount)?; + // get initial otc and router price let otc_price = FixedU128::checked_from_rational(otc.amount_out, otc.amount_in).ok_or(ArithmeticError::Overflow)?; @@ -295,9 +303,8 @@ impl Pallet { pallet_otc::Pallet::::fill_order(RawOrigin::Signed(pallet_acc.clone()).into(), otc_id)?; }; - let otc_amount_out = ::Currency::free_balance(asset_b, &pallet_acc) - .checked_sub(asset_b_balance_before) - .unwrap(); + let otc_amount_out = + ::Currency::balance(asset_b, &pallet_acc).saturating_sub(asset_b_balance_before); log::debug!( target: "offchain_worker::settle_otc", @@ -320,7 +327,7 @@ impl Pallet { // some other error - we can't handle this one properly. // // Compare OTC and Router price - let router_price_after = T::Router::spot_price_with_fee(&route).unwrap(); + let router_price_after = T::Router::spot_price_with_fee(&route).ok_or(Error::::PriceNotAvailable)?; log::debug!( target: "offchain_worker::settle_otc", "final router price: {:?} otc_price: {:?} ", @@ -347,7 +354,7 @@ impl Pallet { } } - let asset_a_balance_after_router_trade = ::Currency::free_balance(asset_a, &pallet_acc); + let asset_a_balance_after_router_trade = ::Currency::balance(asset_a, &pallet_acc); let profit = asset_a_balance_after_router_trade .checked_sub(amount) @@ -355,12 +362,12 @@ impl Pallet { Self::ensure_min_profit(otc.amount_in, profit)?; - ::Currency::transfer(asset_a, &pallet_acc, &T::ProfitReceiver::get(), profit)?; + ::Currency::transfer(asset_a, &pallet_acc, &T::ProfitReceiver::get(), profit, Preservation::Expendable)?; - ::Currency::withdraw(asset_a, &pallet_acc, amount)?; + ::Currency::burn_from(asset_a, &pallet_acc, amount, Precision::Exact, Fortitude::Force)?; - let asset_a_balance_after = ::Currency::free_balance(asset_a, &pallet_acc); - let asset_b_balance_after = ::Currency::free_balance(asset_b, &pallet_acc); + let asset_a_balance_after = ::Currency::balance(asset_a, &pallet_acc); + let asset_b_balance_after = ::Currency::balance(asset_b, &pallet_acc); ensure!( asset_a_balance_after == asset_a_balance_before, @@ -415,6 +422,8 @@ impl Pallet { let otc_price = FixedU128::checked_from_rational(otc.amount_out, otc.amount_in); let route = T::Router::get_route(AssetPair { + // To get the correct price, we need to switch the assets, otherwise + // the price is inverted and not directly comparable to the OTC price. asset_in: otc.asset_out, asset_out: otc.asset_in, }); @@ -427,10 +436,22 @@ impl Pallet { } } - // sort the list by the price diff + // sort the list by the price diff. OTCs with higher price diff are at the beginning of the list. list.sort_by(|a, b| b.3.partial_cmp(&a.3).unwrap()); - sorted_otcs.set(&list); + // remove OTCs without arbitrage opportunity + list.retain(|&(otc_id, otc_price, router_price_before, _)| { + log::debug!( + target: "offchain_worker::settle_otcs", + "no arb, skipping OTC: {:?}", otc_id); + router_price_before <= otc_price + }); + + // keep just the OTC ids + let sorted_otc_ids: Vec = + list.into_iter().map(|(otc_id, _, _, _)| otc_id).collect(); + + sorted_otcs.set(&sorted_otc_ids); }; } } @@ -447,24 +468,17 @@ impl Pallet { .unwrap_or_default() .unwrap_or_default(); - for (otc_id, otc_price, router_price_before, _price_diff) in sorted_otcs.iter() { + for otc_id in sorted_otcs.iter() { log::debug!( target: "offchain_worker::settle_otcs", "test OTC id {:?} ", otc_id); - if router_price_before > otc_price { - log::debug!( - target: "offchain_worker::settle_otcs", - "no arb, skipping OTC: {:?}", otc_id); - continue; - } - let otc = >::get(otc_id).unwrap(); let route = T::Router::get_route(AssetPair { asset_in: otc.asset_out, asset_out: otc.asset_in, }); - let maybe_amount = Self::try_find_trade_amount(*otc_id, route.clone()); + let maybe_amount = Self::try_find_trade_amount(*otc_id, &otc, &route); if let Some(sell_amt) = maybe_amount { log::debug!( target: "offchain_worker::settle_otcs", @@ -483,9 +497,7 @@ impl Pallet { } /// Try to find the correct amount to close the arbitrage opportunity. - fn try_find_trade_amount(otc_id: OrderId, route: Vec>>) -> Option { - let otc = >::get(otc_id).unwrap(); - + fn try_find_trade_amount(otc_id: OrderId, otc: &Order, route: &[Trade>]) -> Option { // use binary search to determine the correct sell amount let mut sell_amt = otc.amount_in; // start by trying to fill the whole order let mut sell_amt_up = sell_amt; @@ -503,7 +515,7 @@ impl Pallet { log::debug!( target: "offchain_worker::settle_otcs::binary_search", "\nsell_amt: {:?}\nsell_amt_up: {:?}\nsell_amt_down: {:?}", sell_amt, sell_amt_up, sell_amt_down); - match Self::settle_otc_order(RawOrigin::None.into(), otc_id, sell_amt, route.clone()) { + match Self::settle_otc_order(RawOrigin::None.into(), otc_id, sell_amt, route.to_vec()) { Ok(_) => { log::debug!( target: "offchain_worker::settle_otcs", diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index 150dba96d..130691119 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -88,7 +88,7 @@ parameter_type_with_key! { } impl pallet_otc_settlements::Config for Test { - type Currency = Currencies; + type Currency = pallet_currencies::fungibles::FungibleCurrencies; type RuntimeEvent = RuntimeEvent; type Router = Router; type ProfitReceiver = TreasuryAccount; diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 0f45d4197..8bdb8d543 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -23,6 +23,7 @@ use super::*; pub use crate::mock::*; use frame_support::{assert_ok, assert_storage_noop}; use hydradx_traits::Inspect; +use orml_traits::MultiCurrency; pub fn expect_events(e: Vec) { e.into_iter().for_each(frame_system::Pallet::::assert_has_event); @@ -133,9 +134,37 @@ fn otcs_list_storage_should_be_sorted_on_new_block() { assert!(!sorted_list_of_otcs.is_empty()); // the list should be sorted - let mut copy_of_list = sorted_list_of_otcs.clone(); - copy_of_list.sort_by(|a, b| b.3.partial_cmp(&a.3).unwrap()); - assert!(sorted_list_of_otcs == copy_of_list); + // create tuples of adjacent elements + let result = sorted_list_of_otcs + .iter() + .zip(sorted_list_of_otcs.iter().skip(1)) + .collect::>(); + + // for all adjacent tuples (a,b) should be true that price_diff_a >= price_diff_b + for (otc_id_a, otc_id_b) in result.iter() { + // calculate price diff for the first otc id + let otc = >::get(otc_id_a).unwrap(); + let otc_price = FixedU128::checked_from_rational(otc.amount_out, otc.amount_in).unwrap(); + + let route = Router::get_route(AssetPair { + asset_in: otc.asset_out, + asset_out: otc.asset_in, + }); + let router_price = Router::spot_price_with_fee(&route.clone()).unwrap(); + let price_diff_a = otc_price.saturating_sub(router_price); + + // calculate price diff for the second otc id + let otc = >::get(otc_id_b).unwrap(); + let otc_price = FixedU128::checked_from_rational(otc.amount_out, otc.amount_in).unwrap(); + + let route = Router::get_route(AssetPair { + asset_in: otc.asset_out, + asset_out: otc.asset_in, + }); + let router_price = Router::spot_price_with_fee(&route.clone()).unwrap(); + let price_diff_b = otc_price.saturating_sub(router_price); + assert!(price_diff_a >= price_diff_b); + } // place new order and verify that the list is not updated again in the same block assert_ok!(OTC::place_order( diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index a8c4d411c..c98dc3184 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -1107,7 +1107,7 @@ impl pallet_otc::Config for Runtime { } impl pallet_otc_settlements::Config for Runtime { - type Currency = Currencies; + type Currency = FungibleCurrencies; type RuntimeEvent = RuntimeEvent; #[cfg(not(feature = "runtime-benchmarks"))] type Router = Router; From e64930c87256d65a6e40c205c0a5ba600a6d39b7 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 29 May 2024 19:40:18 +0200 Subject: [PATCH 41/61] bump crate version --- Cargo.lock | 2 +- integration-tests/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 929c5d22b..b870fc492 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11579,7 +11579,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "1.21.8" +version = "1.21.9" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index b806761a5..34159a26c 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-integration-tests" -version = "1.21.8" +version = "1.21.9" description = "Integration tests" authors = ["GalacticCouncil"] edition = "2021" From b5254e8e7e8803acae8c806f867665961ad5b844 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 29 May 2024 20:14:42 +0200 Subject: [PATCH 42/61] formatting --- pallets/otc-settlements/src/lib.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index dffac8117..0e4e4cf64 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -15,11 +15,13 @@ #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::{pallet_prelude::*, PalletId, +use frame_support::{ + pallet_prelude::*, traits::{ fungibles::{Inspect, Mutate}, - tokens::{Fortitude, Preservation, Precision}, + tokens::{Fortitude, Precision, Preservation}, }, + PalletId, }; use frame_system::{ offchain::{SendTransactionTypes, SubmitTransaction}, @@ -362,7 +364,13 @@ impl Pallet { Self::ensure_min_profit(otc.amount_in, profit)?; - ::Currency::transfer(asset_a, &pallet_acc, &T::ProfitReceiver::get(), profit, Preservation::Expendable)?; + ::Currency::transfer( + asset_a, + &pallet_acc, + &T::ProfitReceiver::get(), + profit, + Preservation::Expendable, + )?; ::Currency::burn_from(asset_a, &pallet_acc, amount, Precision::Exact, Fortitude::Force)?; @@ -497,7 +505,11 @@ impl Pallet { } /// Try to find the correct amount to close the arbitrage opportunity. - fn try_find_trade_amount(otc_id: OrderId, otc: &Order, route: &[Trade>]) -> Option { + fn try_find_trade_amount( + otc_id: OrderId, + otc: &Order, + route: &[Trade>], + ) -> Option { // use binary search to determine the correct sell amount let mut sell_amt = otc.amount_in; // start by trying to fill the whole order let mut sell_amt_up = sell_amt; From 73d67cc13dc37178f0451158346c37aa0a380089 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 29 May 2024 21:02:42 +0200 Subject: [PATCH 43/61] fix benchmark build --- pallets/otc-settlements/src/benchmarks.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pallets/otc-settlements/src/benchmarks.rs b/pallets/otc-settlements/src/benchmarks.rs index 08fe77863..1bd0202d5 100644 --- a/pallets/otc-settlements/src/benchmarks.rs +++ b/pallets/otc-settlements/src/benchmarks.rs @@ -16,7 +16,7 @@ use super::*; use frame_benchmarking::{account, benchmarks}; use frame_support::assert_ok; use frame_system::RawOrigin; -use orml_traits::MultiCurrency; +use frame_support::traits::fungibles::Mutate; pub const ONE: Balance = 1_000_000_000_000; pub const HDX: u32 = 0; @@ -25,14 +25,14 @@ pub const DAI: u32 = 2; benchmarks! { where_clause { where AssetIdOf: From, - ::Currency: MultiCurrency, + ::Currency: Mutate, Balance = Balance>, T: crate::Config + pallet_otc::Config, } settle_otc_order { let account: T::AccountId = account("acc", 1, 1); - ::Currency::deposit(HDX.into(), &account, 1_000_000_000 * ONE)?; - ::Currency::deposit(DAI.into(), &account, 1_000_000_000 * ONE)?; + ::Currency::mint_into(HDX.into(), &account, 1_000_000_000 * ONE)?; + ::Currency::mint_into(DAI.into(), &account, 1_000_000_000 * ONE)?; assert_ok!( pallet_otc::Pallet::::place_order(RawOrigin::Signed(account).into(), HDX.into(), DAI.into(), 100_000_000 * ONE, 200_000_001 * ONE, true) From 8b166cc156ce947b90a2cd2e082714180b2492f9 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 29 May 2024 22:07:16 +0200 Subject: [PATCH 44/61] rebenchmarking --- pallets/otc-settlements/src/benchmarks.rs | 2 +- pallets/otc-settlements/src/weights.rs | 39 +++++++++---------- .../hydradx/src/weights/otc_settlements.rs | 26 ++++++------- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/pallets/otc-settlements/src/benchmarks.rs b/pallets/otc-settlements/src/benchmarks.rs index 1bd0202d5..bee2f31aa 100644 --- a/pallets/otc-settlements/src/benchmarks.rs +++ b/pallets/otc-settlements/src/benchmarks.rs @@ -15,8 +15,8 @@ use super::*; use frame_benchmarking::{account, benchmarks}; use frame_support::assert_ok; -use frame_system::RawOrigin; use frame_support::traits::fungibles::Mutate; +use frame_system::RawOrigin; pub const ONE: Balance = 1_000_000_000_000; pub const HDX: u32 = 0; diff --git a/pallets/otc-settlements/src/weights.rs b/pallets/otc-settlements/src/weights.rs index 7fcbc989f..a47ace3e6 100644 --- a/pallets/otc-settlements/src/weights.rs +++ b/pallets/otc-settlements/src/weights.rs @@ -18,10 +18,10 @@ //! Autogenerated weights for `pallet_otc_settlements` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-04-16, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-05-29, STEPS: `10`, REPEAT: `30`, 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: `Some("dev")`, DB CACHE: `1024` // Executed Command: // target/release/hydradx @@ -32,11 +32,10 @@ // --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --template=.maintain/pallet-weight-template-no-back.hbs +// --template=.maintain/pallet-weight-template.hbs // --pallet=pallet-otc-settlements -// --output=weights-1.1.0/otc_settlements.rs -// --extrinsic=* -// --extra +// --output=weights/otc-settlements.rs +// --extrinsic= #![allow(unused_parens)] #![allow(unused_imports)] @@ -59,18 +58,18 @@ pub struct HydraWeight(PhantomData); impl 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:1 w:1) + /// Storage: `System::Account` (r:2 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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: `644` - // Estimated: `3593` - // Minimum execution time: 96_068_000 picoseconds. - Weight::from_parts(96_704_000, 3593) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) + // Measured: `747` + // Estimated: `6196` + // Minimum execution time: 122_182_000 picoseconds. + Weight::from_parts(123_996_000, 6196) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -78,17 +77,17 @@ impl WeightInfo for HydraWeight { impl WeightInfo for () { /// 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:1 w:1) + /// Storage: `System::Account` (r:2 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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: `644` - // Estimated: `3593` - // Minimum execution time: 96_068_000 picoseconds. - Weight::from_parts(96_704_000, 3593) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Measured: `747` + // Estimated: `6196` + // Minimum execution time: 122_182_000 picoseconds. + Weight::from_parts(123_996_000, 6196) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/runtime/hydradx/src/weights/otc_settlements.rs b/runtime/hydradx/src/weights/otc_settlements.rs index f1681c343..0a50858f1 100644 --- a/runtime/hydradx/src/weights/otc_settlements.rs +++ b/runtime/hydradx/src/weights/otc_settlements.rs @@ -15,13 +15,14 @@ // See the License for the specific language governing permissions and // limitations under the License. + //! Autogenerated weights for `pallet_otc_settlements` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-04-16, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-05-29, STEPS: `10`, REPEAT: `30`, 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: `Some("dev")`, DB CACHE: `1024` // Executed Command: // target/release/hydradx @@ -32,11 +33,10 @@ // --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --template=.maintain/pallet-weight-template-no-back.hbs +// --template=.maintain/pallet-weight-template.hbs // --pallet=pallet-otc-settlements -// --output=weights-1.1.0/otc_settlements.rs -// --extrinsic=* -// --extra +// --output=weights/otc-settlements.rs +// --extrinsic=a #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -53,17 +53,17 @@ pub struct HydraWeight(PhantomData); impl 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:1 w:1) + /// Storage: `System::Account` (r:2 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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: `644` - // Estimated: `3593` - // Minimum execution time: 96_068_000 picoseconds. - Weight::from_parts(96_704_000, 3593) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) + // Measured: `747` + // Estimated: `6196` + // Minimum execution time: 122_182_000 picoseconds. + Weight::from_parts(123_996_000, 6196) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } From 2b614ba4eac20cd534fc30d347856e159f58c638 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 30 May 2024 00:24:22 +0200 Subject: [PATCH 45/61] bump runtime version --- Cargo.lock | 2 +- runtime/hydradx/Cargo.toml | 2 +- runtime/hydradx/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b870fc492..6c7a1262f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4671,7 +4671,7 @@ dependencies = [ [[package]] name = "hydradx-runtime" -version = "241.0.0" +version = "242.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index eefca7dcd..a818cc8c9 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-runtime" -version = "241.0.0" +version = "242.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 9ce01c912..28addad7e 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -109,7 +109,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("hydradx"), impl_name: create_runtime_str!("hydradx"), authoring_version: 1, - spec_version: 241, + spec_version: 242, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From f89f4c41e28d37d5bfbc74a809b2657e80f64e73 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 14 Jun 2024 14:10:26 +0200 Subject: [PATCH 46/61] subtract the initial balance from the profit --- pallets/otc-settlements/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 0e4e4cf64..94ec89d3e 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -359,7 +359,9 @@ impl Pallet { let asset_a_balance_after_router_trade = ::Currency::balance(asset_a, &pallet_acc); let profit = asset_a_balance_after_router_trade - .checked_sub(amount) + // subtract the initial balance + .checked_sub(asset_a_balance_before) + .and_then(|value| value.checked_sub(amount)) .ok_or(ArithmeticError::Overflow)?; Self::ensure_min_profit(otc.amount_in, profit)?; From 968ffaea072ce30acc72d026e71c707b3ca574c4 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 14 Jun 2024 15:03:33 +0200 Subject: [PATCH 47/61] update test --- pallets/otc-settlements/src/tests.rs | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 8bdb8d543..e7c32cc62 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -189,6 +189,7 @@ fn otcs_list_storage_should_be_sorted_on_new_block() { #[test] fn profit_should_be_transferred_to_treasury() { + // test case with zero initial pallet balance let (mut ext, _) = ExtBuilder::default().build(); ext.execute_with(|| { assert_ok!(OTC::place_order( @@ -200,10 +201,48 @@ fn profit_should_be_transferred_to_treasury() { true, )); + let pallet_acc = OtcSettlements::account_id(); + + assert!(Currencies::free_balance(HDX, &pallet_acc) == 0); + assert!(Currencies::free_balance(DAI, &pallet_acc) == 0); + let balance_before = Currencies::free_balance(HDX, &TreasuryAccount::get()); >>::offchain_worker(System::block_number()); + assert!(Currencies::free_balance(HDX, &pallet_acc) == 0); + assert!(Currencies::free_balance(DAI, &pallet_acc) == 0); + + let balance_after = Currencies::free_balance(HDX, &TreasuryAccount::get()); + assert!(balance_after > balance_before); + }); + + // test case with non-zero initial pallet balance + let (mut ext, _) = ExtBuilder::default().build(); + ext.execute_with(|| { + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, + DAI, + 100_000 * ONE, + 201_000 * ONE, + true, + )); + + let pallet_acc = OtcSettlements::account_id(); + let initial_amount = 1_000 * ONE; + ::Currency::mint_into(HDX, &pallet_acc, initial_amount).unwrap(); + + assert!(Currencies::free_balance(HDX, &pallet_acc) == initial_amount); + assert!(Currencies::free_balance(DAI, &pallet_acc) == 0); + + let balance_before = Currencies::free_balance(HDX, &TreasuryAccount::get()); + + >>::offchain_worker(System::block_number()); + + assert!(Currencies::free_balance(HDX, &pallet_acc) == initial_amount); + assert!(Currencies::free_balance(DAI, &pallet_acc) == 0); + let balance_after = Currencies::free_balance(HDX, &TreasuryAccount::get()); assert!(balance_after > balance_before); }); From dedcd16c38411de3139712e339158d27aacd0240 Mon Sep 17 00:00:00 2001 From: Richard Roznovjak Date: Wed, 19 Jun 2024 08:26:19 -0500 Subject: [PATCH 48/61] Update pallets/otc-settlements/src/lib.rs Co-authored-by: Daniel Moka --- pallets/otc-settlements/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 94ec89d3e..9abc2c9c6 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -328,7 +328,7 @@ impl Pallet { // max trade limit reached - we are interested in this one. We can decrease the amount and try again. // some other error - we can't handle this one properly. - // // Compare OTC and Router price + // Compare OTC and Router price let router_price_after = T::Router::spot_price_with_fee(&route).ok_or(Error::::PriceNotAvailable)?; log::debug!( target: "offchain_worker::settle_otc", From ce1e3b47dce9f5fb4ee23f1a7ab5f3295b92e2eb Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 19 Jun 2024 19:59:26 +0200 Subject: [PATCH 49/61] resolve comments from the review --- pallets/otc-settlements/src/lib.rs | 37 ++++++++++++++++++++++------ pallets/otc-settlements/src/mock.rs | 3 ++- pallets/otc-settlements/src/tests.rs | 7 +++--- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 9abc2c9c6..bc1364e89 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -13,6 +13,24 @@ // See the License for the specific language governing permissions and // limitations under the License. +//! # OTC Settlements pallet +//! +//! ## Description +//! The pallet provides implementation of the offchain worker for closing existing arbitrage opportunities between OTC +//! orders and the Omnipool. +//! Two main parts of this pallet are methods to find the correct amount in order to close an existing arbitrage opportunity +//! and an extrinsic. The extrinsic is mainly called by the offchain worker as unsigned extrinsic, but can be also called +//! by any user using signed origin. In the former case, the block producer doesn't pay the fee. +//! +//! ## Notes +//! If the OTC order is partially fillable, the pallet tries to close the arbitrage opportunity by finding the amount that +//! aligns the OTC and the Omnipool prices. Executing this trade needs to be profitable, but we are not trying to maximize +//! the profit. +//! In the case of not partially fillable OTC orders, the pallet tries to maximize the profit. +//! +//! ## Dispatachable functions +//! * `settle_otc_order` - Executes a trade between an OTC order and some route. + #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{ @@ -251,11 +269,15 @@ impl Pallet { } let min_expected_profit = T::MinProfitPercentage::get().mul_floor(otc_amount_in); - // tell the binary search algorithm to find higher values + // if the next condition is not met, tell the binary search algorithm to find higher values + // by throwing the error. ensure!(profit >= min_expected_profit, Error::::TradeAmountTooLow); Ok(()) } + /// Because asset_in in a OTC order becomes asset_out in a router trade, we name + /// this asset just asset_a to make it less confusing. + /// /// Executes two trades: asset_a -> OTC -> asset_b, and asset_b -> Router -> asset_a. /// /// If the OTC order is partially fillable, the extrinsic fails if the existing arbitrage @@ -286,7 +308,7 @@ impl Pallet { ::Currency::mint_into(asset_a, &pallet_acc, amount)?; - // get initial otc and router price + // get initial otc price let otc_price = FixedU128::checked_from_rational(otc.amount_out, otc.amount_in).ok_or(ArithmeticError::Overflow)?; @@ -322,11 +344,10 @@ impl Pallet { 1, route.clone(), ) - .map_err(|_| Error::::TradeAmountTooHigh)?; - // There are 3 possible types of error: - // min trade limit not reached - we start with the largest possible amount, so we can't increase it more. - // max trade limit reached - we are interested in this one. We can decrease the amount and try again. - // some other error - we can't handle this one properly. + // This can fail for different reason, but because we start with the largest possible amount, + // all we can do is to return `TradeAmountTooHigh` to tell the binary search algorithm to + // try again with smaller amount. + .map_err(|_| Error::::TradeAmountTooHigh)?; // Compare OTC and Router price let router_price_after = T::Router::spot_price_with_fee(&route).ok_or(Error::::PriceNotAvailable)?; @@ -563,7 +584,7 @@ impl Pallet { if sell_amt_down == sell_amt_up { return None; } - sell_amt = (sell_amt_up + sell_amt_down) / 2; + sell_amt = (sell_amt_up.checked_add(sell_amt_down)).and_then(|value| value.checked_div(2))?; } None } diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index 130691119..d319a25fe 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -148,6 +148,7 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; type Nonce = u64; type Block = Block; type Hash = H256; @@ -215,8 +216,8 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = NamedReserveIdentifier; type FreezeIdentifier = (); type MaxFreezes = (); - type MaxHolds = (); type RuntimeHoldReason = (); + type RuntimeFreezeReason = (); } impl pallet_currencies::Config for Test { diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index e7c32cc62..ea7306cbe 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -188,8 +188,7 @@ fn otcs_list_storage_should_be_sorted_on_new_block() { } #[test] -fn profit_should_be_transferred_to_treasury() { - // test case with zero initial pallet balance +fn profit_should_be_transferred_to_treasury_when_zero_initial_pallet_balance() { let (mut ext, _) = ExtBuilder::default().build(); ext.execute_with(|| { assert_ok!(OTC::place_order( @@ -216,8 +215,10 @@ fn profit_should_be_transferred_to_treasury() { let balance_after = Currencies::free_balance(HDX, &TreasuryAccount::get()); assert!(balance_after > balance_before); }); +} - // test case with non-zero initial pallet balance +#[test] +fn profit_should_be_transferred_to_treasury_when_nonzero_initial_pallet_balance() { let (mut ext, _) = ExtBuilder::default().build(); ext.execute_with(|| { assert_ok!(OTC::place_order( From 69e567b7debe0cea45038afc03d801a468ca042a Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 20 Jun 2024 09:50:47 +0200 Subject: [PATCH 50/61] rebenchmark lbp, omnipool, stableswap and xyk --- pallets/lbp/src/weights.rs | 383 ++++++++++-------- pallets/omnipool/src/weights.rs | 133 +++--- pallets/stableswap/src/weights.rs | 98 ++--- pallets/xyk/src/weights.rs | 87 ++-- runtime/hydradx/src/weights/pallet_lbp.rs | 371 ++++++++++------- .../hydradx/src/weights/pallet_omnipool.rs | 112 ++--- .../hydradx/src/weights/pallet_stableswap.rs | 96 ++--- runtime/hydradx/src/weights/pallet_xyk.rs | 86 ++-- 8 files changed, 743 insertions(+), 623 deletions(-) diff --git a/pallets/lbp/src/weights.rs b/pallets/lbp/src/weights.rs index c8e18a39f..c8ed81b95 100644 --- a/pallets/lbp/src/weights.rs +++ b/pallets/lbp/src/weights.rs @@ -15,32 +15,28 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Autogenerated weights for `pallet_lbp` + +//! Autogenerated weights for `pallet_xyk` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-05-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: -// ./target/release/hydradx +// target/release/hydradx // benchmark // pallet +// --chain=dev +// --steps=10 +// --repeat=30 // --wasm-execution=compiled -// --pallet -// * -// --extrinsic -// * -// --heap-pages -// 4096 -// --steps -// 50 -// --repeat -// 20 +// --heap-pages=4096 // --template=scripts/pallet-weight-template.hbs -// --output -// weights/ +// --pallet=pallet-xyk +// --output=weights/xyk.rs +// --extrinsic=* #![allow(unused_parens)] #![allow(unused_imports)] @@ -68,224 +64,283 @@ pub trait WeightInfo { /// Weights for pallet_lbp using the hydraDX node and recommended hardware. impl WeightInfo for () { - /// Storage: `LBP::PoolData` (r:1 w:1) + /// Storage: `AssetRegistry::Assets` (r:3 w:1) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) + /// Storage: `LBP::PoolData` (r:1 w:0) /// 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: `Tokens::Accounts` (r:4 w:4) + /// Storage: `XYK::ShareToken` (r:1 w:1) + /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:7 w:7) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// Storage: `AssetRegistry::AssetIds` (r:1 w:1) + /// Proof: `AssetRegistry::AssetIds` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::NextAssetId` (r:1 w:1) + /// Proof: `AssetRegistry::NextAssetId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:1) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) + /// 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: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) + /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:3 w:0) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:3) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:3 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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: `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: `1311` - // Estimated: `11322` - // Minimum execution time: 131_482_000 picoseconds. - Weight::from_parts(132_832_000, 11322) - .saturating_add(RocksDbWeight::get().reads(15_u64)) - .saturating_add(RocksDbWeight::get().writes(8_u64)) - } - /// Storage: `LBP::PoolData` (r:1 w:1) - /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) - /// Storage: `LBP::FeeCollectorWithAsset` (r:1 w:2) - /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) - fn update_pool_data() -> Weight { - // Proof Size summary in bytes: - // Measured: `417` - // Estimated: `3628` - // Minimum execution time: 24_822_000 picoseconds. - Weight::from_parts(25_218_000, 3628) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) + // Measured: `3655` + // Estimated: `19071` + // Minimum execution time: 478_829_000 picoseconds. + Weight::from_parts(482_189_000, 19071) + .saturating_add(RocksDbWeight::get().reads(33_u64)) + .saturating_add(RocksDbWeight::get().writes(20_u64)) } - /// Storage: `LBP::PoolData` (r:1 w:0) - /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:4 w:4) + /// Storage: `XYK::ShareToken` (r:1 w:0) + /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, 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) + /// Proof: `XYK::TotalLiquidity` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) /// Storage: `Duster::AccountBlacklist` (r:1 w:0) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) + /// 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:2 w:0) + /// 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:1 w:0) + /// 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) + /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`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`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `1572` - // Estimated: `11322` - // Minimum execution time: 99_136_000 picoseconds. - Weight::from_parts(99_953_000, 11322) - .saturating_add(RocksDbWeight::get().reads(11_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) + // Measured: `4291` + // Estimated: `19071` + // Minimum execution time: 295_216_000 picoseconds. + Weight::from_parts(297_013_000, 19071) + .saturating_add(RocksDbWeight::get().reads(27_u64)) + .saturating_add(RocksDbWeight::get().writes(13_u64)) } - /// Storage: `LBP::PoolData` (r:1 w:1) - /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:4 w:4) + /// Storage: `XYK::ShareToken` (r:1 w:1) + /// 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: `Tokens::Accounts` (r:7 w:7) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// Storage: `Duster::AccountBlacklist` (r:2 w:1) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) + /// 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:2 w:0) + /// 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:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:1) + /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:2 w:0) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Locks` (r:1 w:0) - /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) - /// Storage: `LBP::FeeCollectorWithAsset` (r:0 w:1) - /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:3) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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: `EmaOracle::WhitelistedAssets` (r:1 w:0) + /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + /// Storage: `XYK::PoolAssets` (r:0 w:1) + /// Proof: `XYK::PoolAssets` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `1687` - // Estimated: `11322` - // Minimum execution time: 129_681_000 picoseconds. - Weight::from_parts(131_072_000, 11322) - .saturating_add(RocksDbWeight::get().reads(13_u64)) - .saturating_add(RocksDbWeight::get().writes(8_u64)) + // Measured: `4341` + // Estimated: `19071` + // Minimum execution time: 432_017_000 picoseconds. + Weight::from_parts(435_171_000, 19071) + .saturating_add(RocksDbWeight::get().reads(29_u64)) + .saturating_add(RocksDbWeight::get().writes(17_u64)) } - /// Storage: `Tokens::Accounts` (r:5 w:5) + /// Storage: `XYK::ShareToken` (r:1 w:0) + /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// 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:1) - /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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:2 w:0) + /// 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:1) + /// 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) + /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// 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`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `1977` - // Estimated: `13905` - // Minimum execution time: 229_471_000 picoseconds. - Weight::from_parts(231_032_000, 13905) - .saturating_add(RocksDbWeight::get().reads(16_u64)) - .saturating_add(RocksDbWeight::get().writes(7_u64)) + // Measured: `4190` + // Estimated: `16488` + // Minimum execution time: 259_720_000 picoseconds. + Weight::from_parts(262_022_000, 16488) + .saturating_add(RocksDbWeight::get().reads(24_u64)) + .saturating_add(RocksDbWeight::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: `Tokens::Accounts` (r:5 w:5) + /// Storage: `XYK::ShareToken` (r:1 w:0) + /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Locks` (r:1 w:1) - /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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:2 w:0) + /// 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:1) + /// 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) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `1977` - // Estimated: `13905` - // Minimum execution time: 230_204_000 picoseconds. - Weight::from_parts(231_446_000, 13905) - .saturating_add(RocksDbWeight::get().reads(16_u64)) - .saturating_add(RocksDbWeight::get().writes(7_u64)) + // Measured: `4190` + // Estimated: `16488` + // Minimum execution time: 258_233_000 picoseconds. + Weight::from_parts(260_534_000, 16488) + .saturating_add(RocksDbWeight::get().reads(24_u64)) + .saturating_add(RocksDbWeight::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: `Tokens::Accounts` (r:5 w:5) + /// Storage: `XYK::ShareToken` (r:1 w:0) + /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Locks` (r:1 w:1) - /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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:2 w:0) + /// 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:1) + /// 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) + /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// 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`) /// 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: `822 + e * (1155 ±0)` - // Estimated: `8799 + e * (7749 ±0)` - // Minimum execution time: 86_477_000 picoseconds. - Weight::from_parts(87_284_000, 8799) - // Standard Error: 227_219 - .saturating_add(Weight::from_parts(978_707, 0).saturating_mul(c.into())) - // Standard Error: 506_080 - .saturating_add(Weight::from_parts(145_385_809, 0).saturating_mul(e.into())) + // Measured: `1221 + e * (2969 ±0)` + // Estimated: `6156 + e * (10332 ±118_379_753_737_997_488)` + // Minimum execution time: 24_323_000 picoseconds. + Weight::from_parts(10_607_591, 6156) + // Standard Error: 167_239 + .saturating_add(Weight::from_parts(7_205_082, 0).saturating_mul(c.into())) + // Standard Error: 167_239 + .saturating_add(Weight::from_parts(243_290_509, 0).saturating_mul(e.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().reads((13_u64).saturating_mul(e.into()))) - .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 7749).saturating_mul(e.into())) + .saturating_add(RocksDbWeight::get().reads((21_u64).saturating_mul(e.into()))) + .saturating_add(RocksDbWeight::get().writes((10_u64).saturating_mul(e.into()))) + .saturating_add(Weight::from_parts(0, 10332).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: `Tokens::Accounts` (r:5 w:5) + /// Storage: `XYK::ShareToken` (r:1 w:0) + /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Locks` (r:1 w:1) - /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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:2 w:0) + /// 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:1) + /// 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) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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`) /// 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 { + fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `822 + e * (1155 ±0)` - // Estimated: `6156 + e * (8544 ±4_363_391_150_632_390)` - // Minimum execution time: 157_384_000 picoseconds. - Weight::from_parts(158_861_000, 6156) - // Standard Error: 426_842 - .saturating_add(Weight::from_parts(2_861_447, 0).saturating_mul(c.into())) - // Standard Error: 1_439_449 - .saturating_add(Weight::from_parts(107_641_350, 0).saturating_mul(e.into())) + // Measured: `1221 + e * (2969 ±0)` + // Estimated: `6156 + e * (10332 ±0)` + // Minimum execution time: 31_926_000 picoseconds. + Weight::from_parts(8_222_348, 6156) + // Standard Error: 100_411 + .saturating_add(Weight::from_parts(8_150_950, 0).saturating_mul(c.into())) + // Standard Error: 170_358 + .saturating_add(Weight::from_parts(243_286_593, 0).saturating_mul(e.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().reads((13_u64).saturating_mul(e.into()))) - .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 8544).saturating_mul(e.into())) + .saturating_add(RocksDbWeight::get().reads((21_u64).saturating_mul(e.into()))) + .saturating_add(RocksDbWeight::get().writes((10_u64).saturating_mul(e.into()))) + .saturating_add(Weight::from_parts(0, 10332).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: `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: `789` - // Estimated: `6156` - // Minimum execution time: 67_298_000 picoseconds. - Weight::from_parts(68_051_000, 6156).saturating_add(RocksDbWeight::get().reads(3)) - } - /// Storage: `LBP::PoolData` (r:1 w:0) - /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:2 w:0) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Locks` (r:1 w:0) - /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: - // Measured: `789` + // Measured: `1021` // Estimated: `6156` - // Minimum execution time: 33_145_000 picoseconds. - Weight::from_parts(33_774_000, 6156).saturating_add(RocksDbWeight::get().reads(4)) + // Minimum execution time: 19_174_000 picoseconds. + Weight::from_parts(19_702_000, 6156) + .saturating_add(RocksDbWeight::get().reads(2_u64)) } } diff --git a/pallets/omnipool/src/weights.rs b/pallets/omnipool/src/weights.rs index bc5fe18e1..b0d260287 100644 --- a/pallets/omnipool/src/weights.rs +++ b/pallets/omnipool/src/weights.rs @@ -15,32 +15,28 @@ // See the License for the specific language governing permissions and // limitations under the License. + //! Autogenerated weights for `pallet_omnipool` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-05-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: -// ./target/release/hydradx +// target/release/hydradx // benchmark // pallet +// --chain=dev +// --steps=10 +// --repeat=30 // --wasm-execution=compiled -// --pallet -// * -// --extrinsic -// * -// --heap-pages -// 4096 -// --steps -// 50 -// --repeat -// 20 +// --heap-pages=4096 // --template=scripts/pallet-weight-template.hbs -// --output -// weights/ +// --pallet=pallet-omnipool +// --output=weights/omnipool.rs +// --extrinsic=* #![allow(unused_parens)] #![allow(unused_imports)] @@ -100,10 +96,10 @@ impl WeightInfo for () { /// Proof: `Omnipool::Positions` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) fn add_token() -> Weight { // Proof Size summary in bytes: - // Measured: `3132` + // Measured: `3128` // Estimated: `7406` - // Minimum execution time: 129_176_000 picoseconds. - Weight::from_parts(130_298_000, 7406) + // Minimum execution time: 129_557_000 picoseconds. + Weight::from_parts(130_648_000, 7406) .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().writes(10_u64)) } @@ -149,10 +145,10 @@ impl WeightInfo for () { /// Proof: `Omnipool::Positions` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `4348` + // Measured: `4344` // Estimated: `8739` - // Minimum execution time: 204_599_000 picoseconds. - Weight::from_parts(205_728_000, 8739) + // Minimum execution time: 212_794_000 picoseconds. + Weight::from_parts(214_077_000, 8739) .saturating_add(RocksDbWeight::get().reads(23_u64)) .saturating_add(RocksDbWeight::get().writes(14_u64)) } @@ -200,10 +196,10 @@ impl WeightInfo for () { /// Proof: `Uniques::ItemPriceOf` (`max_values`: None, `max_size`: Some(113), added: 2588, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `7259` + // Measured: `7255` // Estimated: `11322` - // Minimum execution time: 275_044_000 picoseconds. - Weight::from_parts(276_562_000, 11322) + // Minimum execution time: 283_260_000 picoseconds. + Weight::from_parts(285_188_000, 11322) .saturating_add(RocksDbWeight::get().reads(26_u64)) .saturating_add(RocksDbWeight::get().writes(16_u64)) } @@ -257,10 +253,10 @@ impl WeightInfo for () { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `7619` + // Measured: `7615` // Estimated: `13905` - // Minimum execution time: 327_772_000 picoseconds. - Weight::from_parts(329_562_000, 13905) + // Minimum execution time: 326_103_000 picoseconds. + Weight::from_parts(327_911_000, 13905) .saturating_add(RocksDbWeight::get().reads(41_u64)) .saturating_add(RocksDbWeight::get().writes(23_u64)) } @@ -314,10 +310,10 @@ impl WeightInfo for () { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `7619` + // Measured: `7615` // Estimated: `13905` - // Minimum execution time: 327_371_000 picoseconds. - Weight::from_parts(328_952_000, 13905) + // Minimum execution time: 328_543_000 picoseconds. + Weight::from_parts(330_455_000, 13905) .saturating_add(RocksDbWeight::get().reads(41_u64)) .saturating_add(RocksDbWeight::get().writes(23_u64)) } @@ -325,10 +321,10 @@ impl WeightInfo for () { /// 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: `1309` + // Measured: `1305` // Estimated: `3550` - // Minimum execution time: 27_719_000 picoseconds. - Weight::from_parts(28_329_000, 3550) + // Minimum execution time: 28_191_000 picoseconds. + Weight::from_parts(28_788_000, 3550) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -350,10 +346,10 @@ impl WeightInfo for () { /// 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: `2646` + // Measured: `2642` // Estimated: `6196` - // Minimum execution time: 99_820_000 picoseconds. - Weight::from_parts(100_687_000, 6196) + // Minimum execution time: 99_781_000 picoseconds. + Weight::from_parts(101_151_000, 6196) .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -371,10 +367,10 @@ impl WeightInfo for () { /// Proof: `Uniques::ItemPriceOf` (`max_values`: None, `max_size`: Some(113), added: 2588, mode: `MaxEncodedLen`) fn sacrifice_position() -> Weight { // Proof Size summary in bytes: - // Measured: `2914` + // Measured: `2910` // Estimated: `3655` - // Minimum execution time: 66_207_000 picoseconds. - Weight::from_parts(66_955_000, 3655) + // Minimum execution time: 67_106_000 picoseconds. + Weight::from_parts(67_630_000, 3655) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -382,10 +378,10 @@ impl WeightInfo for () { /// 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: `1309` + // Measured: `1305` // Estimated: `3550` - // Minimum execution time: 28_043_000 picoseconds. - Weight::from_parts(28_560_000, 3550) + // Minimum execution time: 28_644_000 picoseconds. + Weight::from_parts(29_012_000, 3550) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -413,10 +409,10 @@ impl WeightInfo for () { /// 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: `4341` + // Measured: `4337` // Estimated: `8739` - // Minimum execution time: 146_266_000 picoseconds. - Weight::from_parts(147_681_000, 8739) + // Minimum execution time: 146_511_000 picoseconds. + Weight::from_parts(147_743_000, 8739) .saturating_add(RocksDbWeight::get().reads(15_u64)) .saturating_add(RocksDbWeight::get().writes(8_u64)) } @@ -442,10 +438,10 @@ impl WeightInfo for () { /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) fn remove_token() -> Weight { // Proof Size summary in bytes: - // Measured: `3432` + // Measured: `3428` // Estimated: `11322` - // Minimum execution time: 145_092_000 picoseconds. - Weight::from_parts(146_152_000, 11322) + // Minimum execution time: 145_853_000 picoseconds. + Weight::from_parts(147_060_000, 11322) .saturating_add(RocksDbWeight::get().reads(16_u64)) .saturating_add(RocksDbWeight::get().writes(8_u64)) } @@ -495,18 +491,18 @@ impl WeightInfo for () { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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: `1978 + e * (5140 ±0)` - // Estimated: `11390 + e * (7749 ±0)` - // Minimum execution time: 44_566_000 picoseconds. - Weight::from_parts(46_051_604, 11390) - // Standard Error: 113_379 - .saturating_add(Weight::from_parts(283_478_583, 0).saturating_mul(e.into())) + // Measured: `1974 + e * (5140 ±0)` + // Estimated: `6156 + e * (8517 ±251_795_645_551_580_832)` + // Minimum execution time: 44_661_000 picoseconds. + Weight::from_parts(46_229_971, 6156) + // Standard Error: 148_969 + .saturating_add(Weight::from_parts(285_100_297, 0).saturating_mul(e.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((31_u64).saturating_mul(e.into()))) .saturating_add(RocksDbWeight::get().writes((21_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 7749).saturating_mul(e.into())) + .saturating_add(Weight::from_parts(0, 8517).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`) @@ -554,18 +550,18 @@ impl WeightInfo for () { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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 { + fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `7047` + // Measured: `7114` // Estimated: `13905` - // Minimum execution time: 367_889_000 picoseconds. - Weight::from_parts(355_257_176, 13905) - // Standard Error: 169_485 - .saturating_add(Weight::from_parts(15_912_492, 0).saturating_mul(c.into())) - // Standard Error: 169_485 - .saturating_add(Weight::from_parts(1_094_838, 0).saturating_mul(e.into())) - .saturating_add(RocksDbWeight::get().reads(38)) - .saturating_add(RocksDbWeight::get().writes(21)) + // Minimum execution time: 315_214_000 picoseconds. + Weight::from_parts(296_879_705, 13905) + // Standard Error: 261_774 + .saturating_add(Weight::from_parts(18_029_452, 0).saturating_mul(c.into())) + // Standard Error: 261_774 + .saturating_add(Weight::from_parts(2_977_423, 0).saturating_mul(e.into())) + .saturating_add(RocksDbWeight::get().reads(38_u64)) + .saturating_add(RocksDbWeight::get().writes(21_u64)) } /// Storage: `DynamicFees::AssetFee` (r:2 w:0) /// Proof: `DynamicFees::AssetFee` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) @@ -577,7 +573,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1933` // Estimated: `6156` - // Minimum execution time: 47_828_000 picoseconds. - Weight::from_parts(48_456_000, 6156).saturating_add(RocksDbWeight::get().reads(6)) + // Minimum execution time: 43_389_000 picoseconds. + Weight::from_parts(43_919_000, 6156) + .saturating_add(RocksDbWeight::get().reads(6_u64)) } } diff --git a/pallets/stableswap/src/weights.rs b/pallets/stableswap/src/weights.rs index 66e095082..3f26d89a8 100644 --- a/pallets/stableswap/src/weights.rs +++ b/pallets/stableswap/src/weights.rs @@ -15,25 +15,28 @@ // See the License for the specific language governing permissions and // limitations under the License. + //! Autogenerated weights for `pallet_stableswap` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-05-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: -// ./target/release/hydradx +// target/release/hydradx // benchmark // pallet +// --chain=dev +// --steps=10 +// --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --template=.maintain/pallet-weight-template-no-back.hbs +// --template=scripts/pallet-weight-template.hbs // --pallet=pallet-stableswap -// --output=weights-1.1.0/stableswap.rs +// --output=weights/stableswap.rs // --extrinsic=* -// --extra #![allow(unused_parens)] #![allow(unused_imports)] @@ -74,8 +77,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `855` // Estimated: `16590` - // Minimum execution time: 42_284_000 picoseconds. - Weight::from_parts(42_906_000, 16590) + // Minimum execution time: 42_163_000 picoseconds. + Weight::from_parts(42_971_000, 16590) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -105,8 +108,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3471` // Estimated: `29403` - // Minimum execution time: 1_342_534_000 picoseconds. - Weight::from_parts(1_346_186_000, 29403) + // Minimum execution time: 1_327_528_000 picoseconds. + Weight::from_parts(1_331_117_000, 29403) .saturating_add(RocksDbWeight::get().reads(35_u64)) .saturating_add(RocksDbWeight::get().writes(14_u64)) } @@ -136,8 +139,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3339` // Estimated: `19071` - // Minimum execution time: 896_494_000 picoseconds. - Weight::from_parts(900_100_000, 19071) + // Minimum execution time: 896_585_000 picoseconds. + Weight::from_parts(900_938_000, 19071) .saturating_add(RocksDbWeight::get().reads(23_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -167,8 +170,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3363` // Estimated: `19071` - // Minimum execution time: 921_757_000 picoseconds. - Weight::from_parts(924_632_000, 19071) + // Minimum execution time: 925_710_000 picoseconds. + Weight::from_parts(928_674_000, 19071) .saturating_add(RocksDbWeight::get().reads(22_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -198,8 +201,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3363` // Estimated: `19071` - // Minimum execution time: 1_266_805_000 picoseconds. - Weight::from_parts(1_272_407_000, 19071) + // Minimum execution time: 1_412_294_000 picoseconds. + Weight::from_parts(1_416_948_000, 19071) .saturating_add(RocksDbWeight::get().reads(23_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -229,8 +232,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3426` // Estimated: `19071` - // Minimum execution time: 863_718_000 picoseconds. - Weight::from_parts(866_668_000, 19071) + // Minimum execution time: 862_103_000 picoseconds. + Weight::from_parts(867_533_000, 19071) .saturating_add(RocksDbWeight::get().reads(25_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -260,8 +263,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3396` // Estimated: `19071` - // Minimum execution time: 846_241_000 picoseconds. - Weight::from_parts(850_907_000, 19071) + // Minimum execution time: 844_279_000 picoseconds. + Weight::from_parts(848_664_000, 19071) .saturating_add(RocksDbWeight::get().reads(26_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -273,8 +276,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 20_725_000 picoseconds. - Weight::from_parts(21_012_000, 3522) + // Minimum execution time: 21_172_000 picoseconds. + Weight::from_parts(21_538_000, 3522) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -284,8 +287,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 18_190_000 picoseconds. - Weight::from_parts(18_524_000, 3522) + // Minimum execution time: 18_710_000 picoseconds. + Weight::from_parts(19_155_000, 3522) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -295,8 +298,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 19_133_000 picoseconds. - Weight::from_parts(19_315_000, 3522) + // Minimum execution time: 19_403_000 picoseconds. + Weight::from_parts(19_822_000, 3522) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -324,20 +327,18 @@ impl WeightInfo for () { /// 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 * (1805 ±0)` - // Estimated: `13990 + e * (5166 ±0)` - // Minimum execution time: 376_396_000 picoseconds. - Weight::from_parts(353_453_826, 13990) - // Standard Error: 838_992 - .saturating_add(Weight::from_parts(12_974_831, 0).saturating_mul(c.into())) - // Standard Error: 838_992 - .saturating_add(Weight::from_parts(852_434_060, 0).saturating_mul(e.into())) + // Estimated: `13990 + e * (5797 ±201_913_854_157_949_888)` + // Minimum execution time: 371_777_000 picoseconds. + Weight::from_parts(384_499_218, 13990) + // Standard Error: 722_175 + .saturating_add(Weight::from_parts(831_895_585, 0).saturating_mul(e.into())) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().reads((14_u64).saturating_mul(e.into()))) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 5166).saturating_mul(e.into())) + .saturating_add(Weight::from_parts(0, 5797).saturating_mul(e.into())) } /// Storage: `Stableswap::Pools` (r:1 w:0) /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) @@ -363,20 +364,20 @@ impl WeightInfo for () { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, 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 { + fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1620 + e * (1776 ±0)` - // Estimated: `13990 + e * (5166 ±0)` - // Minimum execution time: 375_050_000 picoseconds. - Weight::from_parts(376_366_000, 13990) - // Standard Error: 1_073_561 - .saturating_add(Weight::from_parts(3_994_783, 0).saturating_mul(c.into())) - // Standard Error: 2_391_123 - .saturating_add(Weight::from_parts(488_537_240, 0).saturating_mul(e.into())) + // Estimated: `13990 + e * (5797 ±213_489_293_787_578_112)` + // Minimum execution time: 371_923_000 picoseconds. + Weight::from_parts(373_003_000, 13990) + // Standard Error: 3_999_909 + .saturating_add(Weight::from_parts(15_028_502, 0).saturating_mul(c.into())) + // Standard Error: 8_780_942 + .saturating_add(Weight::from_parts(520_802_190, 0).saturating_mul(e.into())) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().reads((15_u64).saturating_mul(e.into()))) .saturating_add(RocksDbWeight::get().writes((6_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 5166).saturating_mul(e.into())) + .saturating_add(Weight::from_parts(0, 5797).saturating_mul(e.into())) } /// Storage: `Stableswap::Pools` (r:1 w:0) /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) @@ -384,11 +385,14 @@ impl WeightInfo for () { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::Assets` (r:5 w:0) /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:0) + /// 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: `1587` + // Measured: `1827` // Estimated: `13990` - // Minimum execution time: 263_924_000 picoseconds. - Weight::from_parts(264_905_000, 13990).saturating_add(RocksDbWeight::get().reads(11)) + // Minimum execution time: 308_105_000 picoseconds. + Weight::from_parts(309_400_000, 13990) + .saturating_add(RocksDbWeight::get().reads(12_u64)) } } diff --git a/pallets/xyk/src/weights.rs b/pallets/xyk/src/weights.rs index 9e2a9ba13..72ffce87b 100644 --- a/pallets/xyk/src/weights.rs +++ b/pallets/xyk/src/weights.rs @@ -15,16 +15,17 @@ // See the License for the specific language governing permissions and // limitations under the License. + //! Autogenerated weights for `pallet_xyk` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-05-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: -// ./target/release/hydradx +// target/release/hydradx // benchmark // pallet // --chain=dev @@ -32,11 +33,10 @@ // --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --template=.maintain/pallet-weight-template-no-back.hbs +// --template=scripts/pallet-weight-template.hbs // --pallet=pallet-xyk -// --output=weights-1.1.0/xyk.rs +// --output=weights/xyk.rs // --extrinsic=* -// --extra #![allow(unused_parens)] #![allow(unused_imports)] @@ -100,10 +100,10 @@ impl WeightInfo for () { /// Proof: `XYK::PoolAssets` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) fn create_pool() -> Weight { // Proof Size summary in bytes: - // Measured: `3659` + // Measured: `3655` // Estimated: `19071` - // Minimum execution time: 479_166_000 picoseconds. - Weight::from_parts(482_391_000, 19071) + // Minimum execution time: 478_829_000 picoseconds. + Weight::from_parts(482_189_000, 19071) .saturating_add(RocksDbWeight::get().reads(33_u64)) .saturating_add(RocksDbWeight::get().writes(20_u64)) } @@ -137,10 +137,10 @@ impl WeightInfo for () { /// 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: `4295` + // Measured: `4291` // Estimated: `19071` - // Minimum execution time: 295_185_000 picoseconds. - Weight::from_parts(297_223_000, 19071) + // Minimum execution time: 295_216_000 picoseconds. + Weight::from_parts(297_013_000, 19071) .saturating_add(RocksDbWeight::get().reads(27_u64)) .saturating_add(RocksDbWeight::get().writes(13_u64)) } @@ -176,10 +176,10 @@ impl WeightInfo for () { /// Proof: `XYK::PoolAssets` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `4345` + // Measured: `4341` // Estimated: `19071` - // Minimum execution time: 431_770_000 picoseconds. - Weight::from_parts(434_368_000, 19071) + // Minimum execution time: 432_017_000 picoseconds. + Weight::from_parts(435_171_000, 19071) .saturating_add(RocksDbWeight::get().reads(29_u64)) .saturating_add(RocksDbWeight::get().writes(17_u64)) } @@ -209,10 +209,10 @@ impl WeightInfo for () { /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `4194` + // Measured: `4190` // Estimated: `16488` - // Minimum execution time: 257_210_000 picoseconds. - Weight::from_parts(259_165_000, 16488) + // Minimum execution time: 259_720_000 picoseconds. + Weight::from_parts(262_022_000, 16488) .saturating_add(RocksDbWeight::get().reads(24_u64)) .saturating_add(RocksDbWeight::get().writes(10_u64)) } @@ -242,10 +242,10 @@ impl WeightInfo for () { /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `4194` + // Measured: `4190` // Estimated: `16488` - // Minimum execution time: 256_649_000 picoseconds. - Weight::from_parts(257_410_000, 16488) + // Minimum execution time: 258_233_000 picoseconds. + Weight::from_parts(260_534_000, 16488) .saturating_add(RocksDbWeight::get().reads(24_u64)) .saturating_add(RocksDbWeight::get().writes(10_u64)) } @@ -275,16 +275,16 @@ impl WeightInfo for () { /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, 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: `1221 + e * (2973 ±0)` - // Estimated: `8799 + e * (10332 ±0)` - // Minimum execution time: 24_501_000 picoseconds. - Weight::from_parts(10_206_077, 8799) - // Standard Error: 76_653 - .saturating_add(Weight::from_parts(7_446_454, 0).saturating_mul(c.into())) - // Standard Error: 76_653 - .saturating_add(Weight::from_parts(241_285_864, 0).saturating_mul(e.into())) + // Measured: `1221 + e * (2969 ±0)` + // Estimated: `6156 + e * (10332 ±118_379_753_737_997_488)` + // Minimum execution time: 24_323_000 picoseconds. + Weight::from_parts(10_607_591, 6156) + // Standard Error: 167_239 + .saturating_add(Weight::from_parts(7_205_082, 0).saturating_mul(c.into())) + // Standard Error: 167_239 + .saturating_add(Weight::from_parts(243_290_509, 0).saturating_mul(e.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().reads((21_u64).saturating_mul(e.into()))) .saturating_add(RocksDbWeight::get().writes((10_u64).saturating_mul(e.into()))) @@ -316,30 +316,29 @@ impl WeightInfo for () { /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, 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 { + fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1187 + e * (2970 ±0)` + // Measured: `1221 + e * (2969 ±0)` // Estimated: `6156 + e * (10332 ±0)` - // Minimum execution time: 34_243_000 picoseconds. - Weight::from_parts(9_537_362, 6156) - // Standard Error: 44_250 - .saturating_add(Weight::from_parts(8_444_305, 0).saturating_mul(c.into())) - // Standard Error: 75_076 - .saturating_add(Weight::from_parts(289_395_556, 0).saturating_mul(e.into())) - .saturating_add(RocksDbWeight::get().reads(3)) + // Minimum execution time: 31_926_000 picoseconds. + Weight::from_parts(8_222_348, 6156) + // Standard Error: 100_411 + .saturating_add(Weight::from_parts(8_150_950, 0).saturating_mul(c.into())) + // Standard Error: 170_358 + .saturating_add(Weight::from_parts(243_286_593, 0).saturating_mul(e.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().reads((21_u64).saturating_mul(e.into()))) .saturating_add(RocksDbWeight::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: `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: `1187` + // Measured: `1021` // Estimated: `6156` - // Minimum execution time: 26_159_000 picoseconds. - Weight::from_parts(26_805_702, 6156).saturating_add(RocksDbWeight::get().reads(3)) + // Minimum execution time: 19_174_000 picoseconds. + Weight::from_parts(19_702_000, 6156) + .saturating_add(RocksDbWeight::get().reads(2_u64)) } } diff --git a/runtime/hydradx/src/weights/pallet_lbp.rs b/runtime/hydradx/src/weights/pallet_lbp.rs index 5fdc2973c..110f5111e 100644 --- a/runtime/hydradx/src/weights/pallet_lbp.rs +++ b/runtime/hydradx/src/weights/pallet_lbp.rs @@ -16,25 +16,27 @@ // limitations under the License. -//! Autogenerated weights for `pallet_lbp` +//! Autogenerated weights for `pallet_xyk` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-05-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: -// ./target/release/hydradx +// target/release/hydradx // benchmark // pallet +// --chain=dev +// --steps=10 +// --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --template=.maintain/pallet-weight-template-no-back.hbs -// --pallet=pallet-lbp -// --output=weights-1.1.0/lbp.rs +// --template=scripts/pallet-weight-template.hbs +// --pallet=pallet-xyk +// --output=weights/xyk.rs // --extrinsic=* -// --extra #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -50,226 +52,283 @@ pub struct WeightInfo(PhantomData); /// Weights for `pallet_lbp` using the HydraDX node and recommended hardware. pub struct HydraWeight(PhantomData); impl pallet_lbp::WeightInfo for HydraWeight { - /// Storage: `LBP::PoolData` (r:1 w:1) + /// Storage: `AssetRegistry::Assets` (r:3 w:1) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) + /// Storage: `LBP::PoolData` (r:1 w:0) /// 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: `Tokens::Accounts` (r:4 w:4) + /// Storage: `XYK::ShareToken` (r:1 w:1) + /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:7 w:7) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// Storage: `AssetRegistry::AssetIds` (r:1 w:1) + /// Proof: `AssetRegistry::AssetIds` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::NextAssetId` (r:1 w:1) + /// Proof: `AssetRegistry::NextAssetId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Duster::AccountBlacklist` (r:1 w:1) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) + /// 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: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) + /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:3 w:0) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:3) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:3 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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: `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: `1311` - // Estimated: `11322` - // Minimum execution time: 131_482_000 picoseconds. - Weight::from_parts(132_832_000, 11322) - .saturating_add(T::DbWeight::get().reads(15_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) - } - /// Storage: `LBP::PoolData` (r:1 w:1) - /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) - /// Storage: `LBP::FeeCollectorWithAsset` (r:1 w:2) - /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) - fn update_pool_data() -> Weight { - // Proof Size summary in bytes: - // Measured: `417` - // Estimated: `3628` - // Minimum execution time: 24_822_000 picoseconds. - Weight::from_parts(25_218_000, 3628) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `3655` + // Estimated: `19071` + // Minimum execution time: 478_829_000 picoseconds. + Weight::from_parts(482_189_000, 19071) + .saturating_add(T::DbWeight::get().reads(33_u64)) + .saturating_add(T::DbWeight::get().writes(20_u64)) } - /// Storage: `LBP::PoolData` (r:1 w:0) - /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:4 w:4) + /// Storage: `XYK::ShareToken` (r:1 w:0) + /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, 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) + /// Proof: `XYK::TotalLiquidity` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) /// Storage: `Duster::AccountBlacklist` (r:1 w:0) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) + /// 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:2 w:0) + /// 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:1 w:0) + /// 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) + /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`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`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `1572` - // Estimated: `11322` - // Minimum execution time: 99_136_000 picoseconds. - Weight::from_parts(99_953_000, 11322) - .saturating_add(T::DbWeight::get().reads(11_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Measured: `4291` + // Estimated: `19071` + // Minimum execution time: 295_216_000 picoseconds. + Weight::from_parts(297_013_000, 19071) + .saturating_add(T::DbWeight::get().reads(27_u64)) + .saturating_add(T::DbWeight::get().writes(13_u64)) } - /// Storage: `LBP::PoolData` (r:1 w:1) - /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:4 w:4) + /// Storage: `XYK::ShareToken` (r:1 w:1) + /// 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: `Tokens::Accounts` (r:7 w:7) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Duster::AccountBlacklist` (r:1 w:0) + /// Storage: `Duster::AccountBlacklist` (r:2 w:1) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) + /// 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:2 w:0) + /// 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:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:1) + /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:2 w:0) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Locks` (r:1 w:0) - /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) - /// Storage: `LBP::FeeCollectorWithAsset` (r:0 w:1) - /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:3) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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: `EmaOracle::WhitelistedAssets` (r:1 w:0) + /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + /// Storage: `XYK::PoolAssets` (r:0 w:1) + /// Proof: `XYK::PoolAssets` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `1687` - // Estimated: `11322` - // Minimum execution time: 129_681_000 picoseconds. - Weight::from_parts(131_072_000, 11322) - .saturating_add(T::DbWeight::get().reads(13_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) + // Measured: `4341` + // Estimated: `19071` + // Minimum execution time: 432_017_000 picoseconds. + Weight::from_parts(435_171_000, 19071) + .saturating_add(T::DbWeight::get().reads(29_u64)) + .saturating_add(T::DbWeight::get().writes(17_u64)) } - /// Storage: `Tokens::Accounts` (r:5 w:5) + /// Storage: `XYK::ShareToken` (r:1 w:0) + /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// 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:1) - /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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:2 w:0) + /// 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:1) + /// 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) + /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// 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`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `1977` - // Estimated: `13905` - // Minimum execution time: 229_471_000 picoseconds. - Weight::from_parts(231_032_000, 13905) - .saturating_add(T::DbWeight::get().reads(16_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + // Measured: `4190` + // Estimated: `16488` + // Minimum execution time: 259_720_000 picoseconds. + Weight::from_parts(262_022_000, 16488) + .saturating_add(T::DbWeight::get().reads(24_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: `Tokens::Accounts` (r:5 w:5) + /// Storage: `XYK::ShareToken` (r:1 w:0) + /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Locks` (r:1 w:1) - /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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:2 w:0) + /// 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:1) + /// 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) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `1977` - // Estimated: `13905` - // Minimum execution time: 230_204_000 picoseconds. - Weight::from_parts(231_446_000, 13905) - .saturating_add(T::DbWeight::get().reads(16_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + // Measured: `4190` + // Estimated: `16488` + // Minimum execution time: 258_233_000 picoseconds. + Weight::from_parts(260_534_000, 16488) + .saturating_add(T::DbWeight::get().reads(24_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: `Tokens::Accounts` (r:5 w:5) + /// Storage: `XYK::ShareToken` (r:1 w:0) + /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Locks` (r:1 w:1) - /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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:2 w:0) + /// 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:1) + /// 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) + /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) + /// 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`) /// 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 * (1155 ±0)` - // Estimated: `8799 + e * (7749 ±0)` - // Minimum execution time: 86_477_000 picoseconds. - Weight::from_parts(87_284_000, 8799) - // Standard Error: 227_219 - .saturating_add(Weight::from_parts(978_707, 0).saturating_mul(c.into())) - // Standard Error: 506_080 - .saturating_add(Weight::from_parts(145_385_809, 0).saturating_mul(e.into())) + // Measured: `1221 + e * (2969 ±0)` + // Estimated: `6156 + e * (10332 ±118_379_753_737_997_488)` + // Minimum execution time: 24_323_000 picoseconds. + Weight::from_parts(10_607_591, 6156) + // Standard Error: 167_239 + .saturating_add(Weight::from_parts(7_205_082, 0).saturating_mul(c.into())) + // Standard Error: 167_239 + .saturating_add(Weight::from_parts(243_290_509, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(3_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())) + .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: `LBP::PoolData` (r:1 w:0) - /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:5 w:5) + /// Storage: `XYK::ShareToken` (r:1 w:0) + /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:6 w:6) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Locks` (r:1 w:1) - /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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) + /// 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:2 w:0) + /// 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:1) + /// 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) + /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) + /// 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`) /// 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 * (1155 ±0)` - // Estimated: `6156 + e * (8544 ±4_363_391_150_632_390)` - // Minimum execution time: 157_384_000 picoseconds. - Weight::from_parts(158_861_000, 6156) - // Standard Error: 426_842 - .saturating_add(Weight::from_parts(2_861_447, 0).saturating_mul(c.into())) - // Standard Error: 1_439_449 - .saturating_add(Weight::from_parts(107_641_350, 0).saturating_mul(e.into())) + // Measured: `1221 + e * (2969 ±0)` + // Estimated: `6156 + e * (10332 ±0)` + // Minimum execution time: 31_926_000 picoseconds. + Weight::from_parts(8_222_348, 6156) + // Standard Error: 100_411 + .saturating_add(Weight::from_parts(8_150_950, 0).saturating_mul(c.into())) + // Standard Error: 170_358 + .saturating_add(Weight::from_parts(243_286_593, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(3_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())) + .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: `LBP::PoolData` (r:1 w:0) - /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, 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: `789` - // Estimated: `6156` - // Minimum execution time: 67_298_000 picoseconds. - Weight::from_parts(68_051_000, 6156) - .saturating_add(T::DbWeight::get().reads(3)) - } - /// Storage: `LBP::PoolData` (r:1 w:0) - /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:2 w:0) - /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Locks` (r:1 w:0) - /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: - // Measured: `789` + // Measured: `1021` // Estimated: `6156` - // Minimum execution time: 33_145_000 picoseconds. - Weight::from_parts(33_774_000, 6156) - .saturating_add(T::DbWeight::get().reads(4)) + // Minimum execution time: 19_174_000 picoseconds. + Weight::from_parts(19_702_000, 6156) + .saturating_add(T::DbWeight::get().reads(2_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 a912dac43..25742e267 100644 --- a/runtime/hydradx/src/weights/pallet_omnipool.rs +++ b/runtime/hydradx/src/weights/pallet_omnipool.rs @@ -19,22 +19,24 @@ //! Autogenerated weights for `pallet_omnipool` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-05-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: -// ./target/release/hydradx +// target/release/hydradx // benchmark // pallet +// --chain=dev +// --steps=10 +// --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --template=.maintain/pallet-weight-template-no-back.hbs +// --template=scripts/pallet-weight-template.hbs // --pallet=pallet-omnipool -// --output=weights-1.1.0/omnipool.rs +// --output=weights/omnipool.rs // --extrinsic=* -// --extra #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -78,10 +80,10 @@ 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: `3132` + // Measured: `3128` // Estimated: `7406` - // Minimum execution time: 129_176_000 picoseconds. - Weight::from_parts(130_298_000, 7406) + // Minimum execution time: 129_557_000 picoseconds. + Weight::from_parts(130_648_000, 7406) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } @@ -127,10 +129,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: `4348` + // Measured: `4344` // Estimated: `8739` - // Minimum execution time: 204_599_000 picoseconds. - Weight::from_parts(205_728_000, 8739) + // Minimum execution time: 212_794_000 picoseconds. + Weight::from_parts(214_077_000, 8739) .saturating_add(T::DbWeight::get().reads(23_u64)) .saturating_add(T::DbWeight::get().writes(14_u64)) } @@ -178,10 +180,10 @@ 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: `7259` + // Measured: `7255` // Estimated: `11322` - // Minimum execution time: 275_044_000 picoseconds. - Weight::from_parts(276_562_000, 11322) + // Minimum execution time: 283_260_000 picoseconds. + Weight::from_parts(285_188_000, 11322) .saturating_add(T::DbWeight::get().reads(26_u64)) .saturating_add(T::DbWeight::get().writes(16_u64)) } @@ -235,10 +237,10 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `7619` + // Measured: `7615` // Estimated: `13905` - // Minimum execution time: 327_772_000 picoseconds. - Weight::from_parts(329_562_000, 13905) + // Minimum execution time: 326_103_000 picoseconds. + Weight::from_parts(327_911_000, 13905) .saturating_add(T::DbWeight::get().reads(41_u64)) .saturating_add(T::DbWeight::get().writes(23_u64)) } @@ -292,10 +294,10 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `7619` + // Measured: `7615` // Estimated: `13905` - // Minimum execution time: 327_371_000 picoseconds. - Weight::from_parts(328_952_000, 13905) + // Minimum execution time: 328_543_000 picoseconds. + Weight::from_parts(330_455_000, 13905) .saturating_add(T::DbWeight::get().reads(41_u64)) .saturating_add(T::DbWeight::get().writes(23_u64)) } @@ -303,10 +305,10 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// 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: `1309` + // Measured: `1305` // Estimated: `3550` - // Minimum execution time: 27_719_000 picoseconds. - Weight::from_parts(28_329_000, 3550) + // Minimum execution time: 28_191_000 picoseconds. + Weight::from_parts(28_788_000, 3550) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -328,10 +330,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: `2646` + // Measured: `2642` // Estimated: `6196` - // Minimum execution time: 99_820_000 picoseconds. - Weight::from_parts(100_687_000, 6196) + // Minimum execution time: 99_781_000 picoseconds. + Weight::from_parts(101_151_000, 6196) .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -349,10 +351,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: `2914` + // Measured: `2910` // Estimated: `3655` - // Minimum execution time: 66_207_000 picoseconds. - Weight::from_parts(66_955_000, 3655) + // Minimum execution time: 67_106_000 picoseconds. + Weight::from_parts(67_630_000, 3655) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -360,10 +362,10 @@ 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: `1309` + // Measured: `1305` // Estimated: `3550` - // Minimum execution time: 28_043_000 picoseconds. - Weight::from_parts(28_560_000, 3550) + // Minimum execution time: 28_644_000 picoseconds. + Weight::from_parts(29_012_000, 3550) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -391,10 +393,10 @@ 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: `4341` + // Measured: `4337` // Estimated: `8739` - // Minimum execution time: 146_266_000 picoseconds. - Weight::from_parts(147_681_000, 8739) + // Minimum execution time: 146_511_000 picoseconds. + Weight::from_parts(147_743_000, 8739) .saturating_add(T::DbWeight::get().reads(15_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } @@ -420,10 +422,10 @@ 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: `3432` + // Measured: `3428` // Estimated: `11322` - // Minimum execution time: 145_092_000 picoseconds. - Weight::from_parts(146_152_000, 11322) + // Minimum execution time: 145_853_000 picoseconds. + Weight::from_parts(147_060_000, 11322) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } @@ -473,14 +475,14 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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: `1978 + e * (5140 ±0)` - // Estimated: `11390 + e * (7749 ±0)` - // Minimum execution time: 44_566_000 picoseconds. - Weight::from_parts(46_051_604, 11390) - // Standard Error: 113_379 - .saturating_add(Weight::from_parts(283_478_583, 0).saturating_mul(e.into())) + // Measured: `1974 + e * (5140 ±0)` + // Estimated: `6156 + e * (8517 ±251_795_645_551_580_832)` + // Minimum execution time: 44_661_000 picoseconds. + Weight::from_parts(46_229_971, 6156) + // Standard Error: 148_969 + .saturating_add(Weight::from_parts(285_100_297, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((31_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((21_u64).saturating_mul(e.into()))) @@ -534,12 +536,14 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// The range of component `e` is `[0, 1]`. fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `7118` + // Measured: `7114` // Estimated: `13905` - // Minimum execution time: 312_903_000 picoseconds. - Weight::from_parts(305_669_455, 13905) - // Standard Error: 152_808 - .saturating_add(Weight::from_parts(12_462_813, 0).saturating_mul(c.into())) + // Minimum execution time: 315_214_000 picoseconds. + Weight::from_parts(296_879_705, 13905) + // Standard Error: 261_774 + .saturating_add(Weight::from_parts(18_029_452, 0).saturating_mul(c.into())) + // Standard Error: 261_774 + .saturating_add(Weight::from_parts(2_977_423, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(38_u64)) .saturating_add(T::DbWeight::get().writes(21_u64)) } @@ -553,8 +557,8 @@ impl pallet_omnipool::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `1933` // Estimated: `6156` - // Minimum execution time: 47_828_000 picoseconds. - Weight::from_parts(48_456_000, 6156) - .saturating_add(T::DbWeight::get().reads(6)) + // Minimum execution time: 43_389_000 picoseconds. + Weight::from_parts(43_919_000, 6156) + .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 f2c7077c1..9cbf2532a 100644 --- a/runtime/hydradx/src/weights/pallet_stableswap.rs +++ b/runtime/hydradx/src/weights/pallet_stableswap.rs @@ -19,22 +19,24 @@ //! Autogenerated weights for `pallet_stableswap` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-05-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: -// ./target/release/hydradx +// target/release/hydradx // benchmark // pallet +// --chain=dev +// --steps=10 +// --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --template=.maintain/pallet-weight-template-no-back.hbs +// --template=scripts/pallet-weight-template.hbs // --pallet=pallet-stableswap -// --output=weights-1.1.0/stableswap.rs +// --output=weights/stableswap.rs // --extrinsic=* -// --extra #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -60,8 +62,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `855` // Estimated: `16590` - // Minimum execution time: 42_284_000 picoseconds. - Weight::from_parts(42_906_000, 16590) + // Minimum execution time: 42_163_000 picoseconds. + Weight::from_parts(42_971_000, 16590) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -91,8 +93,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `3471` // Estimated: `29403` - // Minimum execution time: 1_342_534_000 picoseconds. - Weight::from_parts(1_346_186_000, 29403) + // Minimum execution time: 1_327_528_000 picoseconds. + Weight::from_parts(1_331_117_000, 29403) .saturating_add(T::DbWeight::get().reads(35_u64)) .saturating_add(T::DbWeight::get().writes(14_u64)) } @@ -122,8 +124,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `3339` // Estimated: `19071` - // Minimum execution time: 896_494_000 picoseconds. - Weight::from_parts(900_100_000, 19071) + // Minimum execution time: 896_585_000 picoseconds. + Weight::from_parts(900_938_000, 19071) .saturating_add(T::DbWeight::get().reads(23_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -153,8 +155,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `3363` // Estimated: `19071` - // Minimum execution time: 921_757_000 picoseconds. - Weight::from_parts(924_632_000, 19071) + // Minimum execution time: 925_710_000 picoseconds. + Weight::from_parts(928_674_000, 19071) .saturating_add(T::DbWeight::get().reads(22_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -184,8 +186,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `3363` // Estimated: `19071` - // Minimum execution time: 1_266_805_000 picoseconds. - Weight::from_parts(1_272_407_000, 19071) + // Minimum execution time: 1_412_294_000 picoseconds. + Weight::from_parts(1_416_948_000, 19071) .saturating_add(T::DbWeight::get().reads(23_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -215,8 +217,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `3426` // Estimated: `19071` - // Minimum execution time: 863_718_000 picoseconds. - Weight::from_parts(866_668_000, 19071) + // Minimum execution time: 862_103_000 picoseconds. + Weight::from_parts(867_533_000, 19071) .saturating_add(T::DbWeight::get().reads(25_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -246,8 +248,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `3396` // Estimated: `19071` - // Minimum execution time: 846_241_000 picoseconds. - Weight::from_parts(850_907_000, 19071) + // Minimum execution time: 844_279_000 picoseconds. + Weight::from_parts(848_664_000, 19071) .saturating_add(T::DbWeight::get().reads(26_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -259,8 +261,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 20_725_000 picoseconds. - Weight::from_parts(21_012_000, 3522) + // Minimum execution time: 21_172_000 picoseconds. + Weight::from_parts(21_538_000, 3522) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -270,8 +272,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 18_190_000 picoseconds. - Weight::from_parts(18_524_000, 3522) + // Minimum execution time: 18_710_000 picoseconds. + Weight::from_parts(19_155_000, 3522) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -281,8 +283,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 19_133_000 picoseconds. - Weight::from_parts(19_315_000, 3522) + // Minimum execution time: 19_403_000 picoseconds. + Weight::from_parts(19_822_000, 3522) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -310,20 +312,18 @@ impl pallet_stableswap::WeightInfo for HydraWeight { /// 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 * (1805 ±0)` - // Estimated: `13990 + e * (5166 ±0)` - // Minimum execution time: 376_396_000 picoseconds. - Weight::from_parts(353_453_826, 13990) - // Standard Error: 838_992 - .saturating_add(Weight::from_parts(12_974_831, 0).saturating_mul(c.into())) - // Standard Error: 838_992 - .saturating_add(Weight::from_parts(852_434_060, 0).saturating_mul(e.into())) + // Estimated: `13990 + e * (5797 ±201_913_854_157_949_888)` + // Minimum execution time: 371_777_000 picoseconds. + Weight::from_parts(384_499_218, 13990) + // Standard Error: 722_175 + .saturating_add(Weight::from_parts(831_895_585, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().reads((14_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())) + .saturating_add(Weight::from_parts(0, 5797).saturating_mul(e.into())) } /// Storage: `Stableswap::Pools` (r:1 w:0) /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) @@ -352,17 +352,17 @@ impl pallet_stableswap::WeightInfo for HydraWeight { fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1620 + e * (1776 ±0)` - // Estimated: `13990 + e * (5166 ±0)` - // Minimum execution time: 375_050_000 picoseconds. - Weight::from_parts(376_366_000, 13990) - // Standard Error: 1_073_561 - .saturating_add(Weight::from_parts(3_994_783, 0).saturating_mul(c.into())) - // Standard Error: 2_391_123 - .saturating_add(Weight::from_parts(488_537_240, 0).saturating_mul(e.into())) + // Estimated: `13990 + e * (5797 ±213_489_293_787_578_112)` + // Minimum execution time: 371_923_000 picoseconds. + Weight::from_parts(373_003_000, 13990) + // Standard Error: 3_999_909 + .saturating_add(Weight::from_parts(15_028_502, 0).saturating_mul(c.into())) + // Standard Error: 8_780_942 + .saturating_add(Weight::from_parts(520_802_190, 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().writes((6_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 5166).saturating_mul(e.into())) + .saturating_add(Weight::from_parts(0, 5797).saturating_mul(e.into())) } /// Storage: `Stableswap::Pools` (r:1 w:0) /// Proof: `Stableswap::Pools` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`) @@ -370,12 +370,14 @@ impl pallet_stableswap::WeightInfo for HydraWeight { /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::Assets` (r:5 w:0) /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:0) + /// 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: `1587` + // Measured: `1827` // Estimated: `13990` - // Minimum execution time: 263_924_000 picoseconds. - Weight::from_parts(264_905_000, 13990) - .saturating_add(T::DbWeight::get().reads(11)) + // Minimum execution time: 308_105_000 picoseconds. + Weight::from_parts(309_400_000, 13990) + .saturating_add(T::DbWeight::get().reads(12_u64)) } } diff --git a/runtime/hydradx/src/weights/pallet_xyk.rs b/runtime/hydradx/src/weights/pallet_xyk.rs index 7953b90d1..37f325e36 100644 --- a/runtime/hydradx/src/weights/pallet_xyk.rs +++ b/runtime/hydradx/src/weights/pallet_xyk.rs @@ -19,22 +19,24 @@ //! Autogenerated weights for `pallet_xyk` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-05-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: -// ./target/release/hydradx +// target/release/hydradx // benchmark // pallet +// --chain=dev +// --steps=10 +// --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --template=.maintain/pallet-weight-template-no-back.hbs +// --template=scripts/pallet-weight-template.hbs // --pallet=pallet-xyk -// --output=weights-1.1.0/xyk.rs +// --output=weights/xyk.rs // --extrinsic=* -// --extra #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -88,10 +90,10 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `XYK::PoolAssets` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) fn create_pool() -> Weight { // Proof Size summary in bytes: - // Measured: `3659` + // Measured: `3655` // Estimated: `19071` - // Minimum execution time: 479_166_000 picoseconds. - Weight::from_parts(482_391_000, 19071) + // Minimum execution time: 478_829_000 picoseconds. + Weight::from_parts(482_189_000, 19071) .saturating_add(T::DbWeight::get().reads(33_u64)) .saturating_add(T::DbWeight::get().writes(20_u64)) } @@ -125,10 +127,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: `4295` + // Measured: `4291` // Estimated: `19071` - // Minimum execution time: 295_185_000 picoseconds. - Weight::from_parts(297_223_000, 19071) + // Minimum execution time: 295_216_000 picoseconds. + Weight::from_parts(297_013_000, 19071) .saturating_add(T::DbWeight::get().reads(27_u64)) .saturating_add(T::DbWeight::get().writes(13_u64)) } @@ -164,10 +166,10 @@ 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: `4345` + // Measured: `4341` // Estimated: `19071` - // Minimum execution time: 431_770_000 picoseconds. - Weight::from_parts(434_368_000, 19071) + // Minimum execution time: 432_017_000 picoseconds. + Weight::from_parts(435_171_000, 19071) .saturating_add(T::DbWeight::get().reads(29_u64)) .saturating_add(T::DbWeight::get().writes(17_u64)) } @@ -197,10 +199,10 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `4194` + // Measured: `4190` // Estimated: `16488` - // Minimum execution time: 257_210_000 picoseconds. - Weight::from_parts(259_165_000, 16488) + // Minimum execution time: 259_720_000 picoseconds. + Weight::from_parts(262_022_000, 16488) .saturating_add(T::DbWeight::get().reads(24_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } @@ -230,10 +232,10 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `4194` + // Measured: `4190` // Estimated: `16488` - // Minimum execution time: 256_649_000 picoseconds. - Weight::from_parts(257_410_000, 16488) + // Minimum execution time: 258_233_000 picoseconds. + Weight::from_parts(260_534_000, 16488) .saturating_add(T::DbWeight::get().reads(24_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } @@ -265,14 +267,14 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// 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 * (2973 ±0)` - // Estimated: `8799 + e * (10332 ±0)` - // Minimum execution time: 24_501_000 picoseconds. - Weight::from_parts(10_206_077, 8799) - // Standard Error: 76_653 - .saturating_add(Weight::from_parts(7_446_454, 0).saturating_mul(c.into())) - // Standard Error: 76_653 - .saturating_add(Weight::from_parts(241_285_864, 0).saturating_mul(e.into())) + // Measured: `1221 + e * (2969 ±0)` + // Estimated: `6156 + e * (10332 ±118_379_753_737_997_488)` + // Minimum execution time: 24_323_000 picoseconds. + Weight::from_parts(10_607_591, 6156) + // Standard Error: 167_239 + .saturating_add(Weight::from_parts(7_205_082, 0).saturating_mul(c.into())) + // Standard Error: 167_239 + .saturating_add(Weight::from_parts(243_290_509, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(3_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()))) @@ -306,29 +308,27 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// 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 * (2973 ±0)` - // Estimated: `6156 + e * (10332 ±94_653_459_118_620)` - // Minimum execution time: 31_769_000 picoseconds. - Weight::from_parts(9_820_195, 6156) - // Standard Error: 25_963 - .saturating_add(Weight::from_parts(7_544_497, 0).saturating_mul(c.into())) - // Standard Error: 43_217 - .saturating_add(Weight::from_parts(239_839_406, 0).saturating_mul(e.into())) + // Measured: `1221 + e * (2969 ±0)` + // Estimated: `6156 + e * (10332 ±0)` + // Minimum execution time: 31_926_000 picoseconds. + Weight::from_parts(8_222_348, 6156) + // Standard Error: 100_411 + .saturating_add(Weight::from_parts(8_150_950, 0).saturating_mul(c.into())) + // Standard Error: 170_358 + .saturating_add(Weight::from_parts(243_286_593, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(3_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: `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: `1187` + // Measured: `1021` // Estimated: `6156` - // Minimum execution time: 26_159_000 picoseconds. - Weight::from_parts(26_805_702, 6156) - .saturating_add(T::DbWeight::get().reads(3)) + // Minimum execution time: 19_174_000 picoseconds. + Weight::from_parts(19_702_000, 6156) + .saturating_add(T::DbWeight::get().reads(2_u64)) } } From 04e23f41f675f768db8905672c24afec26734218 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 20 Jun 2024 10:00:25 +0200 Subject: [PATCH 51/61] fix lbp weights --- pallets/lbp/src/weights.rs | 365 +++++++++------------- runtime/hydradx/src/weights/pallet_lbp.rs | 359 +++++++++------------ 2 files changed, 305 insertions(+), 419 deletions(-) diff --git a/pallets/lbp/src/weights.rs b/pallets/lbp/src/weights.rs index c8ed81b95..2b348a876 100644 --- a/pallets/lbp/src/weights.rs +++ b/pallets/lbp/src/weights.rs @@ -16,7 +16,7 @@ // limitations under the License. -//! Autogenerated weights for `pallet_xyk` +//! Autogenerated weights for `pallet_lbp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 //! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` @@ -34,9 +34,9 @@ // --wasm-execution=compiled // --heap-pages=4096 // --template=scripts/pallet-weight-template.hbs -// --pallet=pallet-xyk -// --output=weights/xyk.rs -// --extrinsic=* +// --pallet=pallet-lbp +// --output=weights/lbp.rs +// --extrinsic=** #![allow(unused_parens)] #![allow(unused_imports)] @@ -64,283 +64,226 @@ pub trait WeightInfo { /// Weights for pallet_lbp using the hydraDX node and recommended hardware. impl WeightInfo for () { - /// Storage: `AssetRegistry::Assets` (r:3 w:1) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) - /// Storage: `LBP::PoolData` (r:1 w:0) + /// Storage: `LBP::PoolData` (r:1 w:1) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) - /// Storage: `XYK::ShareToken` (r:1 w:1) - /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:7 w:7) + /// Storage: `LBP::FeeCollectorWithAsset` (r:1 w:1) + /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetIds` (r:1 w:1) - /// Proof: `AssetRegistry::AssetIds` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::NextAssetId` (r:1 w:1) - /// Proof: `AssetRegistry::NextAssetId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Duster::AccountBlacklist` (r:1 w:1) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::BannedAssets` (r:4 w:0) + /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:3 w:0) - /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) - /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:3 w:3) + /// 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::AcceptedCurrencies` (r:3 w:0) + /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:1) + /// 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: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// 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: `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: `3655` - // Estimated: `19071` - // Minimum execution time: 478_829_000 picoseconds. - Weight::from_parts(482_189_000, 19071) - .saturating_add(RocksDbWeight::get().reads(33_u64)) - .saturating_add(RocksDbWeight::get().writes(20_u64)) + // Measured: `1311` + // Estimated: `11322` + // Minimum execution time: 133_964_000 picoseconds. + Weight::from_parts(135_186_000, 11322) + .saturating_add(T::DbWeight::get().reads(15_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) } - /// Storage: `XYK::ShareToken` (r:1 w:0) - /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:7 w:7) + /// Storage: `LBP::PoolData` (r:1 w:1) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `LBP::FeeCollectorWithAsset` (r:1 w:2) + /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) + fn update_pool_data() -> Weight { + // Proof Size summary in bytes: + // Measured: `417` + // Estimated: `3628` + // Minimum execution time: 25_043_000 picoseconds. + Weight::from_parts(25_363_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: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `XYK::TotalLiquidity` (r:1 w:1) - /// Proof: `XYK::TotalLiquidity` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) /// Storage: `Duster::AccountBlacklist` (r:1 w:0) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::BannedAssets` (r:4 w:0) + /// 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) + /// 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:2) + /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) - /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) - /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `Tokens::TotalIssuance` (r:1 w:1) - /// Proof: `Tokens::TotalIssuance` (`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`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `4291` - // Estimated: `19071` - // Minimum execution time: 295_216_000 picoseconds. - Weight::from_parts(297_013_000, 19071) - .saturating_add(RocksDbWeight::get().reads(27_u64)) - .saturating_add(RocksDbWeight::get().writes(13_u64)) + // Measured: `1572` + // Estimated: `11322` + // Minimum execution time: 100_522_000 picoseconds. + Weight::from_parts(101_333_000, 11322) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - /// Storage: `XYK::ShareToken` (r:1 w:1) - /// 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: `Tokens::Accounts` (r:7 w:7) + /// Storage: `LBP::PoolData` (r:1 w:1) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Duster::AccountBlacklist` (r:2 w:1) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::BannedAssets` (r:3 w:0) + /// 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) + /// Storage: `AssetRegistry::Assets` (r:2 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) - /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:3 w:3) + /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// 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: `EmaOracle::WhitelistedAssets` (r:1 w:0) - /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) - /// Storage: `XYK::PoolAssets` (r:0 w:1) - /// Proof: `XYK::PoolAssets` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:1) + /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Locks` (r:1 w:0) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) + /// Storage: `LBP::FeeCollectorWithAsset` (r:0 w:1) + /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `4341` - // Estimated: `19071` - // Minimum execution time: 432_017_000 picoseconds. - Weight::from_parts(435_171_000, 19071) - .saturating_add(RocksDbWeight::get().reads(29_u64)) - .saturating_add(RocksDbWeight::get().writes(17_u64)) + // Measured: `1687` + // Estimated: `11322` + // Minimum execution time: 131_548_000 picoseconds. + Weight::from_parts(132_825_000, 11322) + .saturating_add(T::DbWeight::get().reads(13_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) } - /// Storage: `XYK::ShareToken` (r:1 w:0) - /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:6 w:6) + /// 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) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Locks` (r:1 w:1) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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:3 w:0) + /// 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:3 w:0) + /// 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:2) + /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) - /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) - /// 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`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `4190` - // Estimated: `16488` - // Minimum execution time: 259_720_000 picoseconds. - Weight::from_parts(262_022_000, 16488) - .saturating_add(RocksDbWeight::get().reads(24_u64)) - .saturating_add(RocksDbWeight::get().writes(10_u64)) + // Measured: `1977` + // Estimated: `13905` + // Minimum execution time: 233_172_000 picoseconds. + Weight::from_parts(234_278_000, 13905) + .saturating_add(T::DbWeight::get().reads(16_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } - /// Storage: `XYK::ShareToken` (r:1 w:0) - /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:6 w:6) + /// Storage: `LBP::PoolData` (r:1 w:0) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, 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) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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:3 w:0) + /// 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:3 w:0) + /// Storage: `AssetRegistry::Assets` (r:2 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) - /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:3 w:2) + /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// 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`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `4190` - // Estimated: `16488` - // Minimum execution time: 258_233_000 picoseconds. - Weight::from_parts(260_534_000, 16488) - .saturating_add(RocksDbWeight::get().reads(24_u64)) - .saturating_add(RocksDbWeight::get().writes(10_u64)) + // Measured: `1977` + // Estimated: `13905` + // Minimum execution time: 232_521_000 picoseconds. + Weight::from_parts(233_949_000, 13905) + .saturating_add(T::DbWeight::get().reads(16_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } - /// Storage: `XYK::ShareToken` (r:1 w:0) - /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:6 w:6) + /// Storage: `LBP::PoolData` (r:1 w:0) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, 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) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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:3 w:0) + /// 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:3 w:0) + /// 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:2) + /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) - /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) - /// 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`) /// 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 * (2969 ±0)` - // Estimated: `6156 + e * (10332 ±118_379_753_737_997_488)` - // Minimum execution time: 24_323_000 picoseconds. - Weight::from_parts(10_607_591, 6156) - // Standard Error: 167_239 - .saturating_add(Weight::from_parts(7_205_082, 0).saturating_mul(c.into())) - // Standard Error: 167_239 - .saturating_add(Weight::from_parts(243_290_509, 0).saturating_mul(e.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().reads((21_u64).saturating_mul(e.into()))) - .saturating_add(RocksDbWeight::get().writes((10_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 10332).saturating_mul(e.into())) + // Measured: `822 + e * (1155 ±0)` + // Estimated: `6156 + e * (7749 ±251_795_645_551_580_832)` + // Minimum execution time: 86_818_000 picoseconds. + Weight::from_parts(88_179_000, 6156) + // Standard Error: 904_459 + .saturating_add(Weight::from_parts(3_650_240, 0).saturating_mul(c.into())) + // Standard Error: 1_985_547 + .saturating_add(Weight::from_parts(154_967_721, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(3_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: `XYK::ShareToken` (r:1 w:0) - /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:6 w:6) + /// Storage: `LBP::PoolData` (r:1 w:0) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, 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) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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:3 w:0) + /// 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:3 w:0) + /// Storage: `AssetRegistry::Assets` (r:2 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) - /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:3 w:2) + /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// 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`) /// 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 * (2969 ±0)` - // Estimated: `6156 + e * (10332 ±0)` - // Minimum execution time: 31_926_000 picoseconds. - Weight::from_parts(8_222_348, 6156) - // Standard Error: 100_411 - .saturating_add(Weight::from_parts(8_150_950, 0).saturating_mul(c.into())) - // Standard Error: 170_358 - .saturating_add(Weight::from_parts(243_286_593, 0).saturating_mul(e.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().reads((21_u64).saturating_mul(e.into()))) - .saturating_add(RocksDbWeight::get().writes((10_u64).saturating_mul(e.into()))) - .saturating_add(Weight::from_parts(0, 10332).saturating_mul(e.into())) + // Measured: `822 + e * (1155 ±0)` + // Estimated: `6156 + e * (7749 ±0)` + // Minimum execution time: 163_430_000 picoseconds. + Weight::from_parts(164_981_000, 6156) + // Standard Error: 1_122_507 + .saturating_add(Weight::from_parts(5_914_893, 0).saturating_mul(c.into())) + // Standard Error: 3_706_588 + .saturating_add(Weight::from_parts(112_896_249, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(3_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: `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_403_000 picoseconds. + Weight::from_parts(90_543_000, 6156) + .saturating_add(T::DbWeight::get().reads(3_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: `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` + // Measured: `822` // Estimated: `6156` - // Minimum execution time: 19_174_000 picoseconds. - Weight::from_parts(19_702_000, 6156) - .saturating_add(RocksDbWeight::get().reads(2_u64)) + // Minimum execution time: 24_307_000 picoseconds. + Weight::from_parts(24_702_000, 6156) + .saturating_add(T::DbWeight::get().reads(4_u64)) } } diff --git a/runtime/hydradx/src/weights/pallet_lbp.rs b/runtime/hydradx/src/weights/pallet_lbp.rs index 110f5111e..1b53799ca 100644 --- a/runtime/hydradx/src/weights/pallet_lbp.rs +++ b/runtime/hydradx/src/weights/pallet_lbp.rs @@ -16,7 +16,7 @@ // limitations under the License. -//! Autogenerated weights for `pallet_xyk` +//! Autogenerated weights for `pallet_lbp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 //! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` @@ -34,8 +34,8 @@ // --wasm-execution=compiled // --heap-pages=4096 // --template=scripts/pallet-weight-template.hbs -// --pallet=pallet-xyk -// --output=weights/xyk.rs +// --pallet=pallet-lbp +// --output=weights/lbp.rs // --extrinsic=* #![cfg_attr(rustfmt, rustfmt_skip)] @@ -52,283 +52,226 @@ pub struct WeightInfo(PhantomData); /// Weights for `pallet_lbp` using the HydraDX node and recommended hardware. pub struct HydraWeight(PhantomData); impl pallet_lbp::WeightInfo for HydraWeight { - /// Storage: `AssetRegistry::Assets` (r:3 w:1) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) - /// Storage: `LBP::PoolData` (r:1 w:0) + /// Storage: `LBP::PoolData` (r:1 w:1) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) - /// Storage: `XYK::ShareToken` (r:1 w:1) - /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:7 w:7) + /// Storage: `LBP::FeeCollectorWithAsset` (r:1 w:1) + /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::AssetIds` (r:1 w:1) - /// Proof: `AssetRegistry::AssetIds` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::NextAssetId` (r:1 w:1) - /// Proof: `AssetRegistry::NextAssetId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Duster::AccountBlacklist` (r:1 w:1) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::BannedAssets` (r:4 w:0) + /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:3 w:0) - /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) - /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:3 w:3) + /// 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::AcceptedCurrencies` (r:3 w:0) + /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:1) + /// 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: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// 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: `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: `3655` - // Estimated: `19071` - // Minimum execution time: 478_829_000 picoseconds. - Weight::from_parts(482_189_000, 19071) - .saturating_add(T::DbWeight::get().reads(33_u64)) - .saturating_add(T::DbWeight::get().writes(20_u64)) + // Measured: `1311` + // Estimated: `11322` + // Minimum execution time: 133_964_000 picoseconds. + Weight::from_parts(135_186_000, 11322) + .saturating_add(T::DbWeight::get().reads(15_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) + } + /// Storage: `LBP::PoolData` (r:1 w:1) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `LBP::FeeCollectorWithAsset` (r:1 w:2) + /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) + fn update_pool_data() -> Weight { + // Proof Size summary in bytes: + // Measured: `417` + // Estimated: `3628` + // Minimum execution time: 25_043_000 picoseconds. + Weight::from_parts(25_363_000, 3628) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: `XYK::ShareToken` (r:1 w:0) - /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:7 w:7) + /// Storage: `LBP::PoolData` (r:1 w:0) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, 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::TotalLiquidity` (r:1 w:1) - /// Proof: `XYK::TotalLiquidity` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) /// Storage: `Duster::AccountBlacklist` (r:1 w:0) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::BannedAssets` (r:4 w:0) + /// 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) + /// 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:2) + /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) - /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) - /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `Tokens::TotalIssuance` (r:1 w:1) - /// Proof: `Tokens::TotalIssuance` (`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`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `4291` - // Estimated: `19071` - // Minimum execution time: 295_216_000 picoseconds. - Weight::from_parts(297_013_000, 19071) - .saturating_add(T::DbWeight::get().reads(27_u64)) - .saturating_add(T::DbWeight::get().writes(13_u64)) + // Measured: `1572` + // Estimated: `11322` + // Minimum execution time: 100_522_000 picoseconds. + Weight::from_parts(101_333_000, 11322) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - /// Storage: `XYK::ShareToken` (r:1 w:1) - /// 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: `Tokens::Accounts` (r:7 w:7) + /// Storage: `LBP::PoolData` (r:1 w:1) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `Duster::AccountBlacklist` (r:2 w:1) + /// Storage: `Duster::AccountBlacklist` (r:1 w:0) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::BannedAssets` (r:3 w:0) + /// 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) + /// Storage: `AssetRegistry::Assets` (r:2 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) - /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:3 w:3) + /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// 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: `EmaOracle::WhitelistedAssets` (r:1 w:0) - /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) - /// Storage: `XYK::PoolAssets` (r:0 w:1) - /// Proof: `XYK::PoolAssets` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:1) + /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Locks` (r:1 w:0) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) + /// Storage: `LBP::FeeCollectorWithAsset` (r:0 w:1) + /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `4341` - // Estimated: `19071` - // Minimum execution time: 432_017_000 picoseconds. - Weight::from_parts(435_171_000, 19071) - .saturating_add(T::DbWeight::get().reads(29_u64)) - .saturating_add(T::DbWeight::get().writes(17_u64)) + // Measured: `1687` + // Estimated: `11322` + // Minimum execution time: 131_548_000 picoseconds. + Weight::from_parts(132_825_000, 11322) + .saturating_add(T::DbWeight::get().reads(13_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) } - /// Storage: `XYK::ShareToken` (r:1 w:0) - /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:6 w:6) + /// 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) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Locks` (r:1 w:1) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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:3 w:0) + /// 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:3 w:0) + /// 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:2) + /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) - /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) - /// 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`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `4190` - // Estimated: `16488` - // Minimum execution time: 259_720_000 picoseconds. - Weight::from_parts(262_022_000, 16488) - .saturating_add(T::DbWeight::get().reads(24_u64)) - .saturating_add(T::DbWeight::get().writes(10_u64)) + // Measured: `1977` + // Estimated: `13905` + // Minimum execution time: 233_172_000 picoseconds. + Weight::from_parts(234_278_000, 13905) + .saturating_add(T::DbWeight::get().reads(16_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } - /// Storage: `XYK::ShareToken` (r:1 w:0) - /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:6 w:6) + /// Storage: `LBP::PoolData` (r:1 w:0) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, 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) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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:3 w:0) + /// 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:3 w:0) + /// Storage: `AssetRegistry::Assets` (r:2 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) - /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:3 w:2) + /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// 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`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `4190` - // Estimated: `16488` - // Minimum execution time: 258_233_000 picoseconds. - Weight::from_parts(260_534_000, 16488) - .saturating_add(T::DbWeight::get().reads(24_u64)) - .saturating_add(T::DbWeight::get().writes(10_u64)) + // Measured: `1977` + // Estimated: `13905` + // Minimum execution time: 232_521_000 picoseconds. + Weight::from_parts(233_949_000, 13905) + .saturating_add(T::DbWeight::get().reads(16_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } - /// Storage: `XYK::ShareToken` (r:1 w:0) - /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:6 w:6) + /// Storage: `LBP::PoolData` (r:1 w:0) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, 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) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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:3 w:0) + /// 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:3 w:0) + /// 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:2) + /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) - /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) - /// 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`) /// 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 * (2969 ±0)` - // Estimated: `6156 + e * (10332 ±118_379_753_737_997_488)` - // Minimum execution time: 24_323_000 picoseconds. - Weight::from_parts(10_607_591, 6156) - // Standard Error: 167_239 - .saturating_add(Weight::from_parts(7_205_082, 0).saturating_mul(c.into())) - // Standard Error: 167_239 - .saturating_add(Weight::from_parts(243_290_509, 0).saturating_mul(e.into())) + // Measured: `822 + e * (1155 ±0)` + // Estimated: `6156 + e * (7749 ±251_795_645_551_580_832)` + // Minimum execution time: 86_818_000 picoseconds. + Weight::from_parts(88_179_000, 6156) + // Standard Error: 904_459 + .saturating_add(Weight::from_parts(3_650_240, 0).saturating_mul(c.into())) + // Standard Error: 1_985_547 + .saturating_add(Weight::from_parts(154_967_721, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(3_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())) + .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: `XYK::ShareToken` (r:1 w:0) - /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:6 w:6) + /// Storage: `LBP::PoolData` (r:1 w:0) + /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, 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) + /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, 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:3 w:0) + /// 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:3 w:0) + /// Storage: `AssetRegistry::Assets` (r:2 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) - /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:3 w:2) + /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:1) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:0) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::ExistentialDepositCounter` (r:1 w:1) - /// 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`) /// 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 * (2969 ±0)` - // Estimated: `6156 + e * (10332 ±0)` - // Minimum execution time: 31_926_000 picoseconds. - Weight::from_parts(8_222_348, 6156) - // Standard Error: 100_411 - .saturating_add(Weight::from_parts(8_150_950, 0).saturating_mul(c.into())) - // Standard Error: 170_358 - .saturating_add(Weight::from_parts(243_286_593, 0).saturating_mul(e.into())) + // Measured: `822 + e * (1155 ±0)` + // Estimated: `6156 + e * (7749 ±0)` + // Minimum execution time: 163_430_000 picoseconds. + Weight::from_parts(164_981_000, 6156) + // Standard Error: 1_122_507 + .saturating_add(Weight::from_parts(5_914_893, 0).saturating_mul(c.into())) + // Standard Error: 3_706_588 + .saturating_add(Weight::from_parts(112_896_249, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(3_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: `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_403_000 picoseconds. + Weight::from_parts(90_543_000, 6156) .saturating_add(T::DbWeight::get().reads(3_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: `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: `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` + // Measured: `822` // Estimated: `6156` - // Minimum execution time: 19_174_000 picoseconds. - Weight::from_parts(19_702_000, 6156) - .saturating_add(T::DbWeight::get().reads(2_u64)) + // Minimum execution time: 24_307_000 picoseconds. + Weight::from_parts(24_702_000, 6156) + .saturating_add(T::DbWeight::get().reads(4_u64)) } } \ No newline at end of file From d69120c4c208d95f46bcd3cf8f1c0392f77945b4 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 20 Jun 2024 10:02:39 +0200 Subject: [PATCH 52/61] fix lbp weights --- pallets/lbp/src/weights.rs | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/pallets/lbp/src/weights.rs b/pallets/lbp/src/weights.rs index 2b348a876..28decd5c4 100644 --- a/pallets/lbp/src/weights.rs +++ b/pallets/lbp/src/weights.rs @@ -88,8 +88,8 @@ impl WeightInfo for () { // Estimated: `11322` // Minimum execution time: 133_964_000 picoseconds. Weight::from_parts(135_186_000, 11322) - .saturating_add(T::DbWeight::get().reads(15_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) + .saturating_add(RocksDbWeight::get().reads(15_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) } /// Storage: `LBP::PoolData` (r:1 w:1) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) @@ -101,8 +101,8 @@ impl WeightInfo for () { // Estimated: `3628` // Minimum execution time: 25_043_000 picoseconds. Weight::from_parts(25_363_000, 3628) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::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`) @@ -122,8 +122,8 @@ impl WeightInfo for () { // Estimated: `11322` // Minimum execution time: 100_522_000 picoseconds. Weight::from_parts(101_333_000, 11322) - .saturating_add(T::DbWeight::get().reads(11_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::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`) @@ -149,8 +149,8 @@ impl WeightInfo for () { // Estimated: `11322` // Minimum execution time: 131_548_000 picoseconds. Weight::from_parts(132_825_000, 11322) - .saturating_add(T::DbWeight::get().reads(13_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) + .saturating_add(RocksDbWeight::get().reads(13_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) } /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) @@ -172,8 +172,8 @@ impl WeightInfo for () { // Estimated: `13905` // Minimum execution time: 233_172_000 picoseconds. Weight::from_parts(234_278_000, 13905) - .saturating_add(T::DbWeight::get().reads(16_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + .saturating_add(RocksDbWeight::get().reads(16_u64)) + .saturating_add(RocksDbWeight::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`) @@ -195,8 +195,8 @@ impl WeightInfo for () { // Estimated: `13905` // Minimum execution time: 232_521_000 picoseconds. Weight::from_parts(233_949_000, 13905) - .saturating_add(T::DbWeight::get().reads(16_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + .saturating_add(RocksDbWeight::get().reads(16_u64)) + .saturating_add(RocksDbWeight::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`) @@ -224,9 +224,9 @@ impl WeightInfo for () { .saturating_add(Weight::from_parts(3_650_240, 0).saturating_mul(c.into())) // Standard Error: 1_985_547 .saturating_add(Weight::from_parts(154_967_721, 0).saturating_mul(e.into())) - .saturating_add(T::DbWeight::get().reads(3_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(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().reads((13_u64).saturating_mul(e.into()))) + .saturating_add(RocksDbWeight::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) @@ -255,9 +255,9 @@ impl WeightInfo for () { .saturating_add(Weight::from_parts(5_914_893, 0).saturating_mul(c.into())) // Standard Error: 3_706_588 .saturating_add(Weight::from_parts(112_896_249, 0).saturating_mul(e.into())) - .saturating_add(T::DbWeight::get().reads(3_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(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().reads((13_u64).saturating_mul(e.into()))) + .saturating_add(RocksDbWeight::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) @@ -270,7 +270,7 @@ impl WeightInfo for () { // Estimated: `6156` // Minimum execution time: 89_403_000 picoseconds. Weight::from_parts(90_543_000, 6156) - .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().reads(3_u64)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) @@ -284,6 +284,6 @@ impl WeightInfo for () { // Estimated: `6156` // Minimum execution time: 24_307_000 picoseconds. Weight::from_parts(24_702_000, 6156) - .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) } } From 6dcc06d5403aab4b3af149947bb105f77f9a3b71 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 20 Jun 2024 10:14:09 +0200 Subject: [PATCH 53/61] rebenchmark router --- pallets/route-executor/src/weights.rs | 78 +++++++++---------- .../src/weights/pallet_route_executor.rs | 55 +++++++------ 2 files changed, 66 insertions(+), 67 deletions(-) diff --git a/pallets/route-executor/src/weights.rs b/pallets/route-executor/src/weights.rs index 91b61bfb1..d72c4de31 100644 --- a/pallets/route-executor/src/weights.rs +++ b/pallets/route-executor/src/weights.rs @@ -15,13 +15,14 @@ // See the License for the specific language governing permissions and // limitations under the License. + //! Autogenerated weights for `pallet_route_executor` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-05-24, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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: `Some("dev")`, DB CACHE: `1024` // Executed Command: // target/release/hydradx @@ -32,11 +33,10 @@ // --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --template=.maintain/pallet-weight-template-no-back.hbs +// --template=scripts/pallet-weight-template.hbs // --pallet=pallet-route-executor -// --output=weights-1.1.0/router.rs +// --output=weights/router.rs // --extrinsic=* -// --extra #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -75,14 +75,14 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 1]`. fn calculate_and_execute_sell_in_lbp(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3502` + // Measured: `3535` // Estimated: `13905` - // Minimum execution time: 350_123_000 picoseconds. - Weight::from_parts(353_120_014, 13905) - // Standard Error: 196_262 - .saturating_add(Weight::from_parts(53_190_547, 0).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(16)) - .saturating_add(RocksDbWeight::get().writes(7)) + // Minimum execution time: 354_159_000 picoseconds. + Weight::from_parts(358_572_573, 13905) + // Standard Error: 306_143 + .saturating_add(Weight::from_parts(70_834_738, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(16_u64)) + .saturating_add(RocksDbWeight::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`) @@ -102,15 +102,15 @@ impl WeightInfo for () { /// 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: `1604 + b * (1923 ±0)` - // Estimated: `6156 + b * (7749 ±99_524_913_928_918_768)` - // Minimum execution time: 76_629_000 picoseconds. - Weight::from_parts(77_524_000, 6156) - // Standard Error: 643_893 - .saturating_add(Weight::from_parts(2_575_705, 0).saturating_mul(c.into())) - // Standard Error: 1_413_530 - .saturating_add(Weight::from_parts(279_458_895, 0).saturating_mul(b.into())) - .saturating_add(RocksDbWeight::get().reads(3)) + // Measured: `1637 + b * (1923 ±0)` + // Estimated: `6156 + b * (7749 ±228_644_766_292_339_040)` + // Minimum execution time: 94_614_000 picoseconds. + Weight::from_parts(96_046_000, 6156) + // Standard Error: 876_130 + .saturating_add(Weight::from_parts(3_658_596, 0).saturating_mul(c.into())) + // Standard Error: 1_923_356 + .saturating_add(Weight::from_parts(272_645_114, 0).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().reads((13_u64).saturating_mul(b.into()))) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(b.into()))) .saturating_add(Weight::from_parts(0, 7749).saturating_mul(b.into())) @@ -139,12 +139,12 @@ impl WeightInfo for () { /// 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: `6393` + // Measured: `6426` // Estimated: `39735` - // Minimum execution time: 2_322_739_000 picoseconds. - Weight::from_parts(2_333_287_000, 39735) - .saturating_add(RocksDbWeight::get().reads(55)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Minimum execution time: 1_917_993_000 picoseconds. + Weight::from_parts(1_930_602_000, 39735) + .saturating_add(RocksDbWeight::get().reads(55_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Router::Routes` (r:0 w:1) /// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`) @@ -152,9 +152,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1012` // Estimated: `0` - // Minimum execution time: 30_683_000 picoseconds. - Weight::from_parts(31_106_000, 0) - .saturating_add(RocksDbWeight::get().writes(1)) + // Minimum execution time: 25_174_000 picoseconds. + Weight::from_parts(25_689_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Router::Routes` (r:1 w:0) /// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`) @@ -162,22 +162,22 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `800` // Estimated: `3555` - // Minimum execution time: 8_542_000 picoseconds. - Weight::from_parts(8_764_000, 3555) - .saturating_add(RocksDbWeight::get().reads(1)) + // Minimum execution time: 7_562_000 picoseconds. + Weight::from_parts(7_748_000, 3555) + .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:2 w:0) - /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:0) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) - fn calculate_spot_price_in_lbp() -> Weight { + /// 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: `1641` + // Measured: `1674` // Estimated: `6156` - // Minimum execution time: 44_947_000 picoseconds. - Weight::from_parts(45_510_000, 6156) - .saturating_add(RocksDbWeight::get().reads(4)) + // Minimum execution time: 36_086_000 picoseconds. + Weight::from_parts(36_646_000, 6156) + .saturating_add(RocksDbWeight::get().reads(4_u64)) } } diff --git a/runtime/hydradx/src/weights/pallet_route_executor.rs b/runtime/hydradx/src/weights/pallet_route_executor.rs index 2d0e62bc8..47258545f 100644 --- a/runtime/hydradx/src/weights/pallet_route_executor.rs +++ b/runtime/hydradx/src/weights/pallet_route_executor.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for `pallet_route_executor` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-05-24, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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` @@ -35,9 +35,8 @@ // --heap-pages=4096 // --template=scripts/pallet-weight-template.hbs // --pallet=pallet-route-executor -// --output=weights/route_executor.rs +// --output=weights/router.rs // --extrinsic=* -// --extra #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -72,10 +71,10 @@ impl pallet_route_executor::WeightInfo for HydraWeight< // Proof Size summary in bytes: // Measured: `3535` // Estimated: `13905` - // Minimum execution time: 353_367_000 picoseconds. - Weight::from_parts(356_268_786, 13905) - // Standard Error: 166_444 - .saturating_add(Weight::from_parts(71_565_213, 0).saturating_mul(c.into())) + // Minimum execution time: 354_159_000 picoseconds. + Weight::from_parts(358_572_573, 13905) + // Standard Error: 306_143 + .saturating_add(Weight::from_parts(70_834_738, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -98,13 +97,13 @@ impl pallet_route_executor::WeightInfo for HydraWeight< fn calculate_and_execute_buy_in_lbp(c: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1637 + b * (1923 ±0)` - // Estimated: `6156 + b * (7749 ±245_709_589_663_843_264)` - // Minimum execution time: 94_954_000 picoseconds. - Weight::from_parts(95_935_000, 6156) - // Standard Error: 916_176 - .saturating_add(Weight::from_parts(3_538_176, 0).saturating_mul(c.into())) - // Standard Error: 2_011_269 - .saturating_add(Weight::from_parts(271_193_375, 0).saturating_mul(b.into())) + // Estimated: `6156 + b * (7749 ±228_644_766_292_339_040)` + // Minimum execution time: 94_614_000 picoseconds. + Weight::from_parts(96_046_000, 6156) + // Standard Error: 876_130 + .saturating_add(Weight::from_parts(3_658_596, 0).saturating_mul(c.into())) + // Standard Error: 1_923_356 + .saturating_add(Weight::from_parts(272_645_114, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().reads((13_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(b.into()))) @@ -136,8 +135,8 @@ impl pallet_route_executor::WeightInfo for HydraWeight< // Proof Size summary in bytes: // Measured: `6426` // Estimated: `39735` - // Minimum execution time: 1_873_189_000 picoseconds. - Weight::from_parts(1_884_759_000, 39735) + // Minimum execution time: 1_917_993_000 picoseconds. + Weight::from_parts(1_930_602_000, 39735) .saturating_add(T::DbWeight::get().reads(55_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -147,8 +146,8 @@ impl pallet_route_executor::WeightInfo for HydraWeight< // Proof Size summary in bytes: // Measured: `1012` // Estimated: `0` - // Minimum execution time: 25_395_000 picoseconds. - Weight::from_parts(25_888_000, 0) + // Minimum execution time: 25_174_000 picoseconds. + Weight::from_parts(25_689_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Router::Routes` (r:1 w:0) @@ -157,22 +156,22 @@ impl pallet_route_executor::WeightInfo for HydraWeight< // Proof Size summary in bytes: // Measured: `800` // Estimated: `3555` - // Minimum execution time: 8_542_000 picoseconds. - Weight::from_parts(8_764_000, 3555) - .saturating_add(T::DbWeight::get().reads(1)) + // Minimum execution time: 7_562_000 picoseconds. + Weight::from_parts(7_748_000, 3555) + .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:2 w:0) - /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:0) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) - fn calculate_spot_price_in_lbp() -> Weight { + /// 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: `1641` + // Measured: `1674` // Estimated: `6156` - // Minimum execution time: 44_947_000 picoseconds. - Weight::from_parts(45_510_000, 6156) - .saturating_add(T::DbWeight::get().reads(4)) + // Minimum execution time: 36_086_000 picoseconds. + Weight::from_parts(36_646_000, 6156) + .saturating_add(T::DbWeight::get().reads(4_u64)) } } \ No newline at end of file From 800a68dca819c3bba5f4b4f0f1fa3a9d72777cd6 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 20 Jun 2024 10:25:27 +0200 Subject: [PATCH 54/61] fix router weights --- pallets/route-executor/src/weights.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/route-executor/src/weights.rs b/pallets/route-executor/src/weights.rs index d72c4de31..e221631b1 100644 --- a/pallets/route-executor/src/weights.rs +++ b/pallets/route-executor/src/weights.rs @@ -53,7 +53,7 @@ pub trait WeightInfo { fn set_route_for_xyk() -> Weight; fn force_insert_route() -> Weight; fn get_route() -> Weight; - fn calculate_spot_price_in_lbp() -> Weight; + fn calculate_spot_price_with_fee_in_lbp() -> Weight; } /// Weights for `pallet_route_executor` using the HydraDX node and recommended hardware. From 1bce5dc2a4a9b5888f457ded2b51a62b4211d9d4 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 20 Jun 2024 14:12:29 +0200 Subject: [PATCH 55/61] fix incorrect weight function name --- runtime/hydradx/src/assets.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index ef2176385..1ca3ff042 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -855,10 +855,10 @@ impl RouterWeightInfo { pub fn calculate_spot_price_overweight() -> Weight { Weight::from_parts( - weights::pallet_route_executor::HydraWeight::::calculate_spot_price_in_lbp() + weights::pallet_route_executor::HydraWeight::::calculate_spot_price_with_fee_in_lbp() .ref_time() .saturating_sub(weights::pallet_lbp::HydraWeight::::calculate_spot_price_with_fee().ref_time()), - weights::pallet_route_executor::HydraWeight::::calculate_spot_price_in_lbp().proof_size(), + weights::pallet_route_executor::HydraWeight::::calculate_spot_price_with_fee_in_lbp().proof_size(), ) } } From 19ae17b8f2358a8bff9bbf6ecb3460e99025d629 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 20 Jun 2024 14:25:17 +0200 Subject: [PATCH 56/61] rebenchmark dca and otc-settlements --- pallets/dca/src/weights.rs | 33 +++++++++-------- pallets/otc-settlements/src/weights.rs | 37 ++++--------------- runtime/hydradx/src/weights/pallet_dca.rs | 31 ++++++++-------- .../src/weights/pallet_otc_settlements.rs | 15 +++----- 4 files changed, 45 insertions(+), 71 deletions(-) diff --git a/pallets/dca/src/weights.rs b/pallets/dca/src/weights.rs index 5791809ea..468116804 100644 --- a/pallets/dca/src/weights.rs +++ b/pallets/dca/src/weights.rs @@ -15,10 +15,11 @@ // See the License for the specific language governing permissions and // limitations under the License. + //! Autogenerated weights for `pallet_dca` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-05-24, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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` @@ -36,7 +37,6 @@ // --pallet=pallet-dca // --output=weights/dca.rs // --extrinsic=* -// --extra #![allow(unused_parens)] #![allow(unused_imports)] @@ -73,10 +73,10 @@ impl WeightInfo for () { /// 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: `54485` + // Measured: `54523` // Estimated: `31902` - // Minimum execution time: 207_153_000 picoseconds. - Weight::from_parts(209_471_000, 31902) + // Minimum execution time: 207_400_000 picoseconds. + Weight::from_parts(211_361_000, 31902) .saturating_add(RocksDbWeight::get().reads(17_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -94,10 +94,10 @@ impl WeightInfo for () { /// 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: `54593` + // Measured: `54631` // Estimated: `31902` - // Minimum execution time: 206_729_000 picoseconds. - Weight::from_parts(210_115_000, 31902) + // Minimum execution time: 209_659_000 picoseconds. + Weight::from_parts(213_448_000, 31902) .saturating_add(RocksDbWeight::get().reads(17_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -107,8 +107,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1113` // Estimated: `3566` - // Minimum execution time: 14_273_000 picoseconds. - Weight::from_parts(14_864_000, 3566).saturating_add(RocksDbWeight::get().reads(1_u64)) + // Minimum execution time: 14_992_000 picoseconds. + Weight::from_parts(15_296_000, 3566) + .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) @@ -134,10 +135,10 @@ impl WeightInfo for () { /// Proof: `DCA::RemainingAmounts` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) fn schedule() -> Weight { // Proof Size summary in bytes: - // Measured: `52618` + // Measured: `52656` // Estimated: `29326` - // Minimum execution time: 153_135_000 picoseconds. - Weight::from_parts(155_526_000, 29326) + // Minimum execution time: 152_493_000 picoseconds. + Weight::from_parts(155_888_000, 29326) .saturating_add(RocksDbWeight::get().reads(17_u64)) .saturating_add(RocksDbWeight::get().writes(8_u64)) } @@ -157,10 +158,10 @@ impl WeightInfo for () { /// Proof: `DCA::ScheduleOwnership` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`) fn terminate() -> Weight { // Proof Size summary in bytes: - // Measured: `2492` + // Measured: `2530` // Estimated: `4714` - // Minimum execution time: 70_794_000 picoseconds. - Weight::from_parts(71_685_000, 4714) + // Minimum execution time: 71_135_000 picoseconds. + Weight::from_parts(71_902_000, 4714) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } diff --git a/pallets/otc-settlements/src/weights.rs b/pallets/otc-settlements/src/weights.rs index a47ace3e6..93dcf1dc7 100644 --- a/pallets/otc-settlements/src/weights.rs +++ b/pallets/otc-settlements/src/weights.rs @@ -1,6 +1,3 @@ -// This file is part of HydraDX. - -// Copyright (C) 2020-2023 Intergalactic, Limited (GIB). // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. + //! Autogenerated weights for `pallet_otc_settlements` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-05-29, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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` @@ -32,10 +30,10 @@ // --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --template=.maintain/pallet-weight-template.hbs +// --template=scripts/pallet-weight-template.hbs // --pallet=pallet-otc-settlements // --output=weights/otc-settlements.rs -// --extrinsic= +// --extrinsic=* #![allow(unused_parens)] #![allow(unused_imports)] @@ -53,27 +51,6 @@ pub trait WeightInfo { } /// Weights for pallet_otc using the hydraDX node and recommended hardware. -pub struct HydraWeight(PhantomData); - -impl 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: `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` - // Estimated: `6196` - // Minimum execution time: 122_182_000 picoseconds. - Weight::from_parts(123_996_000, 6196) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } -} - -// For backwards compatibility and tests impl WeightInfo for () { /// Storage: `OTC::Orders` (r:1 w:0) /// Proof: `OTC::Orders` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `MaxEncodedLen`) @@ -85,8 +62,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `747` // Estimated: `6196` - // Minimum execution time: 122_182_000 picoseconds. - Weight::from_parts(123_996_000, 6196) + // Minimum execution time: 100_657_000 picoseconds. + Weight::from_parts(101_597_000, 6196) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/runtime/hydradx/src/weights/pallet_dca.rs b/runtime/hydradx/src/weights/pallet_dca.rs index 49aa61bae..e03f3ffc4 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-05-24, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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` @@ -37,7 +37,6 @@ // --pallet=pallet-dca // --output=weights/dca.rs // --extrinsic=* -// --extra* #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -67,10 +66,10 @@ impl pallet_dca::WeightInfo for HydraWeight { /// 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: `54485` + // Measured: `54523` // Estimated: `31902` - // Minimum execution time: 207_153_000 picoseconds. - Weight::from_parts(209_471_000, 31902) + // Minimum execution time: 207_400_000 picoseconds. + Weight::from_parts(211_361_000, 31902) .saturating_add(T::DbWeight::get().reads(17_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -88,10 +87,10 @@ impl pallet_dca::WeightInfo for HydraWeight { /// 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: `54593` + // Measured: `54631` // Estimated: `31902` - // Minimum execution time: 206_729_000 picoseconds. - Weight::from_parts(210_115_000, 31902) + // Minimum execution time: 209_659_000 picoseconds. + Weight::from_parts(213_448_000, 31902) .saturating_add(T::DbWeight::get().reads(17_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -101,8 +100,8 @@ impl pallet_dca::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `1113` // Estimated: `3566` - // Minimum execution time: 14_273_000 picoseconds. - Weight::from_parts(14_864_000, 3566) + // Minimum execution time: 14_992_000 picoseconds. + Weight::from_parts(15_296_000, 3566) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) @@ -129,10 +128,10 @@ 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: `52618` + // Measured: `52656` // Estimated: `29326` - // Minimum execution time: 153_135_000 picoseconds. - Weight::from_parts(155_526_000, 29326) + // Minimum execution time: 152_493_000 picoseconds. + Weight::from_parts(155_888_000, 29326) .saturating_add(T::DbWeight::get().reads(17_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } @@ -152,10 +151,10 @@ impl pallet_dca::WeightInfo for HydraWeight { /// Proof: `DCA::ScheduleOwnership` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`) fn terminate() -> Weight { // Proof Size summary in bytes: - // Measured: `2492` + // Measured: `2530` // Estimated: `4714` - // Minimum execution time: 70_794_000 picoseconds. - Weight::from_parts(71_685_000, 4714) + // Minimum execution time: 71_135_000 picoseconds. + Weight::from_parts(71_902_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_otc_settlements.rs b/runtime/hydradx/src/weights/pallet_otc_settlements.rs index 0a50858f1..b5957e31e 100644 --- a/runtime/hydradx/src/weights/pallet_otc_settlements.rs +++ b/runtime/hydradx/src/weights/pallet_otc_settlements.rs @@ -1,6 +1,3 @@ -// This file is part of HydraDX. - -// Copyright (C) 2020-2023 Intergalactic, Limited (GIB). // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,8 +15,8 @@ //! Autogenerated weights for `pallet_otc_settlements` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-05-29, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-06-20, STEPS: `10`, REPEAT: `30`, 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` @@ -33,10 +30,10 @@ // --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --template=.maintain/pallet-weight-template.hbs +// --template=scripts/pallet-weight-template.hbs // --pallet=pallet-otc-settlements // --output=weights/otc-settlements.rs -// --extrinsic=a +// --extrinsic=* #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -61,8 +58,8 @@ impl WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `747` // Estimated: `6196` - // Minimum execution time: 122_182_000 picoseconds. - Weight::from_parts(123_996_000, 6196) + // Minimum execution time: 100_657_000 picoseconds. + Weight::from_parts(101_597_000, 6196) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } From 080cdf44da9fbc19abc84844cf1a766e2553cbe5 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 20 Jun 2024 14:25:29 +0200 Subject: [PATCH 57/61] formatting --- pallets/dca/src/weights.rs | 4 +--- pallets/lbp/src/weights.rs | 11 ++++------- pallets/omnipool/src/weights.rs | 8 +++----- pallets/otc-settlements/src/lib.rs | 2 +- pallets/otc-settlements/src/weights.rs | 1 - pallets/stableswap/src/weights.rs | 8 +++----- pallets/xyk/src/weights.rs | 8 +++----- runtime/hydradx/src/assets.rs | 8 ++++++-- 8 files changed, 21 insertions(+), 29 deletions(-) diff --git a/pallets/dca/src/weights.rs b/pallets/dca/src/weights.rs index 468116804..a2e5f874e 100644 --- a/pallets/dca/src/weights.rs +++ b/pallets/dca/src/weights.rs @@ -15,7 +15,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - //! Autogenerated weights for `pallet_dca` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 @@ -108,8 +107,7 @@ impl WeightInfo for () { // Measured: `1113` // Estimated: `3566` // Minimum execution time: 14_992_000 picoseconds. - Weight::from_parts(15_296_000, 3566) - .saturating_add(RocksDbWeight::get().reads(1_u64)) + Weight::from_parts(15_296_000, 3566).saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) diff --git a/pallets/lbp/src/weights.rs b/pallets/lbp/src/weights.rs index 28decd5c4..7844854cc 100644 --- a/pallets/lbp/src/weights.rs +++ b/pallets/lbp/src/weights.rs @@ -15,7 +15,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - //! Autogenerated weights for `pallet_lbp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 @@ -214,7 +213,7 @@ impl WeightInfo for () { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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: `822 + e * (1155 ±0)` // Estimated: `6156 + e * (7749 ±251_795_645_551_580_832)` @@ -245,7 +244,7 @@ impl WeightInfo for () { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, 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 { + fn router_execution_buy(c: u32, e: u32) -> Weight { // Proof Size summary in bytes: // Measured: `822 + e * (1155 ±0)` // Estimated: `6156 + e * (7749 ±0)` @@ -269,8 +268,7 @@ impl WeightInfo for () { // Measured: `822` // Estimated: `6156` // Minimum execution time: 89_403_000 picoseconds. - Weight::from_parts(90_543_000, 6156) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + Weight::from_parts(90_543_000, 6156).saturating_add(RocksDbWeight::get().reads(3_u64)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) @@ -283,7 +281,6 @@ impl WeightInfo for () { // Measured: `822` // Estimated: `6156` // Minimum execution time: 24_307_000 picoseconds. - Weight::from_parts(24_702_000, 6156) - .saturating_add(RocksDbWeight::get().reads(4_u64)) + Weight::from_parts(24_702_000, 6156).saturating_add(RocksDbWeight::get().reads(4_u64)) } } diff --git a/pallets/omnipool/src/weights.rs b/pallets/omnipool/src/weights.rs index b0d260287..948525e4d 100644 --- a/pallets/omnipool/src/weights.rs +++ b/pallets/omnipool/src/weights.rs @@ -15,7 +15,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - //! Autogenerated weights for `pallet_omnipool` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 @@ -491,7 +490,7 @@ impl WeightInfo for () { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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 * (5140 ±0)` // Estimated: `6156 + e * (8517 ±251_795_645_551_580_832)` @@ -550,7 +549,7 @@ impl WeightInfo for () { /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, 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 { + fn router_execution_buy(c: u32, e: u32) -> Weight { // Proof Size summary in bytes: // Measured: `7114` // Estimated: `13905` @@ -574,7 +573,6 @@ impl WeightInfo for () { // Measured: `1933` // Estimated: `6156` // Minimum execution time: 43_389_000 picoseconds. - Weight::from_parts(43_919_000, 6156) - .saturating_add(RocksDbWeight::get().reads(6_u64)) + Weight::from_parts(43_919_000, 6156).saturating_add(RocksDbWeight::get().reads(6_u64)) } } diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index bc1364e89..39c277b6d 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -347,7 +347,7 @@ impl Pallet { // This can fail for different reason, but because we start with the largest possible amount, // all we can do is to return `TradeAmountTooHigh` to tell the binary search algorithm to // try again with smaller amount. - .map_err(|_| Error::::TradeAmountTooHigh)?; + .map_err(|_| Error::::TradeAmountTooHigh)?; // Compare OTC and Router price let router_price_after = T::Router::spot_price_with_fee(&route).ok_or(Error::::PriceNotAvailable)?; diff --git a/pallets/otc-settlements/src/weights.rs b/pallets/otc-settlements/src/weights.rs index 93dcf1dc7..91c17c391 100644 --- a/pallets/otc-settlements/src/weights.rs +++ b/pallets/otc-settlements/src/weights.rs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - //! Autogenerated weights for `pallet_otc_settlements` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 diff --git a/pallets/stableswap/src/weights.rs b/pallets/stableswap/src/weights.rs index 3f26d89a8..46753cdd5 100644 --- a/pallets/stableswap/src/weights.rs +++ b/pallets/stableswap/src/weights.rs @@ -15,7 +15,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - //! Autogenerated weights for `pallet_stableswap` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 @@ -327,7 +326,7 @@ impl WeightInfo for () { /// 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 * (1805 ±0)` // Estimated: `13990 + e * (5797 ±201_913_854_157_949_888)` @@ -364,7 +363,7 @@ impl WeightInfo for () { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, 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 { + fn router_execution_buy(c: u32, e: u32) -> Weight { // Proof Size summary in bytes: // Measured: `1620 + e * (1776 ±0)` // Estimated: `13990 + e * (5797 ±213_489_293_787_578_112)` @@ -392,7 +391,6 @@ impl WeightInfo for () { // Measured: `1827` // Estimated: `13990` // Minimum execution time: 308_105_000 picoseconds. - Weight::from_parts(309_400_000, 13990) - .saturating_add(RocksDbWeight::get().reads(12_u64)) + Weight::from_parts(309_400_000, 13990).saturating_add(RocksDbWeight::get().reads(12_u64)) } } diff --git a/pallets/xyk/src/weights.rs b/pallets/xyk/src/weights.rs index 72ffce87b..7cd3a85cc 100644 --- a/pallets/xyk/src/weights.rs +++ b/pallets/xyk/src/weights.rs @@ -15,7 +15,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - //! Autogenerated weights for `pallet_xyk` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 @@ -275,7 +274,7 @@ impl WeightInfo for () { /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, 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: `1221 + e * (2969 ±0)` // Estimated: `6156 + e * (10332 ±118_379_753_737_997_488)` @@ -316,7 +315,7 @@ impl WeightInfo for () { /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, 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 { + fn router_execution_buy(c: u32, e: u32) -> Weight { // Proof Size summary in bytes: // Measured: `1221 + e * (2969 ±0)` // Estimated: `6156 + e * (10332 ±0)` @@ -338,7 +337,6 @@ impl WeightInfo for () { // Measured: `1021` // Estimated: `6156` // Minimum execution time: 19_174_000 picoseconds. - Weight::from_parts(19_702_000, 6156) - .saturating_add(RocksDbWeight::get().reads(2_u64)) + Weight::from_parts(19_702_000, 6156).saturating_add(RocksDbWeight::get().reads(2_u64)) } } diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 1ca3ff042..d417620d4 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -857,7 +857,9 @@ impl RouterWeightInfo { Weight::from_parts( weights::pallet_route_executor::HydraWeight::::calculate_spot_price_with_fee_in_lbp() .ref_time() - .saturating_sub(weights::pallet_lbp::HydraWeight::::calculate_spot_price_with_fee().ref_time()), + .saturating_sub( + weights::pallet_lbp::HydraWeight::::calculate_spot_price_with_fee().ref_time(), + ), weights::pallet_route_executor::HydraWeight::::calculate_spot_price_with_fee_in_lbp().proof_size(), ) } @@ -1074,7 +1076,9 @@ impl AmmTradeWeights> for RouterWeightInfo { let amm_weight = match trade.pool { PoolType::Omnipool => weights::pallet_omnipool::HydraWeight::::calculate_spot_price_with_fee(), PoolType::LBP => weights::pallet_lbp::HydraWeight::::calculate_spot_price_with_fee(), - PoolType::Stableswap(_) => weights::pallet_stableswap::HydraWeight::::calculate_spot_price_with_fee(), + PoolType::Stableswap(_) => { + weights::pallet_stableswap::HydraWeight::::calculate_spot_price_with_fee() + } PoolType::XYK => weights::pallet_xyk::HydraWeight::::calculate_spot_price_with_fee(), }; weight.saturating_accrue(amm_weight); From 99c709d709c015519bdffc0bc7c3d2c8c7668e95 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 20 Jun 2024 14:36:18 +0200 Subject: [PATCH 58/61] bump crate versions --- Cargo.lock | 12 ++++++------ pallets/dca/Cargo.toml | 2 +- pallets/lbp/Cargo.toml | 2 +- pallets/omnipool/Cargo.toml | 2 +- pallets/otc/Cargo.toml | 2 +- pallets/stableswap/Cargo.toml | 2 +- pallets/xyk/Cargo.toml | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d444e5ba8..a09c9e2b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7921,7 +7921,7 @@ dependencies = [ [[package]] name = "pallet-dca" -version = "1.4.8" +version = "1.4.9" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -8427,7 +8427,7 @@ dependencies = [ [[package]] name = "pallet-lbp" -version = "4.8.3" +version = "4.8.4" dependencies = [ "frame-benchmarking", "frame-support", @@ -8675,7 +8675,7 @@ dependencies = [ [[package]] name = "pallet-omnipool" -version = "4.3.1" +version = "4.3.2" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -8729,7 +8729,7 @@ dependencies = [ [[package]] name = "pallet-otc" -version = "1.1.4" +version = "1.1.5" dependencies = [ "frame-benchmarking", "frame-support", @@ -9020,7 +9020,7 @@ dependencies = [ [[package]] name = "pallet-stableswap" -version = "3.6.3" +version = "3.6.4" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -9408,7 +9408,7 @@ dependencies = [ [[package]] name = "pallet-xyk" -version = "6.4.3" +version = "6.4.4" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/pallets/dca/Cargo.toml b/pallets/dca/Cargo.toml index c7634b80c..4d3427ce4 100644 --- a/pallets/dca/Cargo.toml +++ b/pallets/dca/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-dca' -version = "1.4.8" +version = "1.4.9" description = 'A pallet to manage DCA scheduling' authors = ['GalacticCouncil'] edition = '2021' diff --git a/pallets/lbp/Cargo.toml b/pallets/lbp/Cargo.toml index 68726ad06..14263533f 100644 --- a/pallets/lbp/Cargo.toml +++ b/pallets/lbp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-lbp" -version = "4.8.3" +version = "4.8.4" description = "HydraDX Liquidity Bootstrapping Pool Pallet" authors = ["GalacticCouncil"] edition = "2021" diff --git a/pallets/omnipool/Cargo.toml b/pallets/omnipool/Cargo.toml index d316eb163..ec37db74f 100644 --- a/pallets/omnipool/Cargo.toml +++ b/pallets/omnipool/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-omnipool" -version = "4.3.1" +version = "4.3.2" authors = ['GalacticCouncil'] edition = "2021" license = "Apache-2.0" diff --git a/pallets/otc/Cargo.toml b/pallets/otc/Cargo.toml index 398e38058..6bf56e1e0 100644 --- a/pallets/otc/Cargo.toml +++ b/pallets/otc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-otc' -version = '1.1.4' +version = '1.1.5' description = 'A pallet for trustless over-the-counter trading' authors = ['GalacticCouncil'] edition = '2021' diff --git a/pallets/stableswap/Cargo.toml b/pallets/stableswap/Cargo.toml index e16b4a778..462c072f5 100644 --- a/pallets/stableswap/Cargo.toml +++ b/pallets/stableswap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-stableswap' -version = '3.6.3' +version = '3.6.4' description = 'AMM for correlated assets' authors = ['GalacticCouncil'] edition = '2021' diff --git a/pallets/xyk/Cargo.toml b/pallets/xyk/Cargo.toml index 68c6df36f..99c415ede 100644 --- a/pallets/xyk/Cargo.toml +++ b/pallets/xyk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-xyk' -version = "6.4.3" +version = "6.4.4" description = 'XYK automated market maker' authors = ['GalacticCouncil'] edition = '2021' From e879ff5088ab009e65ec6bbb6628bf11e0755c58 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 20 Jun 2024 15:20:05 +0200 Subject: [PATCH 59/61] fix integration tests --- integration-tests/src/evm_permit.rs | 2 +- pallets/dca/src/tests/mock.rs | 8 ++++---- pallets/dca/src/tests/on_initialize.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/integration-tests/src/evm_permit.rs b/integration-tests/src/evm_permit.rs index e54713b5e..7e3f496c5 100644 --- a/integration-tests/src/evm_permit.rs +++ b/integration-tests/src/evm_permit.rs @@ -1141,7 +1141,7 @@ fn dispatch_permit_should_increase_account_nonce_correctly() { let hdx_balance = user_acc.balance(HDX); let tx_fee = initial_user_hdx_balance - hdx_balance; - assert_eq!(tx_fee, 1_816_997_321_901); + assert_eq!(tx_fee, 1_797_084_195_590); }) } diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index cc46592bc..36b8f0230 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -54,10 +54,10 @@ pub type BlockNumber = u64; pub type AssetId = u32; type NamedReserveIdentifier = [u8; 8]; -pub const BUY_DCA_FEE_IN_NATIVE: Balance = 1334471000; -pub const BUY_DCA_FEE_IN_DAI: Balance = 1174334480; -pub const SELL_DCA_FEE_IN_NATIVE: Balance = 1335115000; -pub const SELL_DCA_FEE_IN_DAI: Balance = 1174901200; +pub const BUY_DCA_FEE_IN_NATIVE: Balance = 1336361000; +pub const BUY_DCA_FEE_IN_DAI: Balance = 1175997680; +pub const SELL_DCA_FEE_IN_NATIVE: Balance = 1338448000; +pub const SELL_DCA_FEE_IN_DAI: Balance = 1177834240; pub const HDX: AssetId = 0; pub const LRNA: AssetId = 1; diff --git a/pallets/dca/src/tests/on_initialize.rs b/pallets/dca/src/tests/on_initialize.rs index 423aef6f8..f5f27dde4 100644 --- a/pallets/dca/src/tests/on_initialize.rs +++ b/pallets/dca/src/tests/on_initialize.rs @@ -865,7 +865,7 @@ fn full_buy_dca_should_be_completed_when_some_execution_is_successful_but_not_en assert_number_of_executed_buy_trades!(4); assert_eq!(0, Currencies::reserved_balance(HDX, &ALICE)); - let left_over_which_is_not_enough_for_last_trade = 9994662116000; + let left_over_which_is_not_enough_for_last_trade = 9994654556000; assert_balance!( ALICE, From 4008c980bc513c7db527b32116405486b7fbe62e Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 20 Jun 2024 20:20:24 +0200 Subject: [PATCH 60/61] fix: use correct otc value --- Cargo.lock | 1 - pallets/otc-settlements/Cargo.toml | 1 - pallets/otc-settlements/src/lib.rs | 2 +- pallets/otc-settlements/src/tests.rs | 53 ++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a09c9e2b9..d75f6e474 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8753,7 +8753,6 @@ dependencies = [ name = "pallet-otc-settlements" version = "1.0.0" dependencies = [ - "env_logger", "frame-benchmarking", "frame-support", "frame-system", diff --git a/pallets/otc-settlements/Cargo.toml b/pallets/otc-settlements/Cargo.toml index 4b86c3c7b..50280f9d9 100644 --- a/pallets/otc-settlements/Cargo.toml +++ b/pallets/otc-settlements/Cargo.toml @@ -46,7 +46,6 @@ proptest = "1.0.0" pretty_assertions = "1.2.1" test-utils = { workspace = true } parking_lot = "0.12.1" -env_logger = "*" [features] default = ['std'] diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 39c277b6d..6224c60c0 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -290,7 +290,7 @@ impl Pallet { let (asset_a, asset_b) = (otc.asset_in, otc.asset_out); if !otc.partially_fillable { - ensure!(otc.amount_out == amount, Error::::NotPartiallyFillable); + ensure!(otc.amount_in == amount, Error::::NotPartiallyFillable); } ensure!( diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index ea7306cbe..a8057d4f4 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -300,6 +300,59 @@ fn existing_arb_opportunity_should_trigger_trade() { }); } +#[test] +fn existing_arb_opportunity_should_trigger_trade_when_otc_is_not_partially_fillable() { + let (mut ext, _) = ExtBuilder::default().build(); + ext.execute_with(|| { + assert_ok!(OTC::place_order( + RuntimeOrigin::signed(ALICE), + HDX, // otc asset_in + DAI, // otc asset_out + // we got following 2 values from the logs of + // existing_arb_opportunity_should_trigger_trade test + 828_170_776_368_178, + 1_664_623_260_500_037, + false, // not partially fillable + )); + + // get otc price + let otc_id = 0; + let otc = >::get(otc_id).unwrap(); + let otc_price = calculate_otc_price(&otc); + + // get trade price + let route = Router::get_route(AssetPair { + asset_in: otc.asset_out, + asset_out: otc.asset_in, + }); + let router_price = Router::spot_price_with_fee(&route).unwrap(); + + // verify that there's an arb opportunity + assert!(otc_price > router_price); + + let hdx_total_issuance = Currencies::total_issuance(HDX); + let dai_total_issuance = Currencies::total_issuance(DAI); + + assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); + assert!(Currencies::free_balance(DAI, &OtcSettlements::account_id()) == 0); + + >>::offchain_worker(System::block_number()); + + assert_eq!(hdx_total_issuance, Currencies::total_issuance(HDX)); + assert_eq!(dai_total_issuance, Currencies::total_issuance(DAI)); + + // total issuance of tokens should not change + 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: 2_067_802_207_347, + } + .into()]); + }); +} + #[test] fn existing_arb_opportunity_of_insufficient_asset_should_trigger_trade() { let (mut ext, _) = ExtBuilder::default().build(); From 6b381a45766337717ce5b08655acea291c40acb0 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 21 Jun 2024 14:27:45 +0200 Subject: [PATCH 61/61] add comment --- pallets/otc-settlements/src/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pallets/otc-settlements/src/lib.rs b/pallets/otc-settlements/src/lib.rs index 6224c60c0..d5884e214 100644 --- a/pallets/otc-settlements/src/lib.rs +++ b/pallets/otc-settlements/src/lib.rs @@ -232,7 +232,7 @@ pub mod pallet { /// - `origin`: Signed or unsigned origin. Unsigned origin doesn't pay the TX fee, /// but can be submitted only by a collator. /// - `otc_id`: ID of the OTC order with existing arbitrage opportunity. - /// - `amount`: Amount necessary to clone the arb. + /// - `amount`: Amount necessary to close the arb. /// - `route`: The route we trade against. Required for the fee calculation. /// /// Emits `Executed` event when successful. @@ -283,6 +283,11 @@ impl Pallet { /// If the OTC order is partially fillable, the extrinsic fails if the existing arbitrage /// opportunity is not closed after the trade and if there is no profit after the trade. /// If the OTC order is not partially fillable, fails only if there is no profit after the trade. + /// + /// Parameters: + /// - `otc_id`: ID of the OTC order with existing arbitrage opportunity. + /// - `amount`: Amount necessary to close the arb. + /// - `route`: The route we trade against. Required for the fee calculation. pub fn settle_otc(otc_id: OrderId, amount: Balance, route: Vec>>) -> DispatchResult { let pallet_acc = Self::account_id(); @@ -290,6 +295,7 @@ impl Pallet { let (asset_a, asset_b) = (otc.asset_in, otc.asset_out); if !otc.partially_fillable { + // if the OTC is not partially fillable, we need to trade the whole amount of the OTC ensure!(otc.amount_in == amount, Error::::NotPartiallyFillable); } @@ -349,7 +355,6 @@ impl Pallet { // try again with smaller amount. .map_err(|_| Error::::TradeAmountTooHigh)?; - // Compare OTC and Router price let router_price_after = T::Router::spot_price_with_fee(&route).ok_or(Error::::PriceNotAvailable)?; log::debug!( target: "offchain_worker::settle_otc", @@ -358,7 +363,8 @@ impl Pallet { otc_price ); - // in the case of fully fillable orders, the resulting price is not important + // Compare OTC and Router price. + // In the case of fully fillable orders, the resulting price is not important. if otc.partially_fillable { let price_diff = { if otc_price > router_price_after {