diff --git a/common/src/mock.rs b/common/src/mock.rs index 99fcbbacc..f179aac95 100644 --- a/common/src/mock.rs +++ b/common/src/mock.rs @@ -218,22 +218,22 @@ macro_rules! mock_assets_config { pub GetBuyBackDexId: DEXId = DEXId::from(common::DEXId::PolkaswapXSTUSD); } impl assets::Config for $runtime { - type RuntimeEvent = RuntimeEvent; + type AssetId = AssetId; + type AssetRegulator = $asset_regulator; + type BuyBackLiquidityProxy = (); + type Currency = currencies::Pallet<$runtime>; type ExtraAccountId = [u8; 32]; type ExtraAssetRecordArg = common::AssetIdExtraAssetRecordArg; - type AssetId = AssetId; type GetBaseAssetId = GetBaseAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type GetBuyBackSupplyAssets = GetBuyBackSupplyAssets; - type GetBuyBackPercentage = GetBuyBackPercentage; type GetBuyBackAccountId = GetBuyBackAccountId; + type GetBuyBackAssetId = GetBuyBackAssetId; type GetBuyBackDexId = GetBuyBackDexId; - type BuyBackLiquidityProxy = (); - type Currency = currencies::Pallet<$runtime>; + type GetBuyBackPercentage = GetBuyBackPercentage; + type GetBuyBackSupplyAssets = GetBuyBackSupplyAssets; type GetTotalBalance = (); + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); - type AssetRegulator = $asset_regulator; } }; ($runtime:ty) => { @@ -241,38 +241,36 @@ macro_rules! mock_assets_config { }; } -/// Mock of pallet `extended_assets::Config`. -#[macro_export] -macro_rules! mock_extended_assets_config { - ($runtime:ty) => { - impl extended_assets::Config for $runtime { - type RuntimeEvent = RuntimeEvent; - type AssetInfoProvider = assets::Pallet<$runtime>; - type MaxRegulatedAssetsPerSBT = ConstU32<10000>; - type WeightInfo = (); - } - }; -} - -/// Mock of pallet `pallet_balances::Config`. +/// Mock of pallet `band::Config`. #[macro_export] -macro_rules! mock_pallet_balances_config { - ($runtime:ty) => { +macro_rules! mock_band_config { + ($runtime:ty, $on_new_symbol_relayed_hook:ty, $on_symbol_disabled_hook:ty) => { frame_support::parameter_types! { - pub const ExistentialDeposit: u128 = 0; + pub const GetBandRateStalePeriod: u64 = 60*5*1000; // 5 minutes + pub const GetBandRateStaleBlockPeriod: u64 = 600; } - impl pallet_balances::Config for $runtime { - type Balance = Balance; - type DustRemoval = (); + impl band::Config for $runtime { + type GetBandRateStaleBlockPeriod = GetBandRateStaleBlockPeriod; + type GetBandRateStalePeriod = GetBandRateStalePeriod; + type MaxRelaySymbols = frame_support::traits::ConstU32<100>; + type OnNewSymbolsRelayedHook = $on_new_symbol_relayed_hook; + type OnSymbolDisabledHook = $on_symbol_disabled_hook; type RuntimeEvent = RuntimeEvent; - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = System; + type Symbol = common::SymbolName; + type Time = Timestamp; type WeightInfo = (); - type MaxLocks = (); - type MaxReserves = (); - type ReserveIdentifier = (); } }; + ($runtime:ty, $on_symbol_disabled_hook:ty) => { + mock_band_config!( + $runtime, + oracle_proxy::Pallet<$runtime>, + $on_symbol_disabled_hook + ); + }; + ($runtime:ty) => { + mock_band_config!($runtime, oracle_proxy::Pallet<$runtime>, ()); + }; } /// Mock of pallet `common::Config`. @@ -280,10 +278,10 @@ macro_rules! mock_pallet_balances_config { macro_rules! mock_common_config { ($runtime:ty) => { impl common::Config for $runtime { + type AssetManager = assets::Pallet<$runtime>; type DEXId = DEXId; type LstId = common::LiquiditySourceType; type MultiCurrency = currencies::Pallet<$runtime>; - type AssetManager = assets::Pallet<$runtime>; } }; } @@ -293,9 +291,68 @@ macro_rules! mock_common_config { macro_rules! mock_currencies_config { ($runtime:ty) => { impl currencies::Config for $runtime { + type GetNativeCurrencyId = <$runtime as assets::Config>::GetBaseAssetId; type MultiCurrency = Tokens; type NativeCurrency = BasicCurrencyAdapter<$runtime, Balances, Amount, BlockNumber>; - type GetNativeCurrencyId = <$runtime as assets::Config>::GetBaseAssetId; + type WeightInfo = (); + } + }; +} + +/// Mock of pallet `dex_api::Config`. +#[macro_export] +macro_rules! mock_dex_api_config { + ( + $runtime:ty, + $mcbc_pool:ty, + $xyk_pool:ty, + $xst_pool:ty, + $liquidity_source:ty, + $liquidity_source2:ty, + $liquidity_source3:ty, + $liquidity_source4:ty + ) => { + impl dex_api::Config for $runtime { + type DexInfoProvider = dex_manager::Pallet<$runtime>; + type MockLiquiditySource = $liquidity_source; + type MockLiquiditySource2 = $liquidity_source2; + type MockLiquiditySource3 = $liquidity_source3; + type MockLiquiditySource4 = $liquidity_source4; + type MulticollateralBondingCurvePool = $mcbc_pool; + type OrderBook = (); + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); + type XSTPool = $xst_pool; + type XYKPool = $xyk_pool; + } + }; + ($runtime:ty, $mcbc_pool:ty, $xyk_pool:ty, $xst_pool:ty) => { + mock_dex_api_config!($runtime, $mcbc_pool, $xyk_pool, $xst_pool, (), (), (), ()); + }; + ($runtime:ty, $mcbc_pool:ty) => { + mock_dex_api_config!($runtime, $mcbc_pool, pool_xyk::Pallet<$runtime>, ()); + }; + ($runtime:ty) => { + mock_dex_api_config!($runtime, ()); + }; +} + +/// Mock of pallet `dex_manager::Config`. +#[macro_export] +macro_rules! mock_dex_manager_config { + ($runtime:ty) => { + impl dex_manager::Config for $runtime {} + }; +} + +/// Mock of pallet `extended_assets::Config`. +#[macro_export] +macro_rules! mock_extended_assets_config { + ($runtime:ty) => { + impl extended_assets::Config for $runtime { + type AssetInfoProvider = assets::Pallet<$runtime>; + type MaxRegulatedAssetsPerSBT = ConstU32<10000>; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } }; @@ -304,86 +361,149 @@ macro_rules! mock_currencies_config { /// Mock of pallet `frame_system::Config`. #[macro_export] macro_rules! mock_frame_system_config { - ($runtime:ty) => { + ($runtime:ty, $ss58_prefix:ty, $max_consumers:ty, $account_data:ty) => { impl frame_system::Config for $runtime { + type AccountData = $account_data; + type AccountId = AccountId; type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = (); + type BlockHashCount = frame_support::traits::ConstU64<250>; type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type Index = u64; type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = frame_support::traits::ConstU64<250>; + type BlockWeights = (); type DbWeight = (); - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; - type OnNewAccount = (); + type Hash = sp_core::H256; + type Hashing = sp_runtime::traits::BlakeTwo256; + type Header = sp_runtime::testing::Header; + type Index = u64; + type Lookup = sp_runtime::traits::IdentityLookup; + type MaxConsumers = $max_consumers; type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); + type OnNewAccount = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<65536>; + type PalletInfo = PalletInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type SS58Prefix = $ss58_prefix; + type SystemWeightInfo = (); + type Version = (); } }; + ($runtime:ty, $ss58_prefix:ty, $max_consumers:ty) => { + mock_frame_system_config!( + $runtime, + $ss58_prefix, + $max_consumers, + pallet_balances::AccountData + ); + }; + ($runtime:ty, $ss58_prefix:ty) => { + mock_frame_system_config!( + $runtime, + $ss58_prefix, + frame_support::traits::ConstU32<65536> + ); + }; + ($runtime:ty) => { + mock_frame_system_config!($runtime, ()); + }; } -/// Mock of pallet `permissions::Config`. +/// Mock of pallet `liquidity_proxy::Config`. #[macro_export] -macro_rules! mock_permissions_config { +macro_rules! mock_liquidity_proxy_config { ($runtime:ty) => { - impl permissions::Config for $runtime { + frame_support::parameter_types! { + pub GetLiquidityProxyTechAccountId: TechAccountId = { + TechAccountId::from_generic_pair( + liquidity_proxy::TECH_ACCOUNT_PREFIX.to_vec(), + liquidity_proxy::TECH_ACCOUNT_MAIN.to_vec(), + ) + }; + pub GetLiquidityProxyAccountId: AccountId = { + let tech_account_id = GetLiquidityProxyTechAccountId::get(); + technical::Pallet::::tech_account_id_to_account_id(&tech_account_id) + .expect("Failed to get ordinary account id for technical account id.") + }; + pub GetInternalSlippageTolerancePercent: sp_runtime::Permill = sp_runtime::Permill::from_rational(1u32, 1000); // 0.1% + } + impl liquidity_proxy::Config for $runtime { + type ADARCommissionRatioUpdateOrigin = + frame_system::EnsureRoot; + type AssetInfoProvider = assets::Pallet<$runtime>; + type DexInfoProvider = dex_manager::Pallet<$runtime>; + type GetADARAccountId = GetADARAccountId; + type GetChameleonPools = common::mock::GetChameleonPools; + type GetNumSamples = GetNumSamples; + type GetTechnicalAccountId = GetLiquidityProxyAccountId; + type InternalSlippageTolerance = GetInternalSlippageTolerancePercent; + type LiquidityRegistry = dex_api::Pallet<$runtime>; + type LockedLiquiditySourcesManager = trading_pair::Pallet<$runtime>; + type MaxAdditionalDataLengthSwapTransferBatch = ConstU32<2000>; + type MaxAdditionalDataLengthXorlessTransfer = ConstU32<128>; + type PrimaryMarketTBC = (); + type PrimaryMarketXST = (); type RuntimeEvent = RuntimeEvent; + type SecondaryMarket = (); + type TradingPairSourceManager = trading_pair::Pallet<$runtime>; + type VestedRewardsPallet = vested_rewards::Pallet<$runtime>; + type WeightInfo = (); } }; } -/// Mock of pallet `technical::Config`. +/// Mock of pallet `multicollateral_bonding_curve_pool::Config`. #[macro_export] -macro_rules! mock_technical_config { - ($runtime:ty, $swap_action:ty) => { - impl technical::Config for $runtime { - type RuntimeEvent = RuntimeEvent; - type TechAssetId = TechAssetId; - type TechAccountId = TechAccountId; - type Trigger = (); - type Condition = (); - type SwapAction = $swap_action; +macro_rules! mock_multicollateral_bonding_curve_pool_config { + ($runtime:ty, $liquidity_proxy:ty, $buy_back_handler:ty, $price_tool:ty, $trading_pair:ty) => { + frame_support::parameter_types! { + pub GetTBCBuyBackTBCDPercent: common::Fixed = common::fixed!(0.025); + pub GetTbcIrreducibleReservePercent: sp_runtime::Percent = sp_runtime::Percent::from_percent(1); + } + impl multicollateral_bonding_curve_pool::Config for $runtime { + const RETRY_DISTRIBUTION_FREQUENCY: BlockNumber = 1000; type AssetInfoProvider = assets::Pallet<$runtime>; + type BuyBackHandler = $buy_back_handler; + type BuyBackTBCDPercent = GetTBCBuyBackTBCDPercent; + type EnsureDEXManager = dex_manager::Pallet<$runtime>; + type EnsureTradingPairExists = $trading_pair; + type IrreducibleReserve = GetTbcIrreducibleReservePercent; + type LiquidityProxy = $liquidity_proxy; + type PriceToolsPallet = $price_tool; + type RuntimeEvent = RuntimeEvent; + type TradingPairSourceManager = $trading_pair; + type VestedRewardsPallet = VestedRewards; + type WeightInfo = (); } }; + ($runtime:ty, $liquidity_proxy:ty, $buy_back_handler:ty, $price_tool:ty) => { + mock_multicollateral_bonding_curve_pool_config!($runtime, $liquidity_proxy, $buy_back_handler, $price_tool, trading_pair::Pallet<$runtime>); + }; + ($runtime:ty, $liquidity_proxy:ty, $buy_back_handler:ty) => { + mock_multicollateral_bonding_curve_pool_config!($runtime, $liquidity_proxy, $buy_back_handler, ()); + }; + ($runtime:ty, $liquidity_proxy:ty) => { + mock_multicollateral_bonding_curve_pool_config!($runtime, $liquidity_proxy, ()); + }; ($runtime:ty) => { - mock_technical_config!($runtime, ()); + mock_multicollateral_bonding_curve_pool_config!($runtime, ()); }; } -/// Mock of pallet `tokens::Config`. +/// Mock of pallet `oracle_proxy::Config`. #[macro_export] -macro_rules! mock_tokens_config { - ($runtime:ty) => { - frame_support::parameter_types! { - pub const MaxLocks: u32 = 1; - } - impl tokens::Config for $runtime { +macro_rules! mock_oracle_proxy_config { + ($runtime:ty, $band_chain_oracle:ty) => { + impl oracle_proxy::Config for $runtime { + type BandChainOracle = $band_chain_oracle; type RuntimeEvent = RuntimeEvent; - type Balance = Balance; - type Amount = Amount; - type CurrencyId = <$runtime as assets::Config>::AssetId; + type Symbol = <$runtime as band::Config>::Symbol; type WeightInfo = (); - type ExistentialDeposits = ExistentialDeposits; - type CurrencyHooks = (); - type MaxLocks = MaxLocks; - type MaxReserves = (); - type ReserveIdentifier = (); - type DustRemovalWhitelist = Everything; } }; + ($runtime:ty) => { + mock_oracle_proxy_config!($runtime, band::Pallet<$runtime>); + }; } /// Mock of pallet `orml_tokens::Config`. @@ -391,189 +511,292 @@ macro_rules! mock_tokens_config { macro_rules! mock_orml_tokens_config { ($runtime:ty) => { impl orml_tokens::Config for $runtime { - type RuntimeEvent = RuntimeEvent; - type Balance = Balance; type Amount = Amount; + type Balance = Balance; + type CurrencyHooks = (); type CurrencyId = <$runtime as assets::Config>::AssetId; - type WeightInfo = (); + type DustRemovalWhitelist = Everything; type ExistentialDeposits = ExistentialDeposits; - type CurrencyHooks = (); type MaxLocks = (); type MaxReserves = (); type ReserveIdentifier = (); - type DustRemovalWhitelist = Everything; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); } }; } -/// Mock of pallet `pallet_timestamp::Config`. +/// Mock of pallet `pallet_balances::Config`. #[macro_export] -macro_rules! mock_pallet_timestamp_config { +macro_rules! mock_pallet_balances_config { ($runtime:ty) => { frame_support::parameter_types! { - pub const MinimumPeriod: u64 = 5; + pub const ExistentialDeposit: u128 = 0; } - impl pallet_timestamp::Config for $runtime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; + impl pallet_balances::Config for $runtime { + type AccountStore = System; + type Balance = Balance; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type MaxLocks = (); + type MaxReserves = (); + type ReserveIdentifier = (); + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } }; } -/// Mock of pallet `vested-rewards::Config` +/// Mock of pallet `pallet_timestamp::Config`. #[macro_export] -macro_rules! mock_vested_rewards_config { +macro_rules! mock_pallet_timestamp_config { ($runtime:ty) => { frame_support::parameter_types! { - pub const MaxVestingSchedules: u32 = 0; - pub const MinVestedTransfer: Balance = 0; + pub const MinimumPeriod: u64 = 5; } - impl vested_rewards::Config for Runtime { - const BLOCKS_PER_DAY: BlockNumberFor = 14400; - type RuntimeEvent = RuntimeEvent; - type GetMarketMakerRewardsAccountId = GetMarketMakerRewardsAccountId; - type GetBondingCurveRewardsAccountId = GetBondingCurveRewardsAccountId; - type GetFarmingRewardsAccountId = GetFarmingRewardsAccountId; + impl pallet_timestamp::Config for $runtime { + type MinimumPeriod = MinimumPeriod; + type Moment = u64; + type OnTimestampSet = (); type WeightInfo = (); - type AssetInfoProvider = assets::Pallet; - type MaxVestingSchedules = MaxVestingSchedules; - type Currency = Tokens; - type MinVestedTransfer = MinVestedTransfer; - type MaxWeightForAutoClaim = (); } }; } -/// Mock of pallet `dex_manager::Config`. +/// Mock of pallet `permissions::Config`. #[macro_export] -macro_rules! mock_dex_manager_config { +macro_rules! mock_permissions_config { ($runtime:ty) => { - impl dex_manager::Config for $runtime {} + impl permissions::Config for $runtime { + type RuntimeEvent = RuntimeEvent; + } }; } -/// Mock of pallet `trading_pair::Config`. +/// Mock of pallet `pool_xyk::Config`. #[macro_export] -macro_rules! mock_trading_pair_config { - ($runtime:ty) => { - impl trading_pair::Config for $runtime { - type RuntimeEvent = RuntimeEvent; - type EnsureDEXManager = dex_manager::Pallet<$runtime>; +macro_rules! mock_pool_xyk_config { + ($runtime:ty, $trading_pair:ty, $enabled_sources:ty, $on_pool_created:ty) => { + frame_support::parameter_types! { + pub GetXykFee: common::Fixed = common::fixed!(0.003); + pub GetXykIrreducibleReservePercent: sp_runtime::Percent = sp_runtime::Percent::from_percent(1); + pub GetXykMaxIssuanceRatio: common::Fixed = common::fixed!(1.5); + } + impl pool_xyk::Config for $runtime { + const MIN_XOR: Balance = balance!(0.0007); + type AssetInfoProvider = assets::Pallet<$runtime>; + type AssetRegulator = (); + type DepositLiquidityAction = + pool_xyk::DepositLiquidityAction; type DexInfoProvider = dex_manager::Pallet<$runtime>; + type EnabledSourcesManager = $enabled_sources; + type EnsureDEXManager = dex_manager::Pallet<$runtime>; + type EnsureTradingPairExists = $enabled_sources; + type GetChameleonPools = common::mock::GetChameleonPools; + type GetFee = GetXykFee; + type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; + type GetTradingPairRestrictedFlag = common::mock::GetTradingPairRestrictedFlag; + type IrreducibleReserve = GetXykIrreducibleReservePercent; + type OnPoolCreated = $on_pool_created; + type OnPoolReservesChanged = (); + type PairSwapAction = + pool_xyk::PairSwapAction; + type PolySwapAction = + pool_xyk::PolySwapAction; + type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; + type RuntimeEvent = RuntimeEvent; + type TradingPairSourceManager = $trading_pair; type WeightInfo = (); - type AssetInfoProvider = assets::Pallet<$runtime>; + type WithdrawLiquidityAction = + pool_xyk::WithdrawLiquidityAction; + type XSTMarketInfo = (); } }; + ($runtime:ty, $trading_pair:ty, $enabled_trading_pair:ty) => { + mock_pool_xyk_config!( + $runtime, + $trading_pair, + $enabled_trading_pair, + PswapDistribution + ); + }; + ($runtime:ty, $trading_pair:ty) => { + mock_pool_xyk_config!($runtime, $trading_pair, trading_pair::Pallet<$runtime>); + }; + ($runtime:ty) => { + mock_pool_xyk_config!($runtime, trading_pair::Pallet<$runtime>); + }; } /// Mock of pallet `price_tools::Config`. #[macro_export] macro_rules! mock_price_tools_config { - ($runtime:ty) => { + ($runtime:ty, $liquidity_proxy:ty) => { impl price_tools::Config for $runtime { + type LiquidityProxy = $liquidity_proxy; type RuntimeEvent = RuntimeEvent; - type LiquidityProxy = (); - type TradingPairSourceManager = trading_pair::Pallet; - type WeightInfo = price_tools::weights::SubstrateWeight; + type TradingPairSourceManager = trading_pair::Pallet<$runtime>; + type WeightInfo = price_tools::weights::SubstrateWeight<$runtime>; } }; + ($runtime:ty) => { + mock_price_tools_config!($runtime, ()); + }; } -/// Mock of pallet `band::Config`. +/// Mock of pallet `pswap_distribution::Config`. #[macro_export] -macro_rules! mock_band_config { - ($runtime:ty, $on_new_symbol_relayed_hook:ty, $on_symbol_disabled_hook:ty) => { +macro_rules! mock_pswap_distribution_config { + ( + $runtime:ty, + $xyk_pool:ty, + $chameleon_pools:ty, + $liquidity_proxy:ty, + $buy_back_handler:ty + ) => { frame_support::parameter_types! { - pub const GetBandRateStalePeriod: u64 = 60*5*1000; // 5 minutes - pub const GetBandRateStaleBlockPeriod: u64 = 600; + pub GetIncentiveAssetId: AssetId = common::PSWAP.into(); } - impl band::Config for $runtime { + impl pswap_distribution::Config for $runtime { + const PSWAP_BURN_PERCENT: sp_runtime::Percent = sp_runtime::Percent::from_percent(3); + type AssetInfoProvider = assets::Pallet<$runtime>; + type BuyBackHandler = $buy_back_handler; + type CompatBalance = Balance; + type DexInfoProvider = dex_manager::Pallet<$runtime>; + type EnsureDEXManager = (); + type GetBurnUpdateFrequency = GetBurnUpdateFrequency; + type GetBuyBackAssetId = GetBuyBackAssetId; + type GetChameleonPools = $chameleon_pools; + type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; + type GetIncentiveAssetId = GetIncentiveAssetId; + type GetParliamentAccountId = GetParliamentAccountId; + type GetTechnicalAccountId = GetPswapDistributionAccountId; + type LiquidityProxy = $liquidity_proxy; + type OnPswapBurnedAggregator = (); + type PoolXykPallet = $xyk_pool; type RuntimeEvent = RuntimeEvent; - type Symbol = common::SymbolName; type WeightInfo = (); - type OnNewSymbolsRelayedHook = $on_new_symbol_relayed_hook; - type OnSymbolDisabledHook = $on_symbol_disabled_hook; - type GetBandRateStalePeriod = GetBandRateStalePeriod; - type GetBandRateStaleBlockPeriod = GetBandRateStaleBlockPeriod; - type MaxRelaySymbols = frame_support::traits::ConstU32<100>; - type Time = Timestamp; } }; - ($runtime:ty, $on_symbol_disabled_hook:ty) => { - mock_band_config!( + ($runtime:ty, $xyk_pool:ty, $chameleon_pools:ty, $liquidity_proxy:ty) => { + mock_pswap_distribution_config!( $runtime, - oracle_proxy::Pallet, - $on_symbol_disabled_hook + $xyk_pool, + $chameleon_pools, + $liquidity_proxy, + () ); }; + ($runtime:ty, $xyk_pool:ty, $chameleon_pools:ty) => { + mock_pswap_distribution_config!($runtime, $xyk_pool, $chameleon_pools, ()); + }; + ($runtime:ty, $xyk_pool:ty) => { + mock_pswap_distribution_config!($runtime, $xyk_pool, common::mock::GetChameleonPools); + }; ($runtime:ty) => { - mock_band_config!($runtime, oracle_proxy::Pallet, ()); + mock_pswap_distribution_config!($runtime, pool_xyk::Pallet<$runtime>); }; } -/// Mock of pallet `oracle_proxy::Config`. +/// Mock of pallet `technical::Config`. #[macro_export] -macro_rules! mock_oracle_proxy_config { - ($runtime:ty, $band_chain_oracle:ty) => { - impl oracle_proxy::Config for $runtime { +macro_rules! mock_technical_config { + ($runtime:ty, $swap_action:ty) => { + impl technical::Config for $runtime { + type AssetInfoProvider = assets::Pallet<$runtime>; + type Condition = (); + type RuntimeEvent = RuntimeEvent; + type SwapAction = $swap_action; + type TechAccountId = TechAccountId; + type TechAssetId = TechAssetId; + type Trigger = (); + } + }; + ($runtime:ty) => { + mock_technical_config!($runtime, ()); + }; +} + +/// Mock of pallet `tokens::Config`. +#[macro_export] +macro_rules! mock_tokens_config { + ($runtime:ty) => { + frame_support::parameter_types! { + pub const MaxLocks: u32 = 1; + } + impl tokens::Config for $runtime { + type Amount = Amount; + type Balance = Balance; + type CurrencyHooks = (); + type CurrencyId = <$runtime as assets::Config>::AssetId; + type DustRemovalWhitelist = Everything; + type ExistentialDeposits = ExistentialDeposits; + type MaxLocks = MaxLocks; + type MaxReserves = (); + type ReserveIdentifier = (); type RuntimeEvent = RuntimeEvent; - type BandChainOracle = $band_chain_oracle; - type Symbol = ::Symbol; type WeightInfo = (); } }; +} + +/// Mock of pallet `trading_pair::Config`. +#[macro_export] +macro_rules! mock_trading_pair_config { ($runtime:ty) => { - mock_oracle_proxy_config!($runtime, band::Pallet); + impl trading_pair::Config for $runtime { + type AssetInfoProvider = assets::Pallet<$runtime>; + type DexInfoProvider = dex_manager::Pallet<$runtime>; + type EnsureDEXManager = dex_manager::Pallet<$runtime>; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); + } }; } -/// Mock of pallet `dex_api::Config`. +/// Mock of pallet `vested-rewards::Config` #[macro_export] -macro_rules! mock_dex_api_config { - ( - $runtime:ty, - $mcbc_pool:ty, - $xyk_pool:ty, - $xst_pool:ty, - $mock_liquidity_source:ty, - $mock_liquidity_source2:ty, - $mock_liquidity_source3:ty, - $mock_liquidity_source4:ty - ) => { - impl dex_api::Config for $runtime { +macro_rules! mock_vested_rewards_config { + ($runtime:ty) => { + frame_support::parameter_types! { + pub const MaxVestingSchedules: u32 = 0; + pub const MinVestedTransfer: common::prelude::Balance = 0; + } + impl vested_rewards::Config for $runtime { + const BLOCKS_PER_DAY: BlockNumberFor = 14400; + type AssetInfoProvider = assets::Pallet<$runtime>; + type Currency = Tokens; + type GetBondingCurveRewardsAccountId = GetBondingCurveRewardsAccountId; + type GetFarmingRewardsAccountId = GetFarmingRewardsAccountId; + type GetMarketMakerRewardsAccountId = GetMarketMakerRewardsAccountId; + type MaxVestingSchedules = MaxVestingSchedules; + type MaxWeightForAutoClaim = (); + type MinVestedTransfer = MinVestedTransfer; type RuntimeEvent = RuntimeEvent; - type MulticollateralBondingCurvePool = $mcbc_pool; - type XYKPool = $xyk_pool; - type XSTPool = $xst_pool; - type MockLiquiditySource = $mock_liquidity_source; - type MockLiquiditySource2 = $mock_liquidity_source2; - type MockLiquiditySource3 = $mock_liquidity_source3; - type MockLiquiditySource4 = $mock_liquidity_source4; - type DexInfoProvider = dex_manager::Pallet; - type OrderBook = (); type WeightInfo = (); } }; - ( - $runtime:ty, - $mcbc_pool:ty, - $xyk_pool:ty, - $xst_pool:ty - ) => { - mock_dex_api_config!($runtime, $mcbc_pool, $xyk_pool, $xst_pool, (), (), (), ()); +} + +/// Mock of pallet `xst::Config`. +#[macro_export] +macro_rules! mock_xst_config { + ($runtime:ty, $price_tool:ty) => { + impl xst::Config for $runtime { + type AssetInfoProvider = assets::Pallet<$runtime>; + type EnsureDEXManager = dex_manager::Pallet<$runtime>; + type GetSyntheticBaseAssetId = GetSyntheticBaseAssetId; + type GetSyntheticBaseBuySellLimit = GetSyntheticBaseBuySellLimit; + type GetXSTPoolPermissionedTechAccountId = GetXSTPoolPermissionedTechAccountId; + type Oracle = OracleProxy; + type PriceToolsPallet = $price_tool; + type RuntimeEvent = RuntimeEvent; + type Symbol = common::SymbolName; + type TradingPairSourceManager = trading_pair::Pallet<$runtime>; + type WeightInfo = (); + } }; ($runtime:ty) => { - mock_dex_api_config!( - $runtime, - multicollateral_bonding_curve_pool::Pallet<$runtime>, - pool_xyk::Pallet, - (), - (), - (), - (), - () - ); + mock_xst_config!($runtime, ()); }; } diff --git a/pallets/apollo-platform/src/mock.rs b/pallets/apollo-platform/src/mock.rs index d5dd2ea65..51957a146 100644 --- a/pallets/apollo-platform/src/mock.rs +++ b/pallets/apollo-platform/src/mock.rs @@ -1,36 +1,32 @@ use { crate as apollo_platform, common::{ - balance, fixed, hash, - mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}, + balance, hash, + mock::ExistentialDeposits, mock_assets_config, mock_common_config, mock_currencies_config, mock_dex_api_config, - mock_dex_manager_config, mock_frame_system_config, mock_pallet_balances_config, - mock_pallet_timestamp_config, mock_permissions_config, mock_price_tools_config, - mock_technical_config, mock_tokens_config, mock_trading_pair_config, - mock_vested_rewards_config, + mock_dex_manager_config, mock_frame_system_config, mock_liquidity_proxy_config, + mock_multicollateral_bonding_curve_pool_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_price_tools_config, mock_pswap_distribution_config, mock_technical_config, + mock_tokens_config, mock_trading_pair_config, mock_vested_rewards_config, prelude::{Balance, SwapOutcome}, AssetId32, AssetName, AssetSymbol, BalancePrecision, ContentSource, DEXId::Polkaswap, - DEXInfo, Description, Fixed, FromGenericPair, LiquidityProxyTrait, PriceToolsProvider, - PriceVariant, APOLLO_ASSET_ID, CERES_ASSET_ID, DAI, DOT, KSM, PSWAP, VXOR, XOR, XST, + DEXInfo, Description, FromGenericPair, LiquidityProxyTrait, PriceToolsProvider, + PriceVariant, APOLLO_ASSET_ID, CERES_ASSET_ID, DAI, DOT, KSM, VXOR, XOR, XST, }, currencies::BasicCurrencyAdapter, frame_support::{ construct_runtime, pallet_prelude::Weight, parameter_types, - traits::{ConstU64, Everything, GenesisBuild, Hooks}, + traits::{ConstU32, ConstU64, Everything, GenesisBuild, Hooks}, }, frame_system::{ - self, offchain::SendTransactionTypes, pallet_prelude::BlockNumberFor, EnsureRoot, RawOrigin, + self, offchain::SendTransactionTypes, pallet_prelude::BlockNumberFor, RawOrigin, }, permissions::{Scope, MANAGE_DEX}, - sp_core::{ConstU32, H256}, - sp_runtime::{ - testing::{Header, TestXt}, - traits::{BlakeTwo256, IdentityLookup, Zero}, - AccountId32, Perbill, Percent, Permill, - }, + sp_runtime::{testing::TestXt, traits::Zero, AccountId32, Perbill}, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -94,13 +90,17 @@ pub type MockExtrinsic = TestXt; mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); -mock_dex_api_config!(Runtime); +mock_dex_api_config!(Runtime, multicollateral_bonding_curve_pool::Pallet); mock_dex_manager_config!(Runtime); mock_frame_system_config!(Runtime); +mock_liquidity_proxy_config!(Runtime); +mock_multicollateral_bonding_curve_pool_config!(Runtime); mock_pallet_balances_config!(Runtime); mock_pallet_timestamp_config!(Runtime); mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime); mock_price_tools_config!(Runtime); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); mock_trading_pair_config!(Runtime); @@ -119,9 +119,6 @@ parameter_types! { pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub GetIncentiveAssetId: AssetId = PSWAP; pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; pub GetParliamentAccountId: AccountId = AccountId32::from([100; 32]); @@ -132,47 +129,10 @@ parameter_types! { pub const GetNumSamples: usize = 40; pub const GetBaseAssetId: AssetId = APOLLO_ASSET_ID; pub const GetBuyBackAssetId: AssetId = VXOR; - pub GetLiquidityProxyTechAccountId: TechAccountId = { - TechAccountId::from_generic_pair( - liquidity_proxy::TECH_ACCOUNT_PREFIX.to_vec(), - liquidity_proxy::TECH_ACCOUNT_MAIN.to_vec(), - ) - }; - pub GetLiquidityProxyAccountId: AccountId = { - let tech_account_id = GetLiquidityProxyTechAccountId::get(); - technical::Pallet::::tech_account_id_to_account_id(&tech_account_id) - .expect("Failed to get ordinary account id for technical account id.") - }; pub GetADARAccountId: AccountId = AccountId32::from([14; 32]); pub GetMarketMakerRewardsAccountId: AccountId = AccountId32::from([9; 32]); pub GetBondingCurveRewardsAccountId: AccountId = AccountId32::from([10; 32]); pub GetFarmingRewardsAccountId: AccountId = AccountId32::from([12; 32]); - pub GetTBCBuyBackTBCDPercent: Fixed = fixed!(0.025); - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); - pub GetTbcIrreducibleReservePercent: Percent = Percent::from_percent(1); - pub GetInternalSlippageTolerancePercent: Permill = Permill::from_rational(1u32, 1000); // 0.1% -} - -impl liquidity_proxy::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type LiquidityRegistry = dex_api::Pallet; - type GetNumSamples = GetNumSamples; - type GetTechnicalAccountId = GetLiquidityProxyAccountId; - type PrimaryMarketTBC = (); - type PrimaryMarketXST = (); - type SecondaryMarket = (); - type VestedRewardsPallet = vested_rewards::Pallet; - type LockedLiquiditySourcesManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type GetADARAccountId = GetADARAccountId; - type ADARCommissionRatioUpdateOrigin = EnsureRoot; - type MaxAdditionalDataLengthXorlessTransfer = ConstU32<128>; - type MaxAdditionalDataLengthSwapTransferBatch = ConstU32<2000>; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type InternalSlippageTolerance = GetInternalSlippageTolerancePercent; - type WeightInfo = (); } impl ceres_liquidity_locker::Config for Runtime { @@ -184,71 +144,6 @@ impl ceres_liquidity_locker::Config for Runtime { type WeightInfo = (); } -impl multicollateral_bonding_curve_pool::Config for Runtime { - const RETRY_DISTRIBUTION_FREQUENCY: BlockNumber = 1000; - type RuntimeEvent = RuntimeEvent; - type LiquidityProxy = (); - type EnsureDEXManager = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type PriceToolsPallet = (); - type VestedRewardsPallet = VestedRewards; - type TradingPairSourceManager = trading_pair::Pallet; - type BuyBackHandler = (); - type BuyBackTBCDPercent = GetTBCBuyBackTBCDPercent; - type AssetInfoProvider = assets::Pallet; - type IrreducibleReserve = GetTbcIrreducibleReservePercent; - type WeightInfo = (); -} - -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - -impl pswap_distribution::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - pub struct MockPriceTools; impl PriceToolsProvider for MockPriceTools { diff --git a/pallets/assets/src/mock.rs b/pallets/assets/src/mock.rs index 3a32756ee..78b5a486a 100644 --- a/pallets/assets/src/mock.rs +++ b/pallets/assets/src/mock.rs @@ -40,9 +40,6 @@ use currencies::BasicCurrencyAdapter; use frame_support::traits::{Everything, GenesisBuild}; use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types}; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_runtime::DispatchError; use sp_runtime::Perbill; diff --git a/pallets/band/src/mock.rs b/pallets/band/src/mock.rs index b1b4edb86..650dc23f5 100644 --- a/pallets/band/src/mock.rs +++ b/pallets/band/src/mock.rs @@ -29,20 +29,15 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use crate::{self as band, Config}; -use common::{mock_oracle_proxy_config, mock_pallet_timestamp_config}; +use common::{mock_frame_system_config, mock_oracle_proxy_config, mock_pallet_timestamp_config}; use frame_support::{ construct_runtime, parameter_types, - traits::{ConstU16, ConstU64}, -}; -use frame_system as system; -use sp_core::H256; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{ConstU16, ConstU32}, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; +type AccountId = u64; type Moment = u64; // Configure a mock runtime to test the pallet. @@ -64,33 +59,6 @@ parameter_types! { pub const GetRateStaleBlockPeriod: u64 = 600; } -impl system::Config for Runtime { - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU64<250>; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = ConstU16<42>; - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - impl Config for Runtime { type Symbol = String; type RuntimeEvent = RuntimeEvent; @@ -103,12 +71,13 @@ impl Config for Runtime { type MaxRelaySymbols = frame_support::traits::ConstU32<100>; } +mock_frame_system_config!(Runtime, ConstU16<42>, ConstU32<16>, ()); mock_oracle_proxy_config!(Runtime); mock_pallet_timestamp_config!(Runtime); // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default() + frame_system::GenesisConfig::default() .build_storage::() .unwrap() .into() diff --git a/pallets/bridge-proxy/src/mock.rs b/pallets/bridge-proxy/src/mock.rs index 540c85638..3e464593e 100644 --- a/pallets/bridge-proxy/src/mock.rs +++ b/pallets/bridge-proxy/src/mock.rs @@ -40,21 +40,16 @@ use bridge_types::{GenericNetworkId, H160}; use common::mock::ExistentialDeposits; use common::{ balance, mock_assets_config, mock_common_config, mock_currencies_config, - mock_pallet_balances_config, mock_pallet_timestamp_config, mock_permissions_config, - mock_technical_config, mock_tokens_config, Amount, AssetId32, AssetName, AssetSymbol, Balance, - DEXId, FromGenericPair, PredefinedAssetId, DAI, ETH, XOR, XST, + mock_frame_system_config, mock_pallet_balances_config, mock_pallet_timestamp_config, + mock_permissions_config, mock_technical_config, mock_tokens_config, Amount, AssetId32, + AssetName, AssetSymbol, Balance, DEXId, FromGenericPair, PredefinedAssetId, DAI, ETH, XOR, XST, }; use frame_support::parameter_types; -use frame_support::traits::{Everything, GenesisBuild}; -use frame_system as system; -use sp_core::{ConstU128, ConstU64}; +use frame_support::traits::{ConstU128, ConstU32, ConstU64, Everything, GenesisBuild}; +use frame_system::{self, EnsureRoot}; use sp_keyring::sr25519::Keyring; -use sp_runtime::testing::Header; -use sp_runtime::traits::{ - BlakeTwo256, Convert, IdentifyAccount, IdentityLookup, Keccak256, Verify, -}; +use sp_runtime::traits::{Convert, IdentifyAccount, Keccak256, Verify}; use sp_runtime::{AccountId32, DispatchResult, MultiSignature}; -use system::EnsureRoot; use crate as proxy; @@ -85,14 +80,13 @@ frame_support::construct_runtime!( ); pub type Signature = MultiSignature; - pub type AccountId = <::Signer as IdentifyAccount>::AccountId; - pub const BASE_EVM_NETWORK_ID: EVMChainId = EVMChainId::zero(); mock_assets_config!(Test); mock_common_config!(Test); mock_currencies_config!(Test); +mock_frame_system_config!(Test, (), ConstU32<65536>); mock_pallet_balances_config!(Test); mock_pallet_timestamp_config!(Test); mock_permissions_config!(Test); @@ -101,36 +95,6 @@ mock_tokens_config!(Test); parameter_types! { pub const BlockHashCount: u64 = 250; -} - -impl system::Config for Test { - type BaseCallFilter = Everything; - type BlockWeights = (); - type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; - 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 = (); - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<65536>; -} - -parameter_types! { pub const GetBaseAssetId: AssetId = XOR; pub const GetBuyBackAssetId: AssetId = XST; } @@ -155,6 +119,7 @@ parameter_types! { pub const Decimals: u32 = 12; } pub struct FeeConverter; + impl Convert for FeeConverter { fn convert(amount: U256) -> Balance { common::eth::unwrap_balance(amount, Decimals::get()) @@ -295,7 +260,7 @@ impl proxy::Config for Test { } pub fn new_tester() -> sp_io::TestExternalities { - let mut storage = system::GenesisConfig::default() + let mut storage = frame_system::GenesisConfig::default() .build_storage::() .unwrap(); diff --git a/pallets/ceres-governance-platform/src/mock.rs b/pallets/ceres-governance-platform/src/mock.rs index 3b099258a..01fff2da1 100644 --- a/pallets/ceres-governance-platform/src/mock.rs +++ b/pallets/ceres-governance-platform/src/mock.rs @@ -1,23 +1,21 @@ use crate::{self as ceres_governance_platform}; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::Balance; use common::{ - balance, fixed, mock_assets_config, mock_common_config, mock_currencies_config, - mock_frame_system_config, mock_pallet_balances_config, mock_technical_config, - mock_tokens_config, AssetId32, AssetName, AssetSymbol, BalancePrecision, ContentSource, - Description, Fixed, CERES_ASSET_ID, PSWAP, VXOR, + balance, mock_assets_config, mock_common_config, mock_currencies_config, + mock_dex_manager_config, mock_frame_system_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, AssetId32, + AssetName, AssetSymbol, BalancePrecision, ContentSource, Description, CERES_ASSET_ID, VXOR, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::{Everything, GenesisBuild, Hooks}; use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types}; use frame_system::pallet_prelude::BlockNumberFor; -use hex_literal::hex; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Zero}; -use sp_runtime::{Perbill, Percent}; +use sp_runtime::traits::Zero; +use sp_runtime::Perbill; pub type TechAccountId = common::TechAccountId; type TechAssetId = common::TechAssetId; @@ -53,18 +51,19 @@ pub type BlockNumber = u64; pub type Amount = i128; pub type AssetId = AssetId32; -pub const ALICE: AccountId = AccountId::new(hex!( - "0000000000000000000000000000000000000000000000000000000000000001" -)); -pub const BOB: AccountId = AccountId::new(hex!( - "0000000000000000000000000000000000000000000000000000000000000002" -)); +pub const ALICE: AccountId = AccountId32::new([1u8; 32]); +pub const BOB: AccountId = AccountId32::new([2u8; 32]); mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); +mock_dex_manager_config!(Runtime); mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_pallet_timestamp_config!(Runtime); +mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime, (), ()); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); @@ -73,14 +72,10 @@ parameter_types! { pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub GetIncentiveAssetId: AssetId = PSWAP; pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; pub GetParliamentAccountId: AccountId = AccountId32::from([100; 32]); pub GetPswapDistributionAccountId: AccountId = AccountId32::from([101; 32]); - pub const MinimumPeriod: u64 = 5; } parameter_types! { @@ -99,15 +94,8 @@ impl crate::Config for Runtime { parameter_types! { pub const GetBaseAssetId: AssetId = CERES_ASSET_ID; pub const GetBuyBackAssetId: AssetId = VXOR; - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); } -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - -impl dex_manager::Config for Runtime {} - impl demeter_farming_platform::Config for Runtime { type RuntimeEvent = RuntimeEvent; type DemeterAssetId = (); @@ -116,41 +104,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = (); - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = (); - type EnabledSourcesManager = (); - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - -impl pallet_timestamp::Config for Runtime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; @@ -160,27 +113,6 @@ impl ceres_liquidity_locker::Config for Runtime { type WeightInfo = (); } -impl pswap_distribution::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - parameter_types! { pub const StringLimit: u32 = 64; pub const OptionsLimit: u32 = 6; diff --git a/pallets/ceres-launchpad/src/mock.rs b/pallets/ceres-launchpad/src/mock.rs index 6017d6bbd..56f6dd4f1 100644 --- a/pallets/ceres-launchpad/src/mock.rs +++ b/pallets/ceres-launchpad/src/mock.rs @@ -1,14 +1,16 @@ use crate::{self as ceres_launchpad}; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::Balance; pub use common::TechAssetId as Tas; pub use common::TechPurpose::*; use common::{ - balance, fixed, hash, mock_assets_config, mock_common_config, mock_currencies_config, - mock_frame_system_config, mock_pallet_balances_config, mock_technical_config, - mock_tokens_config, mock_vested_rewards_config, AssetName, AssetSymbol, BalancePrecision, - ContentSource, DEXId, DEXInfo, Description, Fixed, CERES_ASSET_ID, PSWAP, VXOR, XOR, XST, - XSTUSD, + balance, hash, mock_assets_config, mock_common_config, mock_currencies_config, + mock_dex_manager_config, mock_frame_system_config, + mock_multicollateral_bonding_curve_pool_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, + mock_trading_pair_config, mock_vested_rewards_config, AssetName, AssetSymbol, BalancePrecision, + ContentSource, DEXId, DEXInfo, Description, CERES_ASSET_ID, PSWAP, VXOR, XOR, XST, XSTUSD, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::{Everything, GenesisBuild, Hooks}; @@ -17,10 +19,8 @@ use frame_support::{construct_runtime, parameter_types}; use frame_system::pallet_prelude::BlockNumberFor; use permissions::{Scope, MANAGE_DEX}; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}; -use sp_runtime::{MultiSignature, Perbill, Percent}; +use sp_runtime::traits::{IdentifyAccount, Verify}; +use sp_runtime::{MultiSignature, Perbill}; pub type BlockNumber = u64; @@ -71,10 +71,17 @@ pub const DEX_B_ID: DEXId = DEXId::PolkaswapXSTUSD; mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); +mock_dex_manager_config!(Runtime); mock_frame_system_config!(Runtime); +mock_multicollateral_bonding_curve_pool_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_pallet_timestamp_config!(Runtime); +mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); +mock_trading_pair_config!(Runtime); mock_vested_rewards_config!(Runtime); parameter_types! { @@ -82,9 +89,6 @@ parameter_types! { pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub GetIncentiveAssetId: AssetId = PSWAP; pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; pub GetParliamentAccountId: AccountId = AccountId32::new([100u8; 32]); @@ -93,8 +97,6 @@ parameter_types! { pub GetBondingCurveRewardsAccountId: AccountId = AccountId32::new([103u8; 32]); pub GetFarmingRewardsAccountId: AccountId = AccountId32::new([104u8; 32]); pub GetCrowdloanRewardsAccountId: AccountId = AccountId32::new([105u8; 32]); - pub const MinimumPeriod: u64 = 5; - pub GetTbcIrreducibleReservePercent: Percent = Percent::from_percent(1); } impl crate::Config for Runtime { @@ -108,22 +110,6 @@ impl crate::Config for Runtime { parameter_types! { pub const GetBaseAssetId: AssetId = XOR; pub const GetBuyBackAssetId: AssetId = VXOR; - pub GetTBCBuyBackTBCDPercent: Fixed = fixed!(0.025); - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); -} - -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - -impl dex_manager::Config for Runtime {} - -impl trading_pair::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type EnsureDEXManager = dex_manager::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type WeightInfo = (); - type AssetInfoProvider = assets::Pallet; } impl demeter_farming_platform::Config for Runtime { @@ -134,50 +120,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - -impl multicollateral_bonding_curve_pool::Config for Runtime { - const RETRY_DISTRIBUTION_FREQUENCY: BlockNumber = 1000; - type RuntimeEvent = RuntimeEvent; - type LiquidityProxy = (); - type EnsureDEXManager = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type PriceToolsPallet = (); - type VestedRewardsPallet = VestedRewards; - type TradingPairSourceManager = trading_pair::Pallet; - type BuyBackHandler = (); - type BuyBackTBCDPercent = GetTBCBuyBackTBCDPercent; - type AssetInfoProvider = assets::Pallet; - type IrreducibleReserve = GetTbcIrreducibleReservePercent; - type WeightInfo = (); -} - parameter_types! { pub const CeresAssetId: AssetId = CERES_ASSET_ID; } @@ -189,13 +131,6 @@ impl ceres_token_locker::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pallet_timestamp::Config for Runtime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; @@ -205,27 +140,6 @@ impl ceres_liquidity_locker::Config for Runtime { type WeightInfo = (); } -impl pswap_distribution::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - #[allow(clippy::type_complexity)] pub struct ExtBuilder { pub endowed_assets: Vec<( diff --git a/pallets/ceres-liquidity-locker/benchmarking/src/mock.rs b/pallets/ceres-liquidity-locker/benchmarking/src/mock.rs index b9b034ec1..fb14c41ea 100644 --- a/pallets/ceres-liquidity-locker/benchmarking/src/mock.rs +++ b/pallets/ceres-liquidity-locker/benchmarking/src/mock.rs @@ -2,11 +2,13 @@ use crate::{Config, *}; #[cfg(test)] -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::{ - fixed, hash, mock_assets_config, mock_common_config, mock_currencies_config, - mock_frame_system_config, mock_pallet_balances_config, mock_technical_config, - mock_tokens_config, Amount, DEXId, DEXInfo, Fixed, PSWAP, VXOR, XST, + hash, mock_assets_config, mock_common_config, mock_currencies_config, mock_dex_api_config, + mock_dex_manager_config, mock_frame_system_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, + mock_trading_pair_config, Amount, DEXId, DEXInfo, VXOR, XST, }; use currencies::BasicCurrencyAdapter; @@ -17,10 +19,7 @@ use frame_system; use common::prelude::Balance; use frame_system::pallet_prelude::BlockNumberFor; use permissions::{Scope, BURN, MANAGE_DEX, MINT}; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; -use sp_runtime::{AccountId32, Percent}; +use sp_runtime::AccountId32; pub type AssetId = common::AssetId32; pub type TechAssetId = common::TechAssetId; @@ -39,10 +38,17 @@ pub fn alice() -> AccountId { mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); +mock_dex_api_config!(Runtime); +mock_dex_manager_config!(Runtime); mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_pallet_timestamp_config!(Runtime); +mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); +mock_trading_pair_config!(Runtime); parameter_types! { pub const BlockHashCount: u64 = 250; @@ -52,11 +58,8 @@ parameter_types! { pub GetPswapDistributionAccountId: AccountId = AccountId32::from([3; 32]); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; - pub GetIncentiveAssetId: AssetId = PSWAP.into(); pub GetParliamentAccountId: AccountId = AccountId32::from([8; 32]); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub const MinimumPeriod: u64 = 5; + pub const GetBuyBackAssetId: AssetId = VXOR; } construct_runtime! { @@ -83,39 +86,6 @@ construct_runtime! { } } -parameter_types! { - pub const GetBuyBackAssetId: AssetId = VXOR; - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); -} - -impl dex_manager::Config for Runtime {} - -impl trading_pair::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type EnsureDEXManager = dex_manager::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type WeightInfo = (); - type AssetInfoProvider = assets::Pallet; -} - -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - -impl dex_api::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type MockLiquiditySource = (); - type MockLiquiditySource2 = (); - type MockLiquiditySource3 = (); - type MockLiquiditySource4 = (); - type MulticollateralBondingCurvePool = (); - type XYKPool = pool_xyk::Pallet; - type XSTPool = (); - type DexInfoProvider = dex_manager::Pallet; - type OrderBook = (); - type WeightInfo = (); -} - impl demeter_farming_platform::Config for Runtime { type RuntimeEvent = RuntimeEvent; type DemeterAssetId = (); @@ -124,62 +94,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - -impl pallet_timestamp::Config for Runtime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; diff --git a/pallets/ceres-liquidity-locker/src/mock.rs b/pallets/ceres-liquidity-locker/src/mock.rs index e6066660f..3fd8862ad 100644 --- a/pallets/ceres-liquidity-locker/src/mock.rs +++ b/pallets/ceres-liquidity-locker/src/mock.rs @@ -1,11 +1,12 @@ use crate::pallet::AccountIdOf; use codec::Decode; -use common::mock::GetTradingPairRestrictedFlag; -use common::prelude::{Balance, Fixed}; +use common::prelude::Balance; use common::{ - balance, fixed, hash, mock_assets_config, mock_common_config, mock_currencies_config, - mock_frame_system_config, mock_orml_tokens_config, mock_pallet_balances_config, - mock_technical_config, DEXId, DEXInfo, VXOR, XOR, XST, + balance, hash, mock_assets_config, mock_common_config, mock_currencies_config, + mock_dex_manager_config, mock_frame_system_config, mock_orml_tokens_config, + mock_pallet_balances_config, mock_pallet_timestamp_config, mock_permissions_config, + mock_pool_xyk_config, mock_pswap_distribution_config, mock_technical_config, + mock_trading_pair_config, DEXId, DEXInfo, VXOR, XOR, XST, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::{Everything, GenesisBuild, Hooks}; @@ -15,10 +16,7 @@ use frame_system; use hex_literal::hex; use orml_traits::parameter_type_with_key; use permissions::{Scope, MANAGE_DEX}; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; -use sp_runtime::{Perbill, Percent}; +use sp_runtime::Perbill; pub use common::mock::*; pub use common::TechAssetId as Tas; @@ -50,16 +48,11 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); pub GetBaseAssetId: AssetId = common::AssetId32::from_bytes(hex!("0200000000000000000000000000000000000000000000000000000000000000").into()); - pub GetIncentiveAssetId: AssetId = common::AssetId32::from_bytes(hex!("0200050000000000000000000000000000000000000000000000000000000000").into()); pub GetPswapDistributionAccountId: AccountId = AccountId::new([3; 32]); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; pub GetParliamentAccountId: AccountId = AccountId::new([8; 32]); - pub GetFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub const MinimumPeriod: u64 = 5; pub const CeresAssetId: AssetId = CERES_ASSET_ID; - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); } parameter_type_with_key! { @@ -94,36 +87,21 @@ construct_runtime! { mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); +mock_dex_manager_config!(Runtime); mock_frame_system_config!(Runtime); mock_orml_tokens_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_pallet_timestamp_config!(Runtime); +mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); - -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - -impl dex_manager::Config for Runtime {} - -impl trading_pair::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type EnsureDEXManager = dex_manager::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type WeightInfo = (); - type AssetInfoProvider = assets::Pallet; -} +mock_trading_pair_config!(Runtime); parameter_types! { pub const GetBuyBackAssetId: AssetId = VXOR; } -impl pallet_timestamp::Config for Runtime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - impl demeter_farming_platform::Config for Runtime { type RuntimeEvent = RuntimeEvent; type DemeterAssetId = (); @@ -132,55 +110,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type GetFee = GetFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = BLOCKS_PER_DAY; type RuntimeEvent = RuntimeEvent; diff --git a/pallets/ceres-staking/src/mock.rs b/pallets/ceres-staking/src/mock.rs index 267b9eb5c..a7f517745 100644 --- a/pallets/ceres-staking/src/mock.rs +++ b/pallets/ceres-staking/src/mock.rs @@ -5,9 +5,9 @@ pub use common::TechAssetId as Tas; pub use common::TechPurpose::*; use common::{ balance, mock_assets_config, mock_common_config, mock_currencies_config, - mock_frame_system_config, mock_pallet_balances_config, mock_technical_config, - mock_tokens_config, AssetId32, AssetName, AssetSymbol, BalancePrecision, ContentSource, DEXId, - Description, CERES_ASSET_ID, XST, + mock_frame_system_config, mock_pallet_balances_config, mock_permissions_config, + mock_technical_config, mock_tokens_config, AssetId32, AssetName, AssetSymbol, BalancePrecision, + ContentSource, DEXId, Description, CERES_ASSET_ID, XST, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::{Everything, GenesisBuild, Hooks}; @@ -15,11 +15,8 @@ use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types}; use frame_system; use frame_system::pallet_prelude::BlockNumberFor; -use hex_literal::hex; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Zero}; +use sp_runtime::traits::Zero; use sp_runtime::Perbill; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -50,18 +47,15 @@ pub type AssetId = AssetId32; pub type TechAssetId = common::TechAssetId; pub type TechAccountId = common::TechAccountId; -pub const ALICE: AccountId = AccountId::new(hex!( - "0000000000000000000000000000000000000000000000000000000000000001" -)); -pub const BOB: AccountId = AccountId::new(hex!( - "0000000000000000000000000000000000000000000000000000000000000002" -)); +pub const ALICE: AccountId = AccountId32::new([1u8; 32]); +pub const BOB: AccountId = AccountId32::new([2u8; 32]); mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_permissions_config!(Runtime); mock_technical_config!(Runtime); mock_tokens_config!(Runtime); @@ -92,10 +86,6 @@ parameter_types! { pub const GetBuyBackAssetId: AssetId = XST; } -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - pub struct ExtBuilder { pub endowed_assets: Vec<( AssetId, diff --git a/pallets/ceres-token-locker/src/mock.rs b/pallets/ceres-token-locker/src/mock.rs index fff5b9fa7..3c62eb89b 100644 --- a/pallets/ceres-token-locker/src/mock.rs +++ b/pallets/ceres-token-locker/src/mock.rs @@ -1,11 +1,12 @@ use crate::{self as ceres_token_locker}; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::Balance; use common::{ - balance, fixed, mock_assets_config, mock_common_config, mock_currencies_config, - mock_frame_system_config, mock_pallet_balances_config, mock_technical_config, - mock_tokens_config, AssetId32, AssetName, AssetSymbol, BalancePrecision, ContentSource, - Description, Fixed, CERES_ASSET_ID, PSWAP, VXOR, + balance, mock_assets_config, mock_common_config, mock_currencies_config, + mock_dex_manager_config, mock_frame_system_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, AssetId32, + AssetName, AssetSymbol, BalancePrecision, ContentSource, Description, CERES_ASSET_ID, VXOR, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::{Everything, GenesisBuild, Hooks}; @@ -13,12 +14,9 @@ use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types}; use frame_system; use frame_system::pallet_prelude::BlockNumberFor; -use hex_literal::hex; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Zero}; -use sp_runtime::{Perbill, Percent}; +use sp_runtime::traits::Zero; +use sp_runtime::Perbill; pub type TechAccountId = common::TechAccountId; type TechAssetId = common::TechAssetId; @@ -54,18 +52,19 @@ pub type BlockNumber = u64; pub type Amount = i128; pub type AssetId = AssetId32; -pub const ALICE: AccountId = AccountId::new(hex!( - "0000000000000000000000000000000000000000000000000000000000000001" -)); -pub const BOB: AccountId = AccountId::new(hex!( - "0000000000000000000000000000000000000000000000000000000000000002" -)); +pub const ALICE: AccountId = AccountId32::new([1u8; 32]); +pub const BOB: AccountId = AccountId32::new([2u8; 32]); mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); +mock_dex_manager_config!(Runtime); mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_pallet_timestamp_config!(Runtime); +mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime, (), ()); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); @@ -74,15 +73,10 @@ parameter_types! { pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub GetIncentiveAssetId: AssetId = PSWAP.into(); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; pub GetParliamentAccountId: AccountId = AccountId32::from([100; 32]); pub GetPswapDistributionAccountId: AccountId = AccountId32::from([101; 32]); - pub const MinimumPeriod: u64 = 5; - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); } parameter_types! { @@ -101,12 +95,6 @@ parameter_types! { pub const GetBuyBackAssetId: AssetId = VXOR; } -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - -impl dex_manager::Config for Runtime {} - impl demeter_farming_platform::Config for Runtime { type RuntimeEvent = RuntimeEvent; type DemeterAssetId = (); @@ -115,62 +103,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = (); - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = (); - type EnabledSourcesManager = (); - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - -impl pswap_distribution::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - -impl pallet_timestamp::Config for Runtime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; diff --git a/pallets/demeter-farming-platform/benchmarking/src/mock.rs b/pallets/demeter-farming-platform/benchmarking/src/mock.rs index 88960b095..e5b4d9dff 100644 --- a/pallets/demeter-farming-platform/benchmarking/src/mock.rs +++ b/pallets/demeter-farming-platform/benchmarking/src/mock.rs @@ -1,14 +1,17 @@ #![cfg(test)] use crate::*; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::Balance; pub use common::TechAssetId as Tas; use common::{ - balance, fixed, hash, mock_assets_config, mock_common_config, mock_currencies_config, - mock_frame_system_config, mock_pallet_balances_config, mock_technical_config, - mock_tokens_config, mock_vested_rewards_config, DEXId, DEXInfo, Fixed, CERES_ASSET_ID, - DEMETER_ASSET_ID, PSWAP, VXOR, XOR, XST, + balance, hash, mock_assets_config, mock_common_config, mock_currencies_config, + mock_dex_manager_config, mock_frame_system_config, + mock_multicollateral_bonding_curve_pool_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, + mock_trading_pair_config, mock_vested_rewards_config, DEXId, DEXInfo, CERES_ASSET_ID, + DEMETER_ASSET_ID, VXOR, XOR, XST, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::{Everything, GenesisBuild}; @@ -18,10 +21,8 @@ use frame_system; use frame_system::pallet_prelude::BlockNumberFor; use permissions::{Scope, MANAGE_DEX}; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}; -use sp_runtime::{MultiSignature, Perbill, Percent}; +use sp_runtime::traits::{IdentifyAccount, Verify}; +use sp_runtime::{MultiSignature, Perbill}; pub type Signature = MultiSignature; pub type BlockNumber = u64; @@ -65,10 +66,17 @@ pub const DEX_A_ID: DEXId = DEXId::Polkaswap; mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); +mock_dex_manager_config!(Runtime); mock_frame_system_config!(Runtime); +mock_multicollateral_bonding_curve_pool_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_pallet_timestamp_config!(Runtime); +mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); +mock_trading_pair_config!(Runtime); mock_vested_rewards_config!(Runtime); parameter_types! { @@ -76,9 +84,6 @@ parameter_types! { pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 1); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub GetIncentiveAssetId: AssetId = PSWAP.into(); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; pub GetParliamentAccountId: AccountId = AccountId32::new([100u8; 32]); @@ -87,7 +92,6 @@ parameter_types! { pub GetBondingCurveRewardsAccountId: AccountId = AccountId32::new([103; 32]); pub GetFarmingRewardsAccountId: AccountId = AccountId32::new([104u8; 32]); pub GetCrowdloanRewardsAccountId: AccountId = AccountId32::new([105u8; 32]); - pub const MinimumPeriod: u64 = 5; } parameter_types! { @@ -104,67 +108,13 @@ impl demeter_farming_platform::Config for Runtime { parameter_types! { pub const GetBaseAssetId: AssetId = XOR; -} - -parameter_types! { pub const GetBuyBackAssetId: AssetId = VXOR; - pub GetTBCBuyBackTBCDPercent: Fixed = fixed!(0.025); - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); - pub GetTbcIrreducibleReservePercent: Percent = Percent::from_percent(1); -} - -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; } -impl dex_manager::Config for Runtime {} - -impl trading_pair::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type EnsureDEXManager = dex_manager::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type WeightInfo = (); - type AssetInfoProvider = assets::Pallet; -} - -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} parameter_types! { pub const CeresAssetId: AssetId = CERES_ASSET_ID; } -impl pallet_timestamp::Config for Runtime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14400; type RuntimeEvent = RuntimeEvent; @@ -174,43 +124,6 @@ impl ceres_liquidity_locker::Config for Runtime { type WeightInfo = (); } -impl multicollateral_bonding_curve_pool::Config for Runtime { - const RETRY_DISTRIBUTION_FREQUENCY: BlockNumber = 1000; - type RuntimeEvent = RuntimeEvent; - type LiquidityProxy = (); - type EnsureDEXManager = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type PriceToolsPallet = (); - type VestedRewardsPallet = VestedRewards; - type TradingPairSourceManager = trading_pair::Pallet; - type BuyBackHandler = (); - type BuyBackTBCDPercent = GetTBCBuyBackTBCDPercent; - type AssetInfoProvider = assets::Pallet; - type IrreducibleReserve = GetTbcIrreducibleReservePercent; - type WeightInfo = (); -} - -impl pswap_distribution::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - pub struct ExtBuilder { initial_dex_list: Vec<(DEXId, DEXInfo)>, endowed_accounts: Vec<(AccountId, AssetId, Balance)>, diff --git a/pallets/demeter-farming-platform/src/mock.rs b/pallets/demeter-farming-platform/src/mock.rs index 2c8d858c3..1af34ce98 100644 --- a/pallets/demeter-farming-platform/src/mock.rs +++ b/pallets/demeter-farming-platform/src/mock.rs @@ -1,11 +1,14 @@ -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::Balance; pub use common::TechAssetId as Tas; use common::{ - balance, fixed, hash, mock_assets_config, mock_common_config, mock_currencies_config, - mock_frame_system_config, mock_pallet_balances_config, mock_technical_config, - mock_tokens_config, mock_vested_rewards_config, DEXId, DEXInfo, Fixed, CERES_ASSET_ID, - DEMETER_ASSET_ID, PSWAP, VXOR, XOR, XST, XSTUSD, + balance, hash, mock_assets_config, mock_common_config, mock_currencies_config, + mock_dex_manager_config, mock_frame_system_config, + mock_multicollateral_bonding_curve_pool_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, + mock_trading_pair_config, mock_vested_rewards_config, DEXId, DEXInfo, CERES_ASSET_ID, + DEMETER_ASSET_ID, VXOR, XOR, XST, XSTUSD, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::{Everything, GenesisBuild, Hooks}; @@ -14,11 +17,8 @@ use frame_support::{construct_runtime, parameter_types}; use frame_system; use frame_system::pallet_prelude::BlockNumberFor; use permissions::{Scope, MANAGE_DEX}; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_runtime::AccountId32; -use sp_runtime::{Perbill, Percent}; +use sp_runtime::Perbill; pub type BlockNumber = u64; pub type AccountId = AccountId32; @@ -63,10 +63,17 @@ pub const DEX_B_ID: DEXId = DEXId::PolkaswapXSTUSD; mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); +mock_dex_manager_config!(Runtime); mock_frame_system_config!(Runtime); +mock_multicollateral_bonding_curve_pool_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_pallet_timestamp_config!(Runtime); +mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); +mock_trading_pair_config!(Runtime); mock_vested_rewards_config!(Runtime); parameter_types! { @@ -74,9 +81,6 @@ parameter_types! { pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub GetIncentiveAssetId: AssetId = PSWAP.into(); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; pub GetParliamentAccountId: AccountId = AccountId32::new([100u8; 32]); @@ -85,10 +89,9 @@ parameter_types! { pub GetBondingCurveRewardsAccountId: AccountId = AccountId32::new([103u8; 32]); pub GetFarmingRewardsAccountId: AccountId = AccountId32::new([104u8; 32]); pub GetCrowdloanRewardsAccountId: AccountId = AccountId32::new([105u8; 32]); - pub const MinimumPeriod: u64 = 5; -} - -parameter_types! { + pub const GetBaseAssetId: AssetId = XOR; + pub const GetBuyBackAssetId: AssetId = VXOR; + pub const CeresAssetId: AssetId = CERES_ASSET_ID; pub const DemeterAssetId: AssetId = DEMETER_ASSET_ID; } @@ -100,66 +103,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -parameter_types! { - pub const GetBaseAssetId: AssetId = XOR; - pub const GetBuyBackAssetId: AssetId = VXOR; - pub GetTBCBuyBackTBCDPercent: Fixed = fixed!(0.025); - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); - pub GetTbcIrreducibleReservePercent: Percent = Percent::from_percent(1); -} - -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - -impl dex_manager::Config for Runtime {} - -impl trading_pair::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type EnsureDEXManager = dex_manager::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type WeightInfo = (); - type AssetInfoProvider = assets::Pallet; -} - -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} -parameter_types! { - pub const CeresAssetId: AssetId = CERES_ASSET_ID; -} - -impl pallet_timestamp::Config for Runtime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14400; type RuntimeEvent = RuntimeEvent; @@ -169,43 +112,6 @@ impl ceres_liquidity_locker::Config for Runtime { type WeightInfo = (); } -impl multicollateral_bonding_curve_pool::Config for Runtime { - const RETRY_DISTRIBUTION_FREQUENCY: BlockNumber = 1000; - type RuntimeEvent = RuntimeEvent; - type LiquidityProxy = (); - type EnsureDEXManager = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type PriceToolsPallet = (); - type VestedRewardsPallet = VestedRewards; - type TradingPairSourceManager = trading_pair::Pallet; - type BuyBackHandler = (); - type BuyBackTBCDPercent = GetTBCBuyBackTBCDPercent; - type AssetInfoProvider = assets::Pallet; - type IrreducibleReserve = GetTbcIrreducibleReservePercent; - type WeightInfo = (); -} - -impl pswap_distribution::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - pub struct ExtBuilder { initial_dex_list: Vec<(DEXId, DEXInfo)>, endowed_accounts: Vec<(AccountId, AssetId, Balance)>, diff --git a/pallets/dex-api/src/mock.rs b/pallets/dex-api/src/mock.rs index d5f61e99d..25974a008 100644 --- a/pallets/dex-api/src/mock.rs +++ b/pallets/dex-api/src/mock.rs @@ -30,14 +30,15 @@ use crate::{self as dex_api, Config}; use common::alt::DiscreteQuotation; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::{Balance, QuoteAmount, SwapAmount, SwapOutcome}; use common::{ balance, fixed, fixed_from_basis_points, hash, mock_assets_config, mock_common_config, mock_currencies_config, mock_dex_manager_config, mock_frame_system_config, mock_pallet_balances_config, mock_pallet_timestamp_config, mock_permissions_config, - mock_technical_config, mock_tokens_config, Amount, AssetId32, DEXId, DEXInfo, Fixed, - LiquiditySource, LiquiditySourceType, RewardReason, DOT, KSM, PSWAP, VXOR, XOR, XST, + mock_pool_xyk_config, mock_pswap_distribution_config, mock_technical_config, + mock_tokens_config, Amount, AssetId32, DEXId, DEXInfo, Fixed, LiquiditySource, + LiquiditySourceType, RewardReason, DOT, KSM, VXOR, XOR, XST, }; use currencies::BasicCurrencyAdapter; use frame_support::sp_runtime::DispatchError; @@ -48,10 +49,7 @@ use frame_system::pallet_prelude::BlockNumberFor; use hex_literal::hex; use permissions::{Scope, INIT_DEX, MANAGE_DEX}; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; -use sp_runtime::{Perbill, Percent}; +use sp_runtime::Perbill; pub type AccountId = AccountId32; pub type BlockNumber = u64; @@ -83,6 +81,8 @@ mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); mock_pallet_timestamp_config!(Runtime); mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime, (), ()); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); @@ -100,11 +100,7 @@ parameter_types! { pub GetPswapDistributionAccountId: AccountId = AccountId32::from([3; 32]); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; - pub GetIncentiveAssetId: AssetId = PSWAP.into(); pub GetParliamentAccountId: AccountId = AccountId32::from([8; 32]); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); } construct_runtime! { @@ -312,54 +308,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = (); - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = (); - type EnabledSourcesManager = (); - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; diff --git a/pallets/dex-manager/src/mock.rs b/pallets/dex-manager/src/mock.rs index 85ef57136..5853cd929 100644 --- a/pallets/dex-manager/src/mock.rs +++ b/pallets/dex-manager/src/mock.rs @@ -33,8 +33,8 @@ use common::mock::ExistentialDeposits; use common::prelude::Balance; use common::{ self, fixed_from_basis_points, mock_assets_config, mock_common_config, mock_currencies_config, - mock_frame_system_config, mock_pallet_balances_config, mock_tokens_config, AssetId32, DEXId, - DEXInfo, Fixed, DOT, XOR, XST, + mock_frame_system_config, mock_pallet_balances_config, mock_permissions_config, + mock_tokens_config, AssetId32, DEXId, DEXInfo, Fixed, DOT, XOR, XST, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::{Everything, GenesisBuild}; @@ -43,9 +43,6 @@ use frame_support::{construct_runtime, parameter_types}; use frame_system; use permissions::Scope; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_runtime::Perbill; pub type AccountId = AccountId32; @@ -95,14 +92,11 @@ mock_common_config!(Runtime); mock_currencies_config!(Runtime); mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_permissions_config!(Runtime); mock_tokens_config!(Runtime); impl Config for Runtime {} -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - parameter_types! { pub const GetBuyBackAssetId: AssetId = XST; } diff --git a/pallets/eth-bridge/src/tests/mock.rs b/pallets/eth-bridge/src/tests/mock.rs index f28d90616..1d1ea86b7 100644 --- a/pallets/eth-bridge/src/tests/mock.rs +++ b/pallets/eth-bridge/src/tests/mock.rs @@ -45,8 +45,9 @@ use common::mock::{ExistentialDeposits, WeightToFixedFee}; use common::prelude::Balance; use common::{ mock_assets_config, mock_common_config, mock_currencies_config, mock_frame_system_config, - mock_pallet_balances_config, mock_tokens_config, Amount, AssetId32, AssetName, AssetSymbol, - DEXId, PredefinedAssetId, DEFAULT_BALANCE_PRECISION, PSWAP, VAL, XOR, XST, + mock_pallet_balances_config, mock_permissions_config, mock_tokens_config, Amount, AssetId32, + AssetName, AssetSymbol, DEXId, PredefinedAssetId, DEFAULT_BALANCE_PRECISION, PSWAP, VAL, XOR, + XST, }; use core::cell::RefCell; use currencies::BasicCurrencyAdapter; @@ -61,10 +62,9 @@ use frame_support::sp_runtime::offchain::testing::{ OffchainState, PoolState, TestOffchainExt, TestTransactionPoolExt, }; use frame_support::sp_runtime::serde::{Serialize, Serializer}; -use frame_support::sp_runtime::testing::Header; use frame_support::sp_runtime::traits::{ - self, Applyable, BlakeTwo256, Checkable, DispatchInfoOf, Dispatchable, IdentifyAccount, - IdentityLookup, PostDispatchInfoOf, SignedExtension, ValidateUnsigned, Verify, + self, Applyable, Checkable, DispatchInfoOf, Dispatchable, IdentifyAccount, PostDispatchInfoOf, + SignedExtension, ValidateUnsigned, Verify, }; use frame_support::sp_runtime::transaction_validity::{ TransactionSource, TransactionValidity, TransactionValidityError, @@ -279,6 +279,7 @@ mock_common_config!(Runtime); mock_currencies_config!(Runtime); mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_permissions_config!(Runtime); mock_tokens_config!(Runtime); impl frame_system::offchain::SignMessage for Runtime { @@ -331,10 +332,6 @@ parameter_types! { pub const GetBuyBackAssetId: AssetId = XST; } -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - impl bridge_multisig::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; diff --git a/pallets/extended-assets/src/mock.rs b/pallets/extended-assets/src/mock.rs index ee282a684..691d1107e 100644 --- a/pallets/extended-assets/src/mock.rs +++ b/pallets/extended-assets/src/mock.rs @@ -37,11 +37,9 @@ use common::{ PredefinedAssetId, XOR, XST, }; use currencies::BasicCurrencyAdapter; -use frame_support::traits::Everything; +use frame_support::traits::{ConstU32, Everything}; use frame_support::{construct_runtime, parameter_types}; -use sp_core::{ConstU32, H256}; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}; +use sp_runtime::traits::{IdentifyAccount, Verify}; use sp_runtime::{AccountId32, MultiSignature}; type AccountId = <::Signer as IdentifyAccount>::AccountId; diff --git a/pallets/farming/src/mock.rs b/pallets/farming/src/mock.rs index d5030d80e..85afab13f 100644 --- a/pallets/farming/src/mock.rs +++ b/pallets/farming/src/mock.rs @@ -29,12 +29,15 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use crate::{self as farming, Config}; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::Balance; use common::{ - balance, fixed, hash, mock_assets_config, mock_common_config, mock_currencies_config, - mock_frame_system_config, mock_pallet_balances_config, mock_technical_config, - mock_tokens_config, mock_vested_rewards_config, AssetName, AssetSymbol, DEXId, DEXInfo, Fixed, + balance, hash, mock_assets_config, mock_common_config, mock_currencies_config, + mock_dex_manager_config, mock_frame_system_config, + mock_multicollateral_bonding_curve_pool_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, + mock_trading_pair_config, mock_vested_rewards_config, AssetName, AssetSymbol, DEXId, DEXInfo, DEFAULT_BALANCE_PRECISION, DOT, PSWAP, VAL, VXOR, XOR, XST, XSTUSD, }; use currencies::BasicCurrencyAdapter; @@ -45,10 +48,7 @@ use frame_system::pallet_prelude::BlockNumberFor; use frame_system::EnsureRoot; use permissions::*; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; -use sp_runtime::{Perbill, Percent}; +use sp_runtime::Perbill; use sp_std::cmp::Ordering; use sp_std::marker::PhantomData; @@ -113,19 +113,13 @@ parameter_types! { pub GetPswapDistributionAccountId: AccountId = AccountId32::from([3; 32]); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; - pub GetIncentiveAssetId: AssetId = common::PSWAP.into(); pub GetParliamentAccountId: AccountId = AccountId32::from([8; 32]); pub RewardDoublingAssets: Vec = vec![VAL.into(), PSWAP.into(), DOT.into()]; - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); pub GetMarketMakerRewardsAccountId: AccountId = AccountId32::from([12; 32]); pub GetBondingCurveRewardsAccountId: AccountId = AccountId32::from([13; 32]); pub GetFarmingRewardsAccountId: AccountId = AccountId32::from([14; 32]); pub GetCrowdloanRewardsAccountId: AccountId = AccountId32::from([15; 32]); pub const SchedulerMaxWeight: Weight = Weight::from_parts(1024, 0); - pub const MinimumPeriod: u64 = 5; - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); - pub GetTbcIrreducibleReservePercent: Percent = Percent::from_percent(1); } construct_runtime! { @@ -158,29 +152,26 @@ construct_runtime! { mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); +mock_dex_manager_config!(Runtime); mock_frame_system_config!(Runtime); +mock_multicollateral_bonding_curve_pool_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_pallet_timestamp_config!(Runtime); +mock_permissions_config!(Runtime); +mock_pool_xyk_config!( + Runtime, + trading_pair::Pallet, + trading_pair::Pallet, + (PswapDistribution, Farming) +); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); +mock_trading_pair_config!(Runtime); mock_vested_rewards_config!(Runtime); -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - -impl dex_manager::Config for Runtime {} - -impl trading_pair::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type EnsureDEXManager = dex_manager::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type WeightInfo = (); - type AssetInfoProvider = assets::Pallet; -} - parameter_types! { pub const GetBuyBackAssetId: AssetId = VXOR; - pub GetTBCBuyBackTBCDPercent: Fixed = fixed!(0.025); } impl demeter_farming_platform::Config for Runtime { @@ -191,71 +182,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = (PswapDistribution, Farming); - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - -impl multicollateral_bonding_curve_pool::Config for Runtime { - const RETRY_DISTRIBUTION_FREQUENCY: BlockNumber = 1000; - type RuntimeEvent = RuntimeEvent; - type LiquidityProxy = (); - type EnsureTradingPairExists = trading_pair::Pallet; - type EnsureDEXManager = dex_manager::Pallet; - type PriceToolsPallet = (); - type VestedRewardsPallet = VestedRewards; - type TradingPairSourceManager = trading_pair::Pallet; - type BuyBackHandler = (); - type BuyBackTBCDPercent = GetTBCBuyBackTBCDPercent; - type AssetInfoProvider = assets::Pallet; - type IrreducibleReserve = GetTbcIrreducibleReservePercent; - type WeightInfo = (); -} - /// Used the compare the privilege of an origin inside the scheduler. pub struct OriginPrivilegeCmp; @@ -287,13 +213,6 @@ impl pallet_scheduler::Config for Runtime { type Preimages = (); } -impl pallet_timestamp::Config for Runtime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; diff --git a/pallets/faucet/src/mock.rs b/pallets/faucet/src/mock.rs index b3896fe8b..645f2ef47 100644 --- a/pallets/faucet/src/mock.rs +++ b/pallets/faucet/src/mock.rs @@ -33,9 +33,9 @@ use common::mock::ExistentialDeposits; use common::prelude::{Balance, FixedWrapper}; use common::{ self, balance, mock_assets_config, mock_common_config, mock_currencies_config, - mock_frame_system_config, mock_pallet_balances_config, mock_technical_config, - mock_tokens_config, Amount, AssetId32, AssetName, AssetSymbol, TechPurpose, - DEFAULT_BALANCE_PRECISION, USDT, VAL, XOR, XST, + mock_frame_system_config, mock_pallet_balances_config, mock_permissions_config, + mock_technical_config, mock_tokens_config, Amount, AssetId32, AssetName, AssetSymbol, + TechPurpose, DEFAULT_BALANCE_PRECISION, USDT, VAL, XOR, XST, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::{Everything, GenesisBuild}; @@ -43,9 +43,6 @@ use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types}; use permissions::{Scope, BURN, MINT}; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_runtime::{Perbill, Percent}; type DEXId = common::DEXId; @@ -109,6 +106,7 @@ mock_common_config!(Runtime); mock_currencies_config!(Runtime); mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_permissions_config!(Runtime); mock_technical_config!(Runtime); mock_tokens_config!(Runtime); @@ -132,11 +130,6 @@ parameter_types! { pub const GetBuyBackAssetId: AssetId = XST; } -// Required by assets::Config -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - pub struct ExtBuilder {} impl ExtBuilder { diff --git a/pallets/hermes-governance-platform/src/mock.rs b/pallets/hermes-governance-platform/src/mock.rs index c977052ab..89abd9228 100644 --- a/pallets/hermes-governance-platform/src/mock.rs +++ b/pallets/hermes-governance-platform/src/mock.rs @@ -1,13 +1,14 @@ use crate::migrations::VotingOption; use crate::{self as hermes_governance_platform}; use codec::{Decode, Encode}; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::Balance; use common::{ - balance, fixed, mock_assets_config, mock_common_config, mock_currencies_config, - mock_frame_system_config, mock_pallet_balances_config, mock_technical_config, - mock_tokens_config, AssetId32, AssetName, AssetSymbol, BalancePrecision, ContentSource, - Description, Fixed, HERMES_ASSET_ID, PSWAP, VXOR, + balance, mock_assets_config, mock_common_config, mock_currencies_config, + mock_dex_manager_config, mock_frame_system_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, AssetId32, + AssetName, AssetSymbol, BalancePrecision, ContentSource, Description, HERMES_ASSET_ID, VXOR, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::{Everything, GenesisBuild, Hooks}; @@ -15,12 +16,9 @@ use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types}; use frame_system; use frame_system::pallet_prelude::BlockNumberFor; -use hex_literal::hex; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Zero}; -use sp_runtime::{Perbill, Percent}; +use sp_runtime::traits::Zero; +use sp_runtime::Perbill; pub type TechAccountId = common::TechAccountId; type TechAssetId = common::TechAssetId; @@ -57,15 +55,9 @@ pub type BlockNumber = u64; pub type Amount = i128; pub type AssetId = AssetId32; -pub const ALICE: AccountId = AccountId::new(hex!( - "0000000000000000000000000000000000000000000000000000000000000001" -)); -pub const BOB: AccountId = AccountId::new(hex!( - "0000000000000000000000000000000000000000000000000000000000000002" -)); -pub const CHARLES: AccountId = AccountId::new(hex!( - "0000000000000000000000000000000000000000000000000000000000000003" -)); +pub const ALICE: AccountId = AccountId32::new([1u8; 32]); +pub const BOB: AccountId = AccountId32::new([2u8; 32]); +pub const CHARLES: AccountId = AccountId32::new([3u8; 32]); #[derive(Encode, Decode, PartialEq, Eq, scale_info::TypeInfo)] pub struct OldHermesVotingInfo { @@ -80,8 +72,13 @@ pub struct OldHermesVotingInfo { mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); +mock_dex_manager_config!(Runtime); mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_pallet_timestamp_config!(Runtime); +mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime, (), ()); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); @@ -90,15 +87,10 @@ parameter_types! { pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub GetIncentiveAssetId: AssetId = PSWAP.into(); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; pub GetParliamentAccountId: AccountId = AccountId32::from([100; 32]); pub GetPswapDistributionAccountId: AccountId = AccountId32::from([101; 32]); - pub const MinimumPeriod: u64 = 5; - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); } parameter_types! { @@ -127,12 +119,6 @@ parameter_types! { pub const GetBuyBackAssetId: AssetId = VXOR; } -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - -impl dex_manager::Config for Runtime {} - impl demeter_farming_platform::Config for Runtime { type RuntimeEvent = RuntimeEvent; type DemeterAssetId = (); @@ -150,41 +136,6 @@ impl ceres_governance_platform::Config for Runtime { type DescriptionLimit = DescriptionLimit; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = (); - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = (); - type EnabledSourcesManager = (); - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - -impl pallet_timestamp::Config for Runtime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; @@ -194,26 +145,6 @@ impl ceres_liquidity_locker::Config for Runtime { type WeightInfo = (); } -impl pswap_distribution::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} pub struct ExtBuilder { endowed_assets: Vec<( AssetId, diff --git a/pallets/iroha-migration/src/mock.rs b/pallets/iroha-migration/src/mock.rs index 8e732f7c6..e1b4107ee 100644 --- a/pallets/iroha-migration/src/mock.rs +++ b/pallets/iroha-migration/src/mock.rs @@ -44,9 +44,6 @@ use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types}; use permissions::{Scope, MINT}; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_runtime::{self, Perbill}; type DEXId = common::DEXId; diff --git a/pallets/kensetsu/src/mock.rs b/pallets/kensetsu/src/mock.rs index 3c9831cd0..4d8d335c3 100644 --- a/pallets/kensetsu/src/mock.rs +++ b/pallets/kensetsu/src/mock.rs @@ -52,8 +52,8 @@ use sp_arithmetic::Percent; use sp_core::crypto::AccountId32; use sp_core::{ConstU32, H256}; use sp_runtime::{ - testing::{Header, TestXt}, - traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, + testing::TestXt, + traits::{IdentifyAccount, Verify}, }; use sp_runtime::{DispatchError, MultiSignature}; diff --git a/pallets/liquidity-proxy/benchmarking/src/mock.rs b/pallets/liquidity-proxy/benchmarking/src/mock.rs index 3640c6f5b..f38475496 100644 --- a/pallets/liquidity-proxy/benchmarking/src/mock.rs +++ b/pallets/liquidity-proxy/benchmarking/src/mock.rs @@ -33,31 +33,32 @@ #![allow(clippy::all)] use crate::{Config, *}; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::{Balance, QuoteAmount}; use common::{ - balance, fixed, fixed_from_basis_points, hash, mock_assets_config, mock_common_config, - mock_currencies_config, mock_extended_assets_config, mock_frame_system_config, - mock_pallet_balances_config, mock_technical_config, mock_tokens_config, - mock_vested_rewards_config, Amount, AssetId32, AssetName, AssetSymbol, BalancePrecision, - ContentSource, DEXId, DEXInfo, Description, Fixed, FromGenericPair, LiquidityProxyTrait, - LiquiditySourceFilter, LiquiditySourceType, PriceToolsProvider, PriceVariant, TechPurpose, - DEFAULT_BALANCE_PRECISION, DOT, PSWAP, USDT, VAL, VXOR, XOR, XST, + balance, fixed_from_basis_points, hash, mock_assets_config, mock_common_config, + mock_currencies_config, mock_dex_api_config, mock_dex_manager_config, + mock_extended_assets_config, mock_frame_system_config, mock_liquidity_proxy_config, + mock_multicollateral_bonding_curve_pool_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_price_tools_config, mock_pswap_distribution_config, mock_technical_config, + mock_tokens_config, mock_trading_pair_config, mock_vested_rewards_config, Amount, AssetId32, + AssetName, AssetSymbol, BalancePrecision, ContentSource, DEXId, DEXInfo, Description, Fixed, + FromGenericPair, LiquidityProxyTrait, LiquiditySourceFilter, LiquiditySourceType, + PriceToolsProvider, PriceVariant, TechPurpose, DEFAULT_BALANCE_PRECISION, DOT, PSWAP, USDT, + VAL, VXOR, XOR, XST, }; use currencies::BasicCurrencyAdapter; use hex_literal::hex; -use frame_support::traits::{Everything, GenesisBuild}; +use frame_support::traits::{ConstU32, Everything, GenesisBuild}; use frame_support::{construct_runtime, parameter_types}; -use frame_system::{pallet_prelude::BlockNumberFor, EnsureRoot}; +use frame_system::pallet_prelude::BlockNumberFor; use multicollateral_bonding_curve_pool::{ DistributionAccount, DistributionAccountData, DistributionAccounts, }; use permissions::{Scope, BURN, MANAGE_DEX, MINT}; -use sp_core::{ConstU32, H256}; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; -use sp_runtime::{AccountId32, DispatchError, DispatchResult, Percent, Permill}; +use sp_runtime::{AccountId32, DispatchError, DispatchResult}; pub type AssetId = AssetId32; pub type TechAssetId = common::TechAssetId; @@ -74,19 +75,6 @@ pub fn alice() -> AccountId { } parameter_types! { - pub GetLiquidityProxyTechAccountId: TechAccountId = { - - TechAccountId::from_generic_pair( - liquidity_proxy::TECH_ACCOUNT_PREFIX.to_vec(), - liquidity_proxy::TECH_ACCOUNT_MAIN.to_vec(), - ) - }; - pub GetLiquidityProxyAccountId: AccountId = { - let tech_account_id = GetLiquidityProxyTechAccountId::get(); - - technical::Pallet::::tech_account_id_to_account_id(&tech_account_id) - .expect("Failed to get ordinary account id for technical account id.") - }; pub const BlockHashCount: u64 = 250; pub const GetNumSamples: usize = 40; pub const GetBaseAssetId: AssetId = XOR; @@ -95,18 +83,12 @@ parameter_types! { pub GetPswapDistributionAccountId: AccountId = AccountId32::from([3; 32]); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 10; - pub GetIncentiveAssetId: AssetId = PSWAP; pub GetParliamentAccountId: AccountId = AccountId32::from([8; 32]); pub GetMarketMakerRewardsAccountId: AccountId = AccountId32::from([9; 32]); pub GetBondingCurveRewardsAccountId: AccountId = AccountId32::from([10; 32]); pub GetFarmingRewardsAccountId: AccountId = AccountId32::from([12; 32]); pub GetCrowdloanRewardsAccountId: AccountId = AccountId32::from([13; 32]); pub GetADARAccountId: AccountId = AccountId32::from([14; 32]); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub const MinimumPeriod: u64 = 5; - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); - pub GetInternalSlippageTolerancePercent: Permill = Permill::from_rational(1u32, 1000); // 0.1% } construct_runtime! { @@ -141,42 +123,32 @@ construct_runtime! { mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); +mock_dex_api_config!(Runtime, multicollateral_bonding_curve_pool::Pallet); +mock_dex_manager_config!(Runtime); mock_extended_assets_config!(Runtime); mock_frame_system_config!(Runtime); +mock_liquidity_proxy_config!(Runtime); +mock_multicollateral_bonding_curve_pool_config!( + Runtime, + liquidity_proxy::Pallet, + liquidity_proxy::LiquidityProxyBuyBackHandler, + MockPriceTools +); mock_pallet_balances_config!(Runtime); +mock_pallet_timestamp_config!(Runtime); +mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime); +mock_price_tools_config!(Runtime, LiquidityProxy); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); +mock_trading_pair_config!(Runtime); mock_vested_rewards_config!(Runtime); -impl liquidity_proxy::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type LiquidityRegistry = dex_api::Pallet; - type GetNumSamples = GetNumSamples; - type GetTechnicalAccountId = GetLiquidityProxyAccountId; - type PrimaryMarketTBC = (); - type PrimaryMarketXST = (); - type SecondaryMarket = (); - type VestedRewardsPallet = vested_rewards::Pallet; - type LockedLiquiditySourcesManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type GetADARAccountId = GetADARAccountId; - type ADARCommissionRatioUpdateOrigin = EnsureRoot; - type MaxAdditionalDataLengthXorlessTransfer = ConstU32<128>; - type MaxAdditionalDataLengthSwapTransferBatch = ConstU32<2000>; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type InternalSlippageTolerance = GetInternalSlippageTolerancePercent; - type WeightInfo = (); -} - parameter_types! { pub const GetBuyBackAssetId: AssetId = VXOR; - pub GetTBCBuyBackTBCDPercent: Fixed = fixed!(0.025); } -impl dex_manager::Config for Runtime {} - impl mock_liquidity_source::Config for Runtime { type GetFee = GetFee; type EnsureDEXManager = dex_manager::Pallet; @@ -205,32 +177,6 @@ impl mock_liquidity_source::Config for Runtime type DexInfoProvider = dex_manager::Pallet; } -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - -impl dex_api::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type MockLiquiditySource = (); - type MockLiquiditySource2 = (); - type MockLiquiditySource3 = (); - type MockLiquiditySource4 = (); - type XYKPool = pool_xyk::Pallet; - type XSTPool = (); - type MulticollateralBondingCurvePool = multicollateral_bonding_curve_pool::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type OrderBook = (); - type WeightInfo = (); -} - -impl trading_pair::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type EnsureDEXManager = dex_manager::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type WeightInfo = (); - type AssetInfoProvider = assets::Pallet; -} - impl demeter_farming_platform::Config for Runtime { type RuntimeEvent = RuntimeEvent; type DemeterAssetId = (); @@ -239,41 +185,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = extended_assets::Pallet; - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - -impl pallet_timestamp::Config for Runtime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; @@ -347,7 +258,6 @@ fn bonding_curve_distribution_accounts() -> DistributionAccounts< parameter_types! { pub GetMbcReservesTechAccountId: TechAccountId = { - TechAccountId::from_generic_pair( multicollateral_bonding_curve_pool::TECH_ACCOUNT_PREFIX.to_vec(), multicollateral_bonding_curve_pool::TECH_ACCOUNT_RESERVES.to_vec(), @@ -355,12 +265,10 @@ parameter_types! { }; pub GetMbcReservesAccountId: AccountId = { let tech_account_id = GetMbcReservesTechAccountId::get(); - technical::Pallet::::tech_account_id_to_account_id(&tech_account_id) .expect("Failed to get ordinary account id for technical account id.") }; pub GetMbcRewardsTechAccountId: TechAccountId = { - TechAccountId::from_generic_pair( multicollateral_bonding_curve_pool::TECH_ACCOUNT_PREFIX.to_vec(), multicollateral_bonding_curve_pool::TECH_ACCOUNT_REWARDS.to_vec(), @@ -368,12 +276,10 @@ parameter_types! { }; pub GetMbcRewardsAccountId: AccountId = { let tech_account_id = GetMbcRewardsTechAccountId::get(); - technical::Pallet::::tech_account_id_to_account_id(&tech_account_id) .expect("Failed to get ordinary account id for technical account id.") }; pub GetMbcFreeReservesTechAccountId: TechAccountId = { - TechAccountId::from_generic_pair( multicollateral_bonding_curve_pool::TECH_ACCOUNT_PREFIX.to_vec(), multicollateral_bonding_curve_pool::TECH_ACCOUNT_FREE_RESERVES.to_vec(), @@ -381,11 +287,9 @@ parameter_types! { }; pub GetMbcFreeReservesAccountId: AccountId = { let tech_account_id = GetMbcFreeReservesTechAccountId::get(); - technical::Pallet::::tech_account_id_to_account_id(&tech_account_id) .expect("Failed to get ordinary account id for technical account id.") }; - pub GetTbcIrreducibleReservePercent: Percent = Percent::from_percent(1); } pub struct MockPriceTools; @@ -420,50 +324,6 @@ impl PriceToolsProvider for MockPriceTools { } } -impl multicollateral_bonding_curve_pool::Config for Runtime { - const RETRY_DISTRIBUTION_FREQUENCY: BlockNumber = 1000; - type RuntimeEvent = RuntimeEvent; - type LiquidityProxy = liquidity_proxy::Pallet; - type EnsureDEXManager = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type PriceToolsPallet = MockPriceTools; - type VestedRewardsPallet = VestedRewards; - type TradingPairSourceManager = trading_pair::Pallet; - type BuyBackHandler = liquidity_proxy::LiquidityProxyBuyBackHandler; - type BuyBackTBCDPercent = GetTBCBuyBackTBCDPercent; - type AssetInfoProvider = assets::Pallet; - type IrreducibleReserve = GetTbcIrreducibleReservePercent; - type WeightInfo = (); -} - -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = liquidity_proxy::Pallet; - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - -impl price_tools::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type LiquidityProxy = LiquidityProxy; - type TradingPairSourceManager = trading_pair::Pallet; - type WeightInfo = price_tools::weights::SubstrateWeight; -} - impl Config for Runtime {} pub struct ExtBuilder { diff --git a/pallets/liquidity-proxy/src/mock.rs b/pallets/liquidity-proxy/src/mock.rs index ae7e7a69f..842709c5a 100644 --- a/pallets/liquidity-proxy/src/mock.rs +++ b/pallets/liquidity-proxy/src/mock.rs @@ -30,20 +30,22 @@ use crate::{self as liquidity_proxy, Config, LiquidityProxyBuyBackHandler}; use common::alt::{DiscreteQuotation, SwapChunk}; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::{ self, balance, fixed, fixed_from_basis_points, fixed_wrapper, hash, mock_assets_config, mock_common_config, mock_currencies_config, mock_dex_api_config, mock_dex_manager_config, - mock_extended_assets_config, mock_frame_system_config, mock_pallet_balances_config, - mock_pallet_timestamp_config, mock_permissions_config, mock_technical_config, - mock_tokens_config, mock_trading_pair_config, mock_vested_rewards_config, Amount, AssetId32, - AssetName, AssetSymbol, DEXInfo, Fixed, FromGenericPair, GetMarketInfo, LiquiditySource, + mock_extended_assets_config, mock_frame_system_config, + mock_multicollateral_bonding_curve_pool_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, + mock_trading_pair_config, mock_vested_rewards_config, Amount, AssetId32, AssetName, + AssetSymbol, DEXInfo, Fixed, FromGenericPair, GetMarketInfo, LiquiditySource, LiquiditySourceType, RewardReason, DAI, DEFAULT_BALANCE_PRECISION, DOT, ETH, KSM, PSWAP, USDT, VAL, VXOR, XOR, XST, XSTUSD, }; use currencies::BasicCurrencyAdapter; -use frame_support::traits::{Everything, GenesisBuild}; +use frame_support::traits::{ConstU32, Everything, GenesisBuild}; use frame_support::weights::Weight; use frame_support::{construct_runtime, ensure, fail, parameter_types}; use frame_system; @@ -52,10 +54,7 @@ use traits::MultiCurrency; use common::prelude::{Balance, FixedWrapper, OutcomeFee, QuoteAmount, SwapAmount, SwapOutcome}; use frame_system::{pallet_prelude::BlockNumberFor, EnsureRoot}; use permissions::{Scope, INIT_DEX, MANAGE_DEX}; -use sp_core::{ConstU32, H256}; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; -use sp_runtime::{AccountId32, DispatchError, Perbill, Percent, Permill}; +use sp_runtime::{AccountId32, DispatchError, Perbill, Permill}; use sp_std::str::FromStr; use std::collections::{BTreeSet, HashMap}; @@ -120,7 +119,6 @@ parameter_types! { pub GetFee10: Fixed = fixed_from_basis_points(10u16); pub GetFee20: Fixed = fixed_from_basis_points(20u16); pub GetFee30: Fixed = fixed_from_basis_points(30u16); - pub GetIncentiveAssetId: AssetId = common::PSWAP.into(); pub GetPswapDistributionAccountId: AccountId = AccountId32::from([151; 32]); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; @@ -129,11 +127,7 @@ parameter_types! { pub GetBondingCurveRewardsAccountId: AccountId = AccountId32::from([10; 32]); pub GetFarmingRewardsAccountId: AccountId = AccountId32::from([12; 32]); pub GetCrowdloanRewardsAccountId: AccountId = AccountId32::from([13; 32]); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); pub GetADARAccountId: AccountId = AccountId32::from([14; 32]); - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); - pub GetTbcIrreducibleReservePercent: Percent = Percent::from_percent(1); pub GetInternalSlippageTolerancePercent: Permill = Permill::from_rational(1u32, 1000); // 0.1% } @@ -185,9 +179,17 @@ mock_dex_api_config!( mock_dex_manager_config!(Runtime); mock_extended_assets_config!(Runtime); mock_frame_system_config!(Runtime); +mock_multicollateral_bonding_curve_pool_config!(Runtime); mock_pallet_balances_config!(Runtime); mock_pallet_timestamp_config!(Runtime); mock_permissions_config!(Runtime); +mock_pool_xyk_config!( + Runtime, + trading_pair::Pallet, + trading_pair::Pallet, + pswap_distribution::Pallet +); +mock_pswap_distribution_config!(Runtime, pool_xyk::Pallet, common::mock::GetChameleonPools, (), LiquidityProxyBuyBackHandler); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); mock_trading_pair_config!(Runtime); @@ -217,7 +219,6 @@ impl Config for Runtime { parameter_types! { pub const GetBuyBackAssetId: AssetId = VXOR; - pub GetTBCBuyBackTBCDPercent: Fixed = fixed!(0.025); } impl mock_liquidity_source::Config for Runtime { @@ -248,27 +249,6 @@ impl mock_liquidity_source::Config for Runtime type DexInfoProvider = dex_manager::Pallet; } -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type PoolXykPallet = pool_xyk::Pallet; - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type BuyBackHandler = LiquidityProxyBuyBackHandler; - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - impl demeter_farming_platform::Config for Runtime { type RuntimeEvent = RuntimeEvent; type DemeterAssetId = (); @@ -277,34 +257,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type OnPoolCreated = pswap_distribution::Pallet; - type OnPoolReservesChanged = (); - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = extended_assets::Pallet; - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; @@ -314,22 +266,6 @@ impl ceres_liquidity_locker::Config for Runtime { type WeightInfo = (); } -impl multicollateral_bonding_curve_pool::Config for Runtime { - const RETRY_DISTRIBUTION_FREQUENCY: BlockNumber = 1000; - type RuntimeEvent = RuntimeEvent; - type LiquidityProxy = (); - type EnsureTradingPairExists = trading_pair::Pallet; - type EnsureDEXManager = dex_manager::Pallet; - type VestedRewardsPallet = VestedRewards; - type TradingPairSourceManager = trading_pair::Pallet; - type PriceToolsPallet = (); - type BuyBackHandler = LiquidityProxyBuyBackHandler; - type BuyBackTBCDPercent = GetTBCBuyBackTBCDPercent; - type AssetInfoProvider = assets::Pallet; - type IrreducibleReserve = GetTbcIrreducibleReservePercent; - type WeightInfo = (); -} - pub struct ExtBuilder { pub total_supply: Balance, pub xyk_reserves: Vec<(DEXId, AssetId, (Balance, Balance))>, diff --git a/pallets/mock-liquidity-source/src/mock.rs b/pallets/mock-liquidity-source/src/mock.rs index 81b670745..acd1373ab 100644 --- a/pallets/mock-liquidity-source/src/mock.rs +++ b/pallets/mock-liquidity-source/src/mock.rs @@ -42,9 +42,6 @@ use frame_support::sp_runtime::AccountId32; use frame_support::traits::{Everything, GenesisBuild}; use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types}; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_runtime::Perbill; pub type AccountId = AccountId32; diff --git a/pallets/multicollateral-bonding-curve-pool/src/mock.rs b/pallets/multicollateral-bonding-curve-pool/src/mock.rs index 1c4793cfa..4cb675863 100644 --- a/pallets/multicollateral-bonding-curve-pool/src/mock.rs +++ b/pallets/multicollateral-bonding-curve-pool/src/mock.rs @@ -29,7 +29,7 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use crate::{self as multicollateral_bonding_curve_pool, Config, Rewards, TotalRewards}; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::{ AssetInfoProvider, Balance, FixedWrapper, OutcomeFee, PriceToolsProvider, QuoteAmount, SwapAmount, SwapOutcome, @@ -38,8 +38,9 @@ use common::{ self, balance, fixed, fixed_wrapper, hash, mock_assets_config, mock_common_config, mock_currencies_config, mock_dex_manager_config, mock_frame_system_config, mock_pallet_balances_config, mock_pallet_timestamp_config, mock_permissions_config, - mock_price_tools_config, mock_technical_config, mock_tokens_config, mock_trading_pair_config, - Amount, AssetId32, AssetName, AssetSymbol, BuyBackHandler, DEXInfo, Fixed, LiquidityProxyTrait, + mock_pool_xyk_config, mock_price_tools_config, mock_pswap_distribution_config, + mock_technical_config, mock_tokens_config, mock_trading_pair_config, Amount, AssetId32, + AssetName, AssetSymbol, BuyBackHandler, DEXInfo, Fixed, LiquidityProxyTrait, LiquiditySourceFilter, LiquiditySourceType, PriceVariant, TechPurpose, Vesting, DAI, DEFAULT_BALANCE_PRECISION, PSWAP, TBCD, USDT, VAL, VXOR, XOR, XST, XSTUSD, }; @@ -49,13 +50,10 @@ use frame_support::traits::{Everything, GenesisBuild}; use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types, Blake2_128Concat}; use frame_system::pallet_prelude::BlockNumberFor; -use hex_literal::hex; use orml_traits::MultiCurrency; use permissions::{Scope, INIT_DEX, MANAGE_DEX}; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Zero}; +use sp_runtime::traits::Zero; use sp_runtime::{DispatchError, DispatchResult, Perbill, Percent}; use std::collections::HashMap; @@ -117,17 +115,13 @@ parameter_types! { pub const CreationFee: u128 = 0; pub const TransactionByteFee: u128 = 1; pub const GetNumSamples: usize = 40; - pub GetIncentiveAssetId: AssetId = common::AssetId32::from_bytes(hex!("0200050000000000000000000000000000000000000000000000000000000000").into()); pub GetPswapDistributionAccountId: AccountId = AccountId32::from([151; 32]); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; pub GetParliamentAccountId: AccountId = AccountId32::from([152; 32]); pub GetMarketMakerRewardsAccountId: AccountId = AccountId32::from([153; 32]); pub GetBondingCurveRewardsAccountId: AccountId = AccountId32::from([154; 32]); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); pub GetTBCBuyBackTBCDPercent: Fixed = fixed!(0.025); - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); pub GetTbcIrreducibleReservePercent: Percent = Percent::from_percent(1); } @@ -166,7 +160,9 @@ mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); mock_pallet_timestamp_config!(Runtime); mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime); mock_price_tools_config!(Runtime); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); mock_trading_pair_config!(Runtime); @@ -193,7 +189,6 @@ impl Config for Runtime { type IrreducibleReserve = GetTbcIrreducibleReservePercent; type WeightInfo = (); } - pub struct BuyBackHandlerImpl; impl BuyBackHandler for BuyBackHandlerImpl { @@ -251,27 +246,6 @@ parameter_types! { pub const GetBuyBackAssetId: AssetId = VXOR; } -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - impl demeter_farming_platform::Config for Runtime { type RuntimeEvent = RuntimeEvent; type DemeterAssetId = (); @@ -280,34 +254,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; diff --git a/pallets/oracle-proxy/src/mock.rs b/pallets/oracle-proxy/src/mock.rs index c31c8e82c..eaad13474 100644 --- a/pallets/oracle-proxy/src/mock.rs +++ b/pallets/oracle-proxy/src/mock.rs @@ -30,17 +30,15 @@ use crate::{self as oracle_proxy, Config}; use band; -use common::{self, mock_band_config, mock_pallet_timestamp_config, SymbolName}; -use frame_support::traits::{ConstU16, ConstU64}; -use frame_system as system; -use sp_core::H256; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, +use common::{ + self, mock_band_config, mock_frame_system_config, mock_pallet_timestamp_config, SymbolName, }; +use frame_support::traits::{ConstU16, ConstU32}; +use frame_system; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; +type AccountId = u64; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( @@ -56,46 +54,20 @@ frame_support::construct_runtime!( } ); -impl system::Config for Runtime { - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU64<250>; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = ConstU16<42>; - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - impl Config for Runtime { - type Symbol = SymbolName; + type BandChainOracle = band::Pallet; type RuntimeEvent = RuntimeEvent; + type Symbol = SymbolName; type WeightInfo = (); - type BandChainOracle = band::Pallet; } mock_band_config!(Runtime); +mock_frame_system_config!(Runtime, ConstU16<42>, ConstU32<16>, ()); mock_pallet_timestamp_config!(Runtime); // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default() + frame_system::GenesisConfig::default() .build_storage::() .unwrap() .into() diff --git a/pallets/permissions/src/mock.rs b/pallets/permissions/src/mock.rs index f8363088e..1664bc6dc 100644 --- a/pallets/permissions/src/mock.rs +++ b/pallets/permissions/src/mock.rs @@ -36,9 +36,6 @@ use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types}; use frame_system; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_runtime::Perbill; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; diff --git a/pallets/pool-xyk/benchmarking/src/mock.rs b/pallets/pool-xyk/benchmarking/src/mock.rs index c3768e01d..210612bed 100644 --- a/pallets/pool-xyk/benchmarking/src/mock.rs +++ b/pallets/pool-xyk/benchmarking/src/mock.rs @@ -31,27 +31,24 @@ #![cfg(test)] use crate::{Config, *}; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::{ - fixed, hash, mock_assets_config, mock_common_config, mock_currencies_config, + hash, mock_assets_config, mock_common_config, mock_currencies_config, mock_dex_api_config, mock_dex_manager_config, mock_extended_assets_config, mock_frame_system_config, mock_pallet_balances_config, mock_pallet_timestamp_config, mock_permissions_config, - mock_technical_config, mock_tokens_config, mock_trading_pair_config, Amount, DEXId, DEXInfo, - Fixed, PSWAP, VXOR, XST, + mock_pool_xyk_config, mock_pswap_distribution_config, mock_technical_config, + mock_tokens_config, mock_trading_pair_config, Amount, DEXId, DEXInfo, VXOR, XST, }; use currencies::BasicCurrencyAdapter; -use frame_support::traits::{Everything, GenesisBuild}; +use frame_support::traits::{ConstU32, Everything, GenesisBuild}; use frame_support::{construct_runtime, parameter_types}; use frame_system; use common::prelude::Balance; use frame_system::pallet_prelude::BlockNumberFor; use permissions::{Scope, BURN, MANAGE_DEX, MINT}; -use sp_core::{ConstU32, H256}; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; -use sp_runtime::{AccountId32, Percent}; +use sp_runtime::AccountId32; pub type AssetId = common::AssetId32; pub type TechAssetId = common::TechAssetId; @@ -75,11 +72,7 @@ parameter_types! { pub GetPswapDistributionAccountId: AccountId = AccountId32::from([3; 32]); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; - pub GetIncentiveAssetId: AssetId = PSWAP.into(); pub GetParliamentAccountId: AccountId = AccountId32::from([8; 32]); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); } construct_runtime! { @@ -110,12 +103,15 @@ construct_runtime! { mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); +mock_dex_api_config!(Runtime); mock_dex_manager_config!(Runtime); mock_extended_assets_config!(Runtime); mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); mock_pallet_timestamp_config!(Runtime); mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); mock_trading_pair_config!(Runtime); @@ -124,20 +120,6 @@ parameter_types! { pub const GetBuyBackAssetId: AssetId = VXOR; } -impl dex_api::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type MockLiquiditySource = (); - type MockLiquiditySource2 = (); - type MockLiquiditySource3 = (); - type MockLiquiditySource4 = (); - type MulticollateralBondingCurvePool = (); - type XYKPool = pool_xyk::Pallet; - type XSTPool = (); - type DexInfoProvider = dex_manager::Pallet; - type OrderBook = (); - type WeightInfo = (); -} - impl demeter_farming_platform::Config for Runtime { type RuntimeEvent = RuntimeEvent; type DemeterAssetId = (); @@ -146,55 +128,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = extended_assets::Pallet; - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; diff --git a/pallets/pool-xyk/src/mock.rs b/pallets/pool-xyk/src/mock.rs index 745773fae..0273169b4 100644 --- a/pallets/pool-xyk/src/mock.rs +++ b/pallets/pool-xyk/src/mock.rs @@ -35,10 +35,11 @@ use common::{ mock_currencies_config, mock_dex_manager_config, mock_extended_assets_config, mock_frame_system_config, mock_oracle_proxy_config, mock_orml_tokens_config, mock_pallet_balances_config, mock_pallet_timestamp_config, mock_permissions_config, - mock_technical_config, DEXInfo, GetMarketInfo, VXOR, + mock_pswap_distribution_config, mock_technical_config, mock_trading_pair_config, + mock_xst_config, DEXInfo, GetMarketInfo, VXOR, }; use currencies::BasicCurrencyAdapter; -use frame_support::traits::{Everything, GenesisBuild}; +use frame_support::traits::{ConstU32, Everything, GenesisBuild}; use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types}; use frame_system; @@ -46,9 +47,6 @@ use hex_literal::hex; use orml_traits::parameter_type_with_key; use permissions::{Scope, MANAGE_DEX}; use sp_core::crypto::AccountId32; -use sp_core::{ConstU32, H256}; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_runtime::{Perbill, Percent}; use sp_std::collections::btree_set::BTreeSet; @@ -74,7 +72,6 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); pub GetBaseAssetId: AssetId = common::AssetId32::from_bytes(hex!("0200000000000000000000000000000000000000000000000000000000000000").into()); - pub GetIncentiveAssetId: AssetId = common::AssetId32::from_bytes(hex!("0200050000000000000000000000000000000000000000000000000000000000").into()); pub GetPswapDistributionAccountId: AccountId = AccountId32::from([3; 32]); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; @@ -129,41 +126,15 @@ mock_orml_tokens_config!(Runtime); mock_pallet_balances_config!(Runtime); mock_pallet_timestamp_config!(Runtime); mock_permissions_config!(Runtime); +mock_pswap_distribution_config!(Runtime, PoolXYK, GetChameleonPools); mock_technical_config!(Runtime, crate::PolySwapAction); - -impl trading_pair::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type EnsureDEXManager = dex_manager::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type WeightInfo = (); - type AssetInfoProvider = assets::Pallet; -} +mock_trading_pair_config!(Runtime); +mock_xst_config!(Runtime); parameter_types! { pub GetBuyBackAssetId: AssetId = VXOR.into(); } -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; @@ -193,20 +164,6 @@ parameter_types! { pub const GetSyntheticBaseBuySellLimit: Balance = balance!(10000000000); } -impl xst::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type GetSyntheticBaseAssetId = GetSyntheticBaseAssetId; - type GetXSTPoolPermissionedTechAccountId = GetXSTPoolPermissionedTechAccountId; - type EnsureDEXManager = DexManager; - type PriceToolsPallet = (); - type WeightInfo = (); - type Oracle = OracleProxy; - type Symbol = SymbolName; - type GetSyntheticBaseBuySellLimit = GetSyntheticBaseBuySellLimit; - type TradingPairSourceManager = trading_pair::Pallet; - type AssetInfoProvider = assets::Pallet; -} - parameter_type_with_key! { pub GetTradingPairRestrictedFlag: |trading_pair: common::TradingPair| -> bool { let common::TradingPair { diff --git a/pallets/price-tools/src/mock.rs b/pallets/price-tools/src/mock.rs index 6fc1597b6..2aa37e43a 100644 --- a/pallets/price-tools/src/mock.rs +++ b/pallets/price-tools/src/mock.rs @@ -29,15 +29,15 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use crate::{self as price_tools, Config}; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::{Balance, QuoteAmount, SwapAmount, SwapOutcome}; use common::{ - self, balance, fixed, hash, mock_assets_config, mock_common_config, mock_currencies_config, + self, balance, hash, mock_assets_config, mock_common_config, mock_currencies_config, mock_dex_manager_config, mock_frame_system_config, mock_pallet_balances_config, - mock_pallet_timestamp_config, mock_permissions_config, mock_technical_config, - mock_tokens_config, Amount, AssetId32, AssetName, AssetSymbol, DEXInfo, Fixed, - LiquidityProxyTrait, LiquiditySourceFilter, LiquiditySourceType, DEFAULT_BALANCE_PRECISION, - ETH, PSWAP, USDT, VAL, VXOR, XOR, XST, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, Amount, AssetId32, + AssetName, AssetSymbol, DEXInfo, LiquidityProxyTrait, LiquiditySourceFilter, + LiquiditySourceType, DEFAULT_BALANCE_PRECISION, ETH, PSWAP, USDT, VAL, VXOR, XOR, XST, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::{Everything, GenesisBuild}; @@ -47,10 +47,8 @@ use frame_system::pallet_prelude::BlockNumberFor; use hex_literal::hex; use permissions::{Scope, INIT_DEX, MANAGE_DEX}; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Zero}; -use sp_runtime::{DispatchError, Perbill, Percent}; +use sp_runtime::traits::Zero; +use sp_runtime::{DispatchError, Perbill}; pub type AccountId = AccountId32; pub type BlockNumber = u64; @@ -92,14 +90,10 @@ parameter_types! { pub const CreationFee: u128 = 0; pub const TransactionByteFee: u128 = 1; pub const GetNumSamples: usize = 40; - pub GetIncentiveAssetId: AssetId = common::AssetId32::from_bytes(hex!("0200050000000000000000000000000000000000000000000000000000000000").into()); pub GetPswapDistributionAccountId: AccountId = AccountId32::from([151; 32]); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; pub GetParliamentAccountId: AccountId = AccountId32::from([152; 32]); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); } construct_runtime! { @@ -126,6 +120,13 @@ construct_runtime! { } } +impl Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type LiquidityProxy = MockDEXApi; + type TradingPairSourceManager = TradingPair; + type WeightInfo = (); +} + mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); @@ -134,45 +135,25 @@ mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); mock_pallet_timestamp_config!(Runtime); mock_permissions_config!(Runtime); +mock_pool_xyk_config!( + Runtime, + TradingPair, + (), + pswap_distribution::Pallet +); +mock_pswap_distribution_config!(Runtime); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); -impl mock_liquidity_source::Config for Runtime { - type GetFee = (); - type EnsureDEXManager = (); - type EnsureTradingPairExists = (); - type DexInfoProvider = dex_manager::Pallet; -} - -impl Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type LiquidityProxy = MockDEXApi; - type TradingPairSourceManager = TradingPair; - type WeightInfo = (); -} - parameter_types! { pub const GetBuyBackAssetId: AssetId = VXOR; } -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; + +impl mock_liquidity_source::Config for Runtime { + type GetFee = (); type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type PoolXykPallet = pool_xyk::Pallet; - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type BuyBackHandler = (); + type EnsureTradingPairExists = (); type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; } impl demeter_farming_platform::Config for Runtime { @@ -239,34 +220,6 @@ impl common::TradingPairSourceManager for TradingPair { } } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = TradingPair; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = (); - type EnabledSourcesManager = (); - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = pswap_distribution::Pallet; - type OnPoolReservesChanged = PriceTools; - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; diff --git a/pallets/pswap-distribution/benchmarking/src/mock.rs b/pallets/pswap-distribution/benchmarking/src/mock.rs index 2a9531924..1be756394 100644 --- a/pallets/pswap-distribution/benchmarking/src/mock.rs +++ b/pallets/pswap-distribution/benchmarking/src/mock.rs @@ -28,12 +28,14 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::Balance; use common::{ balance, fixed, mock_assets_config, mock_common_config, mock_currencies_config, - mock_frame_system_config, mock_pallet_balances_config, mock_technical_config, - mock_tokens_config, AssetName, AssetSymbol, BalancePrecision, ContentSource, Description, + mock_dex_manager_config, mock_frame_system_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, + mock_trading_pair_config, AssetName, AssetSymbol, BalancePrecision, ContentSource, Description, Fixed, FromGenericPair, DEFAULT_BALANCE_PRECISION, PSWAP, VXOR, XOR, }; use currencies::BasicCurrencyAdapter; @@ -43,10 +45,8 @@ use frame_support::{construct_runtime, parameter_types}; use frame_system; use hex_literal::hex; use permissions::Scope; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Zero}; -use sp_runtime::{AccountId32, Perbill, Percent}; +use sp_runtime::traits::Zero; +use sp_runtime::{AccountId32, Perbill}; use sp_std::vec; use crate::Config; @@ -86,7 +86,6 @@ pub const DEX_A_ID: DEXId = common::DEXId::Polkaswap; parameter_types! { pub GetBaseAssetId: AssetId = XOR.into(); - pub GetIncentiveAssetId: AssetId = PSWAP.into(); pub const PoolTokenAId: AssetId = common::AssetId32::from_bytes(hex!("0211110000000000000000000000000000000000000000000000000000000000")); pub const PoolTokenBId: AssetId = common::AssetId32::from_bytes(hex!("0222220000000000000000000000000000000000000000000000000000000000")); pub const BlockHashCount: u64 = 250; @@ -114,11 +113,7 @@ parameter_types! { pub const TransferFee: u128 = 0; pub const CreationFee: u128 = 0; pub const TransactionByteFee: u128 = 1; - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); pub GetParliamentAccountId: AccountId = AccountId32::from([7u8; 32]); - pub const MinimumPeriod: u64 = 5; - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); } construct_runtime! { @@ -144,55 +139,26 @@ construct_runtime! { } } +impl Config for Runtime {} + mock_assets_config!(Runtime); mock_common_config!(Runtime); mock_currencies_config!(Runtime); +mock_dex_manager_config!(Runtime); mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); +mock_pallet_timestamp_config!(Runtime); +mock_permissions_config!(Runtime); +mock_pswap_distribution_config!(Runtime, PoolXYK); +mock_pool_xyk_config!(Runtime); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); - -impl Config for Runtime {} - -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = DexManager; - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - -impl permissions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} +mock_trading_pair_config!(Runtime); parameter_types! { pub const GetBuyBackAssetId: AssetId = VXOR; } -impl dex_manager::Config for Runtime {} - -impl trading_pair::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type EnsureDEXManager = dex_manager::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type WeightInfo = (); - type AssetInfoProvider = assets::Pallet; -} - impl demeter_farming_platform::Config for Runtime { type RuntimeEvent = RuntimeEvent; type DemeterAssetId = (); @@ -201,41 +167,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - -impl pallet_timestamp::Config for Runtime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumber = 14_440; type RuntimeEvent = RuntimeEvent; diff --git a/pallets/pswap-distribution/src/mock.rs b/pallets/pswap-distribution/src/mock.rs index 5067de3f2..0b582b535 100644 --- a/pallets/pswap-distribution/src/mock.rs +++ b/pallets/pswap-distribution/src/mock.rs @@ -29,14 +29,14 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use crate::{self as pswap_distribution, Config}; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::Balance; use common::{ balance, fixed, mock_assets_config, mock_common_config, mock_currencies_config, mock_dex_manager_config, mock_frame_system_config, mock_pallet_balances_config, - mock_pallet_timestamp_config, mock_permissions_config, mock_technical_config, - mock_tokens_config, AssetName, AssetSymbol, BalancePrecision, ContentSource, Description, - Fixed, FromGenericPair, DEFAULT_BALANCE_PRECISION, PSWAP, VXOR, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_technical_config, mock_tokens_config, AssetName, AssetSymbol, BalancePrecision, + ContentSource, Description, Fixed, FromGenericPair, DEFAULT_BALANCE_PRECISION, PSWAP, VXOR, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::{Everything, GenesisBuild}; @@ -46,9 +46,7 @@ use frame_system; use frame_system::pallet_prelude::BlockNumberFor; use hex_literal::hex; use permissions::Scope; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Zero}; +use sp_runtime::traits::Zero; use sp_runtime::{AccountId32, Perbill, Percent}; pub type AccountId = AccountId32; @@ -126,9 +124,6 @@ parameter_types! { pub const CreationFee: u128 = 0; pub const TransactionByteFee: u128 = 1; pub GetParliamentAccountId: AccountId = AccountId32::from([7u8; 32]); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); } construct_runtime! { @@ -161,6 +156,7 @@ mock_frame_system_config!(Runtime); mock_pallet_balances_config!(Runtime); mock_pallet_timestamp_config!(Runtime); mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime, (), ()); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); @@ -197,34 +193,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = (); - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = (); - type EnabledSourcesManager = (); - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; diff --git a/pallets/referrals/src/mock.rs b/pallets/referrals/src/mock.rs index b75cf5709..84b1a11ef 100644 --- a/pallets/referrals/src/mock.rs +++ b/pallets/referrals/src/mock.rs @@ -41,9 +41,6 @@ use frame_support::traits::{Everything, GenesisBuild}; use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types}; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_runtime::{self, Perbill}; type DEXId = common::DEXId; diff --git a/pallets/rewards/src/mock.rs b/pallets/rewards/src/mock.rs index 8e3aa5327..0e50d15d6 100644 --- a/pallets/rewards/src/mock.rs +++ b/pallets/rewards/src/mock.rs @@ -34,9 +34,6 @@ use frame_support::weights::{RuntimeDbWeight, Weight}; use frame_support::{construct_runtime, parameter_types}; use hex_literal::hex; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_runtime::{Perbill, Percent}; use common::mock::ExistentialDeposits; diff --git a/pallets/soratopia/src/mock.rs b/pallets/soratopia/src/mock.rs index c17420a79..209159301 100644 --- a/pallets/soratopia/src/mock.rs +++ b/pallets/soratopia/src/mock.rs @@ -43,11 +43,10 @@ use frame_support::traits::Everything; use frame_system::offchain::SendTransactionTypes; use hex_literal::hex; use sp_core::crypto::AccountId32; -use sp_core::H256; use sp_runtime::MultiSignature; use sp_runtime::{ - testing::{Header, TestXt}, - traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, + testing::TestXt, + traits::{IdentifyAccount, Verify}, }; type AccountId = <::Signer as IdentifyAccount>::AccountId; diff --git a/pallets/technical/src/mock.rs b/pallets/technical/src/mock.rs index 9bb5bd74f..4ec9d99bf 100644 --- a/pallets/technical/src/mock.rs +++ b/pallets/technical/src/mock.rs @@ -43,9 +43,6 @@ use frame_support::{construct_runtime, dispatch, parameter_types}; use frame_system; use orml_traits::parameter_type_with_key; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_runtime::Perbill; use sp_std::marker::PhantomData; use PolySwapActionExample::*; diff --git a/pallets/trading-pair/src/mock.rs b/pallets/trading-pair/src/mock.rs index ca11b48bb..b8c977689 100644 --- a/pallets/trading-pair/src/mock.rs +++ b/pallets/trading-pair/src/mock.rs @@ -44,9 +44,7 @@ use frame_support::{construct_runtime, parameter_types}; use frame_system; use permissions::{Scope, INIT_DEX, MANAGE_DEX}; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Zero}; +use sp_runtime::traits::Zero; use sp_runtime::Perbill; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; diff --git a/pallets/vested-rewards/src/mock.rs b/pallets/vested-rewards/src/mock.rs index d6e53ce94..dac076d87 100644 --- a/pallets/vested-rewards/src/mock.rs +++ b/pallets/vested-rewards/src/mock.rs @@ -29,17 +29,19 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use crate::{self as vested_rewards, Config}; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::{Balance, DEXInfo}; use common::prelude::{LiquiditySourceType, QuoteAmount, SwapAmount, SwapOutcome}; use common::weights::BlockWeights; use common::{ balance, fixed, hash, mock_assets_config, mock_common_config, mock_currencies_config, - mock_dex_manager_config, mock_frame_system_config, mock_pallet_balances_config, - mock_pallet_timestamp_config, mock_permissions_config, mock_technical_config, - mock_tokens_config, AssetId32, AssetName, AssetSymbol, BalancePrecision, ContentSource, DEXId, - Description, Fixed, LiquidityProxyTrait, LiquiditySourceFilter, DEFAULT_BALANCE_PRECISION, DOT, - KSM, PSWAP, TBCD, VXOR, XOR, XST, + mock_dex_manager_config, mock_frame_system_config, + mock_multicollateral_bonding_curve_pool_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_pool_xyk_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, AssetId32, + AssetName, AssetSymbol, BalancePrecision, ContentSource, DEXId, Description, Fixed, + LiquidityProxyTrait, LiquiditySourceFilter, DEFAULT_BALANCE_PRECISION, DOT, KSM, PSWAP, TBCD, + VXOR, XOR, XST, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::Hooks; @@ -52,7 +54,7 @@ use sp_core::crypto::AccountId32; use sp_core::H256; use sp_runtime::testing::Header; use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Zero}; -use sp_runtime::{DispatchError, Perbill, Percent}; +use sp_runtime::{DispatchError, Perbill}; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -139,9 +141,17 @@ mock_common_config!(Runtime); mock_currencies_config!(Runtime); mock_dex_manager_config!(Runtime); mock_frame_system_config!(Runtime); +mock_multicollateral_bonding_curve_pool_config!(Runtime, MockLiquidityProxy, (), (), ()); mock_pallet_balances_config!(Runtime); mock_pallet_timestamp_config!(Runtime); mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime, (), (), pswap_distribution::Pallet); +mock_pswap_distribution_config!( + Runtime, + pool_xyk::Pallet, + common::mock::GetChameleonPools, + MockLiquidityProxy +); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); @@ -150,7 +160,6 @@ parameter_types! { pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); - pub GetIncentiveAssetId: AssetId = common::PSWAP.into(); pub GetPswapDistributionAccountId: AccountId = AccountId32::from([151; 32]); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; @@ -159,11 +168,7 @@ parameter_types! { pub GetBondingCurveRewardsAccountId: AccountId = AccountId32::from([154; 32]); pub GetFarmingRewardsAccountId: AccountId = AccountId32::from([155; 32]); pub GetCrowdloanRewardsAccountId: AccountId = AccountId32::from([156; 32]); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); pub const CrowdloanVestingPeriod: u64 = 14400; - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); - pub GetTbcIrreducibleReservePercent: Percent = Percent::from_percent(1); pub const MaxVestingSchedules: u32 = 5; pub const MinVestedTransfer: Balance = 5; pub MaxWeightForAutoClaim: Weight = Perbill::from_percent(10) * BlockWeights::get().max_block; @@ -186,28 +191,6 @@ impl Config for Runtime { parameter_types! { pub const GetBaseAssetId: AssetId = XOR; pub const GetBuyBackAssetId: AssetId = VXOR; - pub GetTBCBuyBackTBCDPercent: Fixed = fixed!(0.025); -} - -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = MockLiquidityProxy; - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type PoolXykPallet = pool_xyk::Pallet; - type GetParliamentAccountId = GetParliamentAccountId; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; } impl demeter_farming_platform::Config for Runtime { @@ -218,50 +201,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = (); - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = (); - type EnabledSourcesManager = (); - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = pswap_distribution::Pallet; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - -impl multicollateral_bonding_curve_pool::Config for Runtime { - const RETRY_DISTRIBUTION_FREQUENCY: BlockNumber = 1000; - type RuntimeEvent = RuntimeEvent; - type LiquidityProxy = MockLiquidityProxy; - type EnsureTradingPairExists = (); - type EnsureDEXManager = dex_manager::Pallet; - type VestedRewardsPallet = VestedRewards; - type TradingPairSourceManager = (); - type PriceToolsPallet = (); - type BuyBackHandler = (); - type BuyBackTBCDPercent = GetTBCBuyBackTBCDPercent; - type AssetInfoProvider = assets::Pallet; - type IrreducibleReserve = GetTbcIrreducibleReservePercent; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent; diff --git a/pallets/xor-fee/src/mock.rs b/pallets/xor-fee/src/mock.rs index 808c0bfa7..44d734535 100644 --- a/pallets/xor-fee/src/mock.rs +++ b/pallets/xor-fee/src/mock.rs @@ -57,9 +57,6 @@ use frame_support::weights::{ConstantMultiplier, IdentityFee, Weight}; use frame_support::{construct_runtime, parameter_types, storage_alias}; use frame_system::EnsureRoot; use permissions::{Scope, BURN, MINT}; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_runtime::{AccountId32, DispatchError, Percent}; use sp_staking::SessionIndex; use traits::MultiCurrency; diff --git a/pallets/xst/benchmarking/src/mock.rs b/pallets/xst/benchmarking/src/mock.rs index d4d1270e3..6a36527e3 100644 --- a/pallets/xst/benchmarking/src/mock.rs +++ b/pallets/xst/benchmarking/src/mock.rs @@ -29,14 +29,15 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use crate::Config; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::Balance; use common::{ - self, balance, fixed, hash, mock_assets_config, mock_band_config, mock_common_config, + self, balance, hash, mock_assets_config, mock_band_config, mock_common_config, mock_currencies_config, mock_dex_api_config, mock_dex_manager_config, mock_frame_system_config, mock_oracle_proxy_config, mock_pallet_balances_config, mock_pallet_timestamp_config, - mock_permissions_config, mock_price_tools_config, mock_technical_config, mock_tokens_config, - mock_trading_pair_config, Amount, AssetId32, AssetName, AssetSymbol, DEXInfo, Fixed, + mock_permissions_config, mock_pool_xyk_config, mock_price_tools_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, + mock_trading_pair_config, mock_xst_config, Amount, AssetId32, AssetName, AssetSymbol, DEXInfo, FromGenericPair, DAI, DEFAULT_BALANCE_PRECISION, PSWAP, USDT, VAL, VXOR, XOR, XST, XSTUSD, }; use currencies::BasicCurrencyAdapter; @@ -44,13 +45,10 @@ use frame_support::traits::{Everything, GenesisBuild}; use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types}; use frame_system::pallet_prelude::BlockNumberFor; -use hex_literal::hex; use permissions::{Scope, INIT_DEX, MANAGE_DEX}; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Zero}; -use sp_runtime::{Perbill, Percent}; +use sp_runtime::traits::Zero; +use sp_runtime::Perbill; pub type AccountId = AccountId32; pub type BlockNumber = u64; @@ -89,13 +87,10 @@ parameter_types! { pub const CreationFee: u128 = 0; pub const TransactionByteFee: u128 = 1; pub const GetNumSamples: usize = 40; - pub GetIncentiveAssetId: AssetId = common::AssetId32::from_bytes(hex!("0200050000000000000000000000000000000000000000000000000000000000").into()); pub GetPswapDistributionAccountId: AccountId = AccountId32::from([151; 32]); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; pub GetParliamentAccountId: AccountId = AccountId32::from([152; 32]); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); pub GetXSTPoolPermissionedTechAccountId: TechAccountId = { let tech_account_id = TechAccountId::from_generic_pair( xst::TECH_ACCOUNT_PREFIX.to_vec(), @@ -111,7 +106,6 @@ parameter_types! { account_id }; pub const GetSyntheticBaseBuySellLimit: Balance = balance!(10000000000000); - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); } construct_runtime! { @@ -154,55 +148,23 @@ mock_oracle_proxy_config!(Runtime, Band); mock_pallet_balances_config!(Runtime); mock_pallet_timestamp_config!(Runtime); mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime); mock_price_tools_config!(Runtime); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); mock_trading_pair_config!(Runtime); - -impl mock_liquidity_source::Config for Runtime { - type GetFee = (); - type EnsureDEXManager = (); - type EnsureTradingPairExists = (); - type DexInfoProvider = dex_manager::Pallet; -} - -impl xst::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type GetSyntheticBaseAssetId = GetSyntheticBaseAssetId; - type GetXSTPoolPermissionedTechAccountId = GetXSTPoolPermissionedTechAccountId; - type EnsureDEXManager = dex_manager::Pallet; - type PriceToolsPallet = price_tools::Pallet; - type Oracle = OracleProxy; - type Symbol = ::Symbol; - type GetSyntheticBaseBuySellLimit = GetSyntheticBaseBuySellLimit; - type TradingPairSourceManager = trading_pair::Pallet; - type WeightInfo = (); - type AssetInfoProvider = assets::Pallet; -} +mock_xst_config!(Runtime, price_tools::Pallet); parameter_types! { pub const GetBuyBackAssetId: AssetId = XST; } -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; +impl mock_liquidity_source::Config for Runtime { + type GetFee = (); type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type GetBuyBackAssetId = GetPSWAPBuyBackAssetId; - type BuyBackHandler = (); + type EnsureTradingPairExists = (); type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; } impl demeter_farming_platform::Config for Runtime { @@ -213,34 +175,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - impl Config for Runtime {} impl ceres_liquidity_locker::Config for Runtime { diff --git a/pallets/xst/src/mock.rs b/pallets/xst/src/mock.rs index b951bb263..3fea0fb16 100644 --- a/pallets/xst/src/mock.rs +++ b/pallets/xst/src/mock.rs @@ -29,14 +29,15 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use crate::{self as xstpool, Config}; -use common::mock::{ExistentialDeposits, GetTradingPairRestrictedFlag}; +use common::mock::ExistentialDeposits; use common::prelude::{Balance, PriceToolsProvider}; use common::{ - self, balance, fixed, hash, mock_assets_config, mock_band_config, mock_common_config, + self, balance, hash, mock_assets_config, mock_band_config, mock_common_config, mock_currencies_config, mock_dex_api_config, mock_dex_manager_config, mock_frame_system_config, mock_oracle_proxy_config, mock_pallet_balances_config, mock_pallet_timestamp_config, - mock_permissions_config, mock_price_tools_config, mock_technical_config, mock_tokens_config, - mock_trading_pair_config, Amount, AssetId32, AssetIdOf, AssetName, AssetSymbol, DEXInfo, Fixed, + mock_permissions_config, mock_pool_xyk_config, mock_price_tools_config, + mock_pswap_distribution_config, mock_technical_config, mock_tokens_config, + mock_trading_pair_config, Amount, AssetId32, AssetIdOf, AssetName, AssetSymbol, DEXInfo, FromGenericPair, PriceVariant, DAI, DEFAULT_BALANCE_PRECISION, PSWAP, USDT, VAL, VXOR, XOR, XST, XSTUSD, }; @@ -45,13 +46,10 @@ use frame_support::traits::{Everything, GenesisBuild}; use frame_support::weights::Weight; use frame_support::{construct_runtime, parameter_types}; use frame_system::pallet_prelude::BlockNumberFor; -use hex_literal::hex; use permissions::{Scope, INIT_DEX, MANAGE_DEX}; use sp_core::crypto::AccountId32; -use sp_core::H256; -use sp_runtime::testing::Header; -use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Zero}; -use sp_runtime::{Perbill, Percent}; +use sp_runtime::traits::Zero; +use sp_runtime::Perbill; pub type AccountId = AccountId32; pub type BlockNumber = u64; @@ -89,13 +87,10 @@ parameter_types! { pub const CreationFee: u128 = 0; pub const TransactionByteFee: u128 = 1; pub const GetNumSamples: usize = 40; - pub GetIncentiveAssetId: AssetId = common::AssetId32::from_bytes(hex!("0200050000000000000000000000000000000000000000000000000000000000").into()); pub GetPswapDistributionAccountId: AccountId = AccountId32::from([151; 32]); pub const GetDefaultSubscriptionFrequency: BlockNumber = 10; pub const GetBurnUpdateFrequency: BlockNumber = 14400; pub GetParliamentAccountId: AccountId = AccountId32::from([152; 32]); - pub GetXykFee: Fixed = fixed!(0.003); - pub GetXykMaxIssuanceRatio: Fixed = fixed!(1.5); pub GetXSTPoolPermissionedTechAccountId: TechAccountId = { let tech_account_id = TechAccountId::from_generic_pair( crate::TECH_ACCOUNT_PREFIX.to_vec(), @@ -111,7 +106,6 @@ parameter_types! { account_id }; pub const GetSyntheticBaseBuySellLimit: Balance = balance!(10000000); - pub GetXykIrreducibleReservePercent: Percent = Percent::from_percent(1); } construct_runtime! { @@ -143,6 +137,24 @@ construct_runtime! { } } +impl Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type GetSyntheticBaseAssetId = GetSyntheticBaseAssetId; + type GetXSTPoolPermissionedTechAccountId = GetXSTPoolPermissionedTechAccountId; + type EnsureDEXManager = dex_manager::Pallet; + type PriceToolsPallet = price_tools::Pallet; + type Oracle = oracle_proxy::Pallet; + type Symbol = ::Symbol; + type GetSyntheticBaseBuySellLimit = GetSyntheticBaseBuySellLimit; + type TradingPairSourceManager = trading_pair::Pallet; + type WeightInfo = (); + type AssetInfoProvider = assets::Pallet; +} + +parameter_types! { + pub const GetBuyBackAssetId: AssetId = VXOR; +} + mock_assets_config!(Runtime); mock_band_config!(Runtime, crate::Pallet); mock_common_config!(Runtime); @@ -154,7 +166,9 @@ mock_oracle_proxy_config!(Runtime); mock_pallet_balances_config!(Runtime); mock_pallet_timestamp_config!(Runtime); mock_permissions_config!(Runtime); +mock_pool_xyk_config!(Runtime); mock_price_tools_config!(Runtime); +mock_pswap_distribution_config!(Runtime, PoolXYK); mock_technical_config!(Runtime, pool_xyk::PolySwapAction); mock_tokens_config!(Runtime); mock_trading_pair_config!(Runtime); @@ -166,45 +180,6 @@ impl mock_liquidity_source::Config for Runtime type DexInfoProvider = dex_manager::Pallet; } -impl Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type GetSyntheticBaseAssetId = GetSyntheticBaseAssetId; - type GetXSTPoolPermissionedTechAccountId = GetXSTPoolPermissionedTechAccountId; - type EnsureDEXManager = dex_manager::Pallet; - type PriceToolsPallet = price_tools::Pallet; - type Oracle = oracle_proxy::Pallet; - type Symbol = ::Symbol; - type GetSyntheticBaseBuySellLimit = GetSyntheticBaseBuySellLimit; - type TradingPairSourceManager = trading_pair::Pallet; - type WeightInfo = (); - type AssetInfoProvider = assets::Pallet; -} - -parameter_types! { - pub const GetBuyBackAssetId: AssetId = VXOR; -} - -impl pswap_distribution::Config for Runtime { - const PSWAP_BURN_PERCENT: Percent = Percent::from_percent(3); - type RuntimeEvent = RuntimeEvent; - type GetIncentiveAssetId = GetIncentiveAssetId; - type GetBuyBackAssetId = GetBuyBackAssetId; - type LiquidityProxy = (); - type CompatBalance = Balance; - type GetDefaultSubscriptionFrequency = GetDefaultSubscriptionFrequency; - type GetBurnUpdateFrequency = GetBurnUpdateFrequency; - type GetTechnicalAccountId = GetPswapDistributionAccountId; - type EnsureDEXManager = (); - type OnPswapBurnedAggregator = (); - type WeightInfo = (); - type GetParliamentAccountId = GetParliamentAccountId; - type PoolXykPallet = PoolXYK; - type BuyBackHandler = (); - type DexInfoProvider = dex_manager::Pallet; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; -} - impl demeter_farming_platform::Config for Runtime { type RuntimeEvent = RuntimeEvent; type DemeterAssetId = (); @@ -213,34 +188,6 @@ impl demeter_farming_platform::Config for Runtime { type AssetInfoProvider = assets::Pallet; } -impl pool_xyk::Config for Runtime { - const MIN_XOR: Balance = balance!(0.0007); - type RuntimeEvent = RuntimeEvent; - type PairSwapAction = pool_xyk::PairSwapAction; - type DepositLiquidityAction = - pool_xyk::DepositLiquidityAction; - type WithdrawLiquidityAction = - pool_xyk::WithdrawLiquidityAction; - type PolySwapAction = pool_xyk::PolySwapAction; - type EnsureDEXManager = dex_manager::Pallet; - type TradingPairSourceManager = trading_pair::Pallet; - type DexInfoProvider = dex_manager::Pallet; - type EnsureTradingPairExists = trading_pair::Pallet; - type EnabledSourcesManager = trading_pair::Pallet; - type GetFee = GetXykFee; - type GetMaxIssuanceRatio = GetXykMaxIssuanceRatio; - type OnPoolCreated = PswapDistribution; - type OnPoolReservesChanged = (); - type XSTMarketInfo = (); - type GetTradingPairRestrictedFlag = GetTradingPairRestrictedFlag; - type GetChameleonPools = common::mock::GetChameleonPools; - type AssetInfoProvider = assets::Pallet; - type AssetRegulator = (); - type IrreducibleReserve = GetXykIrreducibleReservePercent; - type PoolAdjustPeriod = sp_runtime::traits::ConstU64<1>; - type WeightInfo = (); -} - impl ceres_liquidity_locker::Config for Runtime { const BLOCKS_PER_ONE_DAY: BlockNumberFor = 14_440; type RuntimeEvent = RuntimeEvent;