DEXFeedFactory.sol
1 pragma solidity >=0.6.0; 2 pragma experimental ABIEncoderV2; 3 4 import "../deployment/Deployer.sol"; 5 import "../deployment/ManagedContract.sol"; 6 import "../feeds/DEXOracleV1.sol"; 7 import "../feeds/DEXAggregatorV1.sol"; 8 import "../feeds/DEXFeed.sol"; 9 import "../interfaces/IERC20Details.sol"; 10 11 contract DEXFeedFactory is ManagedContract { 12 13 address private exchangeAddr; 14 address private deployerAddress; 15 address private timeProviderAddress; 16 17 function initialize(Deployer deployer) override internal { 18 deployerAddress = address(deployer); 19 timeProviderAddress = deployer.getContractAddress("TimeProvider"); 20 } 21 22 /* 23 Assumes like dexTokenPair is of Uniswap V2 like 24 */ 25 26 function create(address underlying, address stable, address dexTokenPair) external returns (address) { 27 address oracleAddr = address(new DEXOracleV1(deployerAddress, underlying, stable, dexTokenPair)); 28 address aggAddr = address(new DEXAggregatorV1(oracleAddr)); 29 string memory dexUdlSymbol = IERC20Details(underlying).symbol(); 30 string memory feedName = string(abi.encodePacked(dexUdlSymbol, "/", "USD", "-", dexTokenPair)); 31 uint[] memory times; 32 int[] memory prices; 33 address feedAddr = address( 34 new DEXFeed( 35 feedName, 36 underlying, 37 aggAddr, 38 timeProviderAddress, 39 0, 40 times, 41 prices 42 ) 43 ); 44 return feedAddr; 45 } 46 }