Concept and mechanism of MOLDEX[PART 2]

GAME
GAME
Published in
8 min readMar 4, 2019

This time we will briefly introduce the concept of MOLDEX advanced by MOLD team and outline of exchange protocol.
If you would like to know what DEX is , please refer to the previous article.

Concept of MOLDEX

Currently there are many digital assets based on ERC 721, including Cryptokitties , but the real value of block chain games will be demonstrated in the future when items are traded on the block chain to not only characters but also items in the game It is considered to be. For that purpose, protocols that can freely exchange both in-game items expressed in Fungible token and game characters expressed in Non-Fungible token are needed. Since Fungible token can be expressed not only in the form of circulating as a currency like ERC 20 but also in accordance with the standard of ERC 1155, if opportunities to be used more and more will come out in the future is expected.

※Please refer to the next article on the mechanism and innovation of ERC 1155.

By supporting both Fungible token and Non-Fungible token , MOLDEX can stand differently from existing distributed exchanges according to ERC 20 and ERC 721 standards.

MOLDEX also provides trustless, real-time, high-throughput transactions in combination with block chain based payments. With MOLDEX collectively managing transaction verification and sending of transactions to Ethereum, users

continuously trade without waiting for transactions to be approved on the network and process multiple orders at once Or you can cancel the order immediately without applying Gas .

Features of MOLDEX

MOLDEX consists of smart contracts, trading engines, and mediation of transaction processing. On Smart Contract, all assets are stored in a reliable manner and exchange of digital assets is executed. Also, since all transactions need to be approved by the user’s private key, it is unlikely that problems will occur such as counterfeiting by third parties as well as third parties.

Unlike other distributed exchanges, MOLDEX’s Smart Contract is designed so that only exchanges are allowed to send signed transactions to Ethereum. This allows MOLDEX to control the order of transactions and to separate order matching from the final settlement, so if the user deals, the orderbook will be updated in real time. At the same time, the user’s private key is used to authorize transactions on the Smart Contract, and this approval can prevent the MOLDEX side from initiating an unauthorized transaction.

The user’s signed order is handed to the trading system which manages matching of orders. In Ethereum each transaction is mined in the correct order and in turn issue the exchange pair of order pairs (transaction mediation) to ensure that the balance on the Smart Contract is synchronized with the transaction balance. By controlling the order of transactions, MOLDEX can provide the speed and UX of centralized exchange in combination with DEX security and auditability.

Based on the above characteristics, MOLDEX can be said to have the following properties.

Trustless

The important thing about a distributed exchange is that the user manages the private key. In MOLDEX, deposit and withdraw to Smart Contract are a mechanism that the user directly requests and signs with a secret key in case of placing an order, so the user can not assert assets without fraud without trusting the exchange side Can be realized.

Fast Transaction

On traditional distributed exchanges that match on-chain, it was designed to be impractical for practical use, as it is necessary to wait for orders to be taken into blocks each time a transaction is made. However, in the case of MOLDEX, matching of orders is done only in an off chain, and block chains are used for exchanging actual assets, so that it is possible to make UX as trading in real time from the user’s point of view.

Fast orderbook update

Likewise, with respect to updating the orderbook, it is possible to make updating in nearly real time by utilizing the existing database.

Gas does not take on cancellation

When ordering, the user is asked to sign the order data, but the order itself is managed in the database until the trade order is matched. Therefore, you do not have to stare at the screen before canceling and wait, or pay Gas just to cancel.

Multiple orders available

MOLDEX supports multiple orders that allow you to purchase large amounts of assets at once. However, transaction is issued for each matched pair of buy and sell orders.

All transactions of Assets on Ethereum are possible

In order to realize the concept of MOLDEX, it is also possible to exchange token according to the next ERC standard.

• ERC20
• ERC721
• ERC 1155

Transaction flow in MOLDEX

Next, we will look at the flow when transactions are actually carried out on MOLDEX. The figure below shows a simplified representation of transactions executed on MOLDEX.

0. sign up
First, the user newly creates or imports Ethereum’s address and newly registers it in MOLDEX with password set by himself / herself. Of course, unlike centralized exchanges, users themselves manage the secret key of the address.

1. deposit
Both MAKER and TAKER deposit directly to the Smart Contract. You can
withdraw deposited assets at any time.

2. Reflected in database
Refer to the Smart Contract and update the database which manages
MAKER and TAKER’s balance.

