Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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);
}
}
Loading