Skip to content

Separate margin mode checks on different isolated margin calculations and cross calculation#2095

Open
LukasDeco wants to merge 5 commits intomasterfrom
lukas/be-67-isolated-longterm-solution-run-checks-on-maintenance-margin
Open

Separate margin mode checks on different isolated margin calculations and cross calculation#2095
LukasDeco wants to merge 5 commits intomasterfrom
lukas/be-67-isolated-longterm-solution-run-checks-on-maintenance-margin

Conversation

@LukasDeco
Copy link
Collaborator

  • feat: margin type config for override margin type behavior
  • feat: tests for margin override
  • feat: idl, anchor tests, more cargo tests

@LukasDeco LukasDeco changed the title lukas/be 67 isolated longterm solution run checks on maintenance margin Separate margin mode checks on different isolated margin calculations and cross calculation Feb 3, 2026
@LukasDeco LukasDeco marked this pull request as ready for review February 4, 2026 16:33
market_index,
margin_requirement_type: MarginRequirementType::Initial,
default_isolated_margin_requirement_type: MarginRequirementType::Maintenance,
cross_margin_requirement_type: MarginRequirementType::Initial,
Copy link
Member

Choose a reason for hiding this comment

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

think this can be maintenance

} else {
0_u32
};
let mut user_custom_margin_ratio =
Copy link
Member

Choose a reason for hiding this comment

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

for user_custom_margin_ratio, think we want need to recalculate it for:

  1. the spot positions
  2. 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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ahhh ya you are right


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);
Copy link
Member

Choose a reason for hiding this comment

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

need to recalc this in each perp pos iteration

}
}

pub fn standard_with_config(margin_type_config: MarginTypeConfig) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

should change meets_transfer_isolated_position_deposit_margin_requirement to use this config to make it a bit safer

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.

2 participants