Currently, DeFi is based on some smart contract platforms with Account Model such as Ethereum. Therefore, as it grows, performance bottlenecks inevitably emerge, resulting in a variety of Layer 2 solutions. Although Layer 2 solutions alleviate the performance and transaction friction problems of smart contract platforms, they break the composability in DeFi of Layer 1. But why does no one pay attention to Bitcoin, the UTXO model that can almost expand capacity unlimitedly?

Bitcoin itself has limitations such as its Turing-incomplete scripting system and the low-efficiency of its POW consensus. Even though UTXO is powerful, with these limitations, it is difficult to implement the base function of DeFi.

Chia, however, makes all this possible. It makes Coin a first-class citizen and brings Chialisp, which is not as easy to understand as the account model of Ethereum, but this transformation makes UTXO-based DeFi a reality on Chia. As the superset of Lisp, Chialisp brings the advantage of Lisp into Chia’s Smart Coin. The coin set model and Chialisp complement each other.

What it does

Matrix Protocol is a trading protocol of decentralized orderbooks. Users can create orders, cancel orders, fill orders, and view order history in the frontend which they need to synchronize with Full Node. The whole transaction process is completely independent of any centralized node. Thanks to UTXO-based Coin Set Model and Chialisp, users can trade on Matrix with near-centralized exchange speed with extremely low fees.

How we built it

From a functional perspective, key implementation and standard definition of Matrix Protocol are shown below.

  1. Maker establishes Maker Puzzle and Taker Puzzle based on order information. Taker Puzzle contains order information, such as the address and order amount of Makers. Taker Puzzle Hash and related order information are included in the Maker Puzzle. Maker Coin (Its puzzle is called Maker Puzzle and amount is called Maker Amount) is generated when Maker uses the corresponding wallet (Standard Wallet or Colorful Wallet).
  2. According to the public Matrix Gateway Puzzle, Gateway Coin is generated temporarily. Order params are passed to gateway when you make a solution contains order data to spend the gateway coin.
  3. The transaction is conducted through SpendBundle which is consisted of Gateway Coin Spend and Maker Coin Spend.
  4. Broker monitors puzzles and coins that they are interested in on chain, gathers order information from the Solution of Matrix Gateway Coin and update order status from the Solution of Maker Coin.
  5. Broker maintains orderbooks, creates new orders, updates order status and cancels expired orders
  6. Taker gets order information from the orderbooks.
  7. Taker builds an ephemeral Taker Coin according to order information and spends Maker Coin and Taker Coin simultaneously.
  8. Taker can consume it again, if it is still left in Maker Coin, which can recreate itself.

Challenges we ran into

  • how to ensure the safety of economic design(solved)
  • how to provide liquidity by market-making (solved)

Accomplishments that we're proud of

We verified the feasibility and implemented a minimum viable product.

What we learned

The foundation of Matrix Protocol is based on Chialisp. Numerous computations are done off chain and verification are done on chain, which means Matrix Protocol can almost expand capacity unlimitedly. Moreover, Smart Coin, based on Chialisp, can use formal verification to ensure security, which makes the contract more reliable and auditable. Smart Coin can be considered as a coin contains a program, when you spend it, the program got executed. And Coins in other Chia DApps, also as first-class citizens, can be seamlessly compatible with Matrix Protocol to achieve interoperability of fundamental liquidity. From our perspective, Chia Coin Set Model, based on the design concept of UTXO, is a true electronic cash and programmable money. It is a "banknote" that exists independently in the virtual space. This inspired us to use first principle thinking to go back to the original starting point of "Exchange", to think about how an exchange should be conducted on DeFi, and to explore and experiment with shared fundamental liquidity on Chia Network.

What's next for Matrix Protocol

Price Oracle

With a certain amount of trading volume on Matrix, time-weighted price oracle can be carried out with the help of Singleton pattern.

Margin trade

Build a lending pool that Matrix Protocol will automatically help users borrow/repay when they choose to trade with leverage. The user is trading on margin, and if a large price deviation occurs, it triggers a forced liquidation of the position.

Derivative trade

Users can tokenize a stable coin like xUSD, carbon credits or $APPL on Matrix Protocol. And they can synthesize and trade any asset on Matrix Protocol.

Research on Layer 2

  • Focus on Infinite Scaling of Performance In the future, after Matrix reaches a certain trading volume and trading frequency, we can establish a Layer 2 network to aggregate several transactions and then send them together to the chia network. At the same time, orders of Maker can be shared among layer 2 nodes, to achieve the goal of sharing liquidity. Other projects can easily access Matrix Protocol through the Driver module provided by us, and orders can also be routed to Matrix Protocol for processing through the Matrix Gateway.

Built With

Share this project: