Skip to content

Conversation

@IMEF-FEMI
Copy link
Contributor

Summary

Implements additional safety guards for emode (efficiency mode) configurations to prevent under-collateralized lending
scenarios. This addresses the risk of emode admins inadvertently or maliciously setting collateral/liability weight
configurations that would allow under-collateralized positions.

Key safeguards:

  • Enforces CW < LW (collateral weight must be strictly less than liability weight) to prevent infinite or negative leverage
  • Validates theoretical maximum leverage using the formula: L = 1 / (1 - CW/LW)
  • Enforces configurable group-level maximum leverage limit (default: 20x, range: 1x-100x)
  • Stores max_emode_leverage in bank cache for efficient validation during emode configuration
  • Validates both initial and maintenance weight configurations against leverage limits

@IMEF-FEMI IMEF-FEMI requested review from IliaZyrin and jgur-psyops and removed request for jgur-psyops November 19, 2025 16:22
Copy link
Contributor

@IliaZyrin IliaZyrin left a comment

Choose a reason for hiding this comment

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

Looks good!

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.

3 participants