Docs/Core concepts

Prices

Loans read prices through one seam: a Reading. An oracle adapter builds a Reading, and a market accepts only Readings from the adapter and the price object it was created with. Every refusal happens in that one place.

The Pyth adapter#

On testnet the adapter reads a Pyth price object and turns its spot and EMA prices into a Reading. read and read_inverse are its public entries; read_inverse returns the same price the other way round, for a market whose loan coin is SUI. The mapping underneath is private, so no one can construct a Reading at a price of their choosing.

The testnet markets read Pyth's SUI/USD feed: read for the USDC and Sui Dollar loan markets, read_inverse for the SUI loan market.

Refusals#

RefusalRuleAbort
StaleSpot and EMA must each be at most 300 seconds old.EStale (1)
WideEach price's confidence interval must be at most 1% of the price.EWideConfidence (2)
Not positiveBoth prices must be above zero.ENonPositive (3)
Bad exponentThe exponent must be negative, at most 18 digits.EBadExponent (4)
Wrong feedA market rejects a Reading from another adapter or another price object.EWrongFeed (5, market)

300 seconds is two beats of Pyth's testnet keeper plus a margin; the 1% bound compares with about 0.1% observed on SUI/USD.

A Reading cannot be stored or copied, so it cannot outlive the transaction whose clock checked it.

Which price is used where#

UsePrice
Borrowing limitThe lower of spot and EMA, so a borrow never counts a spike the average has not seen.
LiquidationOver the line at spot and at EMA.
Write-offWorth less than the debt at both; the payer covers at least the higher value.
Collateral seizedValued at spot.
RepaymentNo price at all.

When the price is stale, the API says so up front: a quote is refused with PRICE_STALE, and loan views carry a PRICE_STALE warning.