A reference implementation of the coordinator server. To learn more about coordinators, check out the coordinator specification. To learn more about the specific design decisions of this implementation, read the design choices section.
Fork this repository to get started!
To develop ontop of 0x-coordinator-server
, follow the following instructions:
-
Fork this repository
-
Clone your fork of this repository
-
Make sure you have Yarn installed.
-
Install the dependencies:
yarn
-
Edit the
src/production_configs.ts
file to work with your relayer:
FEE_RECIPIENTS
- Should include the addresses and private keys of thefeeRecipientAddress
's you enforce for your orders (per chainId). Your coordinator's signatures will be generated using these private keys.SELECTIVE_DELAY_MS
- An optional selective delay between fill request receipt and approval. Adding a delay here can help market makers cancel orders without competing on speed with arbitrageurs.EXPIRATION_DURATION_SECONDS
- How long an issued signature should be valid for. This value should be long enough for someone to concievably fill an order, but short enough where off-chain cancellations take effect after some reasonable upper-bound.RPC_URL
- The backing Ethereum node to use for JSON RPC queries. Please add your own Infura API key if using Infura.
-
Build the project
yarn build
or build & watch:
yarn watch
-
Start the Coordinator server
yarn start
yarn build
- Build the codeyarn lint
- Lint the codeyarn start
- Starts the relayeryarn watch
- Watch the source code and rebuild on changeyarn prettier
- Auto-format the code
This project uses TypeORM. It makes it easier for anyone to switch out the backing database used by this project. By default, this project uses an SQLite database.
Before deploying the coordinator to production, make sure to remove the following line from ormconfig.json
:
"synchronize": true,
Otherwise the database schema will be auto-created on every application launch. Read more here.
0x-coordinator-server
ships as a docker container. First, install Docker (mac, windows). Before you can build the image, make sure you've edited your configs as outlined in step 5 of Pre-Requirements.
To build the image run:
docker build -t 0x-coordinator-server .
You can check that the image was built by running:
docker images
And launch it with
docker run -p 3000:3000 -d 0x-coordinator-server
The laws and regulations applicable to the use and exchange of digital assets and blockchain-native tokens, including through any software developed using the licensed work created by ZeroEx Intl. as described here (the “Work”), vary by jurisdiction. As set forth in the Apache License, Version 2.0 applicable to the Work, developers are “solely responsible for determining the appropriateness of using or redistributing the Work,” which includes responsibility for ensuring compliance with any such applicable laws and regulations. See the Apache License, Version 2.0 for the specific language governing all applicable permissions and limitations: http://www.apache.org/licenses/LICENSE-2.0