updateVaultAndCreditDelegationWeight updates all credit delegations for connected markets with the total assets of the vault. _updateCreditDelegations calls market.updateTotalDelegatedCredit, which adds 100% of the vault’s assets to each connected market. This results in each market receiving 100% of the vault's credit, leading to over-allocation, more credit is delegated than the vault can actually provide.
This function updateVaultAndCreditDelegationWeight updates the creditDelegation.weight for all connected markets and the totalCreditDelegationWeight of the vault to the same value:
Here, newWeight is derived from the vault's total assets:
Then _updateCreditDelegations calculates the creditDelegationShareX18 for each market as:
Since creditDelegation.weight and totalCreditDelegationWeight are set to the same value (newWeight), the division results in:
If creditDelegationShareX18 is always 1e18 (100%), then the creditDeltaUsdX18 calculation and delegation update in market:
Thus _updateCreditDelegations will always allocate 100% of the vault's credit capacity to each market. This is clearly problematic, as it would mean that every market receives the full credit capacity of the vault, leading to over-allocation and potential insolvency.
In CreditDelegationBranch, we have withdrawUsdTokenFromMarket, which calculates market's credit capacity by deducting market's debt from market's delegated credit from vault. It then checks the credit capacity of the market, mints USD token to caller and increase market's debt.
Suppose there are 5 markets connected to a vault. If vault has 100 credit capacity, it will delegate 100 credit to all markets. Calls to withdrawUsdTokenFromMarket will check market's credit capacity and then mint tokens and increase debt. If one market uses 100 credit and add 100 debt, vault's credit capacity will become zero. But the other 4 markets still have 100 delegated credit. So other markets will keep issueing USD token to engine. As a result the vault's debt will be too much and the vault will become very unhealthy and it will not have sufficient asset to back the USD tokens minted
Each market would be allocated 100% of the vault's credit capacity, which is impossible in practice. This would lead to a situation where the vault's credit capacity is exhausted by the first market, leaving no liquidity for other markets
credit calculations will lead to liquidity shortages, insolvencies, or protocol failures.
Ensure Proper Credit Delegation Distribution Across Connected Markets. Instead of allocating 100% of vault assets to each market, the contract should distribute credit proportionally across markets
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.