Omniscia Boson Protocol Audit

FundsBase Code Style Findings

FundsBase Code Style Findings

FBE-01C: Inefficient Handling of Dispute Resolution Refund

Description:

The BPIP-8 has introduced a specialized mutualizer address that is meant to handle dispute resolution fee provisions as well as refunds, and this contract has been integrated by the FundsBase::releaseFunds finalization action.

The current integration appears to be inefficient due to two points; firstly, the DisputeResolutionTerms data points are read multiple times inefficiently from storage whereas they should be loaded to memory.

Secondly, the current mechanism will either issue a total refund or no refund at all.

Example:

contracts/protocol/bases/FundsBase.sol
252// Return unused DR fee to mutualizer or seller's pool
253if (drTerms.feeAmount != 0) {
254 uint256 returnAmount = drTerms.feeAmount - payoff.disputeResolver;
255
256 // Use exchange-level mutualizer address (locked at commitment time)
257 if (exchange.mutualizerAddress == address(0)) {
258 if (returnAmount > 0) {
259 increaseAvailableFundsAndEmitEvent(
260 _exchangeId,
261 offer.sellerId,
262 exchangeToken,
263 returnAmount,
264 sender
265 );
266 }
267 } else {
268 if (exchangeToken == address(0)) {
269 IDRFeeMutualizer(exchange.mutualizerAddress).returnDRFee{ value: returnAmount }(
270 _exchangeId,
271 returnAmount
272 );
273 } else {
274 if (returnAmount > 0) {
275 IERC20(exchangeToken).safeApprove(exchange.mutualizerAddress, returnAmount);
276 }
277 IDRFeeMutualizer(exchange.mutualizerAddress).returnDRFee(_exchangeId, returnAmount);
278 }
279 }
280}

Recommendation:

We advise the code to be optimized by loading data into memory and by optimizing the if conditional that triggers the refund to drTerms.feeAmount != 0 && payoff.disputeResolver == 0, permitting the code within to omit several conditionals.

Alleviation (efd5d1a8f23c3bca7c25273ea4c912a367250119):

The exhibit was partly addressed by introducing the memory related optimization, however, the Boson Protocol team clarified that zero-value exchange finalizations on the IDRFeeMutualizer should occur to ensure it is informed that no fee was ultimately captured.

As such, we consider this exhibit fully addressed.