Skip to content

Commit

Permalink
program: add-liquidity-isolated-check (#965)
Browse files Browse the repository at this point in the history
* program: add-liquidity-isolated-check

* update changelog
  • Loading branch information
0xbigz committed Mar 19, 2024
1 parent 1df151e commit 1a68ac9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
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

0 comments on commit 1a68ac9

Please sign in to comment.