Description:
In the current implementation of the OrderBook
contract, several functions are declared with public
visibility. However, these functions are never invoked from within the contract itself, they are only intended to be called externally by users or other contracts. In Solidity, functions marked as public
can be accessed both externally and internally, while external
functions can only be called from outside the contract. Marking such functions as external
instead of public
is a best practice when internal calls are not required.
Impact:
If left unaddressed, this inefficiency can accumulate, especially as the protocol scales and more users interact with these functions. It also sets a precedent for suboptimal gas usage, which can be avoided with a simple change in function visibility. Additionally, using the most restrictive and appropriate visibility modifiers improves code clarity and maintainability, making it easier for future developers and auditors to understand the intended usage of each function.
Recommended Mitigation:
Review all functions in the OrderBook
contract that are currently marked as public
and are not called internally. Change their visibility from public
to external
to optimize gas usage. This includes, but may not be limited to, functions such as createSellOrder
, amendSellOrder
, cancelSellOrder
, buyOrder
, getOrder
, and getOrderDetailsString
. Adopting this practice will help reduce gas costs for users and improve the overall efficiency of the contract.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.