Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

feat: Variable Supply Auctions #188

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0dc006d
[initial] Variable Supply Auctions
neodaoist Oct 10, 2022
1eda347
[draft] Add happy path BDD tests
neodaoist Oct 11, 2022
82b06c7
[draft] Add createAuction functionality
neodaoist Oct 15, 2022
55ae7d7
[draft] Add placeBid; Add ERC721Drop; Switch from auctionForSeller to…
neodaoist Oct 16, 2022
9a43eeb
[refactor] Extract event assertions into dedicated tests
neodaoist Oct 16, 2022
5ee3c44
[draft] Add placeBid sad paths; Extract modifier to setup test auction
neodaoist Oct 16, 2022
348c855
[draft] Begin work on revealBid
neodaoist Oct 16, 2022
5dfc48c
[refactor] Improve bidder usability by using string instead of bytes3…
neodaoist Oct 16, 2022
401aacf
[draft] Add placeBid event tests; Add more NatSpec
neodaoist Oct 16, 2022
cbfeeba
[chore] VSCode tings
neodaoist Oct 16, 2022
67fcc79
[draft] Start work on settleAuction
neodaoist Oct 17, 2022
e5f3cca
[draft] :sparkles: Working v0.1 of settleAuction; Add invariant test …
neodaoist Oct 19, 2022
1afdfc4
[draft] Add initial cancelAuction
neodaoist Oct 20, 2022
63dca45
[draft] Add initial claimRefund
neodaoist Oct 20, 2022
1320aa0
[draft] Add initial calculateSettleOptions
neodaoist Oct 24, 2022
4294ec3
[draft] Add checkAvailableRefund
neodaoist Oct 24, 2022
eacdc1a
[draft] Add initial UML diagrams
neodaoist Oct 24, 2022
bdb38af
[draft] :sparkles: Add generated PlantUML ascii diagrams
neodaoist Oct 25, 2022
30536fc
[draft] General cleanup; Inline UML diagrams
neodaoist Oct 25, 2022
864c9bc
[draft] Improve time test pattern; Add more assertions on settled auc…
neodaoist Oct 27, 2022
5a7387e
[draft] Clean up ERC721Drop interface to match actual
neodaoist Oct 27, 2022
c2b7bed
[draft] Add initial minimum viable revenue biz logic
neodaoist Oct 28, 2022
6820637
[draft] Many an additional check
neodaoist Oct 29, 2022
63feb24
Add EIP-165 support; Clean up member ordering; Write more NatSpec
neodaoist Oct 31, 2022
f0090ea
Improve NatSpec and add to interface
neodaoist Oct 31, 2022
4c5748e
Revise PlantUML diagrams
neodaoist Oct 31, 2022
5500219
Fix auction refund accounting bug
neodaoist Oct 31, 2022
a676e25
[draft] Cleanup specification; Improve Auction struct clarity
neodaoist Oct 31, 2022
12bd2b9
General cleanup
neodaoist Nov 1, 2022
bc27d17
[feat] Variable Supply Auctions v0.1
neodaoist Nov 1, 2022
d959c1c
[refactor] :fuelpump: Replace require strings with custom errors
neodaoist Nov 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
406 changes: 406 additions & 0 deletions .gas-snapshot

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ dist
.DS_Store
coverage
coverage.json
.idea
.idea
.vscode
133 changes: 133 additions & 0 deletions contracts/modules/VariableSupplyAuction/IVariableSupplyAuction.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.10;

