Skip to content

Commit

Permalink
Merge branch 'master' into wphan/fix_place_order_accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
soundsonacid authored Jul 22, 2024
2 parents 6424275 + 8833d1d commit 3cb96ae
Show file tree
Hide file tree
Showing 81 changed files with 3,861 additions and 9,897 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.47
current_version = 0.7.70
commit = True
tag = True
tag_name = {new_version}
Expand Down
107 changes: 107 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: CI
on:
push:
branches:
- master
pull_request:
branches: [master]

defaults:
run:
shell: bash
working-directory: .

jobs:
black:
runs-on: ubicloud
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black
- name: Run Black
run: black --check .

tests:
runs-on: ubicloud
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10.10'
- name: Install and configure Poetry
uses: snok/[email protected]
with:
version: 1.4.2
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Install dependencies
run: poetry install
- name: Install pytest
run: poetry run pip install pytest
- name: Run tests
env:
MAINNET_RPC_ENDPOINT: ${{ secrets.MAINNET_RPC_ENDPOINT }}
DEVNET_RPC_ENDPOINT: ${{ secrets.DEVNET_RPC_ENDPOINT }}
run: poetry run bash scripts/ci.sh

bump-version:
runs-on: ubicloud
needs: [black, tests]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10.10'
- name: Run version bump script
run: python scripts/bump.py
- name: Commit changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add pyproject.toml src/driftpy/__init__.py .bumpversion.cfg
git commit -m "Bump version [skip ci]"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

release:
runs-on: ubicloud
needs: [bump-version]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Pull Latest Changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git pull
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10.10'
- name: Install and configure Poetry
uses: snok/[email protected]
with:
version: 1.4.2
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- run: poetry build
- run: poetry publish --username=__token__ --password=${{ secrets.PYPI_TOKEN }}
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 23.11.0
rev: 24.4.2
hooks:
- id: black
language_version: python3.10
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,8 @@ Fix bug where `DriftClient.send_ixs` wasn't properly awaited

## [0.7.47] - 2024-4-9

Add `UserStatsMap`
Add `UserStatsMap`

## [0.7.49] - 2024-5-15

Update `anchorpy`, `anchorpy-core`, `solana`, `jito-searcher-client` to latest versions
11 changes: 0 additions & 11 deletions Makefile

This file was deleted.

20 changes: 2 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,6 @@ If you intend to use `AccountSubscriptionConfig("demo)`, you *must* call `get_ma

`bash setup.sh`


## Building the docs

Local Docs: `mkdocs serve`

Updating public docs: `poetry run mkdocs gh-deploy --force`

## Releasing a new version of the package

- `python new_release.py`
- 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](https://pypi.org/project/driftpy/))

# Development

Ensure correct python version (using pyenv is recommended):
Expand All @@ -85,10 +72,7 @@ poetry install

Run tests:
```
poetry run bash test.sh
poetry run bash test-scripts/integration_test.sh
poetry run bash test-scripts/math_tests.sh
```

Run Acceptance Tests
```
poetry run bash acceptance_test.sh
```
1 change: 0 additions & 1 deletion acceptance_test.sh

This file was deleted.

41 changes: 28 additions & 13 deletions examples/fetch_all_markets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,42 @@
from driftpy.drift_client import DriftClient, AccountSubscriptionConfig
import asyncio


async def get_all_market_names():
env = 'mainnet-beta' # 'devnet'
rpc = 'https://api.mainnet-beta.solana.com' # todo replace
kp = Keypair() # random wallet
env = "mainnet-beta" # 'devnet'
rpc = "https://api.mainnet-beta.solana.com" # todo replace
kp = Keypair() # random wallet
wallet = Wallet(kp)
connection = AsyncClient(rpc)
provider = Provider(connection, wallet)
drift_client = DriftClient(provider.connection, provider.wallet, env.split('-')[0], account_subscription=AccountSubscriptionConfig("cached"))

all_perps_markets = await drift_client.program.account['PerpMarket'].all()
sorted_all_perps_markets = sorted(all_perps_markets, key=lambda x: x.account.market_index)
result_perp = [bytes(x.account.name).decode('utf-8').strip() for x in sorted_all_perps_markets]
drift_client = DriftClient(
provider.connection,
provider.wallet,
env.split("-")[0],
account_subscription=AccountSubscriptionConfig("cached"),
)

all_perps_markets = await drift_client.program.account["PerpMarket"].all()
sorted_all_perps_markets = sorted(
all_perps_markets, key=lambda x: x.account.market_index
)
result_perp = [
bytes(x.account.name).decode("utf-8").strip() for x in sorted_all_perps_markets
]

all_spot_markets = await drift_client.program.account['SpotMarket'].all()
sorted_all_spot_markets = sorted(all_spot_markets, key=lambda x: x.account.market_index)
result_spot = [bytes(x.account.name).decode('utf-8').strip() for x in sorted_all_spot_markets]
all_spot_markets = await drift_client.program.account["SpotMarket"].all()
sorted_all_spot_markets = sorted(
all_spot_markets, key=lambda x: x.account.market_index
)
result_spot = [
bytes(x.account.name).decode("utf-8").strip() for x in sorted_all_spot_markets
]

result = result_perp + result_spot[1:] # ignore quote spot market index
result = result_perp + result_spot[1:] # ignore quote spot market index
return result

if __name__ == '__main__':

if __name__ == "__main__":
loop = asyncio.new_event_loop()
answer = loop.run_until_complete(get_all_market_names())
print(answer)
26 changes: 0 additions & 26 deletions new_release.py

This file was deleted.

7 changes: 0 additions & 7 deletions noxfile.py

This file was deleted.

1 change: 0 additions & 1 deletion oracle.sh

This file was deleted.

Loading

0 comments on commit 3cb96ae

Please sign in to comment.