Skip to content

Commit

Permalink
Merge pull request #9 from Gearbox-protocol/bounded-price-feed
Browse files Browse the repository at this point in the history
feat: return aggregators from original feed
  • Loading branch information
0xmikko.eth authored Nov 16, 2022
2 parents 8b8c8f8 + e670279 commit 4409ed1
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion contracts/oracles/BoundedPriceFeed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,30 @@
pragma solidity ^0.8.10;

import { AggregatorV3Interface } from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import { AggregatorV2V3Interface } from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol";
import { PERCENTAGE_FACTOR } from "../libraries/PercentageMath.sol";
import { PriceFeedType, IPriceFeedType } from "../interfaces/IPriceFeedType.sol";

// EXCEPTIONS
import { NotImplementedException } from "../interfaces/IErrors.sol";

interface ChainlinkReadableAggregator {
function aggregator() external view returns (address);

function phaseAggregators(uint16 idx)
external
view
returns (AggregatorV2V3Interface);
}

/// @title Price feed with an upper bound on price
/// @notice Used to limit prices on assets that should not rise above
/// a certain level, such as stablecoins and other pegged assets
contract BoundedPriceFeed is AggregatorV3Interface, IPriceFeedType {
contract BoundedPriceFeed is
ChainlinkReadableAggregator,
AggregatorV3Interface,
IPriceFeedType
{
/// @dev Chainlink price feed for the Vault's underlying
AggregatorV3Interface public immutable priceFeed;

Expand Down Expand Up @@ -87,4 +101,21 @@ contract BoundedPriceFeed is AggregatorV3Interface, IPriceFeedType {

answer = _upperBoundValue(answer);
}

/// @dev Returns the current phase's aggregator address
function aggregator() external view returns (address) {
return ChainlinkReadableAggregator(address(priceFeed)).aggregator();
}

/// @dev Returns a phase aggregator by index
function phaseAggregators(uint16 idx)
external
view
returns (AggregatorV2V3Interface)
{
return
ChainlinkReadableAggregator(address(priceFeed)).phaseAggregators(
idx
);
}
}

0 comments on commit 4409ed1

Please sign in to comment.