Order Settlement

Pyth and Keepers

Orders are settled on-demand by the Pyth Network. Pyth is a network of nodes and global trading venues that makes real-time price data available on-chain. Keepers, which anyone can run (see Github), execute orders as they are submitted to CAP's contracts using Pyth prices. For extra security, some Pyth price feeds are bound by Chainlink when available.

How It Works

Market Orders

When you submit a market order, an event is emitted that alerts a keeper that a new order has been submitted and needs a price. The Keeper then proceeds to fetch a real-time price from Pyth for the given market. That price is then submitted to the contracts.

Limit / Stop Orders

When you submit a limit or stop order, the order is stored in the contracts and an event is emitted to alert keepers. Keepers then store that order in their cache and monitors Pyth market prices in real-time. If the market price reaches your order's trigger price, keepers will execute your order.


Keepers also monitor all open positions and their profit and loss (P/L) in real-time. If a position's P/L drops below the market's liquidation threshold, a keeper submits a transaction to liquidate the position. The position's P/L is verified on-chain prior to liquidation.

Price Sources

Pyth sources prices in real-time from the leading venues in each market category. For crypto, that includes top-tier spot exchanges. For foreign exchange, that includes top-tier banks providing institutional grade data performance and reliability.

Several venues are used to source prices in each market category to maximize data availability and speed while minimizing potential downtime.

Keeper Fee

Keepers need ETH to pay for gas on order execution transactions. Keepers receive 5% of the fee of any order they successfully execute.

Front-Running Protection

Since keepers price orders on-demand after they are submitted, they cannot be front-run.

If a given market is supported by Chainlink:

  • orders can be self-executed using Chainlink (after a cooldown period);

  • the submitted Pyth price is bound on-chain by the Chainlink price ± a maximum deviation.

Last updated