Skip to content

Keeper

The keeper is a Python service that automates the delta-neutral strategy.

What It Does

  1. Monitors funding rates on Extended DEX
  2. Opens positions when funding is attractive (buy wBTC + short perp)
  3. Collects funding payments hourly
  4. Rebalances delta when drift exceeds threshold
  5. Harvests profits by calling report() on vault
  6. Manages liquidity to ensure withdrawals work
  7. Closes positions when funding turns negative

Strategy State Machine

IDLE ──► ACTIVE ◄──► REBALANCING
  ▲          │
  │          ▼
  └──── CLOSING
StateAction
IDLEWait for positive funding above threshold
ACTIVECollect funding, harvest profits, check delta
REBALANCINGAdjust position to restore delta = 0
CLOSINGUnwind position when funding negative

Configuration

ParameterDefaultDescription
STRATEGY_INTERVAL_SECONDS60Cycle frequency
MIN_FUNDING_RATE_BPS5Min funding to open (0.05%)
REBALANCE_THRESHOLD_BPS500Delta drift trigger (5%)
HARVEST_INTERVAL_CYCLES60Profit report frequency
MAX_LEVERAGE1No leverage

Integrations

Extended DEX

  • REST API for orders and positions
  • SNIP-12 signed orders
  • Hourly funding collection

AVNU

  • Get optimal swap routes
  • Execute multi-hop swaps
  • Slippage protection

Starknet

  • starknet-py for contract calls
  • V3 transactions
  • Custom gas limits for swaps