CometDocs
Open app
Contents

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

CheckPasses whenApplies to
AgeThe price is at most 25 slots oldEvery reserve
ConfidenceThe interval is within 2% of the priceEvery reserve
Pool priceThe pool’s 5-minute average price is within 3% of the oraclePerps 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.

WaitsGoes through
BorrowDeposit
Withdraw from an account with borrowsRepay
Open or enlarge a range or perpAdd margin
Remove marginClose a range or perp
LiquidateSwap

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.