Skip to content

Commit

Permalink
ah2: gas shavings
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrai committed Oct 6, 2023
1 parent 6726f23 commit 1e98e14
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/nouns-contracts/contracts/NounsAuctionHouseV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,30 @@ contract NounsAuctionHouseV2 is
function createBid(uint256 nounId) external payable override {
INounsAuctionHouseV2.AuctionV2 memory _auction = auctionStorage;

(uint192 _reservePrice, uint56 _timeBuffer, uint8 _minBidIncrementPercentage) = (
reservePrice,
timeBuffer,
minBidIncrementPercentage
);

require(_auction.nounId == nounId, 'Noun not up for auction');
require(block.timestamp < _auction.endTime, 'Auction expired');
require(msg.value >= reservePrice, 'Must send at least reservePrice');
require(msg.value >= _reservePrice, 'Must send at least reservePrice');
require(
msg.value >= _auction.amount + ((_auction.amount * minBidIncrementPercentage) / 100),
msg.value >= _auction.amount + ((_auction.amount * _minBidIncrementPercentage) / 100),
'Must send more than last bid by minBidIncrementPercentage amount'
);

auctionStorage.amount = uint128(msg.value);
auctionStorage.bidder = payable(msg.sender);

// Extend the auction if the bid was received within `timeBuffer` of the auction end time
bool extended = _auction.endTime - block.timestamp < timeBuffer;
bool extended = _auction.endTime - block.timestamp < _timeBuffer;

emit AuctionBid(_auction.nounId, msg.sender, msg.value, extended);

if (extended) {
auctionStorage.endTime = _auction.endTime = uint40(block.timestamp + timeBuffer);
auctionStorage.endTime = _auction.endTime = uint40(block.timestamp + _timeBuffer);
emit AuctionExtended(_auction.nounId, _auction.endTime);
}

Expand Down

0 comments on commit 1e98e14

Please sign in to comment.