Protocol
Oracles
Comet values collateral and debt with Pyth price feeds, and checks each price before a transaction can add leverage.
Prices
Every reserve reads one Pyth feed for its token. A feed publishes a price and a confidence interval, and Comet uses both: collateral is valued at the price minus the confidence, debt at the price plus it.
Health, margin ratios and liquidations all use these oracle prices. A pool’s own price decides only what a swap pays.
Checks
| Check | Passes when | Applies to |
|---|---|---|
| Age | The price is at most 25 slots old | Every reserve |
| Confidence | The interval is within 2% of the price | Every reserve |
| Pool price | The pool’s 5-minute average price is within 3% of the oracle | Perps and leveraged ranges on that pool |
When a check does not pass
Actions that add leverage wait for the next valid price. Actions that reduce it go through.
| Waits | Goes through |
|---|---|
| Borrow | Deposit |
| Withdraw from an account with borrows | Repay |
| Open or enlarge a range or perp | Add margin |
| Remove margin | Close a range or perp |
| Liquidate | Swap |
Entry price and oracle price
A perp’s entry price is the average price of the swap that opened it, fee included. Its margin ratio afterwards is computed from the oracle price, so a position’s first reading sits a little under its opening ratio by the swap’s fee and price impact.