diff --git a/starter-templates/bring-your-own-data/contracts/src/nav/DecimalAggregatorProxy.sol b/starter-templates/bring-your-own-data/contracts/src/nav/DecimalAggregatorProxy.sol index 5a7a32bb..1da6c6de 100644 --- a/starter-templates/bring-your-own-data/contracts/src/nav/DecimalAggregatorProxy.sol +++ b/starter-templates/bring-your-own-data/contracts/src/nav/DecimalAggregatorProxy.sol @@ -9,18 +9,22 @@ pragma solidity 0.8.26; import {ConfirmedOwner} from "@chainlink/contracts/src/v0.8/shared/access/ConfirmedOwner.sol"; import {ITypeAndVersion} from "@chainlink/contracts/src/v0.8/shared/interfaces/ITypeAndVersion.sol"; +import {ICommonAggregator} from "@chainlink/contracts/src/v0.8/data-feeds/interfaces/ICommonAggregator.sol"; import {IDecimalAggregator} from "@chainlink/contracts/src/v0.8/data-feeds/interfaces/IDecimalAggregator.sol"; +import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol"; + +interface IAggregator is IDecimalAggregator, ICommonAggregator {} /// @title A trusted proxy for updating where current answers are read from /// @notice This contract provides a consistent address for the /// CurrentAnswerInterface but delegates where it reads from to the owner, who is /// trusted to update it. -contract DecimalAggregatorProxy is ITypeAndVersion, ConfirmedOwner { +contract DecimalAggregatorProxy is AggregatorV3Interface, ITypeAndVersion, ConfirmedOwner { string public constant override typeAndVersion = "DecimalAggregatorProxy 1.0.0"; - IDecimalAggregator private s_currentAggregator; - IDecimalAggregator private s_proposedAggregator; + IAggregator private s_currentAggregator; + IAggregator private s_proposedAggregator; event AggregatorProposed(address indexed current, address indexed proposed); event AggregatorConfirmed(address indexed previous, address indexed latest); @@ -31,7 +35,7 @@ contract DecimalAggregatorProxy is ITypeAndVersion, ConfirmedOwner { address aggregatorAddress, address owner ) ConfirmedOwner(owner) { - s_currentAggregator = IDecimalAggregator(aggregatorAddress); + s_currentAggregator = IAggregator(aggregatorAddress); } function latestAnswer() external view returns (int256) { @@ -84,14 +88,6 @@ contract DecimalAggregatorProxy is ITypeAndVersion, ConfirmedOwner { ) { return s_currentAggregator.latestRoundData(); - // NOTE: Enable these lines for testing in local env - // return ( - // 1, - // 1_000_000_000_000, - // 1760731719, - // 1760731720, - // 3 - // ); } /// @notice returns the current aggregator address. @@ -104,6 +100,17 @@ contract DecimalAggregatorProxy is ITypeAndVersion, ConfirmedOwner { return s_currentAggregator.decimals(); } + /// @notice the version number representing the type of aggregator the proxy + /// points to. + function version() external view override returns (uint256 aggregatorVersion) { + return s_currentAggregator.version(); + } + + /// @notice returns the description of the aggregator the proxy points to. + function description() external view returns (string memory aggregatorDescription) { + return s_currentAggregator.description(); + } + /// @notice returns the current proposed aggregator function proposedAggregator() external @@ -116,7 +123,7 @@ contract DecimalAggregatorProxy is ITypeAndVersion, ConfirmedOwner { /// @notice Allows the owner to propose a new address for the aggregator /// @param aggregatorAddress The new address for the aggregator contract function proposeAggregator(address aggregatorAddress) external onlyOwner { - s_proposedAggregator = IDecimalAggregator(aggregatorAddress); + s_proposedAggregator = IAggregator(aggregatorAddress); emit AggregatorProposed( address(s_currentAggregator), aggregatorAddress @@ -133,7 +140,7 @@ contract DecimalAggregatorProxy is ITypeAndVersion, ConfirmedOwner { } address previousAggregator = address(s_currentAggregator); delete s_proposedAggregator; - s_currentAggregator = IDecimalAggregator(aggregatorAddress); + s_currentAggregator = IAggregator(aggregatorAddress); emit AggregatorConfirmed(previousAggregator, aggregatorAddress); } }