Skip to content
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

program: add-liquidity-isolated-check #965

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixes

### Breaking
- program: fix checking isolated tier in add_perp_lp_shares

### Breaking

## [2.73.0] - 2023-03-15

Expand All @@ -24,10 +25,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Breaking


## [2.72.0] - 2023-03-14

### Features

- program: skip isolated tier for auction start/end sanitize ([#958](https://github.com/drift-labs/protocol-v2/pull/958))

- program: check isolated perp market in validate spot margin trading ([#957](https://github.com/drift-labs/protocol-v2/pull/957))
Expand Down
17 changes: 7 additions & 10 deletions programs/drift/src/instructions/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::load_mut;
use crate::math::casting::Cast;
use crate::math::liquidation::is_user_being_liquidated;
use crate::math::margin::{
calculate_max_withdrawable_amount, meets_initial_margin_requirement,
calculate_max_withdrawable_amount, meets_place_order_margin_requirement,
meets_withdraw_margin_requirement, validate_spot_margin_trading, MarginRequirementType,
};
use crate::math::safe_math::SafeMath;
Expand Down Expand Up @@ -1691,15 +1691,12 @@ pub fn handle_add_perp_lp_shares<'info>(
}

// check margin requirements
validate!(
meets_initial_margin_requirement(
user,
&perp_market_map,
&spot_market_map,
&mut oracle_map
)?,
ErrorCode::InsufficientCollateral,
"User does not meet initial margin requirement"
meets_place_order_margin_requirement(
user,
&perp_market_map,
&spot_market_map,
&mut oracle_map,
true,
)?;

user.update_last_active_slot(clock.slot);
Expand Down
Loading