Conversation
Collaborator
LukasDeco
commented
Feb 3, 2026
- feat: margin type config for override margin type behavior
- feat: tests for margin override
- feat: idl, anchor tests, more cargo tests
crispheaney
reviewed
Feb 4, 2026
| market_index, | ||
| margin_requirement_type: MarginRequirementType::Initial, | ||
| default_isolated_margin_requirement_type: MarginRequirementType::Maintenance, | ||
| cross_margin_requirement_type: MarginRequirementType::Initial, |
Member
There was a problem hiding this comment.
think this can be maintenance
crispheaney
reviewed
Feb 4, 2026
programs/drift/src/math/margin.rs
Outdated
| } else { | ||
| 0_u32 | ||
| }; | ||
| let mut user_custom_margin_ratio = |
Member
There was a problem hiding this comment.
for user_custom_margin_ratio, think we want need to recalculate it for:
- the spot positions
- each perp position individually
Need to do this since all the spot positions have the same margin type but different ones for each perp pos.
Collaborator
Author
There was a problem hiding this comment.
ahhh ya you are right
crispheaney
reviewed
Feb 4, 2026
|
|
||
| let user_pool_id = user.pool_id; | ||
| let user_high_leverage_mode = user.is_high_leverage_mode(context.margin_type); | ||
| let user_high_leverage_mode = user.is_high_leverage_mode(cross_margin_requirement_type); |
Member
There was a problem hiding this comment.
need to recalc this in each perp pos iteration
crispheaney
reviewed
Feb 4, 2026
| } | ||
| } | ||
|
|
||
| pub fn standard_with_config(margin_type_config: MarginTypeConfig) -> Self { |
Member
There was a problem hiding this comment.
should change meets_transfer_isolated_position_deposit_margin_requirement to use this config to make it a bit safer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.