Author: Fourteen Bacteria, Fourteen Jun

 

For UniSwap, which has a daily trading volume of US$770 million and more than 4 million users, entering the NFT market also means the beginning of a new round of offense and defense. Many platforms are worried about whether the other party will throw out a good card like SudoSwap that is a king bomb at the beginning.

However, the market data after three days of launch is disappointing. With 500WUSDC airdrop + GAS discount, it only got 2% of the transaction share. For a while, mediocrity and unremarkable became synonymous with the Uniswap NFT market. Is it really just like that? In fact, the current market and contracts are not complete versions, and even many functions are not open.

Please follow Shisijun. This article will start from the operation of the NFT trading market and the principle of aggregator, and combine the two latest protocols of Uniswap, Permit2 and Universal Router, to deeply understand how the largest Dex platform thinks about the dilemma of FT and NFT Swap!

 

1. Background

 

1.1. What is an aggregator?

Traditionally, aggregators are mainly used for data aggregation. They can collect data across various websites and then present the information in a platform in different categories to meet the needs of different users. Professional NFT aggregators need to collect all NFT transaction order information from different public chains and applications and integrate them into one platform. This provides users with a smooth transaction experience and improves transaction efficiency. Therefore, the focus of the aggregator is:

  • Tool attributes: Provides functions that a single NFT market does not have, and focuses more on user experience

  • Trading experience: The various trading system architectures will be sorted out below. You can clearly feel the fragmentation of the trading process, and the experience of being unable to complete one-click trading in one step.

So why is there a need for aggregation in NFT purchases? Let’s first outline the operating model of the mainstream NFT market.

1.2. Mainstream trading market model

  • The classification is based on the three core aspects of the transaction life cycle: how to publish, how to bid, and where to match transactions. The different implementations of these three aspects will lead to differences in their traffic sources, operating costs, and market audiences. The typical examples are: On-chain orders:

  • Vertical built-in market: [Contract interpretation] CryptoPunk The world's earliest decentralized NFT trading market

  • AMM Matching Market: One Article Explains - AMM Mechanism of SudoSwap, a Newcomer in the NFT Market - Innovation Challenges and Limitations

  • Off-chain orders:

  • Third-party market: After capturing X2Y2’s 100,000 NFT orders, how many users actually did so after analyzing whether they could waive royalties?

The advantages of on-chain orders are: security, information disclosure, and decentralization, but the disadvantages are high cost and lack of traffic. The advantages of off-chain orders are: low cost and easy traffic aggregation, but the disadvantages are: centralization, trust cost and cancellation cost. The above is the model of a single NFT trading platform, and the aggregator is a tool that calls the system of the above single platform and completes the transaction. Currently, Uniswap has integrated the top 10 trading platforms: OpenSea, X2Y2, LooksRare, Sudoswap, Larva Labs, X2Y2, Foundation, NFT20 and NFTX.

Currently, the third-party market model for off-chain orders is the mainstream (more than 90%), and its greatest competitiveness lies in traffic and user habits, which is closely related to the design of the contract system and is also combined with user cognitive habits.

From the seller's perspective, they will place orders where there are buyers and where transactions are easy to complete, and buyers will naturally look for platforms with more seller orders to quickly complete transactions. However, although there is a giant OS, it is not the end of the competition. Although OS has a solid 80% of the transaction volume, it has always hoped to go the web2 listing route, so it has been slow to issue coins and share revenue with users, and has gradually been eroded by x2y2 and other aggregators this year. However, other platforms are trapped by their own small traffic, and most new users prefer large platforms, so they have mediocre development.

1.3. Working principle of aggregator