3. Order MAKER
MAKER can place orders at any price and quantity. MAKER signs order data with its private key and sends it to the server. If the transaction does not take place after a certain period of time, MAKER’s order will be invalid automatically.

4. Validation of order data and storage in DB
On the server side verify that the signature of MAKER is correct, whether data is sufficient (balance exists) or not. For example, if the signature data of Mr. A does not match the address of Mr. A, the order is rejected as illegal order data, so other people can impersonate Mr. A and place an order without sharing the secret key It has become. When the verification is completed and it is confirmed that the order data is correct, it is stored in the database.

5. Ordering TAKER
TAKER issues an order whose price matches the board information set by MAKER.
If you want to place an order at an arbitrary price, place an order as MAKER.

6. Validation of order data
On the server side, verify that the signature of TAKER is correct, whether data is sufficient (balance exists) or not.

7. matching
The verified TAKER order is paired with the order of MAKER obtained from the database through the transaction matching engine. For details of matching, see next chapter.

8. Database update
And updates the matched trading order pair and the user’s balance. At this point, although transactions are not actually established on the block chain of Ethereum, since the order status is managed off-chain, the user can immediately move on to the next transaction. When the transaction is not established, the state is recorded in the DB.

9. Exchange asset
When the order of MAKER and TAKER matches, execute the trade function of Smart Contract from the server side.

10. Update state of Smart Contract
Transactions are approved on the Ethereum network, the asset exchange
is over and the contents of the wallet are also successfully updated.

※Here, we will call MAKER who ordered first, and those who ordered from the other side so as to hit the order are called TAKER.

The matching system of trading

A powerful trading platform is built around an efficient order assignment algorithm also called matching engine. This algorithm functions as the core of every exchange.
MOLDEX adopts FIFO’s Price-Time-Priority algorithm which is the simplest algorithm.

First of all, let us consider the following model to understand the basic concept of matching engine.

  1. Order
    It corresponds to the order of Taker in MOLDEX.
  2. Orderbook
    It is a set of MAKER orders in MOLDEX.
  3. Trade
    The Order that matches the Orderbook order will be treated as Trade. In the case of MOLDEX, the matched pair will be broadcast to Ethereum’s network after this.
  4. Unmatched Order
    The Order that does not match the order of Orderbook, or the Order that is partially processed as Trade is added to Orderbook as Unmatched Order.

When Order exactly matches Orderbook

Matching engines always try to find the best price available for a particular order. In this case, Sell 1@99that matches cheaply matches for Buy 1@100 ordering, and Sell 1@100 that did not match remains in the orderbook.

When Order partially matches Orderbook

For Buy 4@100 order, Sell 1@99 and Sell 2@100 Order match. The remaining Buy 1@100 is added to the Orderbook because there is no matching sell order.

If Order does not match exactly with Orderbook

If it does not match Orderbook’s order exactly, it will be added to Orderbook as MAKER.

FIFO

If there is a possibility that multiple orders will match the current order, systematically it will be unclear which order to match. Therefore, in addition to the above-mentioned price-based algorithm, the concept of FIFO (First In First Out) is introduced as follows.

That is, with respect to orders of the same price, as the order having the older time is preferentially processed, in the Price-Time-Priority, it is found that the price and the time are arranged in order of matching.

Summary

Since it takes time for a stable protocol to settle around rapidly changing block chain technology, it is unlikely that MOLDEX’s exchange protocol will spread quickly. In addition, it is obvious that the presence or absence of demand for MOLDEX’s exchange protocol becomes a problem in the first place since there is almost none of Ðapps itself carrying both Fungible assets and Non-Fungible assets on the block chain . However, in the future, if a breakthrough such as 2nd Layer technology is put to practical use and infrastructure capable of handling large volume of asset transactions is prepared, the protocol proposed by MOLDEX inevitably needs It will be. Therefore, it can be said that it is now at the stage of research and development of protocols for responding to future demand. Even at MOLD team, we will continue to explore the future of Game in the future as well as develop functions and protocols that will be needed.

Next time: On the specification and innovation of ERC 1155 reference

— — — — — — — — — — — — — — — -
Cosmos Gaming Hub Project(Former MOLD project)
CEO & Co-Founder

Takumi Asano

For all game enthusiasts

--

--

GAME
GAME
Editor for

Cosmos Gaming Hub is a fair and secure distributed gaming platform which supports the development of new games and simplifies the trading of digital assets.