/// @title IVariableSupplyAuction
/// @author neodaoist
/// @notice Interface for Variable Supply Auction
interface IVariableSupplyAuction {
//

/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/

/// @notice A given ERC-721 drop contract can have only 1 live auction at a time
error Auction_AlreadyLiveAuctionForDrop();

/// @notice Seller funds recipient cannot be zero address
error Auction_InvalidFundsRecipient();

/// @notice Auction does not exist
error Auction_AuctionDoesNotExist();

/// @notice Only seller can access this function
error Access_OnlySeller();

/// @notice Cannot cancel an auction with bids before settle phase
error Seller_CannotCancelAuctionWithBidsBeforeSettlePhase();

/// @notice Cannot cancel an auction during settle phase without first calculating outcomes
error Seller_CannotCancelAuctionDuringSettlePhaseWithoutCalculatingOutcomes();

/// @notice Cannot cancel an auction during settle phase with at least one viable price point
error Seller_CannotCancelAuctionWithViablePricePoint();

/// @notice Settling the auction only allowed during settle phase
error Seller_SettleAuctionOnlyAllowedDuringSettlePhase();

/// @notice Cannot settle an auction with no revealed bids
error Seller_CannotSettleWithNoRevealedBids();

/// @notice Cannot settle an auction at a price point that does not meet minimum viable revenue
error Seller_PricePointDoesNotMeetMinimumViableRevenue();

/// @notice Placing bids only allowed during bid phase
error Bidder_BidsOnlyAllowedDuringBidPhase();

/// @notice Cannot place more than 1 bid in any given auction
error Bidder_AlreadyPlacedBidInAuction();

/// @notice Valid bids must include some ether
error Bidder_BidsMustIncludeEther();

/// @notice Revealing bids only allowed during reveal phase
error Bidder_RevealsOnlyAllowedDuringRevealPhase();

/// @notice No bid placed by address in this auction
error Bidder_NoPlacedBidByAddressInThisAuction();

/// @notice Revealed bid cannot be greater than amount of ether sent with sealed bid
error Bidder_RevealedBidCannotBeGreaterThanEtherSentWithSealedBid();

/// @notice Revealed bid does not match sealed bid
error Bidder_RevealedBidDoesNotMatchSealedBid();

/// @notice Refunds only allowed during cleanup phase
error Bidder_RefundsOnlyAllowedDuringCleanupPhase();

/// @notice No refund available for this address in this auction
error Bidder_NoRefundAvailableForAuction();

/*//////////////////////////////////////////////////////////////
FUNCTIONS
//////////////////////////////////////////////////////////////*/

/// @notice Creates a variable supply auction
/// @param _tokenContract The address of the ERC-721 drop contract
/// @param _minimumViableRevenue The minimum revenue the seller aims to generate in this auction --
/// they can settle the auction below this value, but they cannot _not_ settle if the revenue
/// generated by any price point + edition size combination would be at least this value
/// @param _sellerFundsRecipient The address to send funds to once the auction is complete
/// @param _startTime The Unix time that users can begin placing bids
/// @param _bidPhaseDuration The length of time of the bid phase in seconds
/// @param _revealPhaseDuration The length of time of the reveal phase in seconds
/// @param _settlePhaseDuration The length of time of the settle phase in seconds
function createAuction(
address _tokenContract,
uint256 _minimumViableRevenue,
address _sellerFundsRecipient,
uint256 _startTime,
uint256 _bidPhaseDuration,
uint256 _revealPhaseDuration,
uint256 _settlePhaseDuration
) external;

/// @notice Cancels the auction for a given drop
/// @param _tokenContract The address of the ERC-721 drop contract
function cancelAuction(address _tokenContract) external;

/// @notice Places a bid in a variable supply auction
/// @param _tokenContract The address of the ERC-721 drop contract
/// @param _commitmentHash The sha256 hash of the sealed bid amount concatenated with
/// a salt string, both of which need to be included in the subsequent reveal bid tx
function placeBid(address _tokenContract, bytes32 _commitmentHash) external payable;

/// @notice Reveals a previously placed bid
/// @param _tokenContract The address of the ERC-721 drop contract
/// @param _bidAmount The true bid amount
/// @param _salt The string which was used, in combination with the true bid amount,
/// to generate the commitment hash sent with the original placed bid tx
function revealBid(address _tokenContract, uint256 _bidAmount, string calldata _salt) external;

/// @notice Calculate edition size and revenue for each possible price point
/// @param _tokenContract The address of the ERC-721 drop contract
/// @return A tuple of 3 arrays representing the settle outcomes --
/// the possible price points at which to settle, along with the
/// resulting edition sizes and amounts of revenue generated
function calculateSettleOutcomes(address _tokenContract) external returns (uint96[] memory, uint16[] memory, uint96[] memory);

/// @notice Settle an auction at a given price point
/// @param _tokenContract The address of the ERC-721 drop contract
/// @param _settlePricePoint The price point at which to settle the auction
function settleAuction(address _tokenContract, uint96 _settlePricePoint) external;

/// @notice Check available refund -- if a winning bidder, any additional ether sent above
/// your bid amount; if not a winning bidder, the full amount of ether sent with your bid
/// @param _tokenContract The address of the ERC-721 drop contract
function checkAvailableRefund(address _tokenContract) external view returns (uint96);

/// @notice Claim refund -- if a winning bidder, any additional ether sent above your
/// bid amount; if not a winning bidder, the full amount of ether sent with your bid
/// @param _tokenContract The address of the ERC-721 drop contract
function claimRefund(address _tokenContract) external;
}
Loading