Skip to content

program: rm exception in marign check for mismatch pool ids #1559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions programs/drift/src/math/margin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,13 @@ pub fn calculate_margin_requirement_and_total_collateral_and_liability_info(
spot_market.get_max_confidence_interval_multiplier()?,
)?;

let mut skip_token_value = false;
if !(user_pool_id == 1 && spot_market.market_index == 0 && !spot_position.is_borrow()) {
validate!(
user_pool_id == spot_market.pool_id,
ErrorCode::InvalidPoolId,
"user pool id ({}) == spot market pool id ({})",
user_pool_id,
spot_market.pool_id,
)?;
} else {
skip_token_value = true;
}
validate!(
user_pool_id == spot_market.pool_id,
ErrorCode::InvalidPoolId,
"user pool id ({}) == spot market pool id ({})",
user_pool_id,
spot_market.pool_id,
)?;

let oracle_valid =
is_oracle_valid_for_action(oracle_validity, Some(DriftAction::MarginCalc))?;
Expand Down Expand Up @@ -322,10 +317,6 @@ pub fn calculate_margin_requirement_and_total_collateral_and_liability_info(
token_value = 0;
}

if skip_token_value {
token_value = 0;
}

calculation.add_total_collateral(token_value)?;

calculation.update_all_deposit_oracles_valid(oracle_valid);
Expand Down
Loading