OrderBook

First Flight #43
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Valid

Missing Event Indexing + Poor dApp Integration

Description

  • Events should have proper indexing to enable efficient filtering and querying by dApps and indexing services.

  • Several events lack indexed parameters which reduces their usefulness for front-end applications and analytics tools.

event OrderAmended(
uint256 indexed orderId,
uint256 newAmountToSell, // Should be indexed
uint256 newPriceInUSDC, // Should be indexed
uint256 newDeadlineTimestamp // Could be indexed
);
event TokenAllowed(
address indexed token, // Correctly indexed
bool indexed status // Correctly indexed
);
event EmergencyWithdrawal(
address indexed token, // Correctly indexed
uint256 indexed amount, // Should not be indexed (unlikely to filter by amount)
address indexed receiver // Correctly indexed
);

Risk

Likelihood:

  • When dApps need to filter events by specific criteria

  • When building analytics dashboards or order tracking systems

  • When users need to query their order history efficiently

Impact:

  • Reduced performance for dApp event filtering and querying

  • Increased infrastructure costs for indexing services

  • Poor user experience in front-end applications

Proof of Concept

dApp Integration Challenge: This demonstrates how poor event indexing affects front-end applications.

// Current: Cannot efficiently filter orders by price range
// web3.eth.getPastEvents('OrderAmended', {
// filter: {
// newPriceInUSDC: {$gte: 1000, $lte: 5000} // This doesn't work
// }
// });
// With indexed parameters, this would be possible:
// web3.eth.getPastEvents('OrderAmended', {
// filter: {
// newPriceInUSDC: [1000, 2000, 3000, 4000, 5000] // More efficient
// }
// });

Real-world impact on dApps:

  • Inefficient queries: Cannot filter events by price ranges or token amounts

  • Higher infrastructure costs: Must fetch all events and filter client-side

  • Slower user experience: Loading all events takes more time than filtered queries

  • Analytics limitations: Order book analytics and dashboards perform poorly

  • Mobile app issues: Limited bandwidth makes downloading all events impractical

Recommended Mitigation

Solution: Add proper indexing to enable efficient event filtering and querying.

event OrderAmended(
uint256 indexed orderId,
- uint256 newAmountToSell,
- uint256 newPriceInUSDC,
+ uint256 indexed newAmountToSell,
+ uint256 indexed newPriceInUSDC,
uint256 newDeadlineTimestamp
);
event EmergencyWithdrawal(
address indexed token,
- uint256 indexed amount,
+ uint256 amount,
address indexed receiver
);

Why this works:

  • Efficient filtering: dApps can filter by price ranges and token amounts

  • Better performance: Indexed parameters enable faster event queries

  • Lower costs: Reduces infrastructure costs for dApps and indexing services

  • Enhanced UX: Faster loading times improve user experience

Indexing best practices:

  • Limit to 3 indexed parameters per event (EVM limitation)

  • Index commonly filtered fields: orderId, amounts, prices, addresses

  • Don't index large data: Avoid indexing strings or large arrays

  • Consider query patterns: Index parameters that dApps will filter by most often

Updates

Lead Judging Commences

yeahchibyke Lead Judge 6 days ago
Submission Judgement Published
Validated
Assigned finding tags:

Poor event indexing and asset token symbol not displayed

Events not properly indexed. Filtering and querying from analytic tools will be very in-efficient

Support

FAQs

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