Skip to main content
Keeper instructions are permissionless operations that maintain protocol health.

Core Keeper Operations

fill_perp_order

Fills a maker order against a taker.
pub fn fill_perp_order(
    ctx: Context<FillOrder>,
    order_id: Option<u32>,
    // ... fill params
) -> Result<()>

liquidate_perp

Liquidates an undercollateralized position.
pub fn liquidate_perp(
    ctx: Context<LiquidatePerp>,
    market_index: u16,
    // ... liquidation params
) -> Result<()>

update_funding_rate

Updates funding rate for a market.
pub fn update_funding_rate(
    ctx: Context<UpdateFundingRate>,
    market_index: u16,
) -> Result<()>

settle_pnl

Settles realized PnL for a position.

Keeper Rewards

Keepers earn rewards for performing these operations:
  • Order fills: Maker rebates
  • Liquidations: Liquidation fees
  • Funding updates: Protocol rewards
Anyone can run a keeper bot. See keeper-bots-v2 for examples.

Liquidation Bot Example

Build a liquidation bot

Keeper Bots Repo

Example bot implementations

Build docs developers (and LLMs) love