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
{
self.lastVaultDistributedRealizedDebtUsdPerShare =
vaultDistributedRealizedDebtUsdPerShareX18.intoInt256().toInt128();
self.lastVaultDistributedUnrealizedDebtUsdPerShare =
vaultDistributedUnrealizedDebtUsdPerShareX18.intoInt256().toInt128();
self.lastVaultDistributedUsdcCreditPerShare = vaultDistributedUsdcCreditPerShareX18.intoUint128();
self.lastVaultDistributedWethRewardPerShare = vaultDistributedWethRewardPerShareX18.intoUint128();
}
Impact
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
+ );
}