Skip to main content

DutchAuction

DutchAuction

This contract is a simple on-chain Dutch Auction with a pricing view function that decreases over a set period of time. In a Dutch Auction, the seller defines a starting ceiling price and an ending floor price that then decreases over time based on either a linear or nonlinear function. If a bid is made at any point, the bid must match the current price. Once a bid is made, the auction ends and the owner will receive the current price in which the bid was made in ERC20 tokens. The asset is then transferred to the bidder.

version

string version

ERC165TAG

bytes4 ERC165TAG

Start

event Start(uint256 startTime)

Bid

event Bid(address sender, uint256 amount)

Claim

event Claim(address seller, address contractAddr, uint256 tokenId)

asset

struct AuctionLib.Asset asset

acceptableToken

address acceptableToken

seller

address payable seller

saleFeeAddress

address payable saleFeeAddress

auctionDuration

uint256 auctionDuration

startPrice

uint256 startPrice

endPrice

uint256 endPrice

startTime

uint256 startTime

saleFee

uint256 saleFee

isNonLinear

bool isNonLinear

isBought

bool isBought

constructor

constructor() public

initialize

function initialize(address payable _seller, struct AuctionLib.Asset _asset, address ERC20contractAddress, uint256 _startPrice, uint256 _endPrice, uint256 _auctionDuration, bool _isNonLinear, uint256 _saleFee, address payable _saleFeeAddress, address _forwarder) external

Create auction instance

NameTypeDescription
_selleraddress payableaddress of seller for auction
_assetstruct AuctionLib.Assetstruct containing information of the asset to be listed
ERC20contractAddressaddressaddress of ERC20 token accepted as payment
_startPriceuint256highest starting price to start the auction
_endPriceuint256lowest price that seller is willing to accept
_auctionDurationuint256duration of auction (in seconds)
_isNonLinearboolset true if the seller wants to set a nonlinear decrease in price
_saleFeeuint256the percentage of the sale to be sent to the marketplace as commission
_saleFeeAddressaddress payablethe address to which the sale fee is sent
_forwarderaddressthe address for the Trusted Forwarder for Open GSN integration

proxyInitialize

function proxyInitialize(address payable _seller, struct AuctionLib.Asset _asset, address ERC20contractAddress, uint256 _startPrice, uint256 _endPrice, uint256 _auctionDuration, bool _isNonLinear, uint256 _saleFee, address payable _saleFeeAddress, address _forwarder) external

__DutchAuction_init

function __DutchAuction_init(address payable _seller, struct AuctionLib.Asset _asset, address ERC20contractAddress, uint256 _startPrice, uint256 _endPrice, uint256 _auctionDuration, bool _isNonLinear, uint256 _saleFee, address payable _saleFeeAddress, address _forwarder) internal

__DutchAuction_init_unchained

function __DutchAuction_init_unchained(address payable _seller, struct AuctionLib.Asset _asset, address ERC20contractAddress, uint256 _startPrice, uint256 _endPrice, uint256 _auctionDuration, bool _isNonLinear, uint256 _saleFee, address payable _saleFeeAddress) internal

getCurrentPrice

function getCurrentPrice() public view returns (uint256)

Returns the current price of the asset based on the timestamp and type of function

NameTypeDescription
[0]uint256uint256 price of the asset

bid

function bid() external

The required ERC20 tokens must be pre-approved before calling!

Allows a user to bid at the current price

claim

function claim() external

Allows the owner to claim back the asset if nobody bids and auction expires

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)

ERC165 Support

NameTypeDescription
interfaceIdbytes4hash of the interface testing for
NameTypeDescription
[0]boolbool whether interface is supported