The aggregator is a tool in nature. It calls the trading system of other platforms instead of building its own trading protocol. Among the 9 platforms integrated by Uniswap, similar to os, x2y2, etc., all have open order pool systems. The purpose of this opening is to provide a system for programmatic order transactions. Most of this is used by robots. For a platform, a good platform is one that can complete transactions quickly. Opening an order pool is a mutually beneficial intention for ecological co-construction. The on-chain order system parses mainstream on-chain protocols such as sudoswap and nftx. How does aggregation replace third-party markets to complete orders? For example, the pre-process is as shown in the following figure

  • An order can be initiated by the seller or the seller, or even by the platform (including aggregators)

  • First, the seller authorizes the NFT contract (operation 0), thereby allowing the deduction. At this time, x2y2: Exchange can directly transfer the seller's assets in the NFT contract at any time, which is why the third-party platform is too centralized.

  • The transaction intention is confirmed by on-chain signature verification, such as x2y2:Exchange or os:Seaport protocol.

  • The order comes from the web2 system of the third-party market. The aggregator gets the user's signature and the selling conditions (for example, 1 monkey requires 50 ETH to complete the transaction)

The execution flow is:

  1. Construct the buy and sell order parameters (including signature and amount) on the aggregator platform

  2. The user sends a transaction to the aggregator's on-chain contract

  3. The aggregator contract replaces part 1 in the figure below and sends it to the contract on the third-party market chain.

  4. Because it passes through the aggregator contract, multiple purchases can be completed in the same transaction

1.4 Why can aggregators save Gas?

From the above process, the essence of the aggregator is to call the third-party contract, but it does not mean that the lower limit of the transaction is the third-party system, because the cost of an on-chain transaction is composed of three aspects:

  1. Gas consumption of a single transaction: 21000 Gas

  2. Transaction parameter cost: 68 Gas per non-zero byte

  3. Consumption when executing a contract: Gas cost is calculated based on the modification of the storage slot and the EVM workload

So the part that can be saved is: the process of combining N transactions into one, and the cost of N-1 transactions itself saved. Further reading: [Source code interpretation] What exactly is the NFT you bought? Combined with the figure below, the specific calculation of efficiency aggregation transactions is that the more efficient the transaction, the more cost-effective it is: if the platform requires 20WGas to complete a single NFT transaction, then 10 transactions can be made into one transaction, which can save 9*21000 Gas, which is about 9.45% of each transaction. Aggregation itself also has a lot of consumption: for example, a single Gem transaction requires 28W, and a batch transaction of 2 requires 50W. Roughly, each NFT needs to share 6W of aggregation loss, so when the batch transaction is more than 3, it will start to be cost-effective.

The transaction type and Gas table in the figure above (randomly selected, not statistical results)

1.5 What is the value of an aggregator?

The batch trading function caters to the demands of project hype, investor rush, retail investors' easy-to-use tool competition, etc. for a period of time, so it has good traffic to bring orders. In fact, half of x2y2's orders come from aggregators. Compared with the traditional trading market, NFT aggregators have some obvious advantages, including:

  • Highly aggregated information: such as trading volume, floor price, transaction price, quantity, top holders, top buyers, etc.

  • Highly aggregated operations: Users can view, trade, and purchase NFTs on all markets through one platform.

  • Improve transaction efficiency: information and operation aggregation, easy price comparison and decision making

  • Diversified payment methods: Ideally (supported by the third-party market protocol itself), any token can be used for payment on the NFT aggregation platform.

On the whole, all kinds of users can benefit and be reached, including bulk buying and selling by the project parties themselves, bulk buying transactions by large investors, and observation of data information by retail investors. Therefore, the aggregator is going further and further on the road of tool attributes, and the competition is becoming more and more fierce. It tests how to reduce the loss of 60,000 in the contract implementation, and how the tool platform can better present the data. However, the author believes that the main value and goal of Uniswap's NFT market is not to make a good tool that is easy to use, but to achieve a unified on-chain interaction protocol, which is aimed at how to achieve a smoother transaction process when the payment method is not ideal.

2. UniSwap’s NFT Exchange Protocol

Don’t be impatient. Don’t use the current low trading volume to fight back. The author is not endorsing the project or writing soft articles. Instead, I see more reserved functions in its source code implementation, not just the currently open functions. As a platform with a daily trading volume of over 770 million US dollars and more than 4 million users, UniSwap does not have insufficient contract development capabilities or insufficient investment. The more important question is, what kind of NFT trading protocol do users need? UniSwap did not just release an aggregator platform and a scheduling protocol this time, but released two complementary protocols, Permit2 and Universal Router.

