From 5514594aee675f4d2d8ef44875bd67cd0907c9df Mon Sep 17 00:00:00 2001 From: 0xFable <0xfable@protonmail.com> Date: Mon, 15 Apr 2024 12:55:28 +0100 Subject: [PATCH] fix: More clippy --- .../bonding-manager/src/commands.rs | 19 ++++++++++--------- .../pool-manager/src/manager/commands.rs | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/contracts/liquidity_hub/bonding-manager/src/commands.rs b/contracts/liquidity_hub/bonding-manager/src/commands.rs index d26728e6..1f567240 100644 --- a/contracts/liquidity_hub/bonding-manager/src/commands.rs +++ b/contracts/liquidity_hub/bonding-manager/src/commands.rs @@ -22,12 +22,11 @@ pub(crate) fn bond( env: Env, asset: Coin, ) -> Result { - let denom = asset.denom.clone(); - helpers::validate_funds(&deps, &info, &asset, denom.clone())?; + helpers::validate_funds(&deps, &info, &asset, asset.denom.clone())?; helpers::validate_claimed(&deps, &info)?; helpers::validate_bonding_for_current_epoch(&deps, &env)?; let mut bond = BOND - .key((&info.sender, &denom)) + .key((&info.sender, &asset.denom)) .may_load(deps.storage)? .unwrap_or(Bond { asset: Coin { @@ -42,7 +41,7 @@ pub(crate) fn bond( // let new_bond_weight = get_weight(timestamp, bond.weight, asset.amount, config.growth_rate, bond.timestamp)?; bond.weight = bond.weight.checked_add(asset.amount)?; bond = update_local_weight(&mut deps, info.sender.clone(), timestamp, bond)?; - BOND.save(deps.storage, (&info.sender, &denom), &bond)?; + BOND.save(deps.storage, (&info.sender, &asset.denom), &bond)?; // update global values let mut global_index = GLOBAL.may_load(deps.storage)?.unwrap_or_default(); @@ -77,11 +76,13 @@ pub(crate) fn unbond( ContractError::InvalidUnbondingAmount {} ); - let denom = asset.denom.clone(); helpers::validate_claimed(&deps, &info)?; helpers::validate_bonding_for_current_epoch(&deps, &env)?; - if let Some(mut unbond) = BOND.key((&info.sender, &denom)).may_load(deps.storage)? { + if let Some(mut unbond) = BOND + .key((&info.sender, &asset.denom)) + .may_load(deps.storage)? + { // check if the address has enough bond ensure!( unbond.asset.amount >= asset.amount, @@ -95,14 +96,14 @@ pub(crate) fn unbond( unbond.asset.amount = unbond.asset.amount.checked_sub(asset.amount)?; if unbond.asset.amount.is_zero() { - BOND.remove(deps.storage, (&info.sender, &denom)); + BOND.remove(deps.storage, (&info.sender, &asset.denom)); } else { - BOND.save(deps.storage, (&info.sender, &denom), &unbond)?; + BOND.save(deps.storage, (&info.sender, &asset.denom), &unbond)?; } // record the unbonding UNBOND.save( deps.storage, - (&info.sender, &denom, timestamp.nanos()), + (&info.sender, &asset.denom, timestamp.nanos()), &Bond { asset: asset.clone(), weight: Uint128::zero(), diff --git a/contracts/liquidity_hub/pool-manager/src/manager/commands.rs b/contracts/liquidity_hub/pool-manager/src/manager/commands.rs index 991785f1..340cef04 100644 --- a/contracts/liquidity_hub/pool-manager/src/manager/commands.rs +++ b/contracts/liquidity_hub/pool-manager/src/manager/commands.rs @@ -4,7 +4,7 @@ use cosmwasm_std::{ use white_whale_std::{ fee::PoolFee, pool_network::{asset::PairType, querier::query_native_decimals}, - whale_lair::{fill_rewards_msg, fill_rewards_msg_coin}, + whale_lair::fill_rewards_msg_coin, }; use crate::state::{get_pair_by_identifier, NATIVE_TOKEN_DECIMALS, PAIR_COUNTER};