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: fill_perp checks maintenance margin req if position is reduced #714

Merged
merged 7 commits into from
Nov 24, 2023

Conversation

crispheaney
Copy link
Member

No description provided.

Copy link

codecov bot commented Nov 24, 2023

Codecov Report

Merging #714 (19f3c62) into master (a927305) will increase coverage by 0.09%.
Report is 1 commits behind head on master.
The diff coverage is 97.63%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #714      +/-   ##
==========================================
+ Coverage   74.40%   74.49%   +0.09%     
==========================================
  Files         125      125              
  Lines       28940    29054     +114     
==========================================
+ Hits        21533    21645     +112     
- Misses       7407     7409       +2     
Components Coverage Δ
drift 74.70% <97.63%> (+0.09%) ⬆️

based_asset_amount_filled: i64,
market_index: u16,
) -> DriftResult<MarginRequirementType> {
let current_position = maker
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is position after fill? maybe good to specify somewhere

let position_before = current_position.safe_sub(based_asset_amount_filled)?;

if current_position.signum() == position_before.signum()
&& current_position.abs() < position_before.abs()
Copy link
Member

@0xbigz 0xbigz Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good candidate for helper function

position_after.was_reduced(position_before)

@crispheaney crispheaney force-pushed the crispheaney/position-reducing-maker-maint-check branch from e9acb73 to 229ad5a Compare November 24, 2023 20:07
@crispheaney crispheaney merged commit 31e0b6c into master Nov 24, 2023
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants