Skip to content

Commit db6e4e3

Browse files
committed
pull from main
2 parents 912b055 + f478f8b commit db6e4e3

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

contracts/old-marketplace/Marketplace.sol

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,11 @@ contract Marketplace is
253253

254254
// Tokens listed for sale in an auction are escrowed in Marketplace.
255255
if (newListing.listingType == ListingType.Auction) {
256-
require(newListing.buyoutPricePerToken >= newListing.reservePricePerToken, "RESERVE");
256+
require(
257+
newListing.buyoutPricePerToken == 0 ||
258+
newListing.buyoutPricePerToken >= newListing.reservePricePerToken,
259+
"RESERVE"
260+
);
257261
transferListingTokens(tokenOwner, address(this), tokenAmountToList, newListing);
258262
}
259263

@@ -279,7 +283,7 @@ contract Marketplace is
279283
// Can only edit auction listing before it starts.
280284
if (isAuction) {
281285
require(block.timestamp < targetListing.startTime, "STARTED");
282-
require(_buyoutPricePerToken >= _reservePricePerToken, "RESERVE");
286+
require(_buyoutPricePerToken == 0 || _buyoutPricePerToken >= _reservePricePerToken, "RESERVE");
283287
}
284288

285289
if (_startTime < block.timestamp) {
@@ -304,7 +308,7 @@ contract Marketplace is
304308
listingType: targetListing.listingType
305309
});
306310

307-
// Must validate ownership and approval of the new quantity of tokens for diret listing.
311+
// Must validate ownership and approval of the new quantity of tokens for direct listing.
308312
if (targetListing.quantity != safeNewQuantity) {
309313
// Transfer all escrowed tokens back to the lister, to be reflected in the lister's
310314
// balance for the upcoming ownership and approval check.
@@ -461,6 +465,7 @@ contract Marketplace is
461465
if (targetListing.listingType == ListingType.Auction) {
462466
// A bid to an auction must be made in the auction's desired currency.
463467
require(newOffer.currency == targetListing.currency, "must use approved currency to bid");
468+
require(newOffer.pricePerToken != 0, "bidding zero amount");
464469

465470
// A bid must be made for all auction items.
466471
newOffer.quantityWanted = getSafeQuantity(targetListing.tokenType, targetListing.quantity);
@@ -518,7 +523,7 @@ contract Marketplace is
518523
_closeAuctionForBidder(_targetListing, _incomingBid);
519524
} else {
520525
/**
521-
* If there's an exisitng winning bid, incoming bid amount must be bid buffer % greater.
526+
* If there's an existng winning bid, incoming bid amount must be bid buffer % greater.
522527
* Else, bid amount must be at least as great as reserve price
523528
*/
524529
require(

src/test/Marketplace.t.sol

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,36 @@ contract MarketplaceTest is BaseTest {
111111
assertEq(uint8(IMarketplace.ListingType.Auction), uint8(listing.listingType));
112112
}
113113

114+
function test_createListing_auctionListing_ZeroBuyoutAmount() public {
115+
address to = getActor(0);
116+
uint256 tokenId = erc721.nextTokenIdToMint();
117+
erc721.mint(to, 1);
118+
vm.prank(to);
119+
erc721.setApprovalForAll(address(marketplace), true);
120+
121+
vm.warp(0);
122+
Marketplace.ListingParameters memory listing;
123+
124+
listing.assetContract = address(erc721);
125+
listing.tokenId = tokenId;
126+
listing.startTime = 0;
127+
listing.secondsUntilEndTime = 1 * 24 * 60 * 60; // 1 day
128+
listing.quantityToList = 1;
129+
listing.currencyToAccept = NATIVE_TOKEN;
130+
listing.reservePricePerToken = 0;
131+
listing.buyoutPricePerToken = 0;
132+
listing.listingType = IMarketplace.ListingType.Auction;
133+
134+
vm.prank(to);
135+
marketplace.createListing(listing);
136+
uint256 listingId = marketplace.totalListings() - 1;
137+
138+
vm.prank(getActor(0));
139+
vm.warp(1);
140+
vm.expectRevert("bidding zero amount");
141+
marketplace.offer(listingId, 1, NATIVE_TOKEN, 0, type(uint256).max);
142+
}
143+
114144
function test_offer_bidAuctionNativeToken() public {
115145
vm.deal(getActor(0), 100 ether);
116146

@@ -148,6 +178,21 @@ contract MarketplaceTest is BaseTest {
148178
assertEq(winningBid.pricePerToken, 2 ether);
149179
}
150180

181+
function test_revert_offer_bidZeroAmount() public {
182+
vm.warp(0);
183+
(uint256 listingId, ) = createERC721Listing(
184+
getActor(0),
185+
NATIVE_TOKEN,
186+
123456 ether,
187+
IMarketplace.ListingType.Auction
188+
);
189+
190+
vm.prank(getActor(0));
191+
vm.warp(1);
192+
vm.expectRevert("bidding zero amount");
193+
marketplace.offer(listingId, 1, NATIVE_TOKEN, 0, type(uint256).max);
194+
}
195+
151196
// function test_closeAuctionForCreator_afterBuyout() public {
152197
// vm.deal(getActor(0), 100 ether);
153198
// vm.deal(getActor(1), 100 ether);

0 commit comments

Comments
 (0)