Skip to content

Commit

Permalink
Add unchecked blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
zajck committed Jan 8, 2024
1 parent edb59c7 commit ec7dc5d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions contracts/protocol/facets/SequentialCommitHandlerFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,12 @@ contract SequentialCommitHandlerFacet is IBosonSequentialCommitHandler, PriceDis
revert FeeAmountTooHigh();
}

// Get price paid by current buyer
uint256 len = exchangeCosts.length;
uint256 currentPrice = len == 0 ? offer.price : exchangeCosts[len - 1].price;
uint256 currentPrice;
unchecked {
// Get price paid by current buyer
uint256 len = exchangeCosts.length;
currentPrice = len == 0 ? offer.price : exchangeCosts[len - 1].price;
}

// Calculate the minimal amount to be kept in the escrow
escrowAmount =
Expand All @@ -156,7 +159,10 @@ contract SequentialCommitHandlerFacet is IBosonSequentialCommitHandler, PriceDis
}

// Make sure enough get escrowed
payout = exchangeCost.price - escrowAmount;
// Escrow amount is guaranteed to be less than or equal to price
unchecked {
payout = exchangeCost.price - escrowAmount;
}

if (_priceDiscovery.side == Side.Ask) {
if (escrowAmount > 0) {
Expand Down

0 comments on commit ec7dc5d

Please sign in to comment.