From d42d254ba5b48d602f244efc466632ca5f303ed9 Mon Sep 17 00:00:00 2001 From: rbajollari Date: Fri, 10 May 2024 12:50:32 -0400 Subject: [PATCH] Price Feed contract init --- contracts/pricefeed/CloneFactory.sol | 7 ++++--- contracts/pricefeed/PriceFeed.sol | 27 ++++++++++++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/contracts/pricefeed/CloneFactory.sol b/contracts/pricefeed/CloneFactory.sol index 4cf9a78..9607222 100644 --- a/contracts/pricefeed/CloneFactory.sol +++ b/contracts/pricefeed/CloneFactory.sol @@ -22,10 +22,11 @@ contract CloneFactory { /// @notice Create clone of PriceFeed contract and initialize it /// @dev Clone method returns address of created clone - /// @param _initializationData Data to initialize clone with - function createPriceFeed(string calldata _initializationData) external { + /// @param _priceFeedDecimals Amount of decimals a PriceFeed is denominiated in. + /// @param _priceFeedDescription Description of PriceFeed. + function createPriceFeed(uint8 _priceFeedDecimals, string calldata _priceFeedDescription) external { address priceFeedCloneAddress = Clones.clone(implementationAddress); - PriceFeed(priceFeedCloneAddress).initialize(_initializationData); + PriceFeed(priceFeedCloneAddress).initialize(_priceFeedDecimals, _priceFeedDescription); PriceFeedCloneAddresses[msg.sender] = priceFeedCloneAddress; emit PriceFeedCloneCreated(priceFeedCloneAddress); } diff --git a/contracts/pricefeed/PriceFeed.sol b/contracts/pricefeed/PriceFeed.sol index d854b66..a7c0d72 100644 --- a/contracts/pricefeed/PriceFeed.sol +++ b/contracts/pricefeed/PriceFeed.sol @@ -3,27 +3,40 @@ pragma solidity ^0.8.20; import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; +import "../IOjo.sol"; contract PriceFeed is Initializable, AggregatorV3Interface { - string public initializationData; + uint8 public priceFeedDecimals; + + string public priceFeedDescription; + + IOjo public immutable ojo; + + constructor(address ojo_) { + ojo = IOjo(ojo_); + } /// @notice Initialize clone of this contract /// @dev This function is used in place of a constructor in proxy contracts - /// @param _initializationData Data to initialize clone with - function initialize(string calldata _initializationData) external initializer { - initializationData = _initializationData; + /// @param _priceFeedDecimals Amount of decimals a PriceFeed is denominiated in. + /// @param _priceFeedDescription Description of PriceFeed. + function initialize(uint8 _priceFeedDecimals, string calldata _priceFeedDescription) + external + initializer { + priceFeedDecimals = _priceFeedDecimals; + priceFeedDescription = _priceFeedDescription; } function decimals() external view returns (uint8) { - + return priceFeedDecimals; } function description() external view returns (string memory) { - + return priceFeedDescription; } function version() external view returns (uint256) { - + return 1; } function getRoundData(uint80 _roundId)