Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: medium
Invalid

Incorrect calculation and update of vault & credit-delegation weight

Summary

The updateVaultAndCreditDelegationWeight() function currently calculates the weight based on the total assets of the vault instead of the total shares. This miscalculation can lead to significant discrepancies in the representation of ownership stakes and the distribution of credit delegation.

Vulnerability Details

In the current implementation, the weight is calculated using the following line:

// get the total of shares
>> uint128 newWeight = uint128(IERC4626(self.indexToken).totalAssets()); // @audit-info These are not shares
for (uint256 i; i < connectedMarketsIdsCache.length; i++) {
// load the credit delegation to the given market id
CreditDelegation.Data storage creditDelegation =
CreditDelegation.load(self.id, connectedMarkets.at(i).toUint128());
// @audit-info update the credit delegation weight
>> creditDelegation.weight = newWeight;
}
// @audit-info update the vault weight
>> self.totalCreditDelegationWeight = newWeight;

This line retrieves the total assets of the vault, which does not accurately reflect the ownership represented by shares. The correct approach should involve using the total shares, typically obtained via totalSupply(), to ensure that the weight reflects the actual ownership stakes of users in the vault.

Impact

The use of total assets instead of shares for weight calculation can result in:

  • Misrepresentation of Ownership: ownership stakes are inaccurately represented.

  • Incorrect Credit Delegation: The weight used for credit delegation calculations may be skewed, affecting the financial operations of the vault.

Tools Used

Manual Review

Recommendations

Modify the weight calculation in the updateVaultAndCreditDelegationWeight function to use totalSupply() instead of totalAssets().

// get the total of shares
- uint128 newWeight = uint128(IERC4626(self.indexToken).totalAssets());
+ uint128 newWeight = uint128(IERC4626(self.indexToken).totalSupply()); // @audit Use shares
Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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