Skip to content

Commit

Permalink
chore: refactor funds validation
Browse files Browse the repository at this point in the history
  • Loading branch information
kerber0x committed Apr 11, 2024
1 parent ca44eef commit a42267e
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ pub fn withdraw_liquidity(
pair_identifier: String,
) -> Result<Response, ContractError> {
let config = MANAGER_CONFIG.load(deps.storage)?;
let amount = info.funds[0].amount;
// check if the withdraw feature is enabled
if !config.feature_toggle.withdrawals_enabled {
return Err(ContractError::OperationDisabled(
Expand All @@ -220,9 +219,8 @@ pub fn withdraw_liquidity(
let mut pair = get_pair_by_identifier(&deps.as_ref(), &pair_identifier)?;
let liquidity_token = pair.lp_denom.clone();
// Verify that the LP token was sent
if info.funds.is_empty() || info.funds[0].denom != liquidity_token {
return Err(ContractError::Unauthorized {});
}
let amount = cw_utils::must_pay(&info, &liquidity_token)?;

// Get the total share of the pool
let total_share = get_total_share(&deps.as_ref(), liquidity_token.clone())?;

Expand Down

0 comments on commit a42267e

Please sign in to comment.