From Uniswap to see the way to attack DEX

From Uniswap to see the way to attack DEX

Loading

Author

translation

edit

Summary :

Among them, non-custodial, leveraged, and quasi-decentralized transactions are concepts that are hard to ignore

从 Uniswap 看 DEX 的进击之路

Modified image from Fox Searchlight’s 2017 movie “Battle of the Sexes”, about tennis star Billie Jean King

Introduction

As we mentioned in the article “Atomic Exchange and Decentralized Exchange” in January 2019: call options and decentralized exchanges (DEX) should be regarded as the two holy grails of financial technology , and decentralized The concept of stablecoins is tied. In fact, the purpose of decentralization of an exchange or stable currency is quite simple, it is to ensure the stable operation of the system in the face of regulatory pressure. If these systems can really work, even the most extreme skeptics don’t need to worry about the potential for change. Then I have to say that one of the disadvantages of decentralized exchanges may be that they cannot operate in a robust manner.

Under the conditions of a single blockchain ecosystem and the Tokens that exist in the system, DEX is technically feasible. Since all tokens are the native tokens of the blockchain, a DEX can be built on the blockchain. This can be done on Bitcoin (e.g. Counterparty) or Ethereum. The main challenges are scalability, liquidity, availability and ensuring the fairness of the exchange . This report will focus on this type of DEX, that is, DEX without cross-chain capabilities.

Counterparty

As early as 2013, Mastercoin was considered by the public as the first ICO in the blockchain field. The purpose of this project is to launch multiple Token agreements on top of Bitcoin. Subsequently, the Mastercoin Fund was established and used to manage the proceeds of the ICO. However, the community has raised strong opposition to the foundation and believes that the idea that a few people will be given the privilege of managing and controlling funds is unfair .

Therefore, in early 2014, a competing project was established-Counterparty. Compared with Mastercoin’s MSC, it has the same premise as Mastercoin and also has a Token XCP. However, it did not carry out the ICO process by a selected group to manage the funds, but adopted the “certificate of destruction” method . It sends bitcoins to an address that can prove unusable, and the initial XCP Token distribution is determined by who burns the most bitcoins. This avoids the establishment of a controversial foundation. Perhaps it is precisely because of this “fairer” Token launch and the hard work of lead developer Adam Krellenstein that the Counterparty protocol has successfully become the mainstream Token issuance platform in this field. XCP Token itself needs to pay a fee to create a new Token, but other than that, its use is actually very limited.

Counterparty is now the most popular crowdfunding platform in the industry. If an entrepreneur or developer wants to launch a new token, they usually use crowdfunding, and Counterparty is the preferred platform. Below we provide some examples of using Counterparty’s popular tokens:

  • Storj-the first token of the “decentralized cloud storage” platform, and later launched another token on Ethereum
  • LTB-Token rewarded to listeners of the popular “Let’s Talk Bitcoin” podcast. After the ICO bubble in 2017, the token can finally be exchanged for a new POET Token
  • FoldingCoin-Reward Tokens that contribute computer power for folding DNA and researching diseases
  • GetGems — A native token for instant messaging and Bitcoin wallet applications
  • BitCrystals — Token used to reward participation
  • Swarm — Token of a new crowdfunding platform

从 Uniswap 看 DEX 的进击之路

Screenshot of Counterwallet, showing the balances for multiple coins, Source: You Tube

从 Uniswap 看 DEX 的进击之路

Ticket to the launch event for the Swarm Token

There are also some examples of tokens that were early precursors to some of the weakest ideas in the 2017 ICO boom, including FootballCoin and Blockfreight (a shipping logistics token).

In addition to Token, Counterparty has also rapidly developed more precursors to technologies that will later become popular on Ethereum, including gambling. Third-party oracles will announce the results of sports games, and people can check the results on the Bitcoin blockchain. Betting. Betting in the game will even become feasible. We still remember the results of the 2014 FIFA World Cup in Brazil, when we used the Counterparty platform to place bets and successfully played against the traditional hosted sports betting platform. At the same time, Counterpary also quickly implemented other functions, such as paying dividends to Token holders and using the platform to play “rock, paper, and scissors” games.

The most interesting and exciting feature is undoubtedly Counterparty DEX . All Counterparty Tokens can be traded on DEX, which runs on the Bitcoin network. Bitcoin transactions have additional parameters that can be interpreted by the Counterparty protocol as limit bids, limit quotations, or order cancellations. If a Bitcoin block contains matching bids and offers, the agreement will consider the transaction to be executed . At that time, people felt unprecedented excitement when using DEX, as if it were the future.