2.1. Permit2 - A new generation of efficient and secure authorization protocol

2.1.1 Limitations of traditional authorization mechanisms

Remember the architecture diagram of x2y2 in the above article? A new user wants to complete an NFT transaction. For such a simple request, the first thing he needs is to replace Weth and authorize the deduction of Weth and the corresponding NFT contract. The cost ranges from one transaction to two transactions, and there are also risks of unlimited deduction and theft. In the previous OS, because the pending order would not automatically expire, such as the problem of the chain setting, the user transferred the high-net-worth NFT from the cold wallet back to the low-priced transaction.

2.1.2. Withholding authorization is a common problem of ERC20

Although there is Eip-2612: "EIP-20 approved via EIP-712 secp256k1 signature" which has entered the final stage, from the perspective of the protocol, ERC20 is still a second-class token because users do not have the ability to interact with Ethereum without holding any ETH. The above figure shows how to use Eip-2612 to implement unauthorized deductions.

  1. Alice signs the off-chain “permission” message msg and sig, indicating her authorization of the permission (based on EIP-2612) token.

  2. Alice submits msg and sig as part of her protocol contract interaction.

  3. The contract calls permit(), and the Token contract based on 2612 verifies the permission message and signature and grants permission.

  4. At this time, the contract obtains authorization based on EIP-2612 tokens and can deduct Alice's tokens

It is an improvement to the ERC20 standard that solves these shortcomings (extra approval expenses and unlimited deduction risks), but it can only be applied to new token contracts that integrate Eip-2612

2.1.3、uniSwap’s Permit2 authorization optimization mechanism

  1. In order to solve the forward compatibility problem caused by the need to integrate into the token contract layer based on Eip-2612 (that is, the old token cannot be used), permit2 is a design that is compatible with any token, which is equivalent to a unified authorization management contract.

  2. Upper part: Alice calls approve() to grant unlimited authorization to the Permit2 contract based on the ERC20 contract.

  3. Lower half: Alice signs the off-chain "permit2-type" message msg and sig, indicating the signature permission.

  4. Alice calls the interactive function on the protocol contract with msg and sig

  5. The protocol contract calls the Permit2 contract, and after verifying msg and sig, controls the erc20 transfer from its authorization

Overall, although requiring users to authorize a license first seems to be a step backwards, users do not directly grant it to a certain protocol, but rather grant it to a standard Permit2 contract (which can be unique to the public chain). Users only need to authorize once, and then they can skip all subsequent authorization operations for protocols and transactions, and use off-chain signatures instead.

This means that users no longer need to initiate this transaction separately to interact with various protocols. More scenario-specific capabilities can be realized here, such as the automatic validity period of signature authorization, so there is no need to worry about the risk of long-term authorization, batch approval (multiple deduction signatures can be achieved in one go, and batch cancellation of deduction authorization signatures can also be achieved in one go) automatic validity period is similar: [Source code interpretation] How does Ethereum's new standard EIP-4907 realize NFT leasing? Once it is formed, or based on the popularity of Uniswap's own user volume, a completely decentralized protocol that can only control authorization through user signatures will become a must-have for everyone (who would refuse to be safe and cheap). So, what does this have to do with the launch of contracts in the NFT trading market?

Yes, Permit2 has been integrated into the Universal Router released by Uniswap at the same time, which is the underlying protocol of the NFT market. The code has been integrated but the functions have not yet been opened (because the NFT version of Permit2 has not yet been released). Currently, the ERC20 version of Permit2 is only being tested on a small scale.

2.2. Universal Router - Unified FT and NFT Exchange Protocol

The positioning of this protocol is: the next generation router of Uniswap, which unifies the swap transactions of F and NFT into a highly flexible, gas-optimized, secure and scalable exchange router. This also means that the swap functions used by the subsequent 4 million users will be executed by this protocol. Its application scenario is an aggregator, but it is not just an aggregator. The target is a multi-asset swap protocol that can perform exchanges (such as Uniswap pools and NFT markets).

2.2.1. What is the value of the Universal Protocol?

