Skip to main content

Price oracle

openLend’s only oracle dependency is a price for liquidations, and it is not a feed: each liquidation spawns its own openOracle game between the loan’s two tokens, parameterized by the borrower at request time through OracleParams. The settled price of that game is the only external input to the liquidation outcome.

The game openLend creates

When liquidate() runs, openLend creates the oracle game with the loan’s tokens and the borrower’s chosen parameters:
The liquidator is the initial reporter, and their priceRatio sets the opening price. From there the game runs under normal openOracle rules: anyone can swap against a mispriced side by posting a larger two-sided report, each dispute restarts the settlement timer, and sizes grow by multiplier per round until escalationHalt.

How the settled price is used

The game becomes settleable once settlementTime has passed since the last report without a dispute. openLend’s finalize() then reads the stored game directly; it does not require the oracle’s own settle() call, which separately releases the final reporter’s liquidity and pays the settler reward. The settled price is the ratio of the final report’s amounts. Finalization computes the debt valued in collateral terms and compares it to the threshold:
Debt is measured at finalize time: principal plus the greater of accrued interest and commitment interest, minus interest already paid. When the loan’s maxBaseFee is nonzero, an additional gate applies: the liquidation only finalizes against the borrower when block.basefee <= maxBaseFee * currentAmount1 / originalAmount1. The bound scales up as the game escalates, so a heavily disputed game tolerates a proportionally higher base fee. When the gate fails, the liquidation resolves as failed even if the price implies the position is underwater.

Parameter deep dive

These are set by the borrower at requestBorrow(), and can be replaced by staging new oracle parameters in a refinance, applied when a lender accepts.
uint48
The per-round undisputed window, in seconds. Every dispute restarts it, so total game duration is at least settlementTime and grows with each round. Bounded [120, 14400].
uint24
A window after each report during which nobody can swap against its orders, in seconds. It guarantees each reporter a minimum period before their position can be taken. Must be less than settlementTime.
uint24
A proportional fee charged on each dispute’s swap, 1e7 = 100%. It accrues to the loan’s fee receiver and is split half to the borrower and a quarter each to the lender and liquidator. A higher fee makes taking a mispriced order more expensive, which widens the price error a report can hold before disputing it is profitable. Bounded [0, 1e6].
uint16
Sets the escalation halt: escalationHalt = supplyAmount * escalationFactor / 100. Past the halt, disputes continue but sizes stop growing, so it caps the capital anyone needs to keep playing while also capping how hard the game can punish a persistent manipulator. Bounded [10, 5000], and must be at least initialLiquidity.
uint8
The opening report’s token1 size as a percentage of supplyAmount. It is the capital a liquidator must post on each side, and the starting size a false report must be corrected at, so it sets the floor on both liquidation cost and dispute profitability. Bounded [5, 250].
uint16
Per-round growth of the report’s token1 side, 140 = 1.4x. Each disputer must post this multiple of the previous round, which is what makes sustained delay and manipulation geometrically expensive. Bounded [100, 1000].
uint48
The basefee gate described above, in wei. 0 disables it. A nonzero value shifts gas-spike risk from the borrower to the lender: the borrower cannot be finalized against while defense by dispute is expensive in gas terms, and the lender’s liquidation rights pause for the same period.
uint64
Fixed ETH escrowed by the liquidator at liquidate() time and paid to whoever calls finalize(). It exists so resolution happens promptly once the game settles, since debt keeps accruing until finalization lands.