If you want to exchange between different digital assets, you need to go through intermediary channels such as exchanges.
The traditional exchange is a centralized model, that is, the two parties of the transaction exchange according to the exchange rate through the trading platform provided by the third party, and the trading platform side often needs to collect the handling fee from the transaction. This model is not only costly, but also has the risk of relying too much on the trading platform.
To solve these problems, Decentralized Exchange (DEX) was designed. The initial idea is to allow both parties to exchange directly peer-to-peer through a blockchain-based protocol. Since there is no need to participate in the trading platform, the transaction cost is low, and it can be completed in real time without worrying about security risks. Currently, decentralized exchanges are one of the hottest topics in decentralized finance.
To implement a decentralized exchange, some basic problems need to be solved:
- The transaction can be completed automatically without manual participation;
- No one can fake or deceive the other party during the transaction;
- Calculate the exchange rate automatically and complete the transaction according to the exchange rate;
- Avoid excessive market volatility and losses.
At present, decentralized exchanges mainly include three modes according to their order positions: on-chain bookkeeping, off-chain bookkeeping and automatic market makers.
On-chain accounting
The idea of on-chain bookkeeping is very simple, and the exchange transactions are directly stored on the blockchain.This mode is simple to implement, but has major flaws.
- Every transaction needs to be on the chain, and there will be billing fees. When transactions are frequent, the cost of bookkeeping is too high;
- All information needs to be recorded on the chain, which may benefit someone from knowing the transaction information in advance;
- When there are many transactions, the performance requirements of the blockchain are very high, and most public chains cannot support it.
Off-chain accounting
In contrast to on-chain bookkeeping, off-chain bookkeeping stores transactions on a third-party platform. Third-party platforms only write transactions to the blockchain when needed.This method can avoid writing a large number of transactions to the blockchain, but it needs to rely on a third-party platform, and there is a high security risk.
Platforms that have adopted this solution include Binance and others.
Automated market maker
Similar to market makers in the securities market, smart contracts can be used to implement an automated market maker mechanism (AMM).When users need to exchange currency, they do not directly trade with other users, but exchange with blockchain smart contracts.
Behind the smart contract, the exchange rate is calculated in real time according to its liquidity pool and pricing algorithm (such as reciprocal curve, straight line, etc.). A small fee is charged per transaction (e.g. Uniswap charges 0.3%).
This mechanism does not need to rely on transaction bookkeeping, transaction costs are generally low, and risks are small.
Users can also put the currency they hold into the liquidity pool according to the protocol and become a Liquidity Provider (LP). Liquidity providers can obtain benefits from transaction fees.
The main problem of this model is that the depth of the market depends on the liquidity pool, and it is necessary to balance the contradiction between LP income and transaction costs. At the same time, when the currency price fluctuates greatly, LP may incur Impermanent Loss.
Typical implementation protocols include Uniswap, Bancor, etc., and platforms include Chainlink, Kyber, etc.
No comments:
Post a Comment