Verified contractPartialMIT
USDYPriceSource
Address0xa873cb7472597d95993e3ff792e1cc433a318dea
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.34
- Same code
1 more contract
Details
- Compiler
- solc 0.8.34+commit.80d5c536
- Language
- solidity
- Optimization
- Yes, 200 runs
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,743,098
- Creation transaction
- 0x8883851bfd…cd794fdae7
project/contracts/strategies/price/USDYPriceSource.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.34;
import {IReceiptPriceSource, CURRENCY_USD} from "../../interfaces/IReceiptPriceSource.sol";
import {IRWADynamicOracle} from "../../external/IRWADynamicOracle.sol";
/**
* @title USDYPriceSource
* @notice {IReceiptPriceSource} adapter for Ondo USDY, backed by the `RWADynamicOracle`.
* @dev Currency: this is a **USDY/USD** source — `base` = the USDY token, `quote` = {CURRENCY_USD}.
* The oracle returns an 18-decimal USD price of one whole USDY, so `fairPriceE18() ==
* oracle.getPrice()` with no scaling. To value USDY in a non-USD vault token V, compose this with a
* USD/V source (in practice a `FixedPriceSource` USD/V = 1e18 to accept par, since no Chainlink feed
* publishes that direction and there is no inverting wrapper) via {ComposedPriceSource} — the strategy
* will only bind a source whose `quote` equals its vault token.
*
* Revert contract: `getPrice()` reverts when the oracle is paused (correctly blocking swaps;
* {GenericSwapStrategy}'s view path falls back to last-good). The oracle derives its value on read,
* so `lastUpdatedAt()` returns `block.timestamp` (register USDY with `maxPriceAge = 0`).
*/
contract USDYPriceSource is IReceiptPriceSource {
/// @notice The Ondo RWADynamicOracle this adapter reads.
IRWADynamicOracle public immutable oracle;
/// @inheritdoc IReceiptPriceSource
address public immutable override base;
error ZeroAddress();
/// @param oracle_ Ondo RWADynamicOracle. @param usdy USDY token address (the `base` currency).
constructor(address oracle_, address usdy) {
if (oracle_ == address(0) || usdy == address(0)) revert ZeroAddress();
oracle = IRWADynamicOracle(oracle_);
base = usdy;
}
/// @inheritdoc IReceiptPriceSource
function quote() external pure returns (address) {
return CURRENCY_USD;
}
/// @inheritdoc IReceiptPriceSource
function fairPriceE18() external view returns (uint256 priceE18) {
return oracle.getPrice();
}
/// @inheritdoc IReceiptPriceSource
function lastUpdatedAt() external view returns (uint256 updatedAt) {
return block.timestamp;
}
}
project/contracts/external/IRWADynamicOracle.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.34;
/**
* @title IRWADynamicOracle
* @notice Minimal interface for Ondo's `RWADynamicOracle` (USDY price), mainnet
* `0xA0219AA5B31e65Bc920B5b6DFb8EdF0988121De0`.
* @dev All prices are USD with 18 decimals (rounded to 8 dp). USDY has 18 decimals, so the returned
* value is directly the fair USD price of one whole USDY in 1e18 fixed point. The price is a
* deterministic daily-compounding step function derived on read, so it is always fresh to the
* current block. `getPrice()`/`getPriceData()` revert ("Pausable: paused") when the oracle is
* paused; `getPriceHistorical()` never reverts and is the correct pause fallback.
*/
interface IRWADynamicOracle {
/// @dev Reverts when the oracle is paused. 18-decimal USD price.
function getPrice() external view returns (uint256 price);
/// @dev price = 18-dec USD; timestamp = block.timestamp (call time). Also reverts when paused.
function getPriceData() external view returns (uint256 price, uint256 timestamp);
/// @dev No pause modifier: never reverts. Returns 0 for timestamps before genesis.
function getPriceHistorical(uint256 timestamp) external view returns (uint256 price);
function paused() external view returns (bool);
}
project/contracts/interfaces/IReceiptPriceSource.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.34;
// Currency sentinel for USD (ISO-4217 code 840), used as `base`/`quote` when a leg is quoted in fiat
// USD rather than a real token (e.g. Ondo's USD-denominated oracle). Real tokens
// use their own address as the currency id.
address constant CURRENCY_USD = 0x0000000000000000000000000000000000000348;
/**
* @title IReceiptPriceSource
* @notice Uniform price-adapter interface consumed by {GenericSwapStrategy} to value a whitelisted
* yield-source receipt token in the strategy's vault-token currency.
*
* @dev One adapter instance is bound to exactly one receipt token. The adapter normalizes every
* heterogeneous upstream feed (Ondo `RWADynamicOracle`, an ERC-4626 `convertToAssets`, …) into
* a single convention:
*
* `fairPriceE18()` = fair value of **1.0 whole receipt token, denominated in the consuming
* strategy's VAULT-TOKEN currency**, scaled by 1e18.
*
* Example (USDT-denominated vault): USDY ~$1.1385 → ~`1.1385e18`.
*
* CURRENCY: the strategy multiplies this price by the receipt balance (decimal scaling only) to
* get vault-token value, so the price MUST already be in the vault token's currency — the adapter
* owns any quote→vault conversion. If an upstream oracle quotes in a different currency than the
* vault token (e.g. a USDC-quoted oracle for a USDT vault) or the vault-token peg must not be
* assumed at par, compose the raw adapter with an FX/peg leg via {ComposedPriceSource} (e.g. an
* explicit {FixedPriceSource} par leg); the strategy itself performs no currency conversion. Note the USDY
* adapter here returns USD-denominated prices and thus assumes USD ≈ vault-token par unless
* composed with a peg feed.
*
* Two consumption modes with different revert contracts:
*
* 1. **Swap path (state-changing, must be safe-but-strict):** the strategy calls `fairPriceE18()`
* and `lastUpdatedAt()` directly. A revert here (e.g. the upstream oracle is paused) correctly
* blocks the operator swap. The strategy additionally enforces freshness (via `lastUpdatedAt`)
* before trading; beyond that the source's price is trusted (no deviation bound).
*
* 2. **View path (`totalExposure`, must NEVER revert):** the strategy wraps `fairPriceE18()` in a
* try/catch and falls back to its own stored last-good price. This is load-bearing: the vault's
* deallocate / harvest / finalizeStrategyRemoval paths all read `totalExposure()` through a
* reverting wrapper, so a reverting price source would brick recovery of even idle USDT.
*
* Adapters therefore SHOULD revert from `fairPriceE18()` only on a genuinely unavailable price
* (paused/stale upstream), never gratuitously, and MUST NOT depend on `msg.sender`.
*/
interface IReceiptPriceSource {
/**
* @notice The currency this source PRICES (the numerator's subject), as a currency id.
* @dev A real token uses its own address; fiat USD uses {CURRENCY_USD}. For a source registered
* against receipt token A this MUST equal A.
*/
function base() external view returns (address);
/**
* @notice The currency this source prices `base` IN (the denominator), as a currency id.
* @dev `fairPriceE18()` returns units of `quote` per 1.0 `base`. For a source bound to a vault whose
* vault token is V this MUST equal V — otherwise the value is in the wrong currency. Compose an
* A/B source with a B/V source (via {ComposedPriceSource}) to obtain an A/V source.
*/
function quote() external view returns (address);
/**
* @notice Fair value of one whole `base` unit expressed in `quote`, scaled to 1e18.
* @dev MUST revert when a fair price cannot be produced (e.g. upstream oracle paused). MUST NOT
* return 0 as a "no data" sentinel — revert instead, so the strategy's fallback logic engages.
* For a source bound to receipt A in a V-denominated vault, `base==A` and `quote==V`, so this is
* the A/V price the strategy needs.
* @return priceE18 `quote`-per-`base` price in 1e18 fixed point.
*/
function fairPriceE18() external view returns (uint256 priceE18);
/**
* @notice Unix timestamp at which the returned price was last known good / last updated upstream.
* @dev For oracles that derive a continuously-fresh value (e.g. Ondo's interpolating
* `RWADynamicOracle`), return `block.timestamp`; the strategy's staleness gate then never trips
* and such a source is trusted for its price, gated only on availability. For a push oracle that
* publishes discrete updates, return the real upstream update time so the strategy can gate stale swaps.
* @return updatedAt Upstream last-updated timestamp.
*/
function lastUpdatedAt() external view returns (uint256 updatedAt);
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": true
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.