Python client library for interacting with the Project Serum DEX.
pip install pyserum
from pyserum.connection import get_live_markets, get_token_mints
print("tokens: ")
print(get_token_mints())
print("markets: ")
print(get_live_markets())
The source of truth of the market addresses can be found here.
from pyserum.connection import conn
from pyserum.market import Market
cc = conn("https://api.mainnet-beta.solana.com/")
market_address = "5LgJphS6D5zXwUVPU7eCryDBkyta3AidrJ5vjNU6BcGW" # Address for BTC/USDC
# Load the given market
market = Market.load(cc, market_address)
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.info.price, ask.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.info.price, bid.info.size))
Need help? You can find us on the Serum Discord:
- Install pipenv.
brew install pipenv
- Install dev dependencies.
pipenv install --dev
- Activate the pipenv shell.
pipenv shell
make format
make lint
# Unit tests
make unit-tests
# Integration tests
make int-tests
make notebook
./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.