MorphoOracle
Inherits: IMorphoOracle
Title: MorphoOracle
Adapts BasketOracle price to Morpho Blue’s oracle scale (24 decimals for USDC/plDXY).
Supports both plDXY-BEAR (direct) and plDXY-BULL (inverse) pricing.
Note: security-contact: contact@plether.com
Constants
BASKET_ORACLE
Source price feed (BasketOracle).
AggregatorV3Interface public immutable BASKET_ORACLE
CAP
Protocol CAP price (8 decimals).
uint256 public immutable CAP
IS_INVERSE
If true, returns CAP - Price (for plDXY-BULL).
bool public immutable IS_INVERSE
STALENESS_TIMEOUT
Maximum age for valid oracle price.
uint256 public constant STALENESS_TIMEOUT = 24 hours
Functions
constructor
Creates Morpho-compatible oracle wrapper.
constructor(
address _basketOracle,
uint256 _cap,
bool _isInverse
) ;
Parameters
| Name | Type | Description |
|---|---|---|
_basketOracle | address | BasketOracle address. |
_cap | uint256 | Protocol CAP (8 decimals, e.g., 2e8 = $2.00). |
_isInverse | bool | True for plDXY-BULL (CAP - Price), false for plDXY-BEAR. |
price
Returns collateral price in Morpho scale (24 decimals for USDC(6)/plDXY(18)).
Morpho expects: 36 + loanDecimals - collateralDecimals = 36 + 6 - 18 = 24. BEAR (IS_INVERSE=false): min(basketPrice, CAP) * CHAINLINK_TO_MORPHO_SCALE. BULL (IS_INVERSE=true): (CAP - basketPrice) * CHAINLINK_TO_MORPHO_SCALE. Returns 1 (not 0) when BULL price would be zero to avoid Morpho division errors.
function price() external view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Price of 1 plDXY token in USDC terms (24 decimals). |
Errors
MorphoOracle__InvalidPrice
Thrown when source oracle returns zero or negative price.
error MorphoOracle__InvalidPrice();
MorphoOracle__StalePrice
Thrown when source oracle data is stale.
error MorphoOracle__StalePrice();
MorphoOracle__ZeroAddress
Thrown when zero address provided to constructor.
error MorphoOracle__ZeroAddress();