From faa5f6639461227fd8b356b7b7b5ead5e5e65f81 Mon Sep 17 00:00:00 2001 From: talhadaar Date: Fri, 22 Nov 2024 12:58:40 +0500 Subject: [PATCH] account for ED when taking staking pot issuance --- pallets/parachain-staking/src/lib.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index 32126908..99c36aa3 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -167,8 +167,11 @@ pub mod pallet { pallet_prelude::*, storage::bounded_btree_map::BoundedBTreeMap, traits::{ - Currency, EstimateNextSessionRotation, ExistenceRequirement::KeepAlive, Get, - LockIdentifier, LockableCurrency, ReservableCurrency, StorageVersion, WithdrawReasons, + tokens::{fungible::Inspect, Fortitude, Preservation}, + Currency, EstimateNextSessionRotation, + ExistenceRequirement::KeepAlive, + Get, LockIdentifier, LockableCurrency, ReservableCurrency, StorageVersion, + WithdrawReasons, }, BoundedVec, PalletId, }; @@ -228,6 +231,7 @@ pub mod pallet { type Currency: Currency + ReservableCurrency + LockableCurrency + + Inspect + Eq; /// Just the `Currency::Balance` type; we have this item to allow us to @@ -2863,9 +2867,15 @@ pub mod pallet { pub(crate) fn pot_issuance() -> (Weight, BalanceOf) { let pot = Self::account_id(); let weight = Weight::from_parts(1, 0); - let issuance = T::Currency::free_balance(&pot) - .checked_sub(&T::Currency::minimum_balance()) - .unwrap_or_else(Zero::zero); + let ed = >::minimum_balance(); + let issuance = if ed == T::CurrencyBalance::from(0_u32) { + T::Currency::reducible_balance(&pot, Preservation::Preserve, Fortitude::Polite) + // Avoid the pot complaint no balance there + .checked_sub(&T::CurrencyBalance::from(10_u32)) + .unwrap_or_else(Zero::zero) + } else { + T::Currency::reducible_balance(&pot, Preservation::Preserve, Fortitude::Polite) + }; (weight, issuance) }