从 Uniswap 看 DEX 的进击之路

Screenshot of Counterwallet’s DEX

Counterparty’s DEX failed to gain traction

Counterparty’s DEX failed to gain significant appeal. In our opinion, there are five main reasons:

User experience-The user experience is not satisfactory, especially because Bitcoin’s target block interval is 10 minutes, which usually means that users have to wait for several minutes before they can appear in the order book after submitting orders .

  • Lack of liquidity-The liquidity on DEX is very low and market makers have little motivation. At the same time, adjusting orders is a time-consuming and difficult process, which results in market makers having to carry out cumbersome and high-risk on-chain processes to maintain market liquidity and strict spreads. Market makers also face the risk of miners running orders in advance. For most of the time, liquidity on the platform has basically dried up.
  • Scalability -At this time, the cost of Bitcoin has become very high, especially for large Counterparty transactions, either multi-signature transactions, or later use of OP_Return. Just to submit an order, you have to pay a large fee, maybe one dollar, which may be too much of a burden for some people.
  • Awareness of Bitcoin culture -perhaps more important than scalability is a cultural issue. Some people in the Bitcoin community do not welcome this kind of on-chain activity. They believe that Bitcoin is more serious than all these “joke Tokens”. Many people believe that these Tokens will increase verification costs, increase transaction fees, or cause incentives to be misplaced. In our view, it is this cultural concept that has promoted many Token issuance and DEX activities into Ethereum, rather than technical factors.
  • Timing -The ecosystem at the time was too niche, and it was not ready for DEXs. Many members of the community are still familiar with more basic concepts, such as transaction confirmation.

Mastercoin was eventually renamed Omni, and the old Mastercoin Token was no longer used. Subsequently, USD Tether was issued on the Omni layer and finally achieved great success , because Counterparty gradually became irrelevant. In view of the recent success of the DEX issued on Ethereum, and the relatively high fees on Ethereum, it may be an interesting idea for Omni to implement on-chain Bitcoin DEX and realize USDT/BTC transactions.

IDEX

The first generation of Ethereum Token imitated the Counterparty model to a certain extent. Since most Tokens now exist on Ethereum, not Bitcoin, from the point of view of value, developers have little choice other than choosing Ethereum as their DEX platform . Although this situation is changing now, because many popular trading pairs on “DEX” are tokens like WBTC and USDT, these tokens have centralized custodians and can theoretically exist on any platform. In our opinion, the most noteworthy and popular among these Ethereum DEX is IDEX.

Like Counterparty, bids, quotations, and order cancellations are all submitted to the Ethereum blockchain to form a centralized order book. However, in order to solve many user experience problems, the order is first submitted to the IDEX server, IDEX adds its signature to the transaction, and then broadcasts it to the Ethereum network. This means that users must trust a central entity to determine the sequence of events , but the exchange is still non-custodial. In our opinion, this is essentially a non-custodial exchange, not a DEX, and is still an interesting achievement and business model. Similarly, such exchanges have failed to generate significant market attractiveness. The main problem is that it is difficult to generate liquidity . Other reasons are due to the large amount of on-chain data generated by market makers.

Uniswap

The next DEX protocol we are going to look at is Uniswap. After years of trial and error, it finally achieved great success-with a very considerable trading volume.

In order to make a market in Uniswap, the market maker locks the Token into the Ethereum smart contract, and each transaction pair has an independent fund pool . Market makers have the incentive to ensure that the fund pool is divided 50:50 between the two tokens according to the currency value. Then, the price of the two tokens can be calculated by dividing by the amount of each token locked in the liquidity pool. For example, if the pool contains 4000 USDT and 10 ETH, the ETH price can be calculated as 4000/10=400 USD. Simply put, this price of $400 is the value of smart contracts that allow people to exchange ETH for U.S. dollars or U.S. dollars for ETH.

This ingenious but reasonably simple mechanism encourages liquidity providers to ensure that the value of the two tokens in the liquidity pool is 50:50 . If the market price of one of the tokens changes and the market maker does not adjust the size of the liquidity pool, then traders can use this to buy tokens at a price lower than the market. Returning to our previous example, if the price of ETH suddenly plummets to $200, traders will be incentivized to use smart contracts to exchange ETH for USDT, thereby removing ETH from the contract and adding more USDT to the contract Until the ratio reaches 50:50 again.

