// SPDX-License-Identifier: MIT pragma solidity ^0.8.30; import {IAmishOracle} from "../../src/interfaces/IAmishOracle.sol"; /// @dev Configurable price feed for tests. Returns one price/timestamp for any token pair, at a fixed /// number of price decimals (Chainlink-style, default 8). contract MockOracle is IAmishOracle { uint256 public price; uint256 public updatedAt; uint8 public priceDecimals; bool public revertOnGetPrice; bool public revertOnDecimals; constructor(uint256 price_, uint256 updatedAt_) { price = price_; updatedAt = updatedAt_; priceDecimals = 8; } function set(uint256 price_, uint256 updatedAt_) external { price = price_; updatedAt = updatedAt_; } function setDecimals(uint8 decimals_) external { priceDecimals = decimals_; } /// @dev Simulate a dead adapter: make the selected calls revert outright (harder failure than a /// stale timestamp, which {set} can already express). function setReverts(bool getPrice_, bool decimals_) external { revertOnGetPrice = getPrice_; revertOnDecimals = decimals_; } function decimals() external view returns (uint8) { if (revertOnDecimals) revert("MockOracle: decimals dead"); return priceDecimals; } function getPrice(address, address) external view returns (uint256, uint256) { if (revertOnGetPrice) revert("MockOracle: feed dead"); return (price, updatedAt); } }