Skip to content

Commit

Permalink
fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszaaa committed Sep 28, 2023
1 parent 67ecaa8 commit f650478
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
19 changes: 8 additions & 11 deletions pallets/proof-of-stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,19 @@ use frame_support::{
dispatch::{DispatchError, DispatchResult},
ensure,
storage::bounded_btree_map::BoundedBTreeMap,
traits::Nothing,
};
use frame_system::ensure_signed;
use mangata_support::traits::Valuate;
use sp_core::U256;
use sp_runtime::traits::AccountIdConversion;

use frame_support::{
pallet_prelude::*,
traits::{tokens::currency::MultiTokenCurrency, ExistenceRequirement, Get},
transactional,
};
use frame_system::pallet_prelude::*;
use mangata_support::traits::{
ActivationReservesProviderTrait, LiquidityMiningApi, ProofOfStakeRewardsApi, XykFunctionsTrait,
ActivationReservesProviderTrait, LiquidityMiningApi, ProofOfStakeRewardsApi,
};
use mangata_types::{multipurpose_liquidity::ActivateKind, Balance, TokenId};
use orml_tokens::{MultiTokenCurrencyExtended, MultiTokenReservableCurrency};
Expand All @@ -122,7 +120,7 @@ use sp_runtime::{traits::SaturatedConversion, Perbill};
use sp_std::{convert::TryInto, prelude::*};

mod reward_info;
use reward_info::{AsymptoticCurveRewards, ConstCurveRewards, RewardInfo, RewardsCalculator};
use reward_info::{RewardInfo, RewardsCalculator};
mod benchmarking;

#[cfg(test)]
Expand Down Expand Up @@ -167,7 +165,7 @@ const PALLET_ID: frame_support::PalletId = frame_support::PalletId(*b"rewards!")
#[frame_support::pallet]
pub mod pallet {
use frame_support::traits::Currency;
use mangata_support::traits::PoolCreateApi;


use super::*;

Expand Down Expand Up @@ -531,7 +529,7 @@ pub mod pallet {
let schedule_id = ScheduleId::<T>::get();

RewardsSchedules::<T>::try_mutate(|map| {
let key: Option<(_, _, _, _, _)> = map.first_key_value().map(|(x, y)| x.clone());
let key: Option<(_, _, _, _, _)> = map.first_key_value().map(|(x, _y)| x.clone());

if let Some(val) = key {
if current_session > val.0.saturated_into::<u32>() {
Expand Down Expand Up @@ -664,7 +662,6 @@ pub mod pallet {
#[transactional]
#[pallet::call_index(10)]
#[pallet::weight(<<T as Config>::WeightInfo>::claim_native_rewards())]
#[deprecated(note = "claim_native_rewards should be used instead")]
pub fn claim_native_rewards(
origin: OriginFor<T>,
liquidity_token_id: TokenId,
Expand Down Expand Up @@ -1006,7 +1003,7 @@ impl<T: Config> Pallet<T> {
(user.clone(), liquidity_asset_id, liquidity_assets_reward),
|v| {
match v {
Some(x) => {
Some(_x) => {
v.as_mut().map(|a| *a += liquidity_assets_added);
},
None => {
Expand Down Expand Up @@ -1036,10 +1033,10 @@ impl<T: Config> Pallet<T> {
liquidity_assets_burned: Balance,
) -> DispatchResult {
Self::ensure_is_promoted_pool(liquidity_asset_id)?;
let current_time: u32 = Self::get_current_rewards_time()?;
let pool_ratio_current = Self::get_pool_rewards(liquidity_asset_id)?;
let _current_time: u32 = Self::get_current_rewards_time()?;
let _pool_ratio_current = Self::get_pool_rewards(liquidity_asset_id)?;

let mut rewards_info = RewardsInfo::<T>::try_get(user.clone(), liquidity_asset_id)
let rewards_info = RewardsInfo::<T>::try_get(user.clone(), liquidity_asset_id)
.or(Err(DispatchError::from(Error::<T>::MissingRewardsInfoError)))?;
ensure!(
rewards_info.activated_amount >= liquidity_assets_burned,
Expand Down
3 changes: 2 additions & 1 deletion pallets/proof-of-stake/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use frame_support::{
traits::{tokens::currency::MultiTokenCurrency, ConstU128, ConstU32, Contains, Everything},
PalletId,
};
use frame_support::traits::Nothing;

use frame_system as system;
pub use mangata_support::traits::ProofOfStakeRewardsApi;
Expand Down Expand Up @@ -402,7 +403,7 @@ impl ExtBuilder {
.build_storage::<Test>()
.expect("Frame system builds valid default genesis config");

let mut ext = sp_io::TestExternalities::new(t);
let ext = sp_io::TestExternalities::new(t);
Self { ext }
}

Expand Down
4 changes: 2 additions & 2 deletions pallets/proof-of-stake/src/reward_info.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use frame_support::dispatch::DispatchResult;


use crate::{Config, Error, Pallet};
use frame_support::pallet_prelude::*;
Expand Down Expand Up @@ -180,7 +180,7 @@ impl CurveRewards for AsymptoticCurveRewards {
}

impl CurveRewards for ConstCurveRewards {
fn calculate_curve_position(ctx: &RewardsContext, user_info: &RewardInfo) -> Option<U256> {
fn calculate_curve_position(_ctx: &RewardsContext, _user_info: &RewardInfo) -> Option<U256> {
Some(U256::from(0))
}

Expand Down
3 changes: 1 addition & 2 deletions pallets/proof-of-stake/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,6 @@ pub(crate) fn roll_to_while_minting(n: u64, expected_amount_minted: Option<Balan
#[test]
fn test_migrated_from_pallet_issuance() {
new_test_ext().execute_with(|| {
env_logger::try_init();
System::set_block_number(1);

let token_id = TokensOf::<Test>::create(&99999, 2000_000_000).unwrap();
Expand Down Expand Up @@ -1551,7 +1550,7 @@ fn user_can_claim_3rdparty_rewards() {
TokensOf::<Test>::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap();
TokensOf::<Test>::mint(LIQUIDITY_TOKEN, &EVE, 100).unwrap();

let amount = 10_000u128;
let _amount = 10_000u128;

ProofOfStake::reward_pool(
RuntimeOrigin::signed(ALICE),
Expand Down

0 comments on commit f650478

Please sign in to comment.