Skip to content

Commit

Permalink
Price Feed contract init
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari committed May 10, 2024
1 parent 39519f7 commit d42d254
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
7 changes: 4 additions & 3 deletions contracts/pricefeed/CloneFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
27 changes: 20 additions & 7 deletions contracts/pricefeed/PriceFeed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d42d254

Please sign in to comment.