Skip to content

Commit

Permalink
bugfix: fix bug returning empty settlements
Browse files Browse the repository at this point in the history
in case the settlements were warmed up, the timestamp in change to 1
and the previous check would fail
  • Loading branch information
davidbrai committed Oct 5, 2023
1 parent ff650bc commit 05eb47a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/nouns-contracts/contracts/NounsAuctionHouseV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ contract NounsAuctionHouseV2 is
while (actualCount < auctionCount && latestNounId > 0) {
// Skip Nouner reward Nouns, they have no price
// Also skips IDs with no price data
if (settlementHistory[latestNounId].blockTimestamp == 0) {
if (settlementHistory[latestNounId].winner == address(0)) {
--latestNounId;
continue;
}
Expand Down Expand Up @@ -394,7 +394,7 @@ contract NounsAuctionHouseV2 is
while (currentId < endId) {
// Skip Nouner reward Nouns, they have no price
// Also skips IDs with no price data
if (settlementHistory[currentId].blockTimestamp == 0) {
if (settlementHistory[currentId].winner == address(0)) {
++currentId;
continue;
}
Expand Down
22 changes: 22 additions & 0 deletions packages/nouns-contracts/test/foundry/NounsAuctionHouseV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ contract NounsAuctionHouseV2TestBase is Test, DeployUtils {
address owner = address(0x1111);
address noundersDAO = address(0x2222);
address minter = address(0x3333);
uint256[] nounIds;

NounsAuctionHouseV2 auction;

Expand Down Expand Up @@ -343,6 +344,27 @@ contract NounsAuctionHouseV2_OracleTest is NounsAuctionHouseV2TestBase {
assertEq(prices[19].amount, 1 ether);
}

function test_prices_skipsEmptySettlementsPostWarmUp() public {
nounIds = [0, 1, 2, 10, 11, 20, 21];
auction.warmUpSettlementState(nounIds);

for (uint256 i = 1; i <= 20; ++i) {
address bidder = makeAddr(vm.toString(i));
bidAndWinCurrentAuction(bidder, i * 1e18);
}

INounsAuctionHouseV2.Settlement[] memory prices = auction.prices(20);
assertEq(prices[0].nounId, 22);
assertEq(prices[1].nounId, 21);
assertEq(prices[2].nounId, 19);
assertEq(prices[10].nounId, 11);
assertEq(prices[11].nounId, 9);
assertEq(prices[19].nounId, 1);

prices = auction.prices(20, 21);
assertEq(prices.length, 0);
}

function test_prices_2AuctionsNoNewAuction_includesSettledNoun() public {
uint256 bid1Timestamp = bidAndWinCurrentAuction(makeAddr('bidder'), 1 ether);
uint256 bid2Timestamp = bidDontCreateNewAuction(makeAddr('bidder 2'), 2 ether);
Expand Down

0 comments on commit 05eb47a

Please sign in to comment.