MARKET Protocol has been created to provide a secure, flexible, open source foundation for decentralized trading on the Ethereum blockchain. We provide the pieces necessary to create a decentralized exchange, including the requisite clearing and collateral pool infrastructure, enabling third parties to build applications for trading.
Take a look at our docs for a little more explanation.
Join our Discord Community to interact with members of our dev staff and other contributors.
MARKET.js is a library for interacting with MARKET Protocol Smart Contracts.
- Orders
- generating and signing
- filling and cancelling
- verifying signature
- calculating remaining Qtys
- watching for events affecting validity.
- Collateral
- checking a users unallocated collateral balances
- checking a users allocated collateral
- calculation of needed collateral
- wrapper for ERC20 token functionality.
- Positions
- querying users open positions (qty and price)
- Events
- Fills
- Collateral Deposit / Withdraw
- Contract Settlement
- Cancelled / Expired orders
- Contract Registry
- MKT Token Access to contracts
Want to hack on MARKET Protocol? Awesome!
MARKET Protocol is an Open Source project and we welcome contributions of all sorts. There are many ways to help, from reporting issues, contributing code, and helping us improve our community.
Ready to jump in? Check docs.marketprotocol.io/#contributing.
Join our Discord Community to get in touch with our dev staff and other contributors.
A Makefile is provided for easy setup of the local development environment.
Some pre-requisites are required in order to utilize the Makefile.
NodeJS 8.11.2 LTS is recommended for compatibility.
$ git clone https://github.com/MARKETProtocol/MARKET.js # clone this repository
$ git clone https://github.com/MARKETProtocol/ethereum-bridge.git # and the needed oraclize.it bridge (for local test rpc)
From here you will be able to use make commands assuming npm is already installed.
Assuming you have npm already, Install truffle
$ make install_truffle # may require sudo
Install needed dependencies. If this fails on your ubuntu install it may require you to run sudo apt-get install build-essential -y
prior to installing.
$ make install_deps
If you get an error on the node-gyp rebuild
line during make install_deps
, node-gyp
doesn't support Python v3.x.x; v2.7 is recommended. There are several solutions based upon your platform.
The easiest solution?
make install_deps_python2.7
to use Python 2.7. See stack overflow or the npm node-gyp project for details.
You can start the truffle development environment and console
$ make start_console
From here, in a separate console, we now need to bring up the ethereum bridge for the Oraclize.it service.
$ make start_bridge
Once the bridge has fully initialized, you should be able to run the example migrations for the MARKET Protocol smart contracts.
truffle(develop)> migrate --reset
If this fails due to a revert
, please be sure the bridge is listening prior to attempting the migration.
A local blockchain is now running with a fully deployed suite of MARKET Protocol smart contracts.
The needed json
ABI files can now be found in ./build/contracts/
In order for the tests to work, you will need to have followed the above steps to ensure truffle is running, ethereum-bridge
is running, and the migrations have deployed our contracts.
If all of this is set up correctly, the below should work.
$ npm run test
It is possible to build and execute tests in the same way as in Travis CI by using Docker orchestration.
Prerequisites: docker and docker-compose installed.
set -a
source .env
docker-compose up -d
The first run will take a while since images will be pulled from Docker registry. After that images are cached and the start will be much faster.
docker-compose exec marketjs npm install
docker-compose exec eth-bridge scripts/wait_for_oraclize_connector.sh
docker-compose exec marketjs truffle migrate
docker-compose exec marketjs npm run build
docker-compose exec marketjs env TRUFFLE_DEVELOP_HOST="$TRUFFLE_DEVELOP_HOST" npm run test:prod
You can import the generated bundle to use the library modules generated by this project:
import { Contract, Collateral, Order, Settlement } from './marketjs'
Additionally, you can import the transpiled modules from dist/lib
in case you have a modular library:
import { something } from 'marketjs/dist/lib/something'
npm run test
: Run test suitenpm run start
: Runnpm run build
in watch modenpm run test:watch
: Run test suite in interactive watch modenpm run test:prod
: Run linting and generate coveragenpm run build
: Generate bundles and typings, create docsnpm run lint
: Lints codenpm run commit
: Commit using conventional commit style (husky will tell you to use it if you haven't 😉)