diff --git a/Cargo.lock b/Cargo.lock index 1057c1dcf..b663fde52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -625,7 +625,6 @@ dependencies = [ "zrml-court", "zrml-global-disputes", "zrml-hybrid-router", - "zrml-liquidity-mining", "zrml-market-commons", "zrml-neo-swaps", "zrml-orderbook", @@ -14379,7 +14378,6 @@ dependencies = [ "url", "zeitgeist-primitives", "zeitgeist-runtime", - "zrml-liquidity-mining", "zrml-swaps-rpc", ] @@ -14501,7 +14499,6 @@ dependencies = [ "zrml-court", "zrml-global-disputes", "zrml-hybrid-router", - "zrml-liquidity-mining", "zrml-market-commons", "zrml-neo-swaps", "zrml-orderbook", @@ -14651,7 +14648,6 @@ dependencies = [ "zrml-court", "zrml-global-disputes", "zrml-hybrid-router", - "zrml-liquidity-mining", "zrml-market-commons", "zrml-neo-swaps", "zrml-orderbook", @@ -14659,25 +14655,6 @@ dependencies = [ "zrml-simple-disputes", ] -[[package]] -name = "zrml-liquidity-mining" -version = "0.5.2" -dependencies = [ - "env_logger 0.10.1", - "frame-benchmarking", - "frame-support", - "frame-system", - "pallet-balances", - "pallet-timestamp", - "parity-scale-codec", - "scale-info", - "serde", - "sp-io", - "sp-runtime", - "zeitgeist-primitives", - "zrml-market-commons", -] - [[package]] name = "zrml-market-commons" version = "0.5.2" @@ -14733,7 +14710,6 @@ dependencies = [ "zrml-authorized", "zrml-court", "zrml-global-disputes", - "zrml-liquidity-mining", "zrml-market-commons", "zrml-neo-swaps", "zrml-prediction-markets", @@ -14836,7 +14812,6 @@ dependencies = [ "zrml-authorized", "zrml-court", "zrml-global-disputes", - "zrml-liquidity-mining", "zrml-market-commons", "zrml-prediction-markets", "zrml-prediction-markets-runtime-api", diff --git a/Cargo.toml b/Cargo.toml index 3f94c60a9..bb525ff52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,6 @@ default-members = [ "zrml/court", "zrml/hybrid-router", "zrml/global-disputes", - "zrml/liquidity-mining", "zrml/market-commons", "zrml/neo-swaps", "zrml/orderbook", @@ -37,7 +36,6 @@ members = [ "zrml/court", "zrml/hybrid-router", "zrml/global-disputes", - "zrml/liquidity-mining", "zrml/market-commons", "zrml/neo-swaps", "zrml/orderbook", @@ -242,7 +240,6 @@ zrml-authorized = { path = "zrml/authorized", default-features = false } zrml-court = { path = "zrml/court", default-features = false } zrml-global-disputes = { path = "zrml/global-disputes", default-features = false } zrml-hybrid-router = { path = "zrml/hybrid-router", default-features = false } -zrml-liquidity-mining = { path = "zrml/liquidity-mining", default-features = false } zrml-market-commons = { path = "zrml/market-commons", default-features = false } zrml-neo-swaps = { path = "zrml/neo-swaps", default-features = false } zrml-orderbook = { path = "zrml/orderbook", default-features = false } diff --git a/docs/changelog_for_devs.md b/docs/changelog_for_devs.md index e12a38733..dd760aacf 100644 --- a/docs/changelog_for_devs.md +++ b/docs/changelog_for_devs.md @@ -12,6 +12,10 @@ As of 0.3.9, the changelog's format is based on components which query the chain's storage, the extrinsics or the runtime APIs/RPC interface. +## v0.5.4 + +- ⚠️ Remove zrml-liquidity-mining from code base. + ## v0.5.2 [#1310]: https://github.com/zeitgeistpm/zeitgeist/pull/1310 diff --git a/node/Cargo.toml b/node/Cargo.toml index 1b81fe5ef..e8f85c265 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -112,7 +112,6 @@ url = { workspace = true } battery-station-runtime = { workspace = true, optional = true } zeitgeist-primitives = { workspace = true, features = ["default"] } zeitgeist-runtime = { workspace = true, optional = true } -zrml-liquidity-mining = { workspace = true, features = ["default"] } zrml-swaps-rpc = { workspace = true } [features] diff --git a/node/src/chain_spec/battery_station.rs b/node/src/chain_spec/battery_station.rs index 058222791..d521fc206 100644 --- a/node/src/chain_spec/battery_station.rs +++ b/node/src/chain_spec/battery_station.rs @@ -26,7 +26,6 @@ use sc_service::ChainType; use sp_core::crypto::UncheckedInto; use zeitgeist_primitives::{ constants::{ - ztg::{LIQUIDITY_MINING, LIQUIDITY_MINING_PTD}, BASE, }, types::AccountId, diff --git a/node/src/chain_spec/dev.rs b/node/src/chain_spec/dev.rs index 75782f73b..cc8b8e330 100644 --- a/node/src/chain_spec/dev.rs +++ b/node/src/chain_spec/dev.rs @@ -31,7 +31,6 @@ use battery_station_runtime::{ use sc_service::ChainType; use sp_core::sr25519; use zeitgeist_primitives::{ - constants::ztg::{LIQUIDITY_MINING, LIQUIDITY_MINING_PTD}, types::Balance, }; #[cfg(feature = "parachain")] diff --git a/node/src/chain_spec/mod.rs b/node/src/chain_spec/mod.rs index 4d9849948..2449ee8d7 100644 --- a/node/src/chain_spec/mod.rs +++ b/node/src/chain_spec/mod.rs @@ -148,10 +148,6 @@ macro_rules! generate_generic_genesis_function { grandpa: $runtime::GrandpaConfig { authorities: acs.initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(), }, - liquidity_mining: $runtime::LiquidityMiningConfig { - initial_balance: LIQUIDITY_MINING, - per_block_distribution: LIQUIDITY_MINING_PTD.mul_ceil(LIQUIDITY_MINING), - }, #[cfg(feature = "parachain")] parachain_info: $runtime::ParachainInfoConfig { parachain_id: acs.parachain_id }, #[cfg(feature = "parachain")] diff --git a/node/src/chain_spec/zeitgeist.rs b/node/src/chain_spec/zeitgeist.rs index c98d38a26..987de0c2a 100644 --- a/node/src/chain_spec/zeitgeist.rs +++ b/node/src/chain_spec/zeitgeist.rs @@ -27,8 +27,6 @@ use sc_service::ChainType; use sp_core::crypto::UncheckedInto; use zeitgeist_runtime::parameters::SS58Prefix; -use zeitgeist_primitives::constants::ztg::{LIQUIDITY_MINING, LIQUIDITY_MINING_PTD}; - #[cfg(feature = "parachain")] use { super::{generate_inflation_config_function, Extensions}, diff --git a/primitives/src/constants/mock.rs b/primitives/src/constants/mock.rs index 47530ebea..ce19b9247 100644 --- a/primitives/src/constants/mock.rs +++ b/primitives/src/constants/mock.rs @@ -89,11 +89,6 @@ parameter_types! { pub const MaxOrders: u32 = 100; } -// Liquidity Mining parameters -parameter_types! { - pub const LiquidityMiningPalletId: PalletId = PalletId(*b"zge/lymg"); -} - // NeoSwaps parameter_types! { pub storage NeoExitFee: Balance = CENT; diff --git a/primitives/src/constants/ztg.rs b/primitives/src/constants/ztg.rs index c46c63420..b08c91d81 100644 --- a/primitives/src/constants/ztg.rs +++ b/primitives/src/constants/ztg.rs @@ -26,9 +26,6 @@ pub const COMMUNITY_INCENTIVES: u128 = 2_000_000; /// Total ZTG amount for collators. pub const COLLATORS: u128 = 0; -/// Total ZTG amount for liquidity mining. -pub const LIQUIDITY_MINING: u128 = 0; - /// Total ZTG amount for parachain lease. pub const PARACHAIN_LEASE: u128 = 40_000_000; @@ -58,8 +55,5 @@ pub const TOTAL_INITIAL_ZTG: u128 = COMMUNITY_INCENTIVES // Inflation -/// Perthousand liquidity mining inflation. 0% -pub const LIQUIDITY_MINING_PTD: Perbill = Perbill::from_perthousand(0); - /// Perthousand collator staking inflation. 5% pub const STAKING_PTD: Perbill = Perbill::from_perthousand(50); diff --git a/runtime/battery-station/Cargo.toml b/runtime/battery-station/Cargo.toml index 7350447ee..26ecb0257 100644 --- a/runtime/battery-station/Cargo.toml +++ b/runtime/battery-station/Cargo.toml @@ -114,7 +114,6 @@ zrml-authorized = { workspace = true } zrml-court = { workspace = true } zrml-global-disputes = { workspace = true, optional = true } zrml-hybrid-router = { workspace = true } -zrml-liquidity-mining = { workspace = true } zrml-market-commons = { workspace = true } zrml-neo-swaps = { workspace = true } zrml-orderbook = { workspace = true } @@ -216,7 +215,6 @@ runtime-benchmarks = [ "zrml-authorized/runtime-benchmarks", "zrml-court/runtime-benchmarks", "zrml-hybrid-router/runtime-benchmarks", - "zrml-liquidity-mining/runtime-benchmarks", "zrml-neo-swaps/runtime-benchmarks", "zrml-parimutuel/runtime-benchmarks", "zrml-prediction-markets/runtime-benchmarks", @@ -332,7 +330,6 @@ std = [ "zrml-authorized/std", "zrml-court/std", "zrml-hybrid-router/std", - "zrml-liquidity-mining/std", "zrml-market-commons/std", "zrml-neo-swaps/std", "zrml-parimutuel/std", @@ -391,7 +388,6 @@ try-runtime = [ "zrml-authorized/try-runtime", "zrml-court/try-runtime", "zrml-hybrid-router/try-runtime", - "zrml-liquidity-mining/try-runtime", "zrml-market-commons/try-runtime", "zrml-neo-swaps/try-runtime", "zrml-parimutuel/try-runtime", diff --git a/runtime/battery-station/src/lib.rs b/runtime/battery-station/src/lib.rs index 2393a7634..042445ded 100644 --- a/runtime/battery-station/src/lib.rs +++ b/runtime/battery-station/src/lib.rs @@ -194,7 +194,6 @@ impl Contains for IsCallable { _ => true, }, RuntimeCall::SimpleDisputes(_) => false, - RuntimeCall::LiquidityMining(_) => false, RuntimeCall::PredictionMarkets(inner_call) => match inner_call { create_market { dispute_mechanism: Some(MarketDisputeMechanism::SimpleDisputes), diff --git a/runtime/battery-station/src/parameters.rs b/runtime/battery-station/src/parameters.rs index 2cf328b9c..c43e3dfb9 100644 --- a/runtime/battery-station/src/parameters.rs +++ b/runtime/battery-station/src/parameters.rs @@ -228,10 +228,6 @@ parameter_types! { /// be another trie item whose value is the size of an account ID plus 32 bytes. pub const SubAccountDeposit: Balance = deposit(1, 53); - // Liquidity Mining parameters - /// Pallet identifier, mainly used for named balance reserves. - pub const LiquidityMiningPalletId: PalletId = LM_PALLET_ID; - // Multisig // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. pub const DepositBase: Balance = deposit(1, 88); diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index eff5c92c0..eaf88ad4c 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -196,7 +196,6 @@ macro_rules! decl_common_types { CourtPalletId::get(), GlobalDisputesPalletId::get(), HybridRouterPalletId::get(), - LiquidityMiningPalletId::get(), OrderbookPalletId::get(), ParimutuelPalletId::get(), PmPalletId::get(), @@ -312,7 +311,6 @@ macro_rules! create_runtime { MarketCommons: zrml_market_commons::{Pallet, Storage} = 50, Authorized: zrml_authorized::{Call, Event, Pallet, Storage} = 51, Court: zrml_court::{Call, Event, Pallet, Storage} = 52, - LiquidityMining: zrml_liquidity_mining::{Call, Config, Event, Pallet, Storage} = 53, RikiddoSigmoidFeeMarketEma: zrml_rikiddo::::{Pallet, Storage} = 54, SimpleDisputes: zrml_simple_disputes::{Call, Event, Pallet, Storage} = 55, Swaps: zrml_swaps::{Call, Event, Pallet, Storage} = 56, @@ -1221,42 +1219,12 @@ macro_rules! impl_config_traits { type WeightInfo = zrml_court::weights::WeightInfo; } - impl zrml_liquidity_mining::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type MarketCommons = MarketCommons; - type MarketId = MarketId; - type PalletId = LiquidityMiningPalletId; - type WeightInfo = zrml_liquidity_mining::weights::WeightInfo; - } - impl zrml_market_commons::Config for Runtime { type Balance = Balance; type MarketId = MarketId; type Timestamp = Timestamp; } - // NoopLiquidityMining implements LiquidityMiningPalletApi with no-ops. - // Has to be public because it will be exposed by Runtime. - pub struct NoopLiquidityMining; - - impl zrml_liquidity_mining::LiquidityMiningPalletApi for NoopLiquidityMining { - type AccountId = AccountId; - type Balance = Balance; - type BlockNumber = BlockNumber; - type MarketId = MarketId; - - fn add_shares(_: Self::AccountId, _: Self::MarketId, _: Self::Balance) {} - - fn distribute_market_incentives( - _: &Self::MarketId, - ) -> frame_support::pallet_prelude::DispatchResult { - Ok(()) - } - - fn remove_shares(_: &Self::AccountId, _: &Self::MarketId, _: Self::Balance) {} - } - impl zrml_prediction_markets::Config for Runtime { type AdvisoryBond = AdvisoryBond; type AdvisoryBondSlashPercentage = AdvisoryBondSlashPercentage; @@ -1279,10 +1247,6 @@ macro_rules! impl_config_traits { type DisputeBond = DisputeBond; type RuntimeEvent = RuntimeEvent; type GlobalDisputes = GlobalDisputes; - // LiquidityMining is currently unstable. - // NoopLiquidityMining will be applied only to mainnet once runtimes are separated. - type LiquidityMining = NoopLiquidityMining; - // type LiquidityMining = LiquidityMining; type MaxCategories = MaxCategories; type MaxCreatorFee = MaxCreatorFee; type MaxDisputes = MaxDisputes; @@ -1540,7 +1504,6 @@ macro_rules! create_runtime_api { list_benchmark!(list, extra, zrml_hybrid_router, HybridRouter); #[cfg(not(feature = "parachain"))] list_benchmark!(list, extra, zrml_prediction_markets, PredictionMarkets); - list_benchmark!(list, extra, zrml_liquidity_mining, LiquidityMining); list_benchmark!(list, extra, zrml_styx, Styx); list_benchmark!(list, extra, zrml_neo_swaps, NeoSwaps); @@ -1646,7 +1609,6 @@ macro_rules! create_runtime_api { add_benchmark!(params, batches, zrml_hybrid_router, HybridRouter); #[cfg(not(feature = "parachain"))] add_benchmark!(params, batches, zrml_prediction_markets, PredictionMarkets); - add_benchmark!(params, batches, zrml_liquidity_mining, LiquidityMining); add_benchmark!(params, batches, zrml_styx, Styx); add_benchmark!(params, batches, zrml_neo_swaps, NeoSwaps); @@ -2252,7 +2214,6 @@ macro_rules! create_common_tests { #[test_case(AuthorizedPalletId::get(); "authorized")] #[test_case(CourtPalletId::get(); "court")] - #[test_case(LiquidityMiningPalletId::get(); "liquidity_mining")] #[test_case(PmPalletId::get(); "prediction_markets")] #[test_case(SimpleDisputesPalletId::get(); "simple_disputes")] #[test_case(SwapsPalletId::get(); "swaps")] diff --git a/runtime/zeitgeist/Cargo.toml b/runtime/zeitgeist/Cargo.toml index f2a25adea..de016932a 100644 --- a/runtime/zeitgeist/Cargo.toml +++ b/runtime/zeitgeist/Cargo.toml @@ -113,7 +113,6 @@ zrml-authorized = { workspace = true } zrml-court = { workspace = true } zrml-global-disputes = { workspace = true, optional = true } zrml-hybrid-router = { workspace = true } -zrml-liquidity-mining = { workspace = true } zrml-market-commons = { workspace = true } zrml-neo-swaps = { workspace = true } zrml-orderbook = { workspace = true } @@ -214,7 +213,6 @@ runtime-benchmarks = [ "zrml-authorized/runtime-benchmarks", "zrml-court/runtime-benchmarks", "zrml-hybrid-router/runtime-benchmarks", - "zrml-liquidity-mining/runtime-benchmarks", "zrml-neo-swaps/runtime-benchmarks", "zrml-parimutuel/runtime-benchmarks", "zrml-prediction-markets/runtime-benchmarks", @@ -322,7 +320,6 @@ std = [ "zrml-authorized/std", "zrml-court/std", "zrml-hybrid-router/std", - "zrml-liquidity-mining/std", "zrml-market-commons/std", "zrml-neo-swaps/std", "zrml-parimutuel/std", @@ -381,7 +378,6 @@ try-runtime = [ "zrml-authorized/try-runtime", "zrml-court/try-runtime", "zrml-hybrid-router/try-runtime", - "zrml-liquidity-mining/try-runtime", "zrml-market-commons/try-runtime", "zrml-neo-swaps/try-runtime", "zrml-parimutuel/try-runtime", diff --git a/runtime/zeitgeist/src/lib.rs b/runtime/zeitgeist/src/lib.rs index 4fcde1f80..6ffce95e9 100644 --- a/runtime/zeitgeist/src/lib.rs +++ b/runtime/zeitgeist/src/lib.rs @@ -184,7 +184,6 @@ impl Contains for IsCallable { RuntimeCall::Council(set_members { .. }) => false, #[cfg(feature = "parachain")] RuntimeCall::DmpQueue(service_overweight { .. }) => false, - RuntimeCall::LiquidityMining(_) => false, RuntimeCall::PredictionMarkets(inner_call) => { match inner_call { // Disable SimpleDisputes dispute resolution mechanism diff --git a/runtime/zeitgeist/src/parameters.rs b/runtime/zeitgeist/src/parameters.rs index a5c1eacf8..47e8d8a66 100644 --- a/runtime/zeitgeist/src/parameters.rs +++ b/runtime/zeitgeist/src/parameters.rs @@ -226,10 +226,6 @@ parameter_types! { /// be another trie item whose value is the size of an account ID plus 32 bytes. pub const SubAccountDeposit: Balance = deposit(1, 53); - // Liquidity Mining parameters - /// Pallet identifier, mainly used for named balance reserves. DO NOT CHANGE. - pub const LiquidityMiningPalletId: PalletId = LM_PALLET_ID; - // Multisig // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. pub const DepositBase: Balance = deposit(1, 88); diff --git a/zrml/hybrid-router/Cargo.toml b/zrml/hybrid-router/Cargo.toml index 8c4c2b95f..b0c7a5b06 100644 --- a/zrml/hybrid-router/Cargo.toml +++ b/zrml/hybrid-router/Cargo.toml @@ -27,7 +27,6 @@ zrml-asset-router = { workspace = true, optional = true } zrml-authorized = { workspace = true, optional = true } zrml-court = { workspace = true, optional = true } zrml-global-disputes = { workspace = true, optional = true } -zrml-liquidity-mining = { workspace = true, optional = true } zrml-neo-swaps = { workspace = true, optional = true } zrml-orderbook = { workspace = true, optional = true } zrml-prediction-markets = { workspace = true, optional = true } @@ -64,7 +63,6 @@ mock = [ "zrml-authorized/default", "zrml-court/default", "zrml-global-disputes/default", - "zrml-liquidity-mining/default", ] parachain = [ "zrml-prediction-markets/parachain", diff --git a/zrml/hybrid-router/src/mock.rs b/zrml/hybrid-router/src/mock.rs index feb7f3718..2aed74912 100644 --- a/zrml/hybrid-router/src/mock.rs +++ b/zrml/hybrid-router/src/mock.rs @@ -51,7 +51,7 @@ use zeitgeist_primitives::{ CloseEarlyRequestBond, CloseEarlyTimeFramePeriod, CorrectionPeriod, CourtPalletId, DestroyAccountWeight, DestroyApprovalWeight, DestroyFinishWeight, ExistentialDeposit, ExistentialDeposits, GdVotingPeriod, GetNativeCurrencyId, GlobalDisputeLockId, - GlobalDisputesPalletId, HybridRouterPalletId, InflationPeriod, LiquidityMiningPalletId, + GlobalDisputesPalletId, HybridRouterPalletId, InflationPeriod, LockId, MaxAppeals, MaxApprovals, MaxCourtParticipants, MaxCreatorFee, MaxDelegations, MaxDisputeDuration, MaxDisputes, MaxEditReasonLen, MaxGlobalDisputeVotes, MaxGracePeriod, MaxLiquidityTreeDepth, MaxLocks, MaxMarketLifetime, MaxOracleDuration, MaxOrders, @@ -175,7 +175,6 @@ construct_runtime!( CustomAssets: pallet_assets::::{Call, Pallet, Storage, Event}, MarketAssets: pallet_assets::::{Call, Pallet, Storage, Event}, AssetManager: orml_currencies::{Call, Pallet, Storage}, - LiquidityMining: zrml_liquidity_mining::{Config, Event, Pallet}, MarketCommons: zrml_market_commons::{Pallet, Storage}, PredictionMarkets: zrml_prediction_markets::{Event, Pallet, Storage}, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage}, @@ -365,7 +364,6 @@ impl zrml_prediction_markets::Config for Runtime { type DisputeBond = DisputeBond; type RuntimeEvent = RuntimeEvent; type GlobalDisputes = GlobalDisputes; - type LiquidityMining = LiquidityMining; type MaxCategories = MaxCategories; type MaxDisputes = MaxDisputes; type MinDisputeDuration = MinDisputeDuration; @@ -431,15 +429,6 @@ impl zrml_court::Config for Runtime { type WeightInfo = zrml_court::weights::WeightInfo; } -impl zrml_liquidity_mining::Config for Runtime { - type Currency = Balances; - type RuntimeEvent = RuntimeEvent; - type MarketCommons = MarketCommons; - type MarketId = MarketId; - type PalletId = LiquidityMiningPalletId; - type WeightInfo = zrml_liquidity_mining::weights::WeightInfo; -} - impl frame_system::Config for Runtime { type AccountData = pallet_balances::AccountData; type AccountId = AccountIdTest; diff --git a/zrml/liquidity-mining/Cargo.toml b/zrml/liquidity-mining/Cargo.toml deleted file mode 100644 index cecf83500..000000000 --- a/zrml/liquidity-mining/Cargo.toml +++ /dev/null @@ -1,44 +0,0 @@ -[dependencies] -frame-benchmarking = { workspace = true, optional = true } -frame-support = { workspace = true } -frame-system = { workspace = true } -parity-scale-codec = { workspace = true, features = ["derive", "max-encoded-len"] } -scale-info = { workspace = true, features = ["derive"] } -serde = { workspace = true, optional = true } -sp-runtime = { workspace = true } -zeitgeist-primitives = { workspace = true } -zrml-market-commons = { workspace = true } - -[dev-dependencies] -env_logger = { workspace = true } -pallet-balances = { workspace = true, features = ["default"] } -pallet-timestamp = { workspace = true, features = ["default"] } -sp-io = { workspace = true, features = ["default"] } -zeitgeist-primitives = { workspace = true, features = ["mock", "default"] } - -[features] -default = ["std"] -runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", -] -std = [ - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", - "parity-scale-codec/std", - "serde/std", - "sp-runtime/std", - "zeitgeist-primitives/std", - "zrml-market-commons/std", -] -try-runtime = [ - "frame-support/try-runtime", -] - -[package] -authors = ["Zeitgeist PM "] -edition = "2021" -name = "zrml-liquidity-mining" -version = "0.5.2" diff --git a/zrml/liquidity-mining/README.md b/zrml/liquidity-mining/README.md deleted file mode 100644 index c15177065..000000000 --- a/zrml/liquidity-mining/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Liquidity Mining Module - -## Overview - -Manages and distributes incentives to liquidity providers - -Each block has a maximum allowed amount of ZTG that is distributed among the -`PoolShare` owners of that same block. Over time this amount will increase until -a market closes and then all rewards will be distributed accordingly. - -This pallet is mostly self-contained and only need to know about the native -currency. To interact with its functionalities, please use the provided API. diff --git a/zrml/liquidity-mining/src/benchmarks.rs b/zrml/liquidity-mining/src/benchmarks.rs deleted file mode 100644 index 05e32b749..000000000 --- a/zrml/liquidity-mining/src/benchmarks.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2023 Forecasting Technologies LTD. -// Copyright 2021-2022 Zeitgeist PM LLC. -// -// This file is part of Zeitgeist. -// -// Zeitgeist is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the -// Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// Zeitgeist is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Zeitgeist. If not, see . - -#![allow( - // Auto-generated code is a no man's land - clippy::arithmetic_side_effects -)] -#![cfg(feature = "runtime-benchmarks")] - -use crate::pallet::{BalanceOf, Call, Config, Pallet}; -#[cfg(test)] -use crate::Pallet as LiquidityMining; -use frame_benchmarking::benchmarks; -use frame_system::RawOrigin; -use sp_runtime::traits::Bounded; - -benchmarks! { - set_per_block_distribution { - let balance = BalanceOf::::max_value(); - }: set_per_block_distribution(RawOrigin::Root, balance) - - impl_benchmark_test_suite!( - LiquidityMining, - crate::mock::ExtBuilder::default().build(), - crate::mock::Runtime, - ); -} diff --git a/zrml/liquidity-mining/src/lib.rs b/zrml/liquidity-mining/src/lib.rs deleted file mode 100644 index a2346ebfa..000000000 --- a/zrml/liquidity-mining/src/lib.rs +++ /dev/null @@ -1,349 +0,0 @@ -// Copyright 2022-2024 Forecasting Technologies LTD. -// Copyright 2021-2022 Zeitgeist PM LLC. -// -// This file is part of Zeitgeist. -// -// Zeitgeist is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the -// Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// Zeitgeist is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Zeitgeist. If not, see . - -#![doc = include_str!("../README.md")] -#![cfg_attr(not(feature = "std"), no_std)] - -extern crate alloc; - -#[macro_use] -mod utils; - -mod benchmarks; -mod liquidity_mining_pallet_api; -mod mock; -mod owned_values_params; -mod tests; -mod track_incentives_based_on_bought_shares; -mod track_incentives_based_on_sold_shares; -pub mod weights; - -pub use liquidity_mining_pallet_api::LiquidityMiningPalletApi; -pub use pallet::*; - -#[frame_support::pallet] -mod pallet { - use crate::{ - owned_values_params::OwnedValuesParams, - track_incentives_based_on_bought_shares::TrackIncentivesBasedOnBoughtShares, - track_incentives_based_on_sold_shares::TrackIncentivesBasedOnSoldShares, - utils::{ - calculate_average_blocks_of_a_time_period, calculate_perthousand, - calculate_perthousand_value, - }, - weights::WeightInfoZeitgeist, - LiquidityMiningPalletApi, - }; - use alloc::vec::Vec; - use core::marker::PhantomData; - #[cfg(feature = "std")] - use frame_support::traits::GenesisBuild; - use frame_support::{ - dispatch::DispatchResult, - log, - storage::{ - types::{StorageDoubleMap, StorageValue, ValueQuery}, - with_transaction, - }, - traits::{ - Currency, ExistenceRequirement, Get, Hooks, IsType, StorageVersion, WithdrawReasons, - }, - Blake2_128Concat, PalletId, Twox64Concat, - }; - use frame_system::{ensure_root, pallet_prelude::OriginFor}; - use sp_runtime::{ - traits::{AccountIdConversion, Saturating}, - TransactionOutcome, - }; - use zeitgeist_primitives::{ - traits::MarketId, - types::{MarketPeriod, MaxRuntimeUsize}, - }; - use zrml_market_commons::MarketCommonsPalletApi; - - /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(0); - const LOG_TARGET: &str = "runtime::zrml-liquidity-mining"; - - pub(crate) type AccountIdOf = ::AccountId; - pub(crate) type BalanceOf = <::Currency as Currency>>::Balance; - pub(crate) type MomentOf = <::MarketCommons as MarketCommonsPalletApi>::Moment; - - #[pallet::call] - impl Pallet { - #[pallet::call_index(0)] - #[pallet::weight(T::WeightInfo::set_per_block_distribution())] - // MARK(non-transactional): `set_per_block_distribution` is infallible. - pub fn set_per_block_distribution( - origin: OriginFor, - #[pallet::compact] per_block_distribution: BalanceOf, - ) -> DispatchResult { - ensure_root(origin)?; - >::put(per_block_distribution); - Ok(()) - } - } - - #[pallet::config] - pub trait Config: frame_system::Config { - type Currency: Currency; - - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - - type MarketCommons: MarketCommonsPalletApi< - AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, - MarketId = Self::MarketId, - Balance = BalanceOf, - >; - - type MarketId: MarketId; - - #[pallet::constant] - type PalletId: Get; - - type WeightInfo: WeightInfoZeitgeist; - } - - #[pallet::event] - #[pallet::generate_deposit(fn deposit_event)] - pub enum Event - where - T: Config, - { - /// The number of markets that received incentives in a block - AddedIncentives(MaxRuntimeUsize), - /// The total amount of incentives distributed to accounts along side the number - /// of accounts that received these incentives. - DistributedIncentives(BalanceOf, MaxRuntimeUsize), - /// The number of markets that subtracted incentives in a block - SubtractedIncentives(MaxRuntimeUsize), - } - - #[pallet::error] - pub enum Error { - /// Pallet account does not have enough funds - FundDoesNotHaveEnoughBalance, - } - - #[cfg(feature = "std")] - #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { - fn build(&self) { - let _ = T::Currency::deposit_creating( - &Pallet::::pallet_account_id(), - self.initial_balance, - ); - >::put(self.per_block_distribution); - } - } - - #[cfg(feature = "std")] - #[derive(scale_info::TypeInfo, Debug)] - #[pallet::genesis_config] - pub struct GenesisConfig { - pub initial_balance: BalanceOf, - pub per_block_distribution: BalanceOf, - } - - #[cfg(feature = "std")] - impl Default for GenesisConfig - where - T: Config, - { - #[inline] - fn default() -> Self { - Self { - initial_balance: BalanceOf::::from(0u8), - per_block_distribution: BalanceOf::::from(0u8), - } - } - } - - #[pallet::hooks] - impl Hooks for Pallet { - // Manages incentives on each block finalization. - fn on_finalize(block: T::BlockNumber) { - let fun = || { - let added_len = TrackIncentivesBasedOnBoughtShares::::exec(block)?; - if added_len > 0 { - Self::deposit_event(Event::AddedIncentives(added_len.into())); - } - let subtracted_len = TrackIncentivesBasedOnSoldShares::::exec(); - if subtracted_len > 0 { - Self::deposit_event(Event::SubtractedIncentives(subtracted_len.into())); - } - Some(()) - }; - let _ = with_transaction(|| match fun() { - None => { - log::error!(target: LOG_TARGET, "Block {:?} was not finalized", block); - TransactionOutcome::Rollback(Err("Block was not finalized")) - } - Some(_) => TransactionOutcome::Commit(Ok(())), - }); - } - } - - #[pallet::pallet] - #[pallet::storage_version(STORAGE_VERSION)] - pub struct Pallet(PhantomData); - - impl Pallet - where - T: Config, - { - // pot/fund account - #[inline] - pub(crate) fn pallet_account_id() -> T::AccountId { - T::PalletId::get().into_account_truncating() - } - } - - impl LiquidityMiningPalletApi for Pallet - where - T: Config, - { - type AccountId = T::AccountId; - type Balance = BalanceOf; - type BlockNumber = T::BlockNumber; - type MarketId = T::MarketId; - - fn add_shares( - account_id: Self::AccountId, - market_id: Self::MarketId, - shares: Self::Balance, - ) { - >::mutate(market_id, account_id, |total_shares| { - *total_shares = total_shares.saturating_add(shares); - }) - } - - fn distribute_market_incentives(market_id: &Self::MarketId) -> DispatchResult { - let pallet_account_id = Pallet::::pallet_account_id(); - let mut final_total_incentives = BalanceOf::::from(0u8); - - let values: Vec<_> = >::drain_prefix(market_id) - .filter_map( - |( - account_id, - OwnedValuesParams { - participated_blocks, - perpetual_incentives, - total_incentives: local_total_incentives, - .. - }, - )| { - let actual_perpetual_incentives = { - let opt = match T::MarketCommons::market(market_id).ok()?.period { - MarketPeriod::Block(range) => calculate_perthousand( - participated_blocks, - &range.end.saturating_sub(range.start), - ), - MarketPeriod::Timestamp(range) => calculate_perthousand( - participated_blocks, - &calculate_average_blocks_of_a_time_period::(&range), - ), - }; - let ptd_balance = opt.map(|ptd| ptd.into())?; - calculate_perthousand_value(ptd_balance, perpetual_incentives) - }; - let final_incentives = - actual_perpetual_incentives.saturating_add(local_total_incentives); - final_total_incentives = - final_total_incentives.saturating_add(final_incentives); - Some((account_id, final_incentives)) - }, - ) - .collect(); - - T::Currency::ensure_can_withdraw( - &pallet_account_id, - final_total_incentives, - WithdrawReasons::all(), - T::Currency::free_balance(&pallet_account_id) - .saturating_sub(final_total_incentives), - ) - .map_err(|_err| Error::::FundDoesNotHaveEnoughBalance)?; - - let accounts_len = values.len().into(); - for (account_id, incentives) in values { - T::Currency::transfer( - &pallet_account_id, - &account_id, - incentives, - ExistenceRequirement::AllowDeath, - ) - .map_err(|_err| Error::::FundDoesNotHaveEnoughBalance)?; - } - Self::deposit_event(Event::DistributedIncentives(final_total_incentives, accounts_len)); - Ok(()) - } - - fn remove_shares( - account_id: &Self::AccountId, - market_id: &Self::MarketId, - shares: Self::Balance, - ) { - >::mutate(market_id, account_id, |total_shares| { - *total_shares = total_shares.saturating_add(shares); - }) - } - } - - /// Shares bought in the current block being constructed. Automatically *erased* after each finalized block. - #[pallet::storage] - pub type BlockBoughtShares = StorageDoubleMap< - _, - Blake2_128Concat, - T::MarketId, - Twox64Concat, - T::AccountId, - BalanceOf, - ValueQuery, - >; - - /// Shares sold in the current block being constructed. Automatically *erased* after each finalized block. - #[pallet::storage] - pub type BlockSoldShares = StorageDoubleMap< - _, - Blake2_128Concat, - T::MarketId, - Twox64Concat, - T::AccountId, - BalanceOf, - ValueQuery, - >; - - /// Owned balances (not shares) that are going to be distributed as incentives. Automatically - /// *updated* after each finalized block. - #[pallet::storage] - pub type OwnedValues = StorageDoubleMap< - _, - Blake2_128Concat, - T::MarketId, - Twox64Concat, - T::AccountId, - OwnedValuesParams, T::BlockNumber>, - ValueQuery, - >; - - /// Per block distribution. How much each block will distribute across bought shares. - #[pallet::storage] - pub type PerBlockIncentive = StorageValue<_, BalanceOf, ValueQuery>; -} diff --git a/zrml/liquidity-mining/src/liquidity_mining_pallet_api.rs b/zrml/liquidity-mining/src/liquidity_mining_pallet_api.rs deleted file mode 100644 index a0bff48a9..000000000 --- a/zrml/liquidity-mining/src/liquidity_mining_pallet_api.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2021-2022 Zeitgeist PM LLC. -// -// This file is part of Zeitgeist. -// -// Zeitgeist is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the -// Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// Zeitgeist is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Zeitgeist. If not, see . - -use frame_support::dispatch::DispatchResult; - -/// Interface to interact with the Zeitgeist Liquidity Mining pallet. -pub trait LiquidityMiningPalletApi { - type AccountId; - type Balance; - type BlockNumber; - type MarketId; - - /// Increases the number of stored pool shares of an account for a given market. - /// - /// It is up to the caller to synchronize the amount of shares between different pallets - fn add_shares(account_id: Self::AccountId, market_id: Self::MarketId, shares: Self::Balance); - - /// Removes a given `market_id` period from the storage distributing incentives to all - /// related accounts. - fn distribute_market_incentives(market_id: &Self::MarketId) -> DispatchResult; - - /// Decreases the number of stored pool shares of an account on a given market. - /// - /// It is up to the caller to synchronize the amount of shares between different pallets - fn remove_shares( - account_id: &Self::AccountId, - market_id: &Self::MarketId, - shares: Self::Balance, - ); -} diff --git a/zrml/liquidity-mining/src/mock.rs b/zrml/liquidity-mining/src/mock.rs deleted file mode 100644 index b4fa05cbc..000000000 --- a/zrml/liquidity-mining/src/mock.rs +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2022-2024 Forecasting Technologies LTD. -// Copyright 2021-2022 Zeitgeist PM LLC. -// -// This file is part of Zeitgeist. -// -// Zeitgeist is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the -// Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// Zeitgeist is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Zeitgeist. If not, see . - -#![cfg(test)] - -use crate as zrml_liquidity_mining; -use frame_support::{ - construct_runtime, - traits::{Everything, GenesisBuild}, -}; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, -}; -use zeitgeist_primitives::{ - constants::mock::{ - BlockHashCount, ExistentialDeposit, LiquidityMiningPalletId, MaxLocks, MaxReserves, - MinimumPeriod, BASE, - }, - types::{ - AccountIdTest, Balance, BlockNumber, BlockTest, Hash, Index, MarketId, Moment, - UncheckedExtrinsicTest, - }, -}; - -pub const ALICE: AccountIdTest = 0; -pub const BOB: AccountIdTest = 1; - -construct_runtime!( - pub enum Runtime - where - Block = BlockTest, - NodeBlock = BlockTest, - UncheckedExtrinsic = UncheckedExtrinsicTest, - { - Balances: pallet_balances::{Call, Config, Event, Pallet, Storage}, - LiquidityMining: zrml_liquidity_mining::{Config, Event, Pallet}, - MarketCommons: zrml_market_commons::{Pallet, Storage}, - System: frame_system::{Call, Config, Event, Pallet, Storage}, - Timestamp: pallet_timestamp::{Pallet}, - } -); - -impl crate::Config for Runtime { - type Currency = Balances; - type RuntimeEvent = (); - type MarketCommons = MarketCommons; - type MarketId = MarketId; - type PalletId = LiquidityMiningPalletId; - type WeightInfo = crate::weights::WeightInfo; -} - -impl frame_system::Config for Runtime { - type AccountData = pallet_balances::AccountData; - type AccountId = AccountIdTest; - type BaseCallFilter = Everything; - type BlockHashCount = BlockHashCount; - type BlockLength = (); - type BlockNumber = BlockNumber; - type BlockWeights = (); - type RuntimeCall = RuntimeCall; - type DbWeight = (); - type RuntimeEvent = (); - type Hash = Hash; - type Hashing = BlakeTwo256; - type Header = Header; - type Index = Index; - type Lookup = IdentityLookup; - type MaxConsumers = frame_support::traits::ConstU32<16>; - type OnKilledAccount = (); - type OnNewAccount = (); - type RuntimeOrigin = RuntimeOrigin; - type PalletInfo = PalletInfo; - type SS58Prefix = (); - type SystemWeightInfo = (); - type Version = (); - type OnSetCode = (); -} - -impl pallet_balances::Config for Runtime { - type AccountStore = System; - type Balance = Balance; - type DustRemoval = (); - type ReserveIdentifier = [u8; 8]; - type RuntimeEvent = (); - type ExistentialDeposit = ExistentialDeposit; - type MaxLocks = MaxLocks; - type MaxReserves = MaxReserves; - type WeightInfo = (); -} - -impl zrml_market_commons::Config for Runtime { - type Balance = Balance; - type MarketId = MarketId; - type Timestamp = Timestamp; -} - -impl pallet_timestamp::Config for Runtime { - type MinimumPeriod = MinimumPeriod; - type Moment = Moment; - type OnTimestampSet = (); - type WeightInfo = (); -} - -pub struct ExtBuilder { - pub(crate) balances: Vec<(AccountIdTest, Balance)>, - pub(crate) initial_balance: Balance, - pub(crate) per_block_incentives: Balance, -} - -impl Default for ExtBuilder { - fn default() -> Self { - Self { - balances: vec![(ALICE, 1_000 * BASE)], - initial_balance: 100 * BASE, - per_block_incentives: BASE, - } - } -} - -impl ExtBuilder { - pub fn build(self) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - - // see the logs in tests when using `RUST_LOG=debug cargo test -- --nocapture` - let _ = env_logger::builder().is_test(true).try_init(); - - crate::GenesisConfig:: { - initial_balance: self.initial_balance, - per_block_distribution: self.per_block_incentives, - } - .assimilate_storage(&mut t) - .unwrap(); - - pallet_balances::GenesisConfig:: { balances: self.balances } - .assimilate_storage(&mut t) - .unwrap(); - - t.into() - } -} diff --git a/zrml/liquidity-mining/src/owned_values_params.rs b/zrml/liquidity-mining/src/owned_values_params.rs deleted file mode 100644 index 3150d2a66..000000000 --- a/zrml/liquidity-mining/src/owned_values_params.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2021-2022 Zeitgeist PM LLC. -// -// This file is part of Zeitgeist. -// -// Zeitgeist is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the -// Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// Zeitgeist is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Zeitgeist. If not, see . - -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; - -/// Parameters used by the `OwnedValues` storage. -/// -/// # Types -/// -/// * `BA`: BAlance -/// * `BN`: Block Number -#[cfg_attr(feature = "std", derive(serde::Deserialize, serde::Serialize))] -#[derive( - scale_info::TypeInfo, - Clone, - Debug, - Decode, - Default, - Encode, - Eq, - MaxEncodedLen, - Ord, - PartialEq, - PartialOrd, -)] -pub struct OwnedValuesParams -where - BA: MaxEncodedLen, - BN: MaxEncodedLen, -{ - /// The number of blocks an account participated in a market period. - pub participated_blocks: BN, - /// Owned amount of perpetual incentives. Won't go away when accounts exist early and is not - /// attached to any share - pub perpetual_incentives: BA, - /// Owned incentives. Related to the total number of shares. - pub total_incentives: BA, - /// Owned quantity of shares. Related to the total amount of incentives. - pub total_shares: BA, -} diff --git a/zrml/liquidity-mining/src/tests.rs b/zrml/liquidity-mining/src/tests.rs deleted file mode 100644 index 68363ff8c..000000000 --- a/zrml/liquidity-mining/src/tests.rs +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright 2022-2024 Forecasting Technologies LTD. -// Copyright 2021-2022 Zeitgeist PM LLC. -// -// This file is part of Zeitgeist. -// -// Zeitgeist is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the -// Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// Zeitgeist is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Zeitgeist. If not, see . - -#![cfg(test)] - -use crate::{ - mock::{Balances, ExtBuilder, LiquidityMining, Runtime, RuntimeOrigin, System, ALICE, BOB}, - track_incentives_based_on_bought_shares::TrackIncentivesBasedOnBoughtShares, - track_incentives_based_on_sold_shares::TrackIncentivesBasedOnSoldShares, - BlockBoughtShares, BlockSoldShares, LiquidityMiningPalletApi as _, OwnedValues, -}; -use core::ops::Range; -use frame_support::{ - assert_err, assert_ok, - dispatch::DispatchError, - traits::{Currency, OnFinalize}, -}; -use frame_system::RawOrigin; -use zeitgeist_primitives::types::{ - BaseAsset, Deadlines, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, - MarketPeriod, MarketStatus, MarketType, ScoringRule, -}; -use zrml_market_commons::Markets; - -#[test] -fn blocks_shares_are_updated_after_each_block() { - ExtBuilder::default().build().execute_with(|| { - LiquidityMining::add_shares(ALICE, 0, 1); - LiquidityMining::add_shares(ALICE, 1, 1); - LiquidityMining::remove_shares(&ALICE, &0, 1); - assert_eq!(>::iter().count(), 2); - assert_eq!(>::iter().count(), 1); - LiquidityMining::on_finalize(1); - assert_eq!(>::iter().count(), 0); - assert_eq!(>::iter().count(), 0); - }); -} - -#[test] -fn distribute_market_incentives_removes_market_and_distributes_all_incentives_to_lps() { - ExtBuilder::default().build().execute_with(|| { - let initial_alice_balance = Balances::free_balance(ALICE); - create_default_market(0, 1..5); - create_default_market(1, 1..5); - - LiquidityMining::add_shares(ALICE, 0, 10); - LiquidityMining::add_shares(ALICE, 1, 10); - LiquidityMining::on_finalize(2); - - assert_eq!(>::iter().count(), 2); - assert_ok!(LiquidityMining::distribute_market_incentives(&0)); - assert_ok!(LiquidityMining::distribute_market_incentives(&1)); - assert_eq!(>::iter().count(), 0); - - // In this case, each market have the same amount of incentives - let market_incentives = ExtBuilder::default().per_block_incentives / 2; - // Perpetual balance for the entire campaign - let entire_market_perpetual_balance = market_incentives / 1000; - // Account only stayed 1 block out of 4 (25%), i.e, lost 75% of the perpetual balance - let actual_market_perpetual_balance = entire_market_perpetual_balance / 4; - // Ordinary balance - let actual_market_incentives = market_incentives - entire_market_perpetual_balance; - - let new_balance = initial_alice_balance - + 2 * actual_market_incentives - + 2 * actual_market_perpetual_balance; - - assert_eq!(Balances::free_balance(ALICE), new_balance); - }); -} - -#[test] -fn genesis_has_lm_account_and_initial_per_block_distribution() { - ExtBuilder::default().build().execute_with(|| { - let pallet_account_id = crate::Pallet::::pallet_account_id(); - assert_eq!( - Balances::total_balance(&pallet_account_id), - ExtBuilder::default().initial_balance - ); - assert_eq!( - >::get(), - ExtBuilder::default().per_block_incentives - ); - }); -} - -#[test] -fn owned_balances_are_updated_after_bought_shares() { - ExtBuilder::default().build().execute_with(|| { - System::set_block_number(5); - create_default_market(0, 1..11); - create_default_market(1, 1..21); - - LiquidityMining::add_shares(ALICE, 0, 100); - LiquidityMining::add_shares(ALICE, 1, 200); - LiquidityMining::add_shares(BOB, 1, 300); - TrackIncentivesBasedOnBoughtShares::::exec(5); - - let vec = >::iter().collect::>(); - - assert_eq!(vec[2].2.total_shares, 100); - assert_eq!(vec[1].2.total_shares, 200); - assert_eq!(vec[0].2.total_shares, 300); - - // Market 0 has 42.8% of `per_block_incentives` - let market_incentives_0 = 4280000000; - // Market 1 has 57.1% of `per_block_incentives` - let market_incentives_1 = 5710000000; - - // 0.1% of `market_incentives_0`. - let perpetual_incentives_alice_0 = market_incentives_0 / 1000; - - // One share value for Market 1 - let market_1_one_share_value = one_share_value(market_incentives_1, 500); - // Raw incentives for ALICE on Market 1 - let raw_incentives_alice_1 = market_1_one_share_value * 200; - // Raw incentives for BOB on Market 1 - let raw_incentives_bob_1 = market_1_one_share_value * 300; - // 0.1% of `raw_incentives_ALICE_1` - let perpetual_incentives_alice_1 = raw_incentives_alice_1 / 1000; - // 0.1% of `raw_incentives_BOB_1` - let perpetual_incentives_bob_1 = raw_incentives_bob_1 / 1000; - - assert_eq!(vec[2].2.perpetual_incentives, perpetual_incentives_alice_0); - assert_eq!(vec[1].2.perpetual_incentives, perpetual_incentives_alice_1); - assert_eq!(vec[0].2.perpetual_incentives, perpetual_incentives_bob_1); - - assert_eq!(vec[2].2.total_incentives, market_incentives_0 - perpetual_incentives_alice_0); - assert_eq!( - vec[1].2.total_incentives, - raw_incentives_alice_1 - perpetual_incentives_alice_1 - ); - assert_eq!(vec[0].2.total_incentives, raw_incentives_bob_1 - perpetual_incentives_bob_1); - }); -} - -#[test] -fn owned_balances_are_updated_after_sold_shares() { - ExtBuilder::default().build().execute_with(|| { - System::set_block_number(5); - create_default_market(0, 1..11); - create_default_market(1, 1..21); - - LiquidityMining::add_shares(ALICE, 0, 100); - LiquidityMining::add_shares(ALICE, 1, 200); - LiquidityMining::on_finalize(5); - - LiquidityMining::remove_shares(&ALICE, &0, 100); - LiquidityMining::remove_shares(&ALICE, &1, 50); - TrackIncentivesBasedOnSoldShares::::exec(); - - let vec = >::iter().collect::>(); - - // Market 0 has 42.8% of `per_block_incentives` - let market_incentives_0 = 4280000000; - // Market 1 has 57.1% of `per_block_incentives` - let market_incentives_1 = 5710000000; - - // 0.1% of `market_incentives_0`. - let perpetual_incentives_alice_0 = market_incentives_0 / 1000; - // 0.1% of `market_incentives_1`. - let perpetual_incentives_alice_1 = market_incentives_1 / 1000; - // Alice sold 25% of her owned shares - let incentives_alice_1 = (market_incentives_1 - perpetual_incentives_alice_1) / 4 * 3; - - assert_eq!(vec[1].2.total_shares, 0); - assert_eq!(vec[1].2.total_incentives, 0); - assert_eq!(vec[1].2.perpetual_incentives, perpetual_incentives_alice_0); - - assert_eq!(vec[0].2.total_shares, 150); - assert_eq!(vec[0].2.total_incentives, incentives_alice_1); - assert_eq!(vec[0].2.perpetual_incentives, perpetual_incentives_alice_1); - }); -} - -#[test] -fn only_sudo_can_change_per_block_distribution() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(LiquidityMining::set_per_block_distribution(RawOrigin::Root.into(), 100)); - assert_err!( - LiquidityMining::set_per_block_distribution(RuntimeOrigin::signed(ALICE), 100), - DispatchError::BadOrigin - ); - }); -} - -fn create_default_market(market_id: u128, period: Range) { - Markets::::insert( - market_id, - Market { - market_id: Default::default(), - base_asset: BaseAsset::Ztg, - creation: MarketCreation::Permissionless, - creator_fee: sp_runtime::Perbill::zero(), - creator: 0, - market_type: MarketType::Categorical(0), - dispute_mechanism: Some(MarketDisputeMechanism::SimpleDisputes), - metadata: vec![], - oracle: 0, - period: MarketPeriod::Block(period), - deadlines: Deadlines { - grace_period: 1_u64, - oracle_duration: 1_u64, - dispute_duration: 1_u64, - }, - report: None, - resolved_outcome: None, - status: MarketStatus::Closed, - scoring_rule: ScoringRule::AmmCdaHybrid, - bonds: MarketBonds::default(), - early_close: None, - }, - ); -} - -// One bought share value of a particular market in a particular block -fn one_share_value(market_incentives: u128, total_shares: u128) -> u128 { - market_incentives / total_shares -} diff --git a/zrml/liquidity-mining/src/track_incentives_based_on_bought_shares.rs b/zrml/liquidity-mining/src/track_incentives_based_on_bought_shares.rs deleted file mode 100644 index b62893e30..000000000 --- a/zrml/liquidity-mining/src/track_incentives_based_on_bought_shares.rs +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2022 Forecasting Technologies LTD. -// Copyright 2021-2022 Zeitgeist PM LLC. -// -// This file is part of Zeitgeist. -// -// Zeitgeist is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the -// Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// Zeitgeist is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Zeitgeist. If not, see . - -use crate::{ - utils::{calculate_perthousand, calculate_perthousand_value}, - BalanceOf, BlockBoughtShares, MomentOf, OwnedValues, PerBlockIncentive, -}; -use alloc::{collections::BTreeSet, vec::Vec}; -use core::marker::PhantomData; -use sp_runtime::traits::{CheckedDiv, Saturating}; -use zeitgeist_primitives::types::MarketPeriod; -use zrml_market_commons::MarketCommonsPalletApi; - -// Per-thousand that every incentive should transfer to the perpetual balance. -// Currently is 0.1% -const PERPETUAL_PTD: u8 = 1; - -pub struct TrackIncentivesBasedOnBoughtShares(PhantomData); - -// No-one can have more balance than `Balance::MAX` so most functions saturate rewards. -impl TrackIncentivesBasedOnBoughtShares -where - T: crate::Config, -{ - pub(crate) fn exec(curr_block: T::BlockNumber) -> Option { - let per_block_incentives = >::get(); - let market_incentives = Self::markets_incentives(per_block_incentives, curr_block)?; - let market_incentives_len = market_incentives.len(); - let ppb = BalanceOf::::from(PERPETUAL_PTD); - - for (market_id, incentive) in market_incentives { - let mut total_bought_shares = BalanceOf::::from(0u8); - for (_, shares) in >::iter_prefix(market_id) { - total_bought_shares = total_bought_shares.saturating_add(shares); - } - let opt = Self::bought_share_value(&incentive, &total_bought_shares); - let share_value = if let Some(el) = opt { - el - } else { - continue; - }; - for (account_id, bought_shares) in >::iter_prefix(market_id) { - let raw_incentives = share_value.saturating_mul(bought_shares); - let perpetual_incentives = calculate_perthousand_value(ppb, raw_incentives); - let incentives = raw_incentives.saturating_sub(perpetual_incentives); - >::mutate(market_id, account_id, |values| { - let one = T::BlockNumber::from(1u8); - - values.perpetual_incentives = - values.perpetual_incentives.saturating_add(perpetual_incentives); - values.total_incentives = values.total_incentives.saturating_add(incentives); - values.total_shares = values.total_shares.saturating_add(bought_shares); - values.participated_blocks = values.participated_blocks.saturating_add(one); - }); - } - } - - let _ = >::clear(u32::max_value(), None); - Some(market_incentives_len) - } - - // ZTG value of one bought share for the current block being produced. Or in other words: - // Determines how much a share will be worth given the amount of ZTG for liquidity - // mining and the total number of bought shares for the current block. - // - // `None` result means no-one purchased a share. - #[inline] - fn bought_share_value( - incentive: &BalanceOf, - total_bought_shares: &BalanceOf, - ) -> Option> { - incentive.checked_div(total_bought_shares) - } - - // How much incentive each market will receive - #[allow( - // `normalized_total` variable needs to be evaluated first - clippy::needless_collect - )] - fn markets_incentives( - per_block_incentives: BalanceOf, - curr_block: T::BlockNumber, - ) -> Option)>> { - let mut normalized_total = BalanceOf::::from(0u8); - let markets_periods: BTreeSet<_> = >::iter().map(|el| el.0).collect(); - let now = T::MarketCommons::now(); - - let normalized_values: Vec<_> = markets_periods - .into_iter() - .filter_map(|market_id| { - let period = T::MarketCommons::market(&market_id).ok()?.period; - let normalized_value = Self::normalize_market(curr_block, now, &period); - normalized_total = normalized_total.saturating_add(normalized_value); - Some((market_id, normalized_value)) - }) - .collect(); - normalized_values - .into_iter() - .map(|(market_id, normalized_value)| { - let ptd = calculate_perthousand(normalized_value, &normalized_total)?.into(); - let incentive = calculate_perthousand_value(ptd, per_block_incentives); - Some((market_id, incentive)) - }) - .collect() - } - - // Takes any market parameter and outputs a number that will be used as a percentage - // to calculate how much incentives each individual market will receive. - // - // In this case, the output is the percentage of the remaining number of blocks to stimulate - // early liquidity providers. For example, a market starts at 0 and ends at 10. If the current - // block is at 7, then the output is 30. - // - // Another example: A market starts at 500, ends at 700 and the current block is 510. In other - // words, the normalized output will be near 100 (or 100%) because the current block is near - // the start of the market. - // - // ```rust - // let market_period = 500..=700 - // - // let market_total_blocks = 700 - 500 = 200; - // let market_remaining_blocks = 200 - 10 = 190 - // - // let _market_normalized_value = 190 * 100 / 200 = 95 - // ``` - // - // The greater the output, the more incentives the market will receive - fn normalize_market( - curr_block: T::BlockNumber, - now: MomentOf, - period: &MarketPeriod>, - ) -> BalanceOf { - let opt = match period { - MarketPeriod::Block(range) => { - let total_value = range.end.saturating_sub(range.start); - calculate_perthousand(range.end.saturating_sub(curr_block), &total_value) - } - MarketPeriod::Timestamp(range) => { - let total_value = range.end.saturating_sub(range.start); - let value = now.saturating_sub(range.start); - calculate_perthousand(value, &total_value) - } - }; - opt.map(|ptd| ptd.into()).unwrap_or_default() - } -} diff --git a/zrml/liquidity-mining/src/track_incentives_based_on_sold_shares.rs b/zrml/liquidity-mining/src/track_incentives_based_on_sold_shares.rs deleted file mode 100644 index 1efbacf0d..000000000 --- a/zrml/liquidity-mining/src/track_incentives_based_on_sold_shares.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2022 Forecasting Technologies LTD. -// Copyright 2021-2022 Zeitgeist PM LLC. -// -// This file is part of Zeitgeist. -// -// Zeitgeist is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the -// Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// Zeitgeist is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Zeitgeist. If not, see . - -use crate::{ - utils::{calculate_perthousand, calculate_perthousand_value}, - BlockSoldShares, OwnedValues, -}; -use core::marker::PhantomData; -use sp_runtime::traits::Saturating; - -pub struct TrackIncentivesBasedOnSoldShares(PhantomData); - -// No-one can have more balance than `Balance::MAX` so most functions saturate rewards. -impl TrackIncentivesBasedOnSoldShares -where - T: crate::Config, -{ - pub(crate) fn exec() -> usize { - let mut counter = 0; - for (market_id, account_id, sold_shares) in >::iter() { - let values = if let Ok(e) = >::try_get(market_id, account_id.clone()) { - e - } else { - // Trying to retrieve an account that doesn't have any bought shares - continue; - }; - - let ptd = if let Some(el) = calculate_perthousand(sold_shares, &values.total_shares) { - el.into() - } else { - // `total_shares` is zero - continue; - }; - - let balance_to_subtract = calculate_perthousand_value(ptd, values.total_incentives); - - >::mutate(market_id, account_id, |values| { - // `total_balance` or `total_shares` can be less than 0 but this possible - // scenario is ignored here. - values.total_incentives = - values.total_incentives.saturating_sub(balance_to_subtract); - values.total_shares = values.total_shares.saturating_sub(sold_shares); - }); - counter = counter.saturating_add(1); - } - let _ = >::clear(u32::max_value(), None); - counter - } -} diff --git a/zrml/liquidity-mining/src/utils.rs b/zrml/liquidity-mining/src/utils.rs deleted file mode 100644 index f05276dd3..000000000 --- a/zrml/liquidity-mining/src/utils.rs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2021-2022 Zeitgeist PM LLC. -// -// This file is part of Zeitgeist. -// -// Zeitgeist is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the -// Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// Zeitgeist is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Zeitgeist. If not, see . - -use crate::MomentOf; -use core::ops::{Div, Range}; -use sp_runtime::{ - traits::{CheckedDiv, Saturating, UniqueSaturatedInto}, - SaturatedConversion, -}; -use zeitgeist_primitives::constants::MILLISECS_PER_BLOCK; - -// Calculates the **average** number of blocks occurred between the starting and ending time period -// of a market. -// -// To convert the block number type to the moment type, is is necessary to first convert the -// block number value to `u32`, which caps the maximum output to `u32::MAX`. Since this function -// is only used to evaluate perpetual balances, such limitation shouldn't be a problem. -pub fn calculate_average_blocks_of_a_time_period(range: &Range>) -> T::BlockNumber -where - T: crate::Config, -{ - let total_value_time = range.end.saturating_sub(range.start); - let mpb_balance = MILLISECS_PER_BLOCK.into(); - // The following won't overflow because `MILLISECS_PER_BLOCK` is not zero. - let total_value_blocks = total_value_time / mpb_balance; - let total_value_blocks_u32: u32 = total_value_blocks.saturated_into(); - total_value_blocks_u32.into() -} - -// Per-thousand compared to `total_value` and a given `value`. For example, if total is 200, -// then 6 is 3% of 200. -// -// Results currently can't have more than 00.0% accuracy. -pub fn calculate_perthousand(value: T, total_value: &T) -> Option -where - T: CheckedDiv + From + Saturating + UniqueSaturatedInto, -{ - let _1000_balance = T::from(1000u16); - let opaque = value.saturating_mul(_1000_balance).checked_div(total_value)?; - Some(opaque.unique_saturated_into()) -} - -// The value compared to `total_value` and a given `perthousand`. For example, 3% of 200 is 6. -// -// Results currently can't have more than 00.0% accuracy. -pub fn calculate_perthousand_value(perthousand: T, total_value: T) -> T -where - T: Div + Saturating + From, -{ - let _1000_balance = T::from(1000u16); - total_value.saturating_mul(perthousand) / _1000_balance -} diff --git a/zrml/liquidity-mining/src/weights.rs b/zrml/liquidity-mining/src/weights.rs deleted file mode 100644 index 07dc1385b..000000000 --- a/zrml/liquidity-mining/src/weights.rs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022-2024 Forecasting Technologies LTD. -// Copyright 2021-2022 Zeitgeist PM LLC. -// -// This file is part of Zeitgeist. -// -// Zeitgeist is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the -// Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// Zeitgeist is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Zeitgeist. If not, see . - -//! Autogenerated weights for zrml_liquidity_mining -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` - -// Executed Command: -// ./target/production/zeitgeist -// benchmark -// pallet -// --chain=dev -// --steps=50 -// --repeat=20 -// --pallet=zrml_liquidity_mining -// --extrinsic=* -// --execution=wasm -// --wasm-execution=compiled -// --heap-pages=4096 -// --template=./misc/weight_template.hbs -// --header=./HEADER_GPL3 -// --output=./zrml/liquidity-mining/src/weights.rs - -#![allow(unused_parens)] -#![allow(unused_imports)] - -use core::marker::PhantomData; -use frame_support::{traits::Get, weights::Weight}; - -/// Trait containing the required functions for weight retrival within -/// zrml_liquidity_mining (automatically generated) -pub trait WeightInfoZeitgeist { - fn set_per_block_distribution() -> Weight; -} - -/// Weight functions for zrml_liquidity_mining (automatically generated) -pub struct WeightInfo(PhantomData); -impl WeightInfoZeitgeist for WeightInfo { - /// Storage: LiquidityMining PerBlockIncentive (r:0 w:1) - /// Proof: LiquidityMining PerBlockIncentive (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - fn set_per_block_distribution() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 5_170 nanoseconds. - Weight::from_parts(6_020_000, 0).saturating_add(T::DbWeight::get().writes(1)) - } -} diff --git a/zrml/neo-swaps/Cargo.toml b/zrml/neo-swaps/Cargo.toml index 85e982808..955d73ce9 100644 --- a/zrml/neo-swaps/Cargo.toml +++ b/zrml/neo-swaps/Cargo.toml @@ -34,7 +34,6 @@ zrml-asset-router = { workspace = true, optional = true } zrml-authorized = { workspace = true, optional = true } zrml-court = { workspace = true, optional = true } zrml-global-disputes = { workspace = true, optional = true } -zrml-liquidity-mining = { workspace = true, optional = true } zrml-prediction-markets = { workspace = true, optional = true } zrml-prediction-markets-runtime-api = { workspace = true, optional = true } zrml-simple-disputes = { workspace = true, optional = true } @@ -69,7 +68,6 @@ mock = [ "zrml-court/std", "zrml-asset-router/std", "zrml-authorized/std", - "zrml-liquidity-mining/std", "zrml-simple-disputes/std", "zrml-global-disputes/std", "zrml-prediction-markets/std", diff --git a/zrml/neo-swaps/src/mock.rs b/zrml/neo-swaps/src/mock.rs index 610bc955f..28e32d73e 100644 --- a/zrml/neo-swaps/src/mock.rs +++ b/zrml/neo-swaps/src/mock.rs @@ -52,7 +52,7 @@ use zeitgeist_primitives::{ CloseEarlyRequestBond, CloseEarlyTimeFramePeriod, CorrectionPeriod, CourtPalletId, DestroyAccountWeight, DestroyApprovalWeight, DestroyFinishWeight, ExistentialDeposit, ExistentialDeposits, GdVotingPeriod, GetNativeCurrencyId, GlobalDisputeLockId, - GlobalDisputesPalletId, InflationPeriod, LiquidityMiningPalletId, LockId, MaxAppeals, + GlobalDisputesPalletId, InflationPeriod, LockId, MaxAppeals, MaxApprovals, MaxCourtParticipants, MaxCreatorFee, MaxDelegations, MaxDisputeDuration, MaxDisputes, MaxEditReasonLen, MaxGlobalDisputeVotes, MaxGracePeriod, MaxLiquidityTreeDepth, MaxLocks, MaxMarketLifetime, MaxOracleDuration, MaxOwners, @@ -183,7 +183,6 @@ construct_runtime!( CampaignAssets: pallet_assets::::{Call, Pallet, Storage, Event}, Court: zrml_court::{Event, Pallet, Storage}, CustomAssets: pallet_assets::::{Call, Pallet, Storage, Event}, - LiquidityMining: zrml_liquidity_mining::{Config, Event, Pallet}, MarketAssets: pallet_assets::::{Call, Pallet, Storage, Event}, MarketCommons: zrml_market_commons::{Pallet, Storage}, PredictionMarkets: zrml_prediction_markets::{Event, Pallet, Storage}, @@ -350,7 +349,6 @@ impl zrml_prediction_markets::Config for Runtime { type DisputeBond = DisputeBond; type RuntimeEvent = RuntimeEvent; type GlobalDisputes = GlobalDisputes; - type LiquidityMining = LiquidityMining; type MaxCategories = MaxCategories; type MaxDisputes = MaxDisputes; type MinDisputeDuration = MinDisputeDuration; @@ -416,15 +414,6 @@ impl zrml_court::Config for Runtime { type WeightInfo = zrml_court::weights::WeightInfo; } -impl zrml_liquidity_mining::Config for Runtime { - type Currency = Balances; - type RuntimeEvent = RuntimeEvent; - type MarketCommons = MarketCommons; - type MarketId = MarketId; - type PalletId = LiquidityMiningPalletId; - type WeightInfo = zrml_liquidity_mining::weights::WeightInfo; -} - impl frame_system::Config for Runtime { type AccountData = pallet_balances::AccountData; type AccountId = AccountIdTest; diff --git a/zrml/prediction-markets/Cargo.toml b/zrml/prediction-markets/Cargo.toml index a2a8121cb..b4f24633a 100644 --- a/zrml/prediction-markets/Cargo.toml +++ b/zrml/prediction-markets/Cargo.toml @@ -13,7 +13,6 @@ zeitgeist-primitives = { workspace = true } zrml-authorized = { workspace = true } zrml-court = { workspace = true } zrml-global-disputes = { workspace = true } -zrml-liquidity-mining = { workspace = true } zrml-market-commons = { workspace = true } zrml-simple-disputes = { workspace = true } @@ -83,7 +82,6 @@ std = [ "zeitgeist-primitives/std", "zrml-authorized/std", "zrml-court/std", - "zrml-liquidity-mining/std", "zrml-market-commons/std", "zrml-simple-disputes/std", "zrml-global-disputes/std", diff --git a/zrml/prediction-markets/src/lib.rs b/zrml/prediction-markets/src/lib.rs index abefb9275..94949f26e 100644 --- a/zrml/prediction-markets/src/lib.rs +++ b/zrml/prediction-markets/src/lib.rs @@ -81,7 +81,6 @@ mod pallet { }, }; use zrml_global_disputes::{types::InitialItem, GlobalDisputesPalletApi}; - use zrml_liquidity_mining::LiquidityMiningPalletApi; use zrml_market_commons::{types::MarketBuilder, MarketCommonsPalletApi}; /// The current storage version. @@ -1645,13 +1644,6 @@ mod pallet { Self::BlockNumber, >; - type LiquidityMining: LiquidityMiningPalletApi< - AccountId = Self::AccountId, - Balance = BalanceOf, - BlockNumber = Self::BlockNumber, - MarketId = MarketIdOf, - >; - /// The maximum number of categories available for categorical markets. #[pallet::constant] type MaxCategories: Get; @@ -2795,9 +2787,6 @@ mod pallet { } _ => return Err(Error::::InvalidMarketStatus.into()), }; - // TODO: https://github.com/zeitgeistpm/zeitgeist/issues/815 - // Following call should return weight consumed by it. - T::LiquidityMining::distribute_market_incentives(market_id)?; let mut updated_market = market.clone(); diff --git a/zrml/prediction-markets/src/mock.rs b/zrml/prediction-markets/src/mock.rs index 392a7d2df..3ece69e62 100644 --- a/zrml/prediction-markets/src/mock.rs +++ b/zrml/prediction-markets/src/mock.rs @@ -52,7 +52,7 @@ use zeitgeist_primitives::{ CloseEarlyRequestBond, CloseEarlyTimeFramePeriod, CorrectionPeriod, CourtPalletId, DestroyAccountWeight, DestroyApprovalWeight, DestroyFinishWeight, ExistentialDeposit, ExistentialDeposits, GdVotingPeriod, GetNativeCurrencyId, GlobalDisputeLockId, - GlobalDisputesPalletId, InflationPeriod, LiquidityMiningPalletId, LockId, MaxAppeals, + GlobalDisputesPalletId, InflationPeriod, LockId, MaxAppeals, MaxApprovals, MaxCategories, MaxCourtParticipants, MaxCreatorFee, MaxDelegations, MaxDisputeDuration, MaxDisputes, MaxEditReasonLen, MaxGlobalDisputeVotes, MaxGracePeriod, MaxMarketLifetime, MaxOracleDuration, MaxOwners, MaxRejectReasonLen, MaxReserves, @@ -230,7 +230,6 @@ construct_runtime!( CustomAssets: pallet_assets::::{Call, Pallet, Storage, Event}, Court: zrml_court::{Event, Pallet, Storage}, AssetManager: orml_currencies::{Call, Pallet, Storage}, - LiquidityMining: zrml_liquidity_mining::{Config, Event, Pallet}, MarketAssets: pallet_assets::::{Call, Pallet, Storage, Event}, MarketCommons: zrml_market_commons::{Pallet, Storage}, PredictionMarkets: prediction_markets::{Event, Pallet, Storage}, @@ -267,7 +266,6 @@ impl crate::Config for Runtime { type DisputeBond = DisputeBond; type RuntimeEvent = RuntimeEvent; type GlobalDisputes = GlobalDisputes; - type LiquidityMining = LiquidityMining; type MaxCategories = MaxCategories; type MaxDisputes = MaxDisputes; type MinDisputeDuration = MinDisputeDuration; @@ -530,15 +528,6 @@ impl zrml_court::Config for Runtime { type WeightInfo = zrml_court::weights::WeightInfo; } -impl zrml_liquidity_mining::Config for Runtime { - type Currency = Balances; - type RuntimeEvent = RuntimeEvent; - type MarketCommons = MarketCommons; - type MarketId = MarketId; - type PalletId = LiquidityMiningPalletId; - type WeightInfo = zrml_liquidity_mining::weights::WeightInfo; -} - impl zrml_market_commons::Config for Runtime { type Balance = Balance; type MarketId = MarketId;