openzeppelin-contracts
openzeppelin-contracts copied to clipboard
Consider adding a Dutch Auction implementation
🧐 Motivation
TL;DR: Price starts at X reduces by Y every Z minutes until it reaches W.
📝 Details
Found this PR https://github.com/OpenZeppelin/openzeppelin-contracts/pull/989, but it's way too complex and closed due to staleness.
Example: https://github.com/divergencetech/ethier/blob/main/contracts/sales/LinearDutchAuction.sol (I'm not sure if it's production-ready)
It would be pretty straightforward to implement, as follows:
uint256 public constant startPrice = 1 ether;
uint256 public constant endPrice = 0.5 ether;
uint256 public constant priceCurveLength = 120 minutes;
uint256 public constant dropInterval = 40 minutes;
uint256 public constant dropPerStep = (startPrice - endPrice) / (priceCurveLength / dropInterval);
function getAuctionPrice() public view returns (uint256) {
if (block.timestamp < startTime) {
return startPrice;
}
if (block.timestamp - startTime >= priceCurveLength) {
return endPrice;
}
uint256 steps = (block.timestamp - startTime) / dropInterval;
return startPrice - (steps * dropPerStep);
}
Thank you for the suggestion. Can you clarify exactly what contract or functionality are you suggesting to add?
If this is as simple to implement as the code shared in the issue, what value does a standard implementation in OpenZeppelin Contracts provide to the user?
Maybe we should have a math/CommonFunction.sol library, with things like
It could include
function needToFindAGoodName(int256 x0, int256 x1, int256 y0, int256 y1, int256 x) internal pure returns (int256) {
return x <= x0 ? y0
: x >= x1 ? y1
: y0 + (y1-y0) * (x-x0) / (x1-x0);
}
And possibly a stepped version as well
EDIT: something like this
It could be interesting to implement (dutch) auction mechanisms for Non Fungible Tokens (both ERC721 and ERC1155).
@frangio @Amxx do you think we should proceed with building a potential dutch auction mechanism? To answer @frangio's question, many NFT drops today are happening via Dutch Auction, and by having a standard mechanism to do so, a lot of devs would benefit since they wouldn't have to write code for it that is more susceptible to having issues.
LooksRare is the first NFT auction platform conducting Dutch Auction on chain on Ethereum: https://docs.looksrare.org/developers/contract-documentation/StrategyDutchAuction
So far I don't think we should implement a dutch auction. I think the problem of NFT drops is more about mechanism design rather than secure implementation. As far as I can tell, dutch auctions are not necessarily the best way to sell NFTs, and it is an active research area. This is an example of a post from just a few days ago proposing a variation on the mechanism.