conduit

Conduit Conduit - 0x Relayer API

CircleCI code style: prettier

Overview

[Work in progress, PR/Contributions welcome! Testing on Kovan test network]

ZeroEx Open Source Relayer using the Open Orderbook strategy.

Follows ZeroEx Standard Relayer API V0 Draft specification.

Getting started

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
sudo apt-get install redis-server
netstat -p tcp | grep $PORT
lsof -nP -iTCP:$PORT | grep LISTEN
lsof -nP -i:$PORT | grep LISTEN
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
apt-cache policy docker-ce
sudo systemctl status docker

sudo docker-compose

yarn start
yarn run v1.9.4
$ node dist/index
2018-09-25T21:45:42.248Z - info: Conduit starting...
2018-09-25T21:45:42.262Z - verbose: Connected to Web3 Provider Engine
2018-09-25T21:45:42.340Z - verbose: ZeroEx client set up
2018-09-25T21:45:42.348Z - verbose: Redis Publisher setup
2018-09-25T21:45:42.349Z - verbose: Redis Subscriber setup
2018-09-25T21:45:42.349Z - debug: Connected to Redis instance
2018-09-25T21:45:42.391Z - error: Error connecting to Postgres Error: connect ECONNREFUSED 127.0.0.1:5432
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
2018-09-25T21:45:42.391Z - error: Error starting app Error: connect ECONNREFUSED 127.0.0.1:5432
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)

yarn dev
$ ts-node src/index
2018-09-25T22:00:47.690Z - info: Conduit starting...
2018-09-25T22:00:47.708Z - verbose: Connected to Web3 Provider Engine
2018-09-25T22:00:47.823Z - verbose: ZeroEx client set up
2018-09-25T22:00:47.834Z - verbose: Redis Publisher setup
2018-09-25T22:00:47.835Z - verbose: Redis Subscriber setup
2018-09-25T22:00:47.835Z - debug: Connected to Redis instance
2018-09-25T22:00:47.915Z - error: Error connecting to Postgres error: password authentication failed for user "johnjohnson"

Local dev setup

To start the local dev server:

yarn install
yarn start

Configure

Architecture

                       ┌─────────────────────────────┐                       
                       │amis-erc20.github.io/smartdex│
		       │            Amis             │
                       │   	  SmartDex	     │
		       │    	   Client    	     │                       
                       │              		     │                       
                       └─────────────────────────────┘                       
                                    ▲  ▲                             
                            ┌───────┘  └───────┐                     
                            │                  ▼                     
                     ┌─────────────┐    ┌─────────────┐              
                     │             │    │             │              
                     │  WebSocket  │    │  HTTP API   │              
                     │             │    │             │              
                     └─────────────┘    └─────────────┘              
                            ▲                  ▲                     
                            │ emits            │                     
                            └─events┐   ┌──────┘                     
                                    │   │                            
                                    │   ▼                            
    ┌──────────────────┐      ┌──────────────┐       ┌──────────────┐
    │  Relevant event  │      │              │       │◦◦◦◦◦◦◦◦◦◦◦◦◦◦│
    │     streams      │─────▶│  App Engine  │◀─────▶│◦◦◦◦0x.js◦◦◦◦◦│
    │ (includes 0x.js) │      │              │       │◦◦◦◦◦◦◦◦◦◦◦◦◦◦│
    └──────────────────┘      └──────────────┘       └──────────────┘
                                      ▲                              
                                      │                              
                                      ▼                              
                              ┌──────────────┐                       
                              │              │                       
                              │  Orderbook   │                       
                              │              │                       
                              └──────────────┘                       
                                      ▲                              
                                      │                              
                                      ▼                              
                              ┌──────────────┐                       
                              │              │                       
                              │  Data store  │                       
                              │              │                       
                              └──────────────┘                        ### Roadmap

I’ll be adding support for Matching as soon as this proposal is implemented. I personally think the matching strategy will lead to a better UX (atomic, no race conditions, faster relay feedback), but currently requires large upfront capital. Matching engine will use sorted sets on top of red-black trees and will be configured as a separate strategy.

Howto

1/ Search the orderbook for a specific WETH pair:

2/ GET request to retrieve the orders list:

3/ GET request to retrieve the token_pairs