python sdk for drift protocol v2 jit proxy program
Project description
Python JIT Proxy SDK
QuickStart Guide
- Run
poetry installin the/pythondirectory - Add
.envfile in/sdk/exampleswith yourRPC_URLandPRIVATE_KEYas a byte array - Customize
JitParamsin eithershotgun.pyorsniper.py - Run
poetry run python -m examples.sniperorpoetry run python -m examples.shotgunwhile in thesdkdirectory
Shotgun vs Sniper
The JitterShotgun will immediately spray transactions when it detects an eligible auction.
It'll try up to 10 times to fulfill the order, retrying if the order doesn't yet cross or the oracle is stale.
The JitterSniper will wait until it detects an order that has a high chance of crossing the JitParams and retry up to 3 times on errors. It won't send transactions immediately like the JitterShotgun does, but will try to determine that the order will cross the bid/ask during the auction before sending a transaction.
How to set up a JitProxyClient and Jitter
This example uses the JitterShotgun, but the same logic follows for the JitterSniper.
However, the JitterSniper also requires a SlotSubscriber in its constructor.
jit_proxy_client = JitProxyClient(
drift_client,
# JIT program ID
Pubkey.from_string("J1TnP8zvVxbtF5KFp5xRmWuvG9McnhzmBd9XGfCyuxFP"),
)
jitter_shotgun = JitterShotgun(drift_client, auction_subscriber, jit_proxy_client, True) # The boolean is logging verbosity, True = verbose.
jit_params = JitParams(
bid=-1_000_000,
ask=1_010_000,
min_position=0,
max_position=2,
price_type=PriceType.Oracle(),
sub_account_id=None,
)
# Add your parameters to the Jitter before subscribing
jitter_shotgun.update_perp_params(0, jit_params)
await jitter_shotgun.subscribe()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file drift_jit_proxy-0.1.6.tar.gz.
File metadata
- Download URL: drift_jit_proxy-0.1.6.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.10 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d1dc9d095985c2b9a6f1ccaf58647c18fa2c5b14a0dea3db2a1d969fc5bf4b6
|
|
| MD5 |
db0c1c2bb9f778efb93df105ec95cb33
|
|
| BLAKE2b-256 |
fc27913c381a360ea92a7eab9a48fc74401cc1e600aa2c9f98f2696f8355079e
|
File details
Details for the file drift_jit_proxy-0.1.6-py3-none-any.whl.
File metadata
- Download URL: drift_jit_proxy-0.1.6-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.10 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
988e15df22c1d2fb0d2ed45fbdabbfe928c5dccd5520166b2b61a3419c43b924
|
|
| MD5 |
ae6eb6ec0be3f72f1ad15bdb6d065c66
|
|
| BLAKE2b-256 |
ba45afae92581051ca99c00a95edee88afe148ac22090b3905ec7a2774d824fc
|