The above methods are feasible to a certain extent, but the problems of liquidity, slippage and large orders need to be solved . Uniswap was created to solve this fluidity problem. Its core operating principle is related to the curve y=1/x. Find a point on this line to maximize the area under the curve. The x-axis and y-axis respectively represent the number of tokens in each currency in the liquidity pool. Only after the exchange of tokens, the area under the curve is higher than the area before the exchange, including the impact of 0.3% fee, the transaction will be executed, and the 0.3% fee will also be added to the liquidity pool .

Uniswap price curve diagram

从 Uniswap 看 DEX 的进击之路

Consider the following two examples, with the same 4,000 USDT and 10 ETH liquidity pool as above

从 Uniswap 看 DEX 的进击之路

As the above situation illustrates, the greater the volume of transactions a person wishes to conduct, the greater the slippage will be encountered. The system does not have an order book, but only two fund pools, and this alone is sufficient for trading . This makes market making far easier than constantly using the blockchain to adjust orders. Under normal market conditions, if there is no lightning-like price fluctuations, market makers only need to provide liquidity to the fund pool, and rely on other liquidity providers to add and delete tokens from the fund pool, so not all market makers are The need to assist in order placement greatly reduces the use of cumbersome and expensive blockchains. This ingenious mechanism basically partially solves the aforementioned Counterparty’s liquidity and scalability problems . At least to a certain extent, the faster block target time of Ethereum is only 15 seconds, and the availability problem has been partially solved. Therefore, we believe that Uniswap is a powerful innovation agreement and a true DEX.

Uniswap imitators

Before September 2020, Uniswap does not have native tokens. The 0.3% transaction fee is all given to the liquidity provider. Of course, there is another model. For example, 0.25% of the fee goes to the liquidity provider, and 0.05% of the transaction fee goes to the original token holder of the swap agreement. This Token can also be issued partly based on the usage of the protocol, so users can hold this Token and be motivated by more people to use the protocol. Facts have proved that this Token incentive model is very popular in the DeFi field, that is, Token is issued according to a certain activity, and Token holders accumulate fees. Although this model is very popular, it also has many characteristics in common with Ponzi schemes, and leads to extremely unstable usage patterns of many Ethereum smart contracts . The initial issuance schedule of many of these tokens is very aggressive, which may cause some people to question the sustainability of these business models and agreements.

However, Uniswap’s lack of tokens creates an opportunity to emulate the DEX platform and use Uniswap’s method while adding native tokens. This local token will incentivize more people to use it, and the new protocol can gain market share from Uniswap, such as SushiSwap.

从 Uniswap 看 DEX 的进击之路

Branding of the SushiSwap Token

Uniswap Token

A series of imitated DEX, usually related to the name of the food for some reason, seems to have attracted the attention of the Uniswap team. In September 2020, they announced and launched the native token of the Uniswap protocol, named UNI . The issuance of Token will take place within 4 years, and the total supply can reach 1 billion units. At present, about 150 million Tokens have been issued to smart contract users. As of now, UNI Token holders have not received any economic benefits, but they may vote to grant themselves the right to receive transaction fees in the future.

The Uniswap team also allocated 21% of the UNI Token for itself. This can cause problems, especially in the case of DEX. In fact, the meaning of DEX seems to be resistance to censorship. For example, people can build an exchange without worrying about regulatory crackdowns or the need to implement a KYC system. With Ethereum smart contracts, developers can theoretically lock the contract so that it is impossible to modify it, and therefore cannot control the exchange to make it a DEX. However, if developers endow themselves with financial benefits by issuing tokens to themselves, regulators can treat these people as they treat the owners of centralized exchanges, and it is possible to crack down on them .

Since Mastercoin in 2013, we stubbornly believe that it is feasible to issue tokens. However, assigning Tokens to team members or consultants and centralized management by an organization means that the integrity of Tokens is greatly weakened and the organization faces regulatory risks. However, perhaps this esoteric view is simply out of date in today’s environment, and it doesn’t matter. Even if the team allocates the Token to itself, the platform is still very different from a centralized exchange . First, the most important thing is that it is non-custodial, and secondly, the components of the exchange system have been split to some extent. For example, there is no need for a centralized IT infrastructure. Although, it happens that most people use the Uniswap application on the website, which is probably owned and controlled by the same team that issued their own tokens, rather than manually interacting with smart contracts. If the ownership and control of these different components, such as the ownership and control of team tokens and website applications, become more diversified, Uniswap may be more flexible.

The recent DeFi boom

