Part 2

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

`receiveWethReward` does not calculate the reward on a per-share basis

Summary

In the _handleWethRewardDistribution we can see that the received weth reward is not split per share.

Vulnerability Details

In the _handleWethRewardDistribution will call receiveWethReward passing the whole amount as receivedVaultsWethRewardX18. However we can see that it will be added to the wethRewardPerVaultShare without being devided by the total delegated credit to the market:

function receiveWethReward(
Data storage self,
address asset,
UD60x18 receivedProtocolWethRewardX18,
UD60x18 receivedVaultsWethRewardX18
)
internal
{
// if a market credit deposit asset has been used to acquire the received weth, we need to reset its balance
if (asset != address(0)) {
// removes the given asset from the received market fees enumerable map as we assume it's been fully
// swapped to weth
self.receivedFees.remove(asset);
}
// increment the amount of pending weth reward to be distributed to fee recipients
self.availableProtocolWethReward =
ud60x18(self.availableProtocolWethReward).add(receivedProtocolWethRewardX18).intoUint128();
// increment the all time weth reward storage
self.wethRewardPerVaultShare =
ud60x18(self.wethRewardPerVaultShare).add(receivedVaultsWethRewardX18).intoUint128();
}

Here we can see that the whole reward will be added instead of the reward per share. This will result in wrong reward distribution when there is more than one vault which delegated credit to the market.

Impact

Wrong reward distribution. The current implementation will try to distribute more reward then there actually is.

Tools Used

Manual Review

Recommendations

receivedVaultsWethRewardX18 should be devided by the totalDelegatedCreditUsd prior to being added to wethRewardPerVaultShare for the given market.

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.