From 00a00c757f080867abc514b57b32ee272591b53b Mon Sep 17 00:00:00 2001 From: nahem Date: Wed, 7 Feb 2024 09:13:15 +0100 Subject: [PATCH] fix(smart-contracts): ignore possible errors when closing position on incentives --- .../incentive/src/execute/close_position.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/contracts/liquidity_hub/pool-network/incentive/src/execute/close_position.rs b/contracts/liquidity_hub/pool-network/incentive/src/execute/close_position.rs index 4aa82bb9..928799e7 100644 --- a/contracts/liquidity_hub/pool-network/incentive/src/execute/close_position.rs +++ b/contracts/liquidity_hub/pool-network/incentive/src/execute/close_position.rs @@ -20,19 +20,11 @@ pub fn close_position( ) -> Result { //query and check if the user has pending rewards let rewards_query_result = get_rewards(deps.as_ref(), info.sender.clone().into_string()); - match rewards_query_result { - Ok(rewards_response) => { - // can't close a position if there are pending rewards - if !rewards_response.rewards.is_empty() { - return Err(ContractError::PendingRewards {}); - } - } - Err(error) => { - //if it has nothing to claim, then close the position - match error { - ContractError::NothingToClaim {} => {} - _ => return Err(ContractError::InvalidReward {}), - } + + if let Ok(rewards_response) = rewards_query_result { + // can't close a position if there are pending rewards + if !rewards_response.rewards.is_empty() { + return Err(ContractError::PendingRewards {}); } }