Skip to content

Commit

Permalink
adds non transfer check to POS pallet for 3rd party rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
vanderian committed Dec 5, 2024
1 parent 7ffc20d commit fa551bb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pallets/proof-of-stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ use sp_runtime::traits::AccountIdConversion;

use frame_support::{
pallet_prelude::*,
traits::{tokens::currency::MultiTokenCurrency, ExistenceRequirement, Get},
traits::{tokens::currency::MultiTokenCurrency, Contains, ExistenceRequirement, Get},
transactional,
};

Expand Down Expand Up @@ -446,6 +446,9 @@ pub mod pallet {

type WeightInfo: WeightInfo;
type ValuationApi: ValutationApiTrait<Self>;

/// Tokens which cannot be transfered by extrinsics/user or use in pool, unless foundation override
type NontransferableTokens: Contains<CurrencyIdOf<Self>>;
}

#[pallet::error]
Expand Down Expand Up @@ -483,6 +486,8 @@ pub mod pallet {
NoThirdPartyPartyRewardsToClaim,
// cannot promote solo token
SoloTokenPromotionForbiddenError,
/// Asset cannot be used for rewards
NontransferableToken,
}

#[pallet::event]
Expand Down Expand Up @@ -770,6 +775,12 @@ pub mod pallet {
schedule_end: SessionId,
) -> DispatchResult {
let sender = ensure_signed(origin)?;

ensure!(
!T::NontransferableTokens::contains(&token_id),
Error::<T>::NontransferableToken
);

Self::reward_pool_impl(sender, pool, token_id, amount, schedule_end)
}

Expand All @@ -792,6 +803,11 @@ pub mod pallet {
) -> DispatchResultWithPostInfo {
let sender = ensure_signed(origin)?;

ensure!(
!T::NontransferableTokens::contains(&reward_token),
Error::<T>::NontransferableToken
);

Self::activate_liquidity_for_3rdparty_rewards_impl(
sender,
liquidity_token_id,
Expand Down
1 change: 1 addition & 0 deletions rollup/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ impl pallet_proof_of_stake::Config for Runtime {
type Min3rdPartyRewardVolume = cfg::pallet_proof_of_stake::Min3rdPartyRewardVolume;
type SchedulesPerBlock = cfg::pallet_proof_of_stake::SchedulesPerBlock;
type ValuationApi = Xyk;
type NontransferableTokens = tokens::NontransferableTokens;
}

impl pallet_bootstrap::BootstrapBenchmarkingConfig for Runtime {}
Expand Down

0 comments on commit fa551bb

Please sign in to comment.