Market credit capacity is not correctly calculated.
Market's getCreditCapacityUsd() calculates the market's credit capacity by adding the market's credit delegated by vaults to the market's unrealized + realized debt.
This function is called in CreditDelegationBranch
's withdrawUsdTokenFromMarket().
CreditDelegationBranch::withdrawUsdTokenFromMarket():
As can be seen, the passed arguments are marketTotalDebtUsdX18
and delegatedCreditUsdX18
. The marketTotalDebtUsdX18
is actually the market's realized debt (in v1, the unrealized debt is always 0), and the market's realized debt depends on the credit deposits and the net value of usd tokens minted and burned by this market.
It's easy to tell that is the market has debts, then the debt value is positive, therefore, to calculate market's credit capacity, we should substract the debt from the market's delegated credit, instead of adding them together.
Market credit capacity is not correctly calculated.
Manual Review
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.