DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: low
Invalid

Missing Event Emission for Resetting flowData

Summary

In the PerpetuelVault.sol (617-618) contract resets flowData and flow when a trade signal change fails, but it does not emit an event before doing so. This creates a lack of transparency for off-chain bots and keepers tracking positions, making it difficult to debug and restart processes when failures occur.

Vulnerability Details

Affected Code

// If signal change fails, the off-chain script starts again from the current status.
delete flowData;
delete flow;

Issue

  • When a trade signal change fails, the contract resets flowData and flow without notifying off-chain tracking mechanisms.

  • Off-chain bots that rely on event logs will have no way of knowing why the reset occurred.

  • This could lead to inefficiencies, requiring manual intervention to investigate and restart the process.

Impact

  • Lack of transparency: Keepers and bots monitoring the contract will be unaware of failed trade signals.

  • Difficulty in debugging: Without an event, developers and off-chain services cannot easily determine when and why a signal change was reset.

  • Potential operational inefficiencies: Bots may continue operating under incorrect assumptions, leading to potential errors or delays in trade execution.

Tools Used

Manuel Review

Recommendations

Solution: Emit an Event Before Resetting

Modify the existing logic to include an event emission before deleting flowData and flow:

// Add event definition
event FlowReset(uint256 previousFlowData, string reason);
// Before resetting flowData and flow, emit an event
emit FlowReset(flowData, "Signal change failed");
delete flowData;
delete flow;

Benefits of This Fix

  • Improved debugging: Keepers and bots can listen for the FlowReset event to understand why the reset happened.

  • Increased contract transparency: Event logs will provide a historical record of trade signal failures.

  • Better off-chain tracking: Off-chain services can use the event to adjust their strategies accordingly.

Updates

Lead Judging Commences

n0kto Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

n0kto Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

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