Recently, DeFi has developed very rapidly, and DEX such as Uniswap is the key to DeFi’s success . Uniswap can almost be regarded as the underlying platform of DeFi. Of course, the recent DeFi boom is mainly driven by speculation and the desire to earn financial returns. We describe the driving factors of the DeFi boom as four stages, of which the last three stages happen extremely quickly:

  • DEX (2018/2019) -Uniswap was launched at the end of 2018, and the agreement enjoys slow and steady growth until 2020. Uniswap also enables liquidity providers to obtain good financial returns without taking custody risks.
  • Decentralize leverage by combining different protocols (2020) -A key moment in the growth of DeFi is the launch of the Compound protocol . This system allows users to borrow and lend assets on Ethereum. In our opinion, the reason why it is so popular is that it can combine lending and DEX to increase leverage and speculate on price changes. For example, you can lend ETH on Compound and borrow Dai, then use Uniswap to exchange Dai back to ETH, and then lend ETH again on Compound. This cyclical remortgage can happen multiple times. Therefore, the use of multiple DeFi protocols to obtain leverage will increase the risk of ETH. Although this does increase the risk of the system and may lead to large-scale liquidation, price collapse, and serious on-chain congestion, in our view, leverage can be a legitimate part of the financial market, and people should not be too aggressive in such activities. Severe criticism.
  • Yield farming based on the issuance of new tokens (2020) – The next wave of adoption is another layer on top of DEX and lending protocols. These protocols create local tokens to be issued to platform users. Due to the issuance of tokens, more The high rate of return is the so-called “yield farming”. Again, this adoption is mainly driven by speculation and the ability to obtain economic benefits from mining these tokens. This stage relies heavily on the appreciation of the Token price, and it can be considered unsustainable.
  • “Automated” Investment Strategy (2020) -The last layer at the top of the DeFi Pyramid, which we classify as an “Automated” investment strategy for maximizing returns Create an investment fund structure that can engage in multi-layer liquidity mining, lending, exchange, and DEX liquidity supply to earn financial income. Then issue another set of Token to carry out this process. The key example here is YFI.

Complex layers of DeFi interconnection

从 Uniswap 看 DEX 的进击之路

Ethereum’s scalability and network fees

This crazy speculative activity on the Ethereum network and the rush to buy the latest Token have led to a surge in on-chain fees . Facts have proved that network fee prices are extremely inelastic, because traders eager to get ahead of their peers are willing to pay outrageous prices for confirmation. The total network fee of Ethereum is now higher than that of Bitcoin. Some Ethereum-based protocols such as Uniswap have generated almost as much on-chain transaction fees as Bitcoin in certain periods . While the cost has soared, the availability of the network is also declining, because users often have to wait a long time to confirm. Transactions are often stuck, requiring lower fees. Some projects even abandon Ethereum because of high gas fees, because their projects cannot survive economically.

从 Uniswap 看 DEX 的进击之路

In addition to high fees, Ethereum node operators are also struggling to stay at the top . Even if we use Geth on our high-end 64GB RAM machines, we often have difficulty reaching the head, and often stay behind 5 to 50 blocks. Of course, Bitcoin avoids this problem. Many people in the community realized many years ago that a reasonable block size will not be large enough, and the data on the chain cannot be effectively expanded, nor can it retain the anti-censorship feature. These people are now undoubtedly thinking:

I told you…

However, for the Ethereum community, they are already achieving great success, so of course they will not regret it. In fact, the difference between the two communities is mainly cultural. Each community has a significantly different time frame and likes to make different trade-offs between robustness and experimentation.

in conclusion

Uniswap is undoubtedly an interesting, ingenious and successful invention . Of course, if you want to be really interesting, you also need a useful token that is native to Ethereum that is worth trading and investing. There are custodial tokens (such as USDT, DAI, and WBTC) representing U.S. dollars or Bitcoin on Ethereum. However, if the assets are controlled by a centralized custodian, most of the advantages of DEX will be lost. On the other hand, decomposing an exchange into these independent components, only one of which is centralized, can improve the flexibility of the platform at least for a period of time. Therefore, even if USDT and WBTC become the mainstream tokens on DEX, DeFi is still interesting in our opinion.

As for DeFi, it seems to be a highly complex network consisting of interrelated agreements and speculative frenzy, mainly driven by new token issuance, which we believe is unsustainable. It has many similar characteristics with the 2017 ICO bubble. However, at least for us, this is not what we felt during the ICO bubble. It seems to be hidden in the depths of all these complex, crazy and experimental. There may be something brilliant and sustainable, at least towards the DeFi pyramid. Low-level development . Uniswap is perhaps the best example before the launch of its Token.