Skip to content

Commit

Permalink
🚑 ($PALLET) Discard remain reward be less than ed (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenPocketGamer authored Oct 12, 2021
1 parent 1f13cc5 commit 9e00809
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pallets/liquidity-mining/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,16 @@ impl<T: Config> PoolInfo<T> {

for (rtoken, reward) in self.rewards.iter() {
let remain = reward.total.saturating_sub(reward.claimed);
T::MultiCurrency::transfer(*rtoken, &self.keeper, &investor, remain)?;
let can_send =
T::MultiCurrency::ensure_can_withdraw(*rtoken, &self.keeper, remain).is_ok();

let ed = T::MultiCurrency::minimum_balance(*rtoken);
let total = T::MultiCurrency::total_balance(*rtoken, &investor).saturating_add(remain);
let can_get = total >= ed;

if can_send && can_get {
T::MultiCurrency::transfer(*rtoken, &self.keeper, &investor, remain)?;
}
}

Ok(().into())
Expand Down

0 comments on commit 9e00809

Please sign in to comment.