In this section, we will explain how swapping NFTs in Caviar's shared pools works. Swapping is the process of exchanging an NFT for a reserve asset (e.g., ERC20 tokens or ETH) or vice versa. Caviar's automated market maker (AMM) algorithm facilitates this process seamlessly in shared pools, where NFTs are grouped by their desirability using a desirability classifier.

Desirability Classifier

Before diving into the swapping process, it's important to understand the role of the desirability classifier in shared pools. The classifier categorizes NFTs into different desirability groups, such as floor, mid, rare, and grail. Each group has its own shared pool, enabling the trading of an entire collection. This grouping allows for more accurate price discovery and a better trading experience, as NFTs with similar desirability are pooled together.

Swapping Process

Swapping in shared pools follows these steps:
  1. 1.
    Select the pool: The user chooses the appropriate shared pool based on the desirability of the NFT they want to trade. Pools are named according to the desirability group (e.g., floor, mid, rare, or grail).
  2. 2.
    Input the NFT or reserve asset: The user inputs the NFT they want to sell. The AMM algorithm calculates the estimated amount of the output asset based on the pool's current state.
  3. 3.
    Review and confirm the swap: The user reviews the estimated output amount, which is subject to slippage depending on the pool's liquidity and the trade size. If the user is satisfied with the estimated output, they confirm the swap.
  4. 4.
    Execute the swap: The AMM algorithm facilitates the trade by exchanging the input asset for the output asset. The NFT and reserve asset quantities in the shared pool are updated accordingly.
  5. 5.
    Apply fees: A 1% trading fee is applied to each swap. The fee is distributed to the liquidity providers of the pool as a reward for their contribution to the market liquidity.
  6. 6.
    Update pool state: After the swap is complete, the AMM algorithm updates the pool state, adjusting NFT and reserve asset quantities and recalculating the price based on the xy=k invariant.
By following these steps, users can easily swap NFTs for reserve assets or vice versa in Caviar's shared pools. The desirability classifier and AMM algorithm work together to ensure a smooth and efficient trading experience with accurate price discovery.