From 0e7b44a15fcc75e4670a72a0af7b70b5c970831e Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 12 Dec 2023 13:14:58 +0100 Subject: [PATCH 1/3] lower down limit of active schedules to 10k --- runtime/common/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 79977c02ff..1481698e9d 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -1477,7 +1477,7 @@ where use super::*; parameter_types! { - pub const RewardsSchedulesLimit: u32 = 100_000u32; + pub const RewardsSchedulesLimit: u32 = 10_000u32; // TODO: allign properly pub const Min3rdPartyRewardValutationPerSession: u128 = 100 * 30_000 * currency::DOLLARS; pub const Min3rdPartyRewardVolume: u128 = 100 * 30_000 * currency::DOLLARS; From 13d7dd96ece8503230d359d66084b37c9dc19c80 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 12 Dec 2023 14:18:33 +0100 Subject: [PATCH 2/3] dedicated event for PoolPromotion --- pallets/proof-of-stake/src/lib.rs | 14 +++++++++++++- pallets/proof-of-stake/src/mock.rs | 8 ++++++++ pallets/proof-of-stake/src/tests.rs | 27 +++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index ee02e38025..c02172fe40 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -497,6 +497,12 @@ pub mod pallet { CurrencyIdOf, BalanceOf, ), + ThirdPartySuccessfulPoolPromotion( + T::AccountId, + CurrencyIdOf, + CurrencyIdOf, + BalanceOf, + ), } #[pallet::storage] @@ -1471,7 +1477,6 @@ impl Pallet { pub(crate) fn reward_pool_impl( sender: T::AccountId, - pool: (CurrencyIdOf, CurrencyIdOf), token_id: CurrencyIdOf, amount: BalanceOf, @@ -1552,6 +1557,13 @@ impl Pallet { _ => {}, // invariant assures this will never happen } + Pallet::::deposit_event(Event::ThirdPartySuccessfulPoolPromotion( + sender, + liquidity_token_id, + token_id, + amount, + )); + Ok(()) } diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index c6af9e5d94..a0ac9a96ce 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -448,6 +448,14 @@ impl ExtBuilder { } } +pub(crate) fn events() -> Vec> { + System::events() + .into_iter() + .map(|r| r.event) + .filter_map(|e| if let RuntimeEvent::ProofOfStake(inner) = e { Some(inner) } else { None }) + .collect::>() +} + /// Compares the system events with passed in events /// Prints highlighted diff iff assert_eq fails #[macro_export] diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 21a3051686..fe41cf7b4f 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -4492,3 +4492,30 @@ fn test_amount_of_rewards_when_activation_happens_after_schedule_was_processed_i assert_eq!((alice_rewards + bob_rewards + 1), 100_000_000_000_000_000_000_000_000); }); } + +#[test] +#[serial] +fn test_event_is_emmited_when_pool_is_rewarded() { + ExtBuilder::new() + .issue(ALICE, LIQUIDITY_TOKEN, 100_000_000_000u128) + .issue(BOB, REWARD_TOKEN, 100_000_000_000_000_000_000_000_000u128) + .issue(BOB, LIQUIDITY_TOKEN, 500_000_000_000u128) + .execute_with_default_mocks(|| { + forward_to_block::(36); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(BOB), + REWARDED_PAIR, + REWARD_TOKEN, + 100_000_000_000_000_000_000_000_000u128, + 7u32.into(), + ) + .unwrap(); + + assert_event_emitted!(Event::::ThirdPartySuccessfulPoolPromotion( + BOB, + LIQUIDITY_TOKEN, + REWARD_TOKEN, + 100_000_000_000_000_000_000_000_000u128 + )); + }); +} From 5841d0ee1775ea4ed3826d8a62788de0c925fcf6 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 13 Dec 2023 12:57:00 +0100 Subject: [PATCH 3/3] update Min3rdPartyRewardValutationPerSession & Min3rdPartyRewardVolume params --- runtime/common/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 1481698e9d..24858cefd4 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -1478,9 +1478,9 @@ where parameter_types! { pub const RewardsSchedulesLimit: u32 = 10_000u32; - // TODO: allign properly - pub const Min3rdPartyRewardValutationPerSession: u128 = 100 * 30_000 * currency::DOLLARS; - pub const Min3rdPartyRewardVolume: u128 = 100 * 30_000 * currency::DOLLARS; + // NOTE: 1725 is how much USDT you get for one MGX as of 12.2023 + pub const Min3rdPartyRewardValutationPerSession: u128 = 10 * 1725 * currency::DOLLARS; + pub const Min3rdPartyRewardVolume: u128 = 10_000 * 1725 * currency::DOLLARS; pub const SchedulesPerBlock: u32 = 5; } }