If marketDebtRatio is equals to the autoDeleverageStartThresholdx18 then adjusted factor will be zero.
Vulnerability Details
function getAdjustedProfitForMarketId in creditDelegationBranch calls market.getAutoDeleverageFactor() in this function deleverage calculated based on the market debt ratio and delegated credit .
Function getAdjustedProfitForMarketId() calls market.getAutoDeleverageFactor()
In function getAutoDeleverageFactor()
scenarion like
Parameter | Value |
---|---|
Total Delegated Credit | $1,000,000$ |
Total Market Debt | $700,000$ |
Auto-Deleverage Start Threshold | 0.75 |
Auto-Deleverage End Threshold | 0.95 |
market debt Ratio = 700000 / 1000000 = 0.75
Unscaled Deleverage Factor=0.95−0.75 min(0.75,0.95)−0.75 = 0
Ajustedprofitx18 = someValue * 0 = 0
Impact
If the market debt ratio is lesser than the autoDeleverageEndThyresholdx18 then adjusted profit will be always zero after exponentiation which loss to the market which are connected.
Panic underflow/overflow error CODE: 0x11
Add this code in test/integration/market-making/credit-branch/delegation-/getAdjustedProfitForMarketId/getAdjustedProfitForMarketId.t.sol
Add Different logic to calculate and handle zero like auto deleverage to not apply zero leverage in cases where the market ratio is below the threshold.
Add Lower bound for deleveraged Factor like Math.max(deleveragedFactor , ConstantMiniValue). So that some profit remains.
In function isAutoDeleverageTriggered() make change to gte() to gt() trigger only happens at greater than start thershold.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.