A Detailed Explanation of the AMM Mechanism of the Newcomer in the NFT Market, SudoSwap
Author: Shijiu Jun
The recent downturn in the NFT trading market has been frequent, with a significant decrease in overall market liquidity. At this time, SudoSwap, which emerged in August, has captured public attention with its impressive growth data based on the AMM mechanism.
As of August 20, on-chain data analysis shows that over a thousand NFT projects have entered the market, involving the completion of transactions for 85,000 NFTs, with a cumulative trading volume of 20 million USD.
This article will start from the mainstream models of the NFT trading market, and by restoring Uniswap's classic constant product formula, will delve into SudoSwap's unique pricing function and functional details, ultimately evaluating its value for the development of the trading market from various strengths and weaknesses.
1. Mainstream Models of the NFT Trading Market
The classification of trading market operation models is based on three core aspects: how to publish, how to bid, and where to match transactions.
The different implementations of these three aspects lead to variations in traffic sources, operational costs, and target market audiences.
1. Built-in Markets like Punk
The famous CRYPTOPUNKS actually has a built-in trading market that integrates various mechanisms for on-chain publishing, on-chain bidding, and on-chain transaction completion, all achieved within just 230 lines of code. More details can be found here: 【Contract Interpretation】CryptoPunk: The World's First Decentralized NFT Trading Market
Other projects with built-in markets include: StepN, Axie Infinity, NBA Top Shot, etc.
Overall, achieving transactions is not complicated, but having every step on-chain is very detrimental to the core liquidity issue of NFTs. As a buyer, you must lock in funds before the seller confirms whether to sell, and the unrestricted waiting period has led to Punk's contract regularly locking up 6,400 ETH.
The pricing question of how a unique artwork should be sold requires a reasonable public auction mechanism to assist in matching. The model of paying gas fees upfront for each bid can only be ignored in high-value Punks, while long-tail NFTs can only look on from the sidelines.
Top blue-chip NFTs may not need direct trading liquidity, as most loyal long-term holders likely expect that top blue-chip NFTs will gradually become financial derivatives, applied in lending, leasing, and other markets, where there may be prices without markets and no one placing orders. Further reading:
【Source Code Interpretation】How does Ethereum's new standard EIP-4907 achieve NFT leasing?
Thus, as an early market, Punk's mechanism exploration has a high trust advantage with full on-chain processes, but is also limited by liquidity and pricing disadvantages.
2. Third-party Markets like OpenSea and X2Y2
These markets are currently the leaders based on total trading value, with an overall operational model of off-chain publishing and pricing matching, and on-chain transaction completion.
Various auction mechanisms allow for the assessment of price rationality, and OpenSea's new protocol Seaport is considered one of the strongest contract designs of the era. Through extensive optimization, it reduces gas costs by 30%, and the flexibility of various order types is maximized. In the open-source environment of Seaport, it is very beneficial for various niche projects (gamefi, creative copyrights, etc.) to integrate trading capabilities.
The disadvantages of such platforms primarily include a high degree of centralization, as users almost always need to authorize the NFT to the platform's contract. Even platforms like X2Y2 are filled with numerous proxy upgrade settings, which could allow for sudden sell-offs.
Secondly, the rationality of pricing still depends on current attention levels. For long-tail NFT projects, it seems to be in a death spiral, heavily reliant on whether project parties will engage, otherwise even whitelist mints may not sell out. The recent popularity of free mints reflects the market's lack of confidence.
3. Summary
Before SudoSwap, it seemed that NFTs were destined to be illiquid, only able to achieve peer-to-peer transactions through the large scale of platforms. In this context:
The breakthrough is more usable NFTs, which can support market prices by providing basic application value. Further reading: NFT Leasing Proposal EIP-5006 is entering final review! Making large overseas games' blockchain transformations possible
Secondly, SudoSwap, through its "official pool" called Based Ghouls Pool, also provides a tool platform for long-tail NFT projects to "get things done."
Why can it help long-tail projects encircle the city, like Pinduoduo battling Taobao? Let's analyze its publishing, pricing, and transaction mechanisms further.
The following image shows the core data performance of SudoSwap as of August 20.
2. Understanding the AMM Mechanism
Similar to the three major dimensions of publishing, bidding, and transaction, SudoSwap operates on-chain publishing, on-chain pricing based on the AMM mechanism, and on-chain transactions, with a high degree of decentralization, where the market determines who to sell to and at what price.
SudoSwap's AMM mechanism is not complicated, similar to Uniswap AMM V3, with its k=x*y constant product function being one of the most elegant curves in DeFi, in my opinion.
1. Brief Overview of Uniswap Mechanism
In Uniswap, anyone can create a liquidity pool, allowing everyone to inject liquidity, helping transactions while also earning LP rewards.
Each transaction changes the price of the next exchange, hence there is a slippage design to accept the range of price fluctuations. This is relatively easy to handle in FT, as ERC20 tokens can be highly divisible.
Let's walk through the lifecycle of Uniswap using the following diagram to clarify the x*y=k formula.
2. Creation Phase
As shown on the left side of the diagram, if I want to be an LP (liquidity provider), I must provide the Atoken and Btoken that I wish to form a trading pair and transfer them into the contract. Every time liquidity is deposited into the pool, liquidity tokens are minted for me (LP), with the amount calculated based on the proportion of the amount provided to the total pool amount. These tokens represent the LP's contribution to the liquidity pool, and LPs can earn 0.03% of others' transaction fees as dividends.
《Uniswap's Liquidity Pool Construction Mechanism Diagram》
3. Exchange Phase
As shown on the right side of the diagram, after constructing the pool, when any token is withdrawn (purchased), it must be deposited (sold) in another token according to the "ratio" to maintain the total amount unchanged. This ratio is represented in K, which is also the exchange rate of X and Y.
Although K is theoretically a constant value, each transaction generates fees, meaning that during the token AB exchange process, K will gradually increase.
As shown in the diagram, when there is an AB token trading pair: Atoken - 1200 units, Btoken - 400 units, the current exchange rate is 3.
If I transfer 3 TokenA into the contract and pay an additional fee, the smart contract will give me 1 TokenB after the exchange.
At this point, due to the change in the total amount of the Token pool, the new exchange rate changes to 3.015.
《Uniswap's Trading Pair Purchase Mechanism Diagram》
Since the price is entirely determined by the real-time calculation logic of the on-chain contract, the price of the trading pair can only be changed through transactions. Therefore, once the Uniswap price diverges from the external price, it creates arbitrage opportunities. This mechanism ensures that Uniswap prices always tend to market prices.
I really like this logic, allowing arbitrageurs to help the system improve while also making a profit. Further reading:
Explaining - The Latest Stablecoin GHO Proposal from DeFi King AAVE
3. Principles of SudoSwap's AMM Mechanism
Similar to UniSwap, SudoAMM treats NFTs as TokenA and ETH as TokenB, allowing users to market NFTs-ETH at specified prices on SudoAMM. For both buyers and sellers, the pool enables instant buying and selling.
Due to the indivisibility of NFTs, the calculation formula cannot be directly measured as k=X*Y (otherwise one side would inevitably remain), so SudoSwap designed SudoAMM, providing both linear and exponential pricing functions.
1. Linear Pricing Function (Linear Curve)
In the calculation curve program LinearCurve.sol
, the new price is calculated based on a gradient accumulation system.
Assuming the delta value is 0.1, it means that each time you buy (or sell), the price will increase (or decrease) by 0.1 ETH.
Normal (1E) → Buy (1.1E) → Buy (1.2E) → Sell (1.1E), and so on.
2. Exponential Pricing Function (Exponential Curve)
In the calculation curve program - ExponentialCurve.sol
, the price increases multiplicatively based on the number of purchases.
Assuming the delta value is 1.1, it means that each time you buy (or sell), the price will be multiplied (or divided) by 1.1.
Normal (1E) → Buy 4 times (1.46E) → Sell 3 times (1.1E) → Sell 3 times (0.75E), and so on.
3. How Much Power Do LPs Have in Creating Liquidity Pools?
Creating a liquidity pool uses the createPairETH
function in the LSSVMPairFactory.sol program. Remarkably, compared to Uniswap, it allows for many core parameters to be set. The execution of creation adopts the EIP-1167 standard and deploys a mini proxy contract, ensuring both the security of an independent contract (with assets stored in the newly deployed contract address) and giving LPs super administrator rights to control pricing functions, incremental thresholds, initial fees, and global transaction fees.
Question 1: How is it calculated when buying multiple NFTs at once? It will be settled one by one (calculated linearly).
(Current spot price) + (Current spot price + 1delta) + (Current spot price + 2delta) + … + (Current spot price + (n-1)delta), so this equals n(Current spot price) + (delta)(n(n-1))/2.
Question 2: Which NFT is purchased? It can be any NFT from the pool specified by the user.
By reviewing the method calls to the contract address on Ethereum, it can be found that the operation to exchange ETH for NFTs is: 0x11132000
.
The corresponding contract method swapETHForSpecificNFTs
requires four parameters:
swapList
: The list of tokens to be traded and the corresponding NFT IDs to be purchased.Recipient
: The address to receive any unused ETH input.nftRecipient
: The address to receive the NFT output.deadline
: A timestamp; if exceeded, the order will not be executed.
It can be seen that the concept of rarity is flattened here, as pricing is unrelated to rarity.
In addition to the AMM mechanism, there are two additional functions or limitations:
1: Each liquidity pool can only have one LP, mostly the project party itself.
2: Limit order function, allowing users to set a floor price when depositing NFTs, waiting for transactions.
Participants' rights will not be lower than their rational price transactions, equivalent to OpenSea's listing.
4. Summary - Highlights of SudoSwap
1. Starting from Functionality
Sudoswap has a strong advantage of "instant pricing," with market matching providing immediate pricing through arbitrageurs seeking suitable prices. Reflecting on Uniswap's rise, it solved the problem of small and medium project parties issuing tokens, achieving encirclement of the city to become a leader.
2. Starting from Scenarios
For long-tail NFTs, it can have remarkable effects. Currently, NFTs are divided into two major categories: blue chips and others. For Punks, Apes, and Azukis, liquidity is not a core issue, as explained in the previous Punk section. For "others," the differences in rarity are not significant, but they are extremely reliant on liquidity. The quick pricing advantage + the introduction of official pools is essentially equivalent to a stock buyback mechanism, helping project parties to get things done.
3. Starting from Mechanisms
Interestingly, it is not the AMM mechanism, but rather the LP mechanism that surprises me. AMM allows sellers to sell immediately and gain instant liquidity, while LPs fully control the pricing of the liquidity pool (from price functions to delta values, all customizable, and parameters can be adjusted at any time).
What does this resemble? Setting up a stall or opening a store, it is platform-based rather than a large supermarket. Project parties can not only have a trading venue but also have control, unlike OpenSea, which reads on-chain addresses for centralized matching. Project parties can control whether to buy back, the extent of price fluctuations based on project development cycles, meaning rights return to users, both in mechanisms and costs (project parties are also considered users).
Moreover, LP income can replace royalties, bringing diversified income balance to project parties.
Ranking by transaction fees: Punk (0%) < SudoSwap ≤ X2Y2 (0.5%) < Looksrare (2%) < OS (2.5%).
4. Starting from Code
Elegant code always makes independent researchers in technical fields like Shijiu feel comfortable. The design of SudoSwap's code has many optimization points, with overall transaction gas fees at an industry-leading level. A single NFT purchase requires only 14W GAS, and multiple transactions are also better than OS, X2Y2, etc.
Ranking by transaction GAS: Punk < SudoSwap < OpenSea < GEM < Genie < X2Y2 < Looksrare.
The project has the endorsement of two auditing firms. Although a number of risk issues were identified, they do not threaten the core mechanism. I have compiled relevant information (source code audit reports) that can be obtained by replying "sudoswap" on the public account.
In Conclusion
By sorting through the logic of this article, it is indeed true that SudoSwap's rise has certain market value.
Its AMM mechanism introduces NFTs as market makers, naturally allowing for financial strategies to quantify arbitrage. As long as the liquidity pool grows, buying and selling can support NFT prices, further extending to scenarios like NFT leasing and lending, focusing on helping long-tail projects succeed, closely aligning with Uniswap's early history. It may potentially grow into a true protocol in the future.
However, SudoSwap has also lost the differentiation of rarity; the value of NFTs in the same series tends to converge, and NFTs have evolved into another form of FT. Therefore, SudoSwap's scenarios are limited, only applicable to certain long-tail projects or highly homogeneous application NFTs.
High homogeneity, long-tail, and numerous quantities—doesn't each word perfectly match NFTs in Gamefi? Indeed, in a good gaming ecosystem, both the Dragon-slaying Sword and the Branch Long Sword are necessary.
I believe that fully on-chain SudoSwap, while only supporting 721, will become a high-quality trading market model in many GameFi or creator economies in the future. It is easy for project parties to get things done, easy for creators to spread, and easier for low-priced, high-quantity goods to find reasonable prices through AMM.
In the future, I will continue to study leading NFT market platforms like OpenSea, X2Y2, Looksrare, and Gem, starting from the contracts to examine their advantages and limitations. Interested readers, please like and follow for future updates!