From 10c0bd3430c495cf35150a3cbc2a8dfc96255a55 Mon Sep 17 00:00:00 2001 From: nahem Date: Mon, 5 Feb 2024 16:17:40 +0100 Subject: [PATCH] feat(smart-contracts): add remove swap routes in pool router & clean-up clippy warnings --- contracts/liquidity_hub/pool-network/incentive/src/helpers.rs | 4 ++-- contracts/liquidity_hub/whale_lair/src/queries.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/liquidity_hub/pool-network/incentive/src/helpers.rs b/contracts/liquidity_hub/pool-network/incentive/src/helpers.rs index 9109504c..65c3effc 100644 --- a/contracts/liquidity_hub/pool-network/incentive/src/helpers.rs +++ b/contracts/liquidity_hub/pool-network/incentive/src/helpers.rs @@ -63,7 +63,7 @@ pub fn delete_weight_history_for_user( pub fn get_flow_asset_amount_at_epoch(flow: &Flow, epoch: u64) -> Uint128 { let mut asset_amount = flow.flow_asset.amount; - if let Some((_, &(change_amount, _))) = flow.asset_history.range(..=epoch).rev().next() { + if let Some((_, &(change_amount, _))) = flow.asset_history.range(..=epoch).next_back() { asset_amount = change_amount; } @@ -85,7 +85,7 @@ pub fn get_flow_end_epoch(flow: &Flow) -> u64 { pub fn get_flow_current_end_epoch(flow: &Flow, epoch: u64) -> u64 { let mut end_epoch = flow.end_epoch; - if let Some((_, &(_, current_end_epoch))) = flow.asset_history.range(..=epoch).rev().next() { + if let Some((_, &(_, current_end_epoch))) = flow.asset_history.range(..=epoch).next_back() { end_epoch = current_end_epoch; } diff --git a/contracts/liquidity_hub/whale_lair/src/queries.rs b/contracts/liquidity_hub/whale_lair/src/queries.rs index 85c90042..8ad390a2 100644 --- a/contracts/liquidity_hub/whale_lair/src/queries.rs +++ b/contracts/liquidity_hub/whale_lair/src/queries.rs @@ -102,8 +102,8 @@ pub(crate) fn query_unbonding( .collect::>>()?; // aggregate all the amounts in unbonding vec and return uint128 - let unbonding_amount = unbonding.iter().fold(Ok(Uint128::zero()), |acc, bond| { - acc.and_then(|acc| acc.checked_add(bond.asset.amount)) + let unbonding_amount = unbonding.iter().try_fold(Uint128::zero(), |acc, bond| { + acc.checked_add(bond.asset.amount) })?; Ok(UnbondingResponse {