Skip to main content

Lending oracles

Lending markets that accept yb-LP shares as collateral need a price for one share. A separate set of contracts, the lending oracles, gives that price. The sections below describe how each lending oracle prices a share and where to find its address.

LEVAMM, the market's leveraged automated market maker, reads a different contract: the LP oracle, CryptopoolLPOracle.vy. The lending oracles are not part of the rebalancing path.

YBLendingOracle​

YBLendingOracle is a stateless contract. It computes the USD or asset price of one yb-LP share. It reads these inputs:

  • The Curve pool:
    • price_oracle, the pool's own exponential moving average (EMA) of trade prices.
    • price_scale, the pool's internal price.
    • virtual_price, the pool's growth accounting per LP token.
    • D, the pool invariant.
  • The crvUSD aggregator, Curve's crvUSD/USD price contract.
  • The LEVAMM state.

YBLendingOracle values the position at the price that arbitrage moves the LEVAMM to, within the LEVAMM safe-debt limits. When the LEVAMM cannot trade, it uses the balance value that LT.emergency_withdraw pays. LT is the market's vault contract. YBLendingOracle deploys one price() proxy per market.

LlamaLend variant​

For each market, YBLendingOracleLLFactory deploys a variant for LlamaLend, Curve's lending markets. This variant applies an EMA to the Fundamental Value of the yb-LP share. Fundamental Value is the value of one share on the vault's books. One EMA per market serves both the asset price and the USD price. To check the default EMA time, call default_ema_time() on the factory.

Addresses and ENS names​

Do not use older oracle deployments. Newer deployments supersede them.

Contract addresses lists both contracts and the per-market oracles, as does the yb-core repository (docs/oracles_addresses.md). The ENS name oracles.yieldbasis.eth resolves to YBLendingOracle, and oracles-ll.yieldbasis.eth resolves to YBLendingOracleLLFactory.