DeFiFoundrySolidity
16,653 OP
View results
Submission Details
Severity: medium
Invalid

Missing Events

Issue Description

As per OpenZeppelin's Smart Contract Guidelines, all critical state-changing operations should emit events. This enables external consumers, such as dApps or monitoring services, to track the contract’s state and activity. However, in the current implementation, no events are emitted during critical state-modifying operations within the addRoute function. The absence of these events can lead to difficulties in monitoring state changes, affecting transparency and potentially complicating contract management.

Affected Code:

function addRoute(
address[11] calldata _route,
uint256[5][5] calldata _swapParams,
address[5] calldata _pools
) external onlyManagement {
routes[nRoutes] = _route;
swapParams[nRoutes] = _swapParams;
pools[nRoutes] = _pools;
nRoutes++;
}

This function alters multiple contract states:

  • The routes mapping

  • The swapParams mapping

  • The pools mapping

  • The incrementing of nRoutes

However, no event is emitted to record these important changes.

Recommendation

To improve transparency and comply with OpenZeppelin guidelines, we recommend emitting an event upon successfully adding a new route. This would allow external services to capture when a new route is added and track the associated parameters. Below is the suggested change:

event RouteAdded(
uint256 indexed routeId,
address[11] route,
address[5] pools
);
function addRoute(
address[11] calldata _route,
uint256[5][5] calldata _swapParams,
address[5] calldata _pools
) external onlyManagement {
routes[nRoutes] = _route;
swapParams[nRoutes] = _swapParams;
pools[nRoutes] = _pools;
emit RouteAdded(nRoutes, _route, _pools);
nRoutes++;
}

Impact of Change

  • Transparency: External systems can track route changes and associated parameters.

  • Auditability: Events provide a clear historical record of changes to the contract state.

  • Security: Event emissions serve as an important tool in post-deployment monitoring, ensuring that the contract behaves as expected.

Updates

Appeal created

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
drlaravel Submitter
7 months ago
inallhonesty Lead Judge
7 months ago
inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

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