Order – is a public announcement about the fact that user is ready to exchange cryptocurrency X for the cryptocurrency Y.
Orderbook – is the effective lists of orders used by users to find each other and exchange cryptocurrencies promptly.
On both centralized and semi-decentralized exchanges (e.g. IDEX) orderbook is stored on the basic server. Thus, the server owner is responsible for the matching between buyers and sellers, similarly to the owners of torrent-trackers.
So, the decentralized orderbook addresses the elimination of the administrator’s influence on the exchange processes and on online order matching.
We have solved this problem via the ipfs pubsub library means.
So, how does it work?
- We launch the ipfs library and ipfs-pub-sub-room (https://github.com/ipfs-shipyard/ipfs-pubsub-room#use )
- We set external public signal server to find the first peer in network (https://github.com/swaponline/swap.react/blob/master/config/mainnet/ipfs.js )
- User comes and gets connected to some other users. Imagine, they are in the same chat room. This information is shown in the bottom of the page.
5.The order is formed and sent through the libp2p library here (https://github.com/swaponline/swap.core/blob/master/src/swap.orders/SwapOrders.js#L317 ).
6. Every message is signed by the private key from the Ethereum network and then checked through web3.ecrecover (https://github.com/swaponline/swap.core/blob/master/src/swap.room/SwapRoom.js#L174)
7. Swap.online dApp receives the avaliable orders and shows it to the users.
8. Moreover, this orderbook is analyzed during the exchange via the simplified interface, where the user enters only the sum for exchange and gets the request with the most profitable order
Full range of messages transferred via the IPFS system:
- user online
- user offline
- new orders
- new order
- remove order
- hide orders
- show orders
- accept request
- decline request
- request swap
- new order request
- accept swap request
- request partial fulfilment
- accept partial fulfilment
- decline partial fulfilment
- new partial fulfilment request
and some messages inside the swap.