Skip to main content

Off-chain HIP-2 Hyperliquidity market maker for Hyperliquid spot markets

Project description

pyperliquidity

PyPI version Python 3.11+ License: MIT

A Python implementation of HIP-2 "Hyperliquidity" market-making algorithm. While HIP-2's logic runs fully on-chain, certain spot markets (especially bridged assets) are unable to use this feature. pyperliquidity recovers HIP-2 behavior using an off-chain market maker.

Core concept: Uniswap V2 / infinite-range liquidity pools, but on an order book.

Installation

pip install pyperliquidity

For development:

git clone https://github.com/AlliedToasters/pyperliquidity.git
cd pyperliquidity
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"

Quick Start

  1. Create a config file — copy and edit the example:
cp config.example.toml config.toml

Key parameters in config.toml:

[strategy]
coin = "@1434"          # Spot pair symbol
start_px = 0.01         # Initial price (bottom of the grid)
n_orders = 100          # Number of price levels
order_sz = 1000.0       # Tokens per tranche

[allocation]
allocated_token = 1000.0
allocated_usdc = 500.0
  1. Set environment variables for your Hyperliquid wallet:
export PYPERLIQUIDITY_PRIVATE_KEY="0x..."
export PYPERLIQUIDITY_WALLET="0x..."
  1. Run the market maker:
pyperliquidity run --config config.toml

See config.example.toml for all available parameters including tuning, rate limit, and reconciliation settings.

Architecture

WebSocket Feeds ──► StateManager ──► QuotingEngine ──► OrderDiffer ──► BatchEmitter ──► API
     ▲                (single source      (pure math,     (dead zone +     (budget-aware,   │
     │                 of truth)           no I/O)         level-index      prioritized)     │
     └──────────── orderUpdates / userFills / webData2 ──────────────────────────────────────┘
  • QuotingEngine — pure math, no I/O. Translates inventory position on a geometric price grid into desired orders.
  • OrderDiffer — dead-zone filtering and tolerance checks to minimize unnecessary API calls.
  • BatchEmitter — budget-aware, prioritized order emission that respects Hyperliquid's rate limit model.
  • WsState — WebSocket-first state management with periodic REST reconciliation.

Development

This project uses OpenSpec for spec-driven development. Domain specs live in openspec/specs/.

.venv/bin/pytest              # Run tests
.venv/bin/mypy src/           # Type check
.venv/bin/ruff check src/     # Lint

License

MIT

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

pyperliquidity-0.2.3.tar.gz (141.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyperliquidity-0.2.3-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file pyperliquidity-0.2.3.tar.gz.

File metadata

  • Download URL: pyperliquidity-0.2.3.tar.gz
  • Upload date:
  • Size: 141.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyperliquidity-0.2.3.tar.gz
Algorithm Hash digest
SHA256 d650e90c98ada4391441bb799260af9fc0f24cc608007237f802d60beabadd3a
MD5 caad3e1e70c81b8d441bf1de8020f0c3
BLAKE2b-256 37f9570d6f4f7f5b20ce043b0797b5d1847fcb0548d09292560135487c4ef294

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyperliquidity-0.2.3.tar.gz:

Publisher: release.yml on AlliedToasters/pyperliquidity

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyperliquidity-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: pyperliquidity-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyperliquidity-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5175316639834869bd4ff6bda8e9dc3b87ba6d0244d0efb12a1a814fde6bb15a
MD5 bc6d5c4adfc0f4cac9f4689b2cabf2fc
BLAKE2b-256 74f8d9018db26a973ff7b45566b53aee9f37a23fafbf074eb31c3aef2f081eab

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyperliquidity-0.2.3-py3-none-any.whl:

Publisher: release.yml on AlliedToasters/pyperliquidity

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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