python sdk for drift protocol v2 jit proxy program
Project description
Python JIT Proxy SDK
QuickStart Guide
- Run
poetry install
in the/python
directory - Add
.env
file in/sdk/examples
with yourRPC_URL
andPRIVATE_KEY
as a byte array - Customize
JitParams
in eithershotgun.py
orsniper.py
- Run
poetry run python -m examples.sniper
orpoetry run python -m examples.shotgun
while in thesdk
directory
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
File details
Details for the file drift_jit_proxy-0.1.2.tar.gz
.
File metadata
- Download URL: drift_jit_proxy-0.1.2.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.10 Linux/6.5.0-1015-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1259e39b6b15a8bbb7dfdc6dc2a25dfeb307cd2ba461fd72c185f736fdea2c35 |
|
MD5 | 604f022b2b7384efba176ea07b79f4d7 |
|
BLAKE2b-256 | 08c1099d181570130c73f168e8e9f66373162d68388d27adbd76d29e5e0b4f57 |
File details
Details for the file drift_jit_proxy-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: drift_jit_proxy-0.1.2-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-1015-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 775d60b71730d9209b1012d38c87ffae8d744b085bb655ce5dd7ea9f77441737 |
|
MD5 | e114617fe81478a42f2f43a533940ae0 |
|
BLAKE2b-256 | 5be008ed31219d93552386cc874a63b1fcef44fc71597aba551202fa5d7dbecc |