Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: high
Valid

`recalculateVaultsCreditCapacity` will not distribute weth reward correctly

Summary

recalculateVaultsCreditCapacitywill not distribute the weth reward correctly when one market is connected to more than one vault

Vulnerability Details

The root cause of this issue is that getVaultAccumulatedValues will not return the accumulated reward for the individual vault. Instead it will only return the reward per share:

function getVaultAccumulatedValues(
Data storage self,
UD60x18 vaultDelegatedCreditUsdX18,
SD59x18 lastVaultDistributedRealizedDebtUsdPerShareX18,
SD59x18 lastVaultDistributedUnrealizedDebtUsdPerShareX18,
UD60x18 lastVaultDistributedUsdcCreditPerShareX18,
UD60x18 lastVaultDistributedWethRewardPerShareX18
)
internal
view
returns (
SD59x18 realizedDebtChangeUsdX18,
SD59x18 unrealizedDebtChangeUsdX18,
UD60x18 usdcCreditChangeX18,
UD60x18 wethRewardChangeX18
)
{
// TODO: fix the vaultCreditShareX18 flow to multiply by `wethRewardChangeX18`
wethRewardChangeX18 = ud60x18(self.wethRewardPerVaultShare).sub(lastVaultDistributedWethRewardPerShareX18);
}

Here we can see that the whole weth reward for the market will be returned. This is incorrect because the vault will only be entitled to a portion of this value. As a result there will be insolvency since there will not be enough rewards to cover for all the requests from the vault.

Impact

Wrong reward distribution will allocate more reward then there actually is.

Tools Used

Manual Review

Recommendations

Get the specific vault reward allocation

Updates

Lead Judging Commences

inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Validated
Assigned finding tags:

`wethRewardPerVaultShare` is incremented by `receivedVaultWethReward` amount which is not divided by number of shares.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.