diff --git a/src/adapters/source-adapters/SnapshotSource.sol b/src/adapters/lib/SnapshotSourceLib.sol similarity index 68% rename from src/adapters/source-adapters/SnapshotSource.sol rename to src/adapters/lib/SnapshotSourceLib.sol index 52a00be..2ed6328 100644 --- a/src/adapters/source-adapters/SnapshotSource.sol +++ b/src/adapters/lib/SnapshotSourceLib.sol @@ -1,37 +1,36 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; -import {DiamondRootOval} from "../../DiamondRootOval.sol"; - /** - * @title SnapshotSource contract to be used in conjunction with a source adapter that needs to snapshot historic data. + * @title SnapshotSourceLib library to be used by a source adapter that needs to snapshot historic data. */ -abstract contract SnapshotSource is DiamondRootOval { +library SnapshotSourceLib { // Snapshot records the historical answer at a specific timestamp. struct Snapshot { int256 answer; uint256 timestamp; } - Snapshot[] public snapshots; // Historical answer and timestamp snapshots. - event SnapshotTaken(uint256 snapshotIndex, uint256 indexed timestamp, int256 indexed answer); /** * @notice Returns the latest snapshot data. + * @param snapshots Pointer to source adapter's snapshots array. * @return Snapshot The latest snapshot data. */ - function latestSnapshotData() public view returns (Snapshot memory) { + function latestSnapshotData(Snapshot[] storage snapshots) internal view returns (Snapshot memory) { if (snapshots.length > 0) return snapshots[snapshots.length - 1]; return Snapshot(0, 0); } /** * @notice Snapshot the current source data. + * @param snapshots Pointer to source adapter's snapshots array. + * @param latestAnswer The latest answer from the source. + * @param latestTimestamp The timestamp of the latest answer from the source. */ - function snapshotData() public virtual override { - (int256 answer, uint256 timestamp) = getLatestSourceData(); - Snapshot memory snapshot = Snapshot(answer, timestamp); + function snapshotData(Snapshot[] storage snapshots, int256 latestAnswer, uint256 latestTimestamp) internal { + Snapshot memory snapshot = Snapshot(latestAnswer, latestTimestamp); if (snapshot.timestamp == 0) return; // Should not store invalid data. // We expect source timestamps to be increasing over time, but there is little we can do to recover if source @@ -45,15 +44,20 @@ abstract contract SnapshotSource is DiamondRootOval { emit SnapshotTaken(snapshotIndex, snapshot.timestamp, snapshot.answer); } - function _tryLatestDataAt(uint256 timestamp, uint256 maxTraversal) internal view returns (Snapshot memory) { - (int256 answer, uint256 _timestamp) = getLatestSourceData(); - Snapshot memory latestData = Snapshot(answer, _timestamp); + function _tryLatestDataAt( + Snapshot[] storage snapshots, + int256 latestAnswer, + uint256 latestTimestamp, + uint256 timestamp, + uint256 maxTraversal + ) internal view returns (Snapshot memory) { + Snapshot memory latestData = Snapshot(latestAnswer, latestTimestamp); // In the happy path there have been no source updates since requested time, so we can return the latest data. // We can use timestamp property as it matches the block timestamp of the latest source update. if (latestData.timestamp <= timestamp) return latestData; // Attempt traversing historical snapshot data. This might still be newer or uninitialized. - Snapshot memory historicalData = _searchSnapshotAt(timestamp, maxTraversal); + Snapshot memory historicalData = _searchSnapshotAt(snapshots, timestamp, maxTraversal); // Validate returned data. If it is uninitialized we fallback to returning the current latest round data. if (historicalData.timestamp > 0) return historicalData; @@ -62,7 +66,11 @@ abstract contract SnapshotSource is DiamondRootOval { // Tries finding latest snapshotted data not newer than requested timestamp. Might still return newer data than // requested if exceeded traversal or hold uninitialized data that should be handled by the caller. - function _searchSnapshotAt(uint256 timestamp, uint256 maxTraversal) internal view returns (Snapshot memory) { + function _searchSnapshotAt(Snapshot[] storage snapshots, uint256 timestamp, uint256 maxTraversal) + internal + view + returns (Snapshot memory) + { Snapshot memory snapshot; uint256 traversedSnapshots = 0; uint256 snapshotId = snapshots.length; // Will decrement when entering loop. diff --git a/src/adapters/source-adapters/BoundedUnionSourceAdapter.sol b/src/adapters/source-adapters/BoundedUnionSourceAdapter.sol index 7497c0b..6a245d3 100644 --- a/src/adapters/source-adapters/BoundedUnionSourceAdapter.sol +++ b/src/adapters/source-adapters/BoundedUnionSourceAdapter.sol @@ -9,7 +9,6 @@ import {IPyth} from "../../interfaces/pyth/IPyth.sol"; import {ChainlinkSourceAdapter} from "./ChainlinkSourceAdapter.sol"; import {ChronicleMedianSourceAdapter} from "./ChronicleMedianSourceAdapter.sol"; import {PythSourceAdapter} from "./PythSourceAdapter.sol"; -import {SnapshotSource} from "./SnapshotSource.sol"; /** * @title BoundedUnionSourceAdapter contract to read data from multiple sources and return the newest, contingent on it @@ -58,7 +57,7 @@ abstract contract BoundedUnionSourceAdapter is /** * @notice Snapshots is a no-op for this adapter as its never used. */ - function snapshotData() public override(ChainlinkSourceAdapter, SnapshotSource) {} + function snapshotData() public override(ChainlinkSourceAdapter, ChronicleMedianSourceAdapter, PythSourceAdapter) {} /** * @notice Tries getting latest data as of requested timestamp. Note that for all historic lookups we simply return diff --git a/src/adapters/source-adapters/ChronicleMedianSourceAdapter.sol b/src/adapters/source-adapters/ChronicleMedianSourceAdapter.sol index c4049ed..f0bc7c3 100644 --- a/src/adapters/source-adapters/ChronicleMedianSourceAdapter.sol +++ b/src/adapters/source-adapters/ChronicleMedianSourceAdapter.sol @@ -1,16 +1,19 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; -import {SnapshotSource} from "./SnapshotSource.sol"; +import {DiamondRootOval} from "../../DiamondRootOval.sol"; +import {SnapshotSourceLib} from "../lib/SnapshotSourceLib.sol"; import {IMedian} from "../../interfaces/chronicle/IMedian.sol"; import {SafeCast} from "openzeppelin-contracts/contracts/utils/math/SafeCast.sol"; /** * @title ChronicleMedianSourceAdapter contract to read data from Chronicle and standardize it for Oval. */ -abstract contract ChronicleMedianSourceAdapter is SnapshotSource { +abstract contract ChronicleMedianSourceAdapter is DiamondRootOval { IMedian public immutable CHRONICLE_SOURCE; + SnapshotSourceLib.Snapshot[] public chronicleMedianSnapshots; // Historical answer and timestamp snapshots. + event SourceSet(address indexed sourceOracle); constructor(IMedian _chronicleSource) { @@ -19,6 +22,14 @@ abstract contract ChronicleMedianSourceAdapter is SnapshotSource { emit SourceSet(address(_chronicleSource)); } + /** + * @notice Snapshot the current source data. + */ + function snapshotData() public virtual override { + (int256 latestAnswer, uint256 latestTimestamp) = ChronicleMedianSourceAdapter.getLatestSourceData(); + SnapshotSourceLib.snapshotData(chronicleMedianSnapshots, latestAnswer, latestTimestamp); + } + /** * @notice Returns the latest data from the source. * @dev The standard chronicle implementation will revert if the latest answer is not valid when calling the read @@ -33,7 +44,7 @@ abstract contract ChronicleMedianSourceAdapter is SnapshotSource { /** * @notice Tries getting latest data as of requested timestamp. If this is not possible, returns the earliest data * available past the requested timestamp within provided traversal limitations. - * @dev Chronicle does not support historical lookups so this uses SnapshotSource to get historic data. + * @dev Chronicle does not support historical lookups so this uses SnapshotSourceLib to get historic data. * @param timestamp The timestamp to try getting latest data at. * @param maxTraversal The maximum number of rounds to traverse when looking for historical data. * @return answer The answer as of requested timestamp, or earliest available data if not available, in 18 decimals. @@ -46,7 +57,10 @@ abstract contract ChronicleMedianSourceAdapter is SnapshotSource { override returns (int256, uint256) { - Snapshot memory snapshot = _tryLatestDataAt(timestamp, maxTraversal); + (int256 latestAnswer, uint256 latestTimestamp) = ChronicleMedianSourceAdapter.getLatestSourceData(); + SnapshotSourceLib.Snapshot memory snapshot = SnapshotSourceLib._tryLatestDataAt( + chronicleMedianSnapshots, latestAnswer, latestTimestamp, timestamp, maxTraversal + ); return (snapshot.answer, snapshot.timestamp); } } diff --git a/src/adapters/source-adapters/OSMSourceAdapter.sol b/src/adapters/source-adapters/OSMSourceAdapter.sol index f53d73e..dcff97c 100644 --- a/src/adapters/source-adapters/OSMSourceAdapter.sol +++ b/src/adapters/source-adapters/OSMSourceAdapter.sol @@ -1,19 +1,22 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; -import {SnapshotSource} from "./SnapshotSource.sol"; +import {DiamondRootOval} from "../../DiamondRootOval.sol"; +import {SnapshotSourceLib} from "../lib/SnapshotSourceLib.sol"; import {IOSM} from "../../interfaces/makerdao/IOSM.sol"; /** * @title OSMSourceAdapter contract to read data from MakerDAO OSM and standardize it for Oval. */ -abstract contract OSMSourceAdapter is SnapshotSource { +abstract contract OSMSourceAdapter is DiamondRootOval { IOSM public immutable osmSource; // MakerDAO performs decimal conversion in collateral adapter contracts, so all oracle prices are expected to have // 18 decimals and we can skip decimal conversion. uint8 public constant decimals = 18; + SnapshotSourceLib.Snapshot[] public osmSnapshots; // Historical answer and timestamp snapshots. + event SourceSet(address indexed sourceOracle); constructor(IOSM source) { @@ -22,6 +25,14 @@ abstract contract OSMSourceAdapter is SnapshotSource { emit SourceSet(address(source)); } + /** + * @notice Snapshot the current source data. + */ + function snapshotData() public virtual override { + (int256 latestAnswer, uint256 latestTimestamp) = OSMSourceAdapter.getLatestSourceData(); + SnapshotSourceLib.snapshotData(osmSnapshots, latestAnswer, latestTimestamp); + } + /** * @notice Returns the latest data from the source. * @return answer The latest answer in 18 decimals. @@ -34,14 +45,16 @@ abstract contract OSMSourceAdapter is SnapshotSource { /** * @notice Tries getting latest data as of requested timestamp. If this is not possible, returns the earliest data * available past the requested timestamp within provided traversal limitations. - * @dev OSM does not support historical lookups so this uses SnapshotSource to get historic data. + * @dev OSM does not support historical lookups so this uses SnapshotSourceLib to get historic data. * @param timestamp The timestamp to try getting latest data at. * @param maxTraversal The maximum number of rounds to traverse when looking for historical data. * @return answer The answer as of requested timestamp, or earliest available data if not available, in 18 decimals. * @return updatedAt The timestamp of the answer. */ function tryLatestDataAt(uint256 timestamp, uint256 maxTraversal) public view override returns (int256, uint256) { - Snapshot memory snapshot = _tryLatestDataAt(timestamp, maxTraversal); + (int256 latestAnswer, uint256 latestTimestamp) = OSMSourceAdapter.getLatestSourceData(); + SnapshotSourceLib.Snapshot memory snapshot = + SnapshotSourceLib._tryLatestDataAt(osmSnapshots, latestAnswer, latestTimestamp, timestamp, maxTraversal); return (snapshot.answer, snapshot.timestamp); } } diff --git a/src/adapters/source-adapters/PythSourceAdapter.sol b/src/adapters/source-adapters/PythSourceAdapter.sol index c9e0f2d..a8012dc 100644 --- a/src/adapters/source-adapters/PythSourceAdapter.sol +++ b/src/adapters/source-adapters/PythSourceAdapter.sol @@ -2,16 +2,19 @@ pragma solidity 0.8.17; import {IPyth} from "../../interfaces/pyth/IPyth.sol"; -import {SnapshotSource} from "./SnapshotSource.sol"; +import {DiamondRootOval} from "../../DiamondRootOval.sol"; +import {SnapshotSourceLib} from "../lib/SnapshotSourceLib.sol"; import {DecimalLib} from "../lib/DecimalLib.sol"; /** * @title PythSourceAdapter contract to read data from Pyth and standardize it for Oval. */ -abstract contract PythSourceAdapter is SnapshotSource { +abstract contract PythSourceAdapter is DiamondRootOval { IPyth public immutable PYTH_SOURCE; bytes32 public immutable PYTH_PRICE_ID; + SnapshotSourceLib.Snapshot[] public pythSnapshots; // Historical answer and timestamp snapshots. + event SourceSet(address indexed sourceOracle, bytes32 indexed pythPriceId); constructor(IPyth _pyth, bytes32 _pythPriceId) { @@ -21,6 +24,14 @@ abstract contract PythSourceAdapter is SnapshotSource { emit SourceSet(address(_pyth), _pythPriceId); } + /** + * @notice Snapshot the current source data. + */ + function snapshotData() public virtual override { + (int256 latestAnswer, uint256 latestTimestamp) = PythSourceAdapter.getLatestSourceData(); + SnapshotSourceLib.snapshotData(pythSnapshots, latestAnswer, latestTimestamp); + } + /** * @notice Returns the latest data from the source. * @return answer The latest answer in 18 decimals. @@ -34,7 +45,7 @@ abstract contract PythSourceAdapter is SnapshotSource { /** * @notice Tries getting latest data as of requested timestamp. If this is not possible, returns the earliest data * available past the requested timestamp within provided traversal limitations. - * @dev Pyth does not support historical lookups so this uses SnapshotSource to get historic data. + * @dev Pyth does not support historical lookups so this uses SnapshotSourceLib to get historic data. * @param timestamp The timestamp to try getting latest data at. * @param maxTraversal The maximum number of rounds to traverse when looking for historical data. * @return answer The answer as of requested timestamp, or earliest available data if not available, in 18 decimals. @@ -47,7 +58,9 @@ abstract contract PythSourceAdapter is SnapshotSource { override returns (int256, uint256) { - Snapshot memory snapshot = _tryLatestDataAt(timestamp, maxTraversal); + (int256 latestAnswer, uint256 latestTimestamp) = PythSourceAdapter.getLatestSourceData(); + SnapshotSourceLib.Snapshot memory snapshot = + SnapshotSourceLib._tryLatestDataAt(pythSnapshots, latestAnswer, latestTimestamp, timestamp, maxTraversal); return (snapshot.answer, snapshot.timestamp); } diff --git a/src/adapters/source-adapters/UnionSourceAdapter.sol b/src/adapters/source-adapters/UnionSourceAdapter.sol index 76a25d0..2b7513d 100644 --- a/src/adapters/source-adapters/UnionSourceAdapter.sol +++ b/src/adapters/source-adapters/UnionSourceAdapter.sol @@ -7,7 +7,6 @@ import {IPyth} from "../../interfaces/pyth/IPyth.sol"; import {ChainlinkSourceAdapter} from "./ChainlinkSourceAdapter.sol"; import {ChronicleMedianSourceAdapter} from "./ChronicleMedianSourceAdapter.sol"; import {PythSourceAdapter} from "./PythSourceAdapter.sol"; -import {SnapshotSource} from "./SnapshotSource.sol"; /** * @title UnionSourceAdapter contract to read data from multiple sources and return the newest. @@ -45,8 +44,9 @@ abstract contract UnionSourceAdapter is ChainlinkSourceAdapter, ChronicleMedianS /** * @notice Snapshots data from all sources that require it. */ - function snapshotData() public override(ChainlinkSourceAdapter, SnapshotSource) { - SnapshotSource.snapshotData(); + function snapshotData() public override(ChainlinkSourceAdapter, ChronicleMedianSourceAdapter, PythSourceAdapter) { + ChronicleMedianSourceAdapter.snapshotData(); + PythSourceAdapter.snapshotData(); } /** diff --git a/src/adapters/source-adapters/UniswapAnchoredViewSourceAdapter.sol b/src/adapters/source-adapters/UniswapAnchoredViewSourceAdapter.sol index 0ebe586..0d41b64 100644 --- a/src/adapters/source-adapters/UniswapAnchoredViewSourceAdapter.sol +++ b/src/adapters/source-adapters/UniswapAnchoredViewSourceAdapter.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; +import {DiamondRootOval} from "../../DiamondRootOval.sol"; import {DecimalLib} from "../lib/DecimalLib.sol"; -import {SnapshotSource} from "./SnapshotSource.sol"; +import {SnapshotSourceLib} from "../lib/SnapshotSourceLib.sol"; import {IAggregatorV3Source} from "../../interfaces/chainlink/IAggregatorV3Source.sol"; import {IUniswapAnchoredView} from "../../interfaces/compound/IUniswapAnchoredView.sol"; import {IValidatorProxy} from "../../interfaces/compound/IValidatorProxy.sol"; @@ -11,13 +12,15 @@ import {IValidatorProxy} from "../../interfaces/compound/IValidatorProxy.sol"; * @title UniswapAnchoredViewSourceAdapter contract to read data from UniswapAnchoredView and standardize it for Oval. * */ -abstract contract UniswapAnchoredViewSourceAdapter is SnapshotSource { +abstract contract UniswapAnchoredViewSourceAdapter is DiamondRootOval { IUniswapAnchoredView public immutable UNISWAP_ANCHORED_VIEW; address public immutable C_TOKEN; uint8 public immutable SOURCE_DECIMALS; IAggregatorV3Source public aggregator; + SnapshotSourceLib.Snapshot[] public uniswapAnchoredViewSnapshots; // Historical answer and timestamp snapshots. + event SourceSet(address indexed sourceOracle, address indexed cToken, uint8 indexed sourceDecimals); event AggregatorSet(address indexed aggregator); @@ -51,6 +54,14 @@ abstract contract UniswapAnchoredViewSourceAdapter is SnapshotSource { emit AggregatorSet(current); } + /** + * @notice Snapshot the current source data. + */ + function snapshotData() public virtual override { + (int256 latestAnswer, uint256 latestTimestamp) = UniswapAnchoredViewSourceAdapter.getLatestSourceData(); + SnapshotSourceLib.snapshotData(uniswapAnchoredViewSnapshots, latestAnswer, latestTimestamp); + } + /** * @notice Returns the latest data from the source. * @return answer The latest answer in 18 decimals. @@ -65,14 +76,17 @@ abstract contract UniswapAnchoredViewSourceAdapter is SnapshotSource { /** * @notice Tries getting latest data as of requested timestamp. If this is not possible, returns the earliest data * available past the requested timestamp within provided traversal limitations. - * @dev UniswapAnchoredView does not support historical lookups so this uses SnapshotSource to get historic data. + * @dev UniswapAnchoredView does not support historical lookups so this uses SnapshotSourceLib to get historic data. * @param timestamp The timestamp to try getting latest data at. * @param maxTraversal The maximum number of rounds to traverse when looking for historical data. * @return answer The answer as of requested timestamp, or earliest available data if not available, in 18 decimals. * @return updatedAt The timestamp of the answer. */ function tryLatestDataAt(uint256 timestamp, uint256 maxTraversal) public view override returns (int256, uint256) { - Snapshot memory snapshot = _tryLatestDataAt(timestamp, maxTraversal); + (int256 latestAnswer, uint256 latestTimestamp) = UniswapAnchoredViewSourceAdapter.getLatestSourceData(); + SnapshotSourceLib.Snapshot memory snapshot = SnapshotSourceLib._tryLatestDataAt( + uniswapAnchoredViewSnapshots, latestAnswer, latestTimestamp, timestamp, maxTraversal + ); return (snapshot.answer, snapshot.timestamp); } } diff --git a/test/mocks/MockSnapshotSourceAdapter.sol b/test/mocks/MockSnapshotSourceAdapter.sol index 76b2413..d699fdb 100644 --- a/test/mocks/MockSnapshotSourceAdapter.sol +++ b/test/mocks/MockSnapshotSourceAdapter.sol @@ -1,9 +1,10 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.17; -import {SnapshotSource} from "../../src/adapters/source-adapters/SnapshotSource.sol"; +import {SnapshotSourceLib} from "../../src/adapters/lib/SnapshotSourceLib.sol"; +import {DiamondRootOval} from "../../src/DiamondRootOval.sol"; -abstract contract MockSnapshotSourceAdapter is SnapshotSource { +abstract contract MockSnapshotSourceAdapter is DiamondRootOval { struct SourceData { int256 answer; uint256 timestamp; @@ -11,10 +12,17 @@ abstract contract MockSnapshotSourceAdapter is SnapshotSource { SourceData[] public sourceRounds; + SnapshotSourceLib.Snapshot[] public mockSnapshots; + function publishSourceData(int256 answer, uint256 timestamp) public { sourceRounds.push(SourceData(answer, timestamp)); } + function snapshotData() public virtual override { + (int256 latestAnswer, uint256 latestTimestamp) = MockSnapshotSourceAdapter.getLatestSourceData(); + SnapshotSourceLib.snapshotData(mockSnapshots, latestAnswer, latestTimestamp); + } + function getLatestSourceData() public view virtual override returns (int256, uint256) { SourceData memory latestData = _latestSourceData(); return (latestData.answer, latestData.timestamp); @@ -27,10 +35,17 @@ abstract contract MockSnapshotSourceAdapter is SnapshotSource { override returns (int256, uint256) { - SnapshotSource.Snapshot memory latestData = _tryLatestDataAt(timestamp, maxTraversal); + (int256 latestAnswer, uint256 latestTimestamp) = MockSnapshotSourceAdapter.getLatestSourceData(); + SnapshotSourceLib.Snapshot memory latestData = + SnapshotSourceLib._tryLatestDataAt(mockSnapshots, latestAnswer, latestTimestamp, timestamp, maxTraversal); return (latestData.answer, latestData.timestamp); } + function latestSnapshotData() public view returns (SnapshotSourceLib.Snapshot memory) { + if (mockSnapshots.length > 0) return mockSnapshots[mockSnapshots.length - 1]; + return SnapshotSourceLib.Snapshot(0, 0); + } + function _latestSourceData() internal view returns (SourceData memory) { if (sourceRounds.length > 0) return sourceRounds[sourceRounds.length - 1]; return SourceData(0, 0); diff --git a/test/unit/SnapshotSource.SnapshotData.sol b/test/unit/SnapshotSource.SnapshotData.sol index 1e5cdbf..a87fab6 100644 --- a/test/unit/SnapshotSource.SnapshotData.sol +++ b/test/unit/SnapshotSource.SnapshotData.sol @@ -5,6 +5,7 @@ import {CommonTest} from "../Common.sol"; import {MockSnapshotSourceAdapter} from "../mocks/MockSnapshotSourceAdapter.sol"; import {Oval} from "../../src/Oval.sol"; import {BaseController} from "../../src/controllers/BaseController.sol"; +import {SnapshotSourceLib} from "../../src/adapters/lib/SnapshotSourceLib.sol"; contract TestSnapshotSource is MockSnapshotSourceAdapter, Oval, BaseController {} @@ -21,10 +22,10 @@ contract SnapshotSourceSnapshotDataTest is CommonTest { // Verify that the snapshotting did not store any data (snapshots array is empty). vm.expectRevert(); - snapshotSource.snapshots(0); + snapshotSource.mockSnapshots(0); // latestSnapshotData should return uninitialized data. - MockSnapshotSourceAdapter.Snapshot memory snapshot = snapshotSource.latestSnapshotData(); + SnapshotSourceLib.Snapshot memory snapshot = snapshotSource.latestSnapshotData(); assertTrue(snapshot.answer == 0 && snapshot.timestamp == 0); } @@ -34,7 +35,7 @@ contract SnapshotSourceSnapshotDataTest is CommonTest { snapshotSource.snapshotData(); // Verify snapshotted data. - MockSnapshotSourceAdapter.Snapshot memory snapshot = snapshotSource.latestSnapshotData(); + SnapshotSourceLib.Snapshot memory snapshot = snapshotSource.latestSnapshotData(); assertTrue(snapshot.answer == 100 && snapshot.timestamp == 1000); } @@ -45,7 +46,7 @@ contract SnapshotSourceSnapshotDataTest is CommonTest { snapshotSource.snapshotData(); // Verify the latest data got snapshotted. - MockSnapshotSourceAdapter.Snapshot memory snapshot = snapshotSource.latestSnapshotData(); + SnapshotSourceLib.Snapshot memory snapshot = snapshotSource.latestSnapshotData(); assertTrue(snapshot.answer == 200 && snapshot.timestamp == 2000); } @@ -55,11 +56,11 @@ contract SnapshotSourceSnapshotDataTest is CommonTest { snapshotSource.snapshotData(); // Verify snapshotted data. - MockSnapshotSourceAdapter.Snapshot memory snapshot = snapshotSource.latestSnapshotData(); + SnapshotSourceLib.Snapshot memory snapshot = snapshotSource.latestSnapshotData(); assertTrue(snapshot.answer == 100 && snapshot.timestamp == 1000); // The first snapshots element should match the latest snapshot data. - (int256 snapshotAnswer, uint256 snapshotTimestamp) = snapshotSource.snapshots(0); + (int256 snapshotAnswer, uint256 snapshotTimestamp) = snapshotSource.mockSnapshots(0); assertTrue(snapshotAnswer == 100 && snapshotTimestamp == 1000); // Publish and snapshot the same source data again. @@ -68,7 +69,7 @@ contract SnapshotSourceSnapshotDataTest is CommonTest { // Verify that the snapshotting did not store any new data (snapshots array still holds one element). vm.expectRevert(); - snapshotSource.snapshots(1); + snapshotSource.mockSnapshots(1); // latestSnapshotData should return the same data. snapshot = snapshotSource.latestSnapshotData();