Git Product home page Git Product logo

driftpy's Introduction

DriftPy

DriftPy is the Python client for the Drift protocol. It allows you to trade and fetch data from Drift using Python.

Read The Documentation

Installation

pip install driftpy

Note: requires Python >= 3.9.

Examples

Arbitrage Trading

Querying and Visualization

Development

  • run git submodule init and git submodule update to get the protocol-v1 codebase

Development Setup

If you want to contribute to DriftPy, follow these steps to get set up:

  1. Install poetry
  2. Install dev dependencies (in local env):
poetry install
  1. Install nox-poetry (note: do not use Poetry to install this, see here)

Testing

  1. Run make test.
  2. Run make lint.

Local Dev

  • run anchor build in drift-core/ with v0.19.0
  • modify drift-core/program pubkeys to match target/deploy/{...}-keypair.json pubkeys (can use solana-keygen pubkey {..}.json view pubkeys) -- for example, for programs/clearing_house/src/lib.rs:
// #[cfg(feature = "mainnet-beta")]
// declare_id!("...");
// #[cfg(not(feature = "mainnet-beta"))]
declare_id!("{...}"); // use `solana-keygen pubkey target/deploy/clearing_house-keypair.json` here 
  • also change clearing-house address in drift-core/Anchor.toml with the same value
[programs.localnet]
clearing_house = "{...}"
  • re-build: anchor build

Local Dev: Clean Up

  • when running tests, you need to kill the validator after each test run

  • you can shutdown the validator by finding its PID with ps aux | grep solana and sending a kill command, kill {PID}

  • example with fish shell below:

pytest -v; bash -c $(kill $(ps aux | grep solana | string split ' ' --no-empty | awk "NR==2"))

Building the docs

Run mkdocs serve to build the docs and serve them locally.

Updating the embedded IDLs

DriftPy ships with IDL files for the user's convenience. These live at src/driftpy/idl if you need to update them.

Releasing a new version of the package

  1. Make sure CHANGELOG.md is updated.
  2. Run bumpversion major|minor|patch to update the version number locally and create a tagged commit.
  3. Run git push origin <version_number> to push the tag to GitHub.
  4. After merging your PR on GitHub, create a new release at https://github.com/drift-labs/driftpy/releases. The CI process will upload a new version of the package to PyPI.

Updating the drift-core subtree

  • This repo pulls in the main Drift repo using git subtree. Follow that linked tutorial if you want to see how it was done.

The short answer: git subtree pull --prefix drift-core drift-protocol mainnet-beta --squash

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.