How do batch auctions work?

How do Batch Auctions work?
  1. 1.
    In batch auctions, there is one auctioneer and multiple bidders.
  2. 2.
    The auctioneer sets the amount of an asset they want to sell and the minimum price they are willing to receive for the asset.
  3. 3.
    Once the auction is started by the auctioneer, bidders can participate by placing their bids, through limit orders, specifying an amount and a price.
  4. 4.
    The auction runs until a certain date. After this date the auction is over, and no more bids can be placed.
  5. 5.
    The smart contract sorts bids from highest to lowest price.
  6. 6.
    The smart contract works backward from the highest bid, cumulatively adding each bid’s amount of tokens to sell, until the bid's sum multiplied by the price of the lowest bid to be included equals the sell amount of tokens (pre-defined by the auctioneer).
  7. 7.
    The price of the bid (added to all previous bids’ amount of tokens) that reaches the amount of tokens to sell is selected as the final clearing price for all participants.
  8. 8.
    Bidders who specified a maximum price in their limit order that is greater than the final clearing price receive tokens at the clearing price.
  9. 9.
    Bidders that specified a maximum price in their limit order that is less than the final clearing price do not receive the tokens being auctioned. Sure they can still withdraw their bidding tokens from the DEX.
Let's take a deeper look at the example provided in the diagram below.
The following diagram shows an auction in which 14 tokens are offered at 2 blocks per share:
The diagram shows an example of how an auction calculates the final price:
  • At first, the auctioneer establishes the minimum price for which they are willing to sell tokens and an amount of tokens to be auctioned. In this example the auctioneer is selling 14 tokens at a minimum price of 2 tokens (established by the first square on the X axis).
  • Once the auction begins, bidders can start placing bids, in which they specify how much of the bid token they would like to buy with and at what price.
  • When the auction duration time has come to an end, the smart contract sorts the bids from highest to lowest, stopping at the price in which the cumulative volume of the bids have reached the amount the auctioneer was willing to sell, in this case 14.
    • Since we have 14 tokens to auction, the diagram shows that the highest bid price was 2 tokens at price 9, followed by 3 tokens at price 8, 5 tokens at price 7, and 4 tokens at price 6.
    • With the last bid (4 tokens at price 6), the auctioneer has no more tokens to sell, and the auction establishes that the auctioned token final clearing price is at 6 for all participants.
    • Participants whose bid is equal to or greater than the final clearing price will receive the auctioned tokens. Participants with bids less than the final clearing price can reclaim the token balance with which they had bid.