This project is a peer-to-peer (p2p) orderbook implemented in js. The orderbook facilitates decentralized trading by allowing users to submit buy and sell orders directly to each other without the need for a centralized exchange.
- Decentralized Trading: Users can submit buy and sell orders directly to each other.
- Order Matching: The orderbook matches buy and sell orders based on price and quantity.
- Peer-to-Peer Communication: Uses a p2p network for order broadcasting and order matching.
The order-book state is shared among the p2p peers. to avoid to create multiple connection between peers there is a central websockets server that broadcast messages to all peers in order to update the orderbook, if a peer doesn't found a orderbook server it becomes the server. Later peers who wants to trade discover the "Current" server using grenache-nodejs-link (the powerfull DHT).
- Install grape
npm i -g grenache-grape
- Start grape
grape --dp 20001 --aph 30001 --bn '127.0.0.1:20002'
grape --dp 20002 --aph 40001 --bn '127.0.0.1:20001'
- Install dependencies
$ npm install
- Enjoy the P2P trading 🚀
$ node ./bin/server.js -g http://localhost:30001 --p BTCUSD
$ npm test
- If a server dies, a client can become a new server and announce this change to other clients.
- when client connects it must sync state with server.
- The state could not be warranted :(.