Turn:
Development of digital currency exchange system (Technology)
The digital currency exchange is mainly composed of the following five systems:
1. Account system
Whether it is leek or dealer, as long as it is the user of the exchange, it will have its own centralized account. This account contains the user's identity information, asset information and transaction information. These information need to be recorded and controlled uniformly by the account system.
2. Debit and credit system
The in / out accounting system does not record data. Its main function is to complete the business logic of accounting and posting in the process of transaction, recharge or withdrawal, and connect the changes of assets with the account data.
3. Transaction management system
Corresponding to the casino scenario, the function of this system is to define and record all game rules and data. The trading range, K-line and trading data of the exchange are managed by this system.
4. Matchmaking engine
It has only one function - order matching. All the buying and selling demands of the exchange need the matching engine to combine the buying and selling orders into transactions.
5. blockchain Wallet
All digital assets developed by the digital currency exchange system and users are stored in the blockchain wallet. The interaction on the chain generated by each actual recharge and withdrawal of users is completed by the wallet.
Among the above five systems, two are the top priority in system construction, one is matchmaking engine and the other is blockchain wallet.
The matching engine is as important to the exchange as the heart is to people. The matching engine needs to drive the operation of other systems of the exchange on its own. An excellent matchmaking engine needs to meet the following three requirements:
1. Strong to abnormal performance: the larger the size of the exchange, the more concurrent transactions. The performance of the matching engine directly restricts the development of the exchange's business.
2. Multiple order types are fully compatible: common order types include price limit order, market price order, profit and loss stop order, etc.
3. Support of contract function: in the current exchange industry, contract trading has almost become a necessary function. The realization of contract matching is much more complex than that of spot, and the requirements for technology will be higher.
In terms of technology, the matching system has been half successful, and the key to the success of the other half is the blockchain wallet.
On the one hand, the wallet needs to bridge the centralization and decentralization to get through the asset data of the two. On the other hand, the wallet must also realize the function of fund management safely and steadily. Once there is a problem with the wallet and the theft of money occurs, it will lead to serious damage to the vitality of the exchange and direct bankruptcy of the exchange.
function buyNewLevel(uint8 matrix, uint8 level) external payable { require(isUserExists(msg.sender), "user is not exists. Register first."); require(matrix == 1 || matrix == 2, "invalid matrix"); require(msg.value == levelPrice[level], "invalid price"); require(level > 1 && level <= LAST_LEVEL, "invalid level"); if (matrix == 1) { require(!users[msg.sender].activeX3Levels[level], "level already activated"); if (users[msg.sender].x3Matrix[level-1].blocked) { users[msg.sender].x3Matrix[level-1].blocked = false; } address freeX3Referrer = findFreeX3Referrer(msg.sender, level); users[msg.sender].x3Matrix[level].currentReferrer = freeX3Referrer; users[msg.sender].activeX3Levels[level] = true; updateX3Referrer(msg.sender, freeX3Referrer, level); emit Upgrade(msg.sender, freeX3Referrer, 1, level); } else { require(!users[msg.sender].activeX6Levels[level], "level already activated"); if (users[msg.sender].x6Matrix[level-1].blocked) { users[msg.sender].x6Matrix[level-1].blocked = false; } address freeX6Referrer = findFreeX6Referrer(msg.sender, level); users[msg.sender].activeX6Levels[level] = true; updateX6Referrer(msg.sender, freeX6Referrer, level); emit Upgrade(msg.sender, freeX6Referrer, 2, level); } }
Turn:
Development of digital currency exchange system (Technology)
--Posted from Rpc