Skip to content

Commit

Permalink
Merge pull request #275 from White-Whale-Defi-Platform/fix/ignore-pos…
Browse files Browse the repository at this point in the history
…sible-errors-on-close-position

fix(smart-contracts): ignore possible errors when closing position on…
  • Loading branch information
nseguias authored Feb 7, 2024
2 parents f513e6a + a15b829 commit 377a226
Showing 1 changed file with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,11 @@ pub fn close_position(
) -> Result<Response, ContractError> {
//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 {});
}
}

Expand Down

0 comments on commit 377a226

Please sign in to comment.