# Auction House: Overview v2 ## Background The Auction House program is one of the most important programs by Metaplex which promotes decentralisation in NFT marketplaces. NFT marketplaces are usually centralised websites where NFT traders can list, bid for, and buy NFTs. The usual trading process is as follows: 1. The seller lists an NFT for sale at a given price. In doing so, the marketplace pulls the NFT from the seller's wallet into an escrow wallet A owned by the marketplace and also pulls a small fee for this transaction to take place 3. The potential buyers bid. In doing so, the marketplace pulls the bidding amount from the buyer's wallet into an escrow wallet B owned by the marketplace and also pulls a small fee for this transaction to take place 5. Once the seller agrees to the bid, the marketplace executes the sale. In doing so, the NFT is moved from the escrow wallet A to the buyer's wallet, and the bid amount is moved from the escrow wallet B to the seller's wallet thus completing a trade The above trading setup has some profound issues: * For a trade to take place, the NFT and the bid amount needs gets moved to escrow wallets owned by the marketplace. Thus once the user lists an NFT, the NFT is no longer present in the user's wallet. This has major shortcomings: * If the user wants to sell the listed NFT on a different marketplace, they will have to delist the NFT first and thus can not list NFTs on multiple marketplaces at once, potentially losing potential buyers * Proof of ownership: The user can not utilise the NFT for other benefits like staking, discord NFT-gated channel access, airdrops and in general does not have true ownership of the listed NFT * Safety: the user doesn't have to rely on the marketplaces’ escrow contracts to safely hold their NFTs. * The marketplace is highly centralised, as the marketplace has ownership of the NFTs and the bid amount, and also is responsible for executing the sale once the seller approves the bid amount * The users, both sellers and buyers need to pay for the fees for the transactions to take place This is where the Auction House program comes in. Auction House resolves all the above issues and gives even more firepower to the trading experience. ## Introduction Summarising the previous section: the Auction house program is a transaction protocol for marketplaces to implement a decentralised, escrow-less sales contract. Using the Auction House program, the user can buy, sell and execute the sales of NFTs from marketplaces. The users, in practice can: 1. list their NFTs in > 1 marketplace 2. bid for NFTs in > 1 marketplace 3. cancel all listings / bids with a single command for their NFTs in all marketplaces, to avoid the possibility of an unwanted sale going through Some other key features of the Auction House contract are the following: * No more escrowing NFTs - the NFTs remain in the user's wallet till the time the sale goes through * No more making an offer on an NFT and having to return to the site to execute the final sale - it just happens * Secondaries can now do price matching on the user's behalf - easier to find potential matches for their NFTs and hence make NFTs more liquid than before * Secondaries can pay the user's fees for them - thus enabling selling NFTs with 0 SOL in the user's wallet ## Auction in action Lets dive a little deep into how the Auction House program works. The Auction House (AH) contract allows users to deploy Auction house instances, which are the keyspaces of the Auction House program, ie, public keys owned by the Auction House program. These Auction House instances are simple [Program Derived Addresses (PDAs)](https://solanacookbook.com/core-concepts/pdas.html). These instances interact with three main instructions: 1. Sell Order 2. Buy Order 3. Execute Sale The core concept behind these instructions are special PDAs that are known as ***Trade States***. *But why use these special PDAs and what makes them so important for the Auction House protocol?* They are used to cut down the cost: Trade States are very cheap. This is because these PDAs only have 1 byte of data, which is the bump of the PDA and the only data required to be saved in a PDA. These PDAs are called ***Trade States*** because they represent the state of a trade, ie, they effectively represent a bid (*Sell Order*) or an offer (*Buy Order*) for an NFT. There are two main trade states: `SellerTradeState` and `BuyerTradeState` for an offer and a bid respectively. There is also another trade state know as `FreeSellerTradeState`. We will discuss its use in the [custom order matching section](#COM). ![](https://i.imgur.com/ki27Ds8.png) ## Auctioning Fungible Assets You might be wondering: is the Auction House restricted to trading NFTs? The answer is no. Auction House has no restrictions on the token type and size that can be auctioned using it. So in practice any ***SPL-token*** / fungible / ***semi-fungible*** asset can be auctioned off using the Auction House protocol. Auction House can be used not only to create NFT marketplaces but also to create Decentralised Exchanges (DEX). In case of DEXs, with the help of ***Partial Order Fulfillment*** [add link to POF discussed in subsequent pages], Auction House protocol can be used to replicate the order of actions in traditional DEXs where a user can make a buy order for less than equal to the quantity of tokens offered by other users. ## <a name="COM"></a>Custom Order Matching As stated in the introduction of Auction House, one of the key features of this protocol is that it allows marketplaces to implement their own, custom, order matching algorithms. This is again done using the 3rd and the final Trade State in the Auction House protocol: the `FreeSellerTradeState`. If the buyer intentionally lists their NFT for a price of 0, a new `FreeSellerTradeState` is made. The Auction House can then change the sale price to match a matching Bid that is greater than 0. This allows the Auction house to do complicated order matching to find the best price for the seller. The Auction House can only sell it for 0 if you sign the transaction with your key, but currently it can sell it for an arbitarily low price, e.g. 1 lamport. ## Auctioneer The current Auction House implementation is designed with instant sales in mind and currently has no features that enable the various auction types that have become popular in the Solana ecosystem (ex. ***Timed auctions***) Auctioneer is a customized contract type, written by the user, that uses the composability pattern of Auction House to control an individual Auction House instance. To fully enable Auctioneer to use an Auction House instance's instructions, it must be explicitly delegated. The `DelegateAuctioneer` command is used to tell the Auction House instance which program will be using the `auctioneer_\<method>` instructions. ## References * Prof Lupin's Auction House guide: https://proflupin.xyz/metaplex-auction-house * Jordan's twitter thread: https://twitter.com/redacted_j/status/1453926144248623104 * Armani's twitter thread: https://twitter.com/armaniferrante/status/1460760940454965248