Skip to content
Request an audit

‹ All findings

OstiumLinkUpKeep:removeFromWatchList() complexity could be reduced

Low/InfoOstium·Three Sigma · RWA perpetuals DEX · 19th February, 20243S-OS-N24

Description

OstiumLinkUpKeep:removeFromWatchList() currently iterates over the full s_registryWatchLists to find the keeperIds and delete them if equal. This has O(n^2) complexity, which could cost a significant amount of gas.

Recommendation

One way to tackle this problem is tweaking the isInWatchList mapping to store the index of the array instead of a bool, adding 1 to each index so that 0 is not a valid index and can be used to check for abcense. This way, when removing, the index can be fetchd from the corresponding mapping.

Status

Acknowledged