Go to file
Michael Huang a6c0f31f05
Set up code coverage (#38)
* Setup code coverage

* Update main.yml

* Use codecov.yml, add badges and clean up scripts

* Add pytest-cov to dev deps
2020-09-19 19:09:40 -05:00
.github/workflows Set up code coverage (#38) 2020-09-19 19:09:40 -05:00
.vscode Set up repo 2020-08-29 17:28:24 -05:00
notebooks Bump solana to 0.2.0 and add docker-compose.yml 2020-09-10 18:03:44 -05:00
scripts Set up code coverage (#38) 2020-09-19 19:09:40 -05:00
src Refactored state out of market. (#36) 2020-09-19 19:47:56 +08:00
tests Refactored state out of market. (#36) 2020-09-19 19:47:56 +08:00
.codecov.yml Set up code coverage (#38) 2020-09-19 19:09:40 -05:00
.flake8 Set up repo 2020-08-29 17:28:24 -05:00
.gitignore Remove serum-dex dependency from integration tests (#30) 2020-09-13 21:49:18 -05:00
.pydocstyle Set up repo 2020-08-29 17:28:24 -05:00
.pylintrc Added Market Structure. (#8) 2020-08-31 20:52:51 +01:00
LICENSE Initial commit 2020-08-29 16:47:19 -05:00
Makefile Added match and cancel order to market class. 2020-09-15 11:52:19 +08:00
Pipfile Set up code coverage (#38) 2020-09-19 19:09:40 -05:00
Pipfile.lock Set up code coverage (#38) 2020-09-19 19:09:40 -05:00
README.md Set up code coverage (#38) 2020-09-19 19:09:40 -05:00
docker-compose.yml Remove serum-dex dependency from integration tests (#30) 2020-09-13 21:49:18 -05:00
pytest.ini Set up repo 2020-08-29 17:28:24 -05:00
setup.py Set up repo 2020-08-29 17:28:24 -05:00

README.md

ActionsStatus Codecov

PySerum

Python client library for interacting with the Project Serum DEX.

Get Started

from src.market import Market

endpoint = "https://api.mainnet-beta.solana.com/"
market_address = "CAgAeMD7quTdnr6RPa7JySQpjf3irAmefYNdTb6anemq" # Address for BTC/USDC

# Load the given market
market = Market.load(endpoint, market_address, None)
asks = market.load_asks()
# Show all current ask order
print("Ask Orders:")
for ask in asks:
    print("Order id: %d, price: %f, size: %f." % (
          ask.order_id, ask.order_info.price, ask.order_info.size))

print("\n")
# Show all current bid order
print("Bid Orders:")
bids = market.load_bids()
for bid in bids:
    print("Order id: %d, price: %f, size: %f." % (
          bid.order_id, bid.order_info.price, bid.order_info.size))

Market Addresses in Main Net

The source of truth of the market address can be found here. Feel free to open a PR if the following addresses needs modification or addition.

Currency Pair Address
MSRM/USDT H4snTKK9adiU15gP22ErfZYtro3aqR9BTMXiH3AwiUTQ
MSRM/USDC 7kgkDyW7dmyMeP8KFXzbcUZz1R2WHsovDZ7n3ihZuNDS
BTC/USDT 8AcVjMG2LTbpkjNoyq8RwysokqZunkjy3d5JDzxC6BJa
BTC/USDC CAgAeMD7quTdnr6RPa7JySQpjf3irAmefYNdTb6anemq
ETH/USDT HfCZdJ1wfsWKfYP2qyWdXTT5PWAGWFctzFjLH48U1Hsd
ETH/USDC ASKiV944nKg1W9vsf7hf3fTsjawK6DwLwrnB2LH9n61c
SRM/USDT HARFLhSq8nECZk4DVFKvzqXMNMA9a3hjvridGMFizeLa
SRM/USDC 68J6nkWToik6oM9rTatKSR5ibVSykAtzftBUEAvpRsys
FTT/USDT DHDdghmkBhEpReno3tbzBPtsxCt6P3KrMzZvxavTktJt
FTT/USDC FZqrBXz7ADGsmDf1TM9YgysPUfvtG8rJiNUrqDpHc9Au
YFI/USDT 5zu5bTZZvqESAAgFsr12CUMxdQvMrvU9CgvC1GW8vJdf
YFI/USDC FJg9FUtbN3fg3YFbMCFiZKjGh5Bn4gtzxZmtxFzmz9kT
LINK/USDT F5xschQBMpu1gD2q1babYEAVJHR1buj1YazLiXyQNqSW
LINK/USDC 7GZ59DMgJ7D6dfoJTpszPayTRyua9jwcaGJXaRMMF1my

Development

Setup

  1. Install pipenv.
brew install pipenv
  1. Install dev dependencies.
pipenv install --dev
  1. Activate the pipenv shell.
pipenv shell

Lint

make lint

Tests

# Unit tests
make unit-tests
# Integration tests
make int-tests

Using Jupyter Notebook

make notebook

Start Serum in Docker image

./scripts/bootstrap_dex.sh

This will start a docker container with solana image and deploy a serum DEX which you can use for testing.

The market address, program id, and wallet addresses can be found in the new crank.log file after the script runs successfully.