The value comes from the current complexity of executing NFT purchases.

  • There is little protocol layer support for purchasing NFTs with any ERC20 (except for the natural support of OpenSea's Seaport protocol). As a result, if you want to purchase NFTs directly with any ERC20 (such as USDC), you will need at least two transactions from USDC→ETH and from ETH→NFT.

  • Both buying and selling NFTs require an authorization, and cross-platform transactions require multiple authorizations, resulting in high protocol compatibility and upgrade costs. It can naturally integrate uniswapV2 and V3, perform multiple token exchanges (as shown below), and purchase NFTs from multiple markets in one transaction.

In fact, the Seaport protocol, the culmination of OS, also realizes the exchange between any asset combinations (also, the web3 end website currently does not open all the protocol preset functions). The support of the full on-chain protocol layer can allow more applications to naturally integrate the direct exchange between on-chain FT and FT, FT and NFT combinations. Higher transaction efficiency will also open up more application scenarios (refer to the World of Warcraft trading system, the most basic point-to-point single commodity transactions will eventually be replaced by batch and mixed transactions)

The ultimate value of multi-token payment is that users do not need to keep ETH as a handling fee. The transaction link is reduced again. Of course, to fully realize this, it is probably still dependent on the future blueprint of the account system based on ERC-4337. Further reading: Ethereum Account Abstract Ten Thousand Words Research Report: Disassembling 10 Related EIP Proposals and the Seven-Year Road to Impacting the Bottleneck of Ten Million Daily Active Users. Of course, you cannot see the actual operation of such multi-token payment in on-chain transactions at present, because it has not been fully released (the NFT version of permit2 is still required), and it is still in a stage of optimization waiting for the modification of the vulnerability plan.

2.2.1. How many resources does approve occupy?

Based on the statistics of on-chain data, as of the 15.97W block height, Ethereum has accumulated a total of 1.757 billion transactions. There are a total of 47.7 million transactions that execute the ERC20 approve function, with an average gas consumption of 84,699 per transaction and a historical average gasPrice of 73Gwei. Finally, converted to ETH, the cumulative consumption is 295,345 ETH, which is 380 million US dollars at the current price.

 

Summarize

 

Although this article looks weak, even in the case of significant on-chain data (insufficient transaction volume), it is still analyzing the advantages and disadvantages of such a transaction protocol. In the final analysis, the author is more optimistic about such an ownerless protocol that cannot be upgraded. Open code and SDK, any application and protocol can be integrated. Similarly, although the Seaport protocol of os requires the coordination of a huge off-chain centralized system to operate, such a highly optimized and fully functional multi-order system is completely open source to the outside world and is suitable for countless dapps (such as gamefi) that need to build their own internal trading platforms. ) and so on provide the shoulders of giants, and the web3 world can gradually establish its value based on decentralized protocols.

  • The current protocol does have limitations

At present, if you want to realize NFT interactive functions by integrating this protocol, the core problem is that it is too dependent on the centralized order pool. Today, order information is queried through the official website of Uniswap itself on os, x2y2, etc., in addition to direct queries of contracts that are fully supported on the chain like SudoSwap (SudoSwap's initial concept was amazing, but its operation was bleak, and the token distribution protocol it released was too biased towards the development team, and gradually no one cared).

The gas optimization effect of transaction aggregation still depends largely on the number of NFTs traded, so the tool-oriented (for project investors) attribute positioning remains unchanged. Although Uniswap's protocol is positioned to build a public infrastructure that drives the development of cryptocurrency, it adopts a model that is easier for developers and other dapps to integrate. At present, the function of the product itself is still based on the starting point of the aggregator, but there are no more tool integrations that meet the needs of aggregator users.

Naturally, it was not welcomed at the beginning, even with 5 million USDC for airdrop. It has been half a year since Uniswap Labs acquired Genie, and the Uniswap NFT market launched today is almost the same as Genie half a year ago.

Nowadays, due to the emergence of NFT markets such as X2Y2 and Blur that understand user needs, users have to endure the bad product experience and the era of using products is over. Scott, the head of Uniswap NFT products, once said on Twitter that Uniswap will implement NFT transactions by inheriting Sudoswap. It is expected that the infrastructure launched later will no longer be such a fat protocol, but a thin application.