Part 2

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

Missing Events for Critical State Changes in updateVaultLastDistributedValues::CreditDelegation

Summary

The CreditDelegation contract lacks event emissions for critical state changes in the updateVaultLastDistributedValues function. This omission makes it difficult to track and monitor important state transitions off-chain.

Vulnerability Details

In CreditDelegation.sol, the updateVaultLastDistributedValues function modifies critical state variables but does not emit any events to log these changes. Events are crucial for off-chain monitoring and tracking of state changes in the blockchain.

function updateVaultLastDistributedValues(
Data storage self,
SD59x18 vaultDistributedRealizedDebtUsdPerShareX18,
SD59x18 vaultDistributedUnrealizedDebtUsdPerShareX18,
UD60x18 vaultDistributedUsdcCreditPerShareX18,
UD60x18 vaultDistributedWethRewardPerShareX18
)
internal
{
// updates the credit delegation state
self.lastVaultDistributedRealizedDebtUsdPerShare =
vaultDistributedRealizedDebtUsdPerShareX18.intoInt256().toInt128();
self.lastVaultDistributedUnrealizedDebtUsdPerShare =
vaultDistributedUnrealizedDebtUsdPerShareX18.intoInt256().toInt128();
self.lastVaultDistributedUsdcCreditPerShare = vaultDistributedUsdcCreditPerShareX18.intoUint128();
self.lastVaultDistributedWethRewardPerShare = vaultDistributedWethRewardPerShareX18.intoUint128();
}

Impact

  • Reduced transparency of state changes

  • Difficulty in tracking and monitoring vault distribution values off-chain

  • Challenges in building effective monitoring tools and dashboards

  • Potential complications in debugging and auditing historical changes

The function modifies critical state variables:

  • lastDistributedCredit

  • lastDistributedDebt

Without events, there's no way to efficiently track these changes through blockchain logs.

Tools Used

Manual review

Recommendations

// Add event declaration
+ event VaultDistributionValuesUpdated(
+ int128 realizedDebtUsdPerShare,
+ int128 unrealizedDebtUsdPerShare,
+ uint128 usdcCreditPerShare,
+ uint128 wethRewardPerShare
+ );
function updateVaultLastDistributedValues(
Data storage self,
SD59x18 vaultDistributedRealizedDebtUsdPerShareX18,
SD59x18 vaultDistributedUnrealizedDebtUsdPerShareX18,
UD60x18 vaultDistributedUsdcCreditPerShareX18,
UD60x18 vaultDistributedWethRewardPerShareX18
) internal {
int128 realizedDebt = vaultDistributedRealizedDebtUsdPerShareX18.intoInt256().toInt128();
int128 unrealizedDebt = vaultDistributedUnrealizedDebtUsdPerShareX18.intoInt256().toInt128();
uint128 usdcCredit = vaultDistributedUsdcCreditPerShareX18.intoUint128();
uint128 wethReward = vaultDistributedWethRewardPerShareX18.intoUint128();
self.lastVaultDistributedRealizedDebtUsdPerShare = realizedDebt;
self.lastVaultDistributedUnrealizedDebtUsdPerShare = unrealizedDebt;
self.lastVaultDistributedUsdcCreditPerShare = usdcCredit;
self.lastVaultDistributedWethRewardPerShare = wethReward;
// Emit event for tracking
+ emit VaultDistributionValuesUpdated(
+ realizedDebt,
+ unrealizedDebt,
+ usdcCredit,
+ wethReward
+ );
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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