Omniscia Boson Protocol Audit
BosonPriceDiscovery Code Style Findings
BosonPriceDiscovery Code Style Findings
BPD-01C: Ineffectual Usage of Safe Arithmetics
| Type | Severity | Location |
|---|---|---|
| Language Specific | ![]() | BosonPriceDiscovery.sol:L246 |
Description:
The linked mathematical operation is guaranteed to be performed safely by logical inference, such as surrounding conditionals evaluated in require checks or if-else constructs.
Example:
contracts/protocol/clients/priceDiscovery/BosonPriceDiscovery.sol
238if (thisNativeBalanceAfter > thisNativeBalanceBefore) {239 // _msgSender==address(0) represents the wrapper, where it's not allowed to return the surplus240 if (_msgSender == address(0)) revert NativeNotAllowed();241
242 // Return the surplus to the sender243 FundsLib.transferFundsFromProtocol(244 address(0),245 payable(_msgSender),246 thisNativeBalanceAfter - thisNativeBalanceBefore247 );248}Recommendation:
Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statement to be wrapped in an unchecked code block thereby optimizing its execution cost.
Alleviation:
The referenced arithmetic operation has been wrapped in an unchecked code block as advised.
