@@ -297,7 +297,7 @@ contract ClustersMarketV1 is UUPSUpgradeable, Initializable, Ownable, Reentrancy
297
297
} else {
298
298
uint256 newBidAmount = F.rawSub (oldBidAmount, delta);
299
299
if (newBidAmount < _minAnnualPrice (contracts)) revert Insufficient ();
300
- b.bidAmount = SafeCastLib. toUint88 (newBidAmount);
300
+ b.bidAmount = uint88 (newBidAmount);
301
301
b.bidUpdated = uint40 (block .timestamp );
302
302
emit BidReduced (clusterName, sender, oldBidAmount, newBidAmount);
303
303
}
@@ -379,25 +379,24 @@ contract ClustersMarketV1 is UUPSUpgradeable, Initializable, Ownable, Reentrancy
379
379
380
380
/// @dev Allows the owner to set the minimum bid increment.
381
381
function setMinBidIncrement (uint256 newMinBidIncrement ) public onlyOwner {
382
- ClustersMarketStorage storage $ = _getClustersMarketStorage ();
383
- $.minBidIncrement = SafeCastLib.toUint88 (newMinBidIncrement);
382
+ _getClustersMarketStorage ().minBidIncrement = SafeCastLib.toUint88 (newMinBidIncrement);
384
383
emit MinBidIncrementSet (newMinBidIncrement);
385
384
}
386
385
387
386
/// @dev Allows the owner to set the bid timelock.
388
387
function setBidTimelock (uint256 newBidTimelock ) public onlyOwner {
389
- ClustersMarketStorage storage $ = _getClustersMarketStorage ();
390
- $.bidTimelock = SafeCastLib.toUint32 (newBidTimelock);
388
+ _getClustersMarketStorage ().bidTimelock = SafeCastLib.toUint32 (newBidTimelock);
391
389
emit BidTimelockSet (newBidTimelock);
392
390
}
393
391
394
392
/// @dev Allows the owner to withdraw the protocol accrual.
395
393
function withdrawProtocolAccural (address to , uint256 amount ) public onlyOwner {
396
394
ClustersMarketStorage storage $ = _getClustersMarketStorage ();
397
- // Will revert if `amount > $.protocolAccural`.
398
- $.protocolAccural -= SafeCastLib.toUint88 (amount);
399
- SafeTransferLib.forceSafeTransferETH (to, amount);
400
- emit ProtocolAccuralWithdrawn (to, amount);
395
+ uint256 accrual = $.protocolAccural;
396
+ uint256 clampedAmount = F.min (amount, accrual);
397
+ $.protocolAccural = uint88 (F.rawSub (accrual, clampedAmount));
398
+ SafeTransferLib.forceSafeTransferETH (to, clampedAmount);
399
+ emit ProtocolAccuralWithdrawn (to, clampedAmount);
401
400
}
402
401
403
402
/*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
0 commit comments