The market's debt is not correctly updated in recalculateVaultsCreditCapacity()
.
When recalculateVaultsCreditCapacity() is called, protocol gets market's unrealized debt (which is always 0 in v1) and realized debt, and distributes the debt.
Vault::_recalculateConnectedMarketsState():
And the market's realizedDebtUsdPerVaultShare
and unrealizedDebtUsdPerVaultShare
is updated based on the market's totalDelegatedCreditUsd
.
Market::distributeDebtToVaults():
The problem is that both the market's realizedDebtUsdPerVaultShare
and unrealizedDebtUsdPerVaultShare
are up to date by the time the debt is distributed, but the market's totalDelegatedCreditUsd
is not, and its value is only updated at the end of recalculateVaultsCreditCapacity()
when _updateCreditDelegations() is called.
Vault::_updateCreditDelegations():
And using outdated totalDelegatedCreditUsd
value will get us incorrect realizedDebtUsdPerVaultShare
and unrealizedDebtUsdPerVaultShare
values.
realizedDebtUsdPerVaultShare
and unrealizedDebtUsdPerVaultShare
are later used to get the vault's accumulated debt, credit changes in getVaultAccumulatedValues().
Vault::_recalculateConnectedMarketsState():
Market::getVaultAccumulatedValues():
Incorrect realizedDebtUsdPerVaultShare
and unrealizedDebtUsdPerVaultShare
lead to incorrect value changes, and the state of the Maket Making Engine is not correctly accounted, this can bring huge risk to the whole system.
Manual Review
Update market's totalDelegatedCreditUsd
before distribute debt.
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.