Skip to main content

python sdk for drift protocol v2 jit proxy program

Project description

Python JIT Proxy SDK

QuickStart Guide

  1. Run poetry install in the /python directory
  2. Add .env file in /sdk/examples with your RPC_URL and PRIVATE_KEY as a byte array
  3. Customize JitParams in either shotgun.py or sniper.py
  4. Run poetry run python -m examples.sniper or poetry run python -m examples.shotgun while in the sdk 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

drift_jit_proxy-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

drift_jit_proxy-0.1.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file drift_jit_proxy-0.1.0.tar.gz.

File metadata

  • Download URL: drift_jit_proxy-0.1.0.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.2.0-1018-azure

File hashes

Hashes for drift_jit_proxy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9b7154d47dd284c2956119f14e4a2b8fc8b3d5afde2d6b62c13980c719cd35ff
MD5 c8934de1554a14c9f2cd2c647a1b6760
BLAKE2b-256 8d6b76762c4ad2566cf465138b68b6cf60354e91cf6673344286ae9e83a0acd0

See more details on using hashes here.

File details

Details for the file drift_jit_proxy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: drift_jit_proxy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.10 Linux/6.2.0-1018-azure

File hashes

Hashes for drift_jit_proxy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03c0e7d81d5e7ee8ea3a56673f6bd0a4614b166e3c8c92c9e104f3078d9e70cb
MD5 f0975246771e0455e8e47ddcef833d64
BLAKE2b-256 a6eaea3eed4f42e3683da396d129fdd52346bfa41c0dc9162a51669d131fca95

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page