From 6933a264fef18822f210c1ba608f18d2a3c884c5 Mon Sep 17 00:00:00 2001 From: Phil Elsasser Date: Fri, 7 Dec 2018 08:54:32 -0700 Subject: [PATCH 1/3] remove MKT token for now --- .../chainlink/MarketContractFactoryChainLink.sol | 8 -------- .../oraclize/MarketContractFactoryOraclize.sol | 9 +-------- .../TestableMarketContractFactoryOraclize.sol | 9 +-------- migrations/2_market_contracts.js | 16 ++++------------ migrations/3_oraclize_contracts.js | 2 -- migrations/4_chainlink_contracts.js | 2 -- 6 files changed, 6 insertions(+), 40 deletions(-) diff --git a/contracts/chainlink/MarketContractFactoryChainLink.sol b/contracts/chainlink/MarketContractFactoryChainLink.sol index 7c671c16..1f516ac2 100644 --- a/contracts/chainlink/MarketContractFactoryChainLink.sol +++ b/contracts/chainlink/MarketContractFactoryChainLink.sol @@ -19,7 +19,6 @@ pragma solidity ^0.4.24; import "./MarketContractChainLink.sol"; import "./OracleHubChainLink.sol"; import "../MarketContractRegistryInterface.sol"; -import "../tokens/MarketToken.sol"; contract MarketContractFactoryChainLink is Ownable { @@ -27,9 +26,6 @@ contract MarketContractFactoryChainLink is Ownable { address public marketContractRegistry; address public oracleHubAddress; - address public MKT_TOKEN_ADDRESS; - MarketToken public MKT_TOKEN; - event MarketContractCreated(address indexed creator, address indexed contractAddress); constructor( @@ -37,8 +33,6 @@ contract MarketContractFactoryChainLink is Ownable { address mktTokenAddress ) public { marketContractRegistry = registryAddress; - MKT_TOKEN_ADDRESS = mktTokenAddress; - MKT_TOKEN = MarketToken(mktTokenAddress); } /// @param contractName viewable name of this contract (BTC/ETH, LTC/ETH, etc) @@ -64,8 +58,6 @@ contract MarketContractFactoryChainLink is Ownable { bytes32 onDemandJobId ) external { - require(MKT_TOKEN.isBalanceSufficientForContractCreation(msg.sender)); // creator must be MKT holder - MarketContractChainLink mktContract = new MarketContractChainLink( contractName, [ diff --git a/contracts/oraclize/MarketContractFactoryOraclize.sol b/contracts/oraclize/MarketContractFactoryOraclize.sol index a2880712..cf1f17e6 100644 --- a/contracts/oraclize/MarketContractFactoryOraclize.sol +++ b/contracts/oraclize/MarketContractFactoryOraclize.sol @@ -18,7 +18,6 @@ pragma solidity ^0.4.24; import "./MarketContractOraclize.sol"; import "../MarketContractRegistryInterface.sol"; -import "../tokens/MarketToken.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; @@ -28,18 +27,13 @@ import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; contract MarketContractFactoryOraclize is Ownable { address public marketContractRegistry; - address public MKT_TOKEN_ADDRESS; - MarketToken public MKT_TOKEN; event MarketContractCreated(address indexed creator, address indexed contractAddress); /// @dev deploys our factory and ties it the a supply registry address /// @param registryAddress - address of our MARKET registry - /// @param mktTokenAddress - MARKET Token address - constructor(address registryAddress, address mktTokenAddress) public { + constructor(address registryAddress) public { marketContractRegistry = registryAddress; - MKT_TOKEN_ADDRESS = mktTokenAddress; - MKT_TOKEN = MarketToken(mktTokenAddress); } /// @dev Deploys a new instance of a market contract and adds it to the whitelist. @@ -63,7 +57,6 @@ contract MarketContractFactoryOraclize is Ownable { string oracleQuery ) external { - require(MKT_TOKEN.isBalanceSufficientForContractCreation(msg.sender)); // creator must be MKT holder MarketContractOraclize mktContract = new MarketContractOraclize( contractName, [ diff --git a/contracts/oraclize/TestableMarketContractFactoryOraclize.sol b/contracts/oraclize/TestableMarketContractFactoryOraclize.sol index 651dd9dc..51d72073 100644 --- a/contracts/oraclize/TestableMarketContractFactoryOraclize.sol +++ b/contracts/oraclize/TestableMarketContractFactoryOraclize.sol @@ -20,7 +20,6 @@ import "./TestableMarketContractOraclize.sol"; import "../MarketContractRegistryInterface.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -import "../tokens/MarketToken.sol"; /// @title TestableMarketContractFactoryOraclize @@ -28,18 +27,13 @@ import "../tokens/MarketToken.sol"; contract TestableMarketContractFactoryOraclize is Ownable { address public marketContractRegistry; - address public MKT_TOKEN_ADDRESS; - MarketToken public MKT_TOKEN; event MarketContractCreated(address indexed creator, address indexed contractAddress); /// @dev deploys our factory and ties it the a supply registry address /// @param registryAddress - address of our MARKET registry - /// @param mktTokenAddress - MARKET Token address - constructor(address registryAddress, address mktTokenAddress) public { + constructor(address registryAddress) public { marketContractRegistry = registryAddress; - MKT_TOKEN_ADDRESS = mktTokenAddress; - MKT_TOKEN = MarketToken(mktTokenAddress); } /// @dev Deploys a new instance of a market contract and adds it to the whitelist. @@ -63,7 +57,6 @@ contract TestableMarketContractFactoryOraclize is Ownable { string oracleQuery ) external { - require(MKT_TOKEN.isBalanceSufficientForContractCreation(msg.sender)); // creator must be MKT holder MarketContractOraclize mktContract = new TestableMarketContractOraclize( contractName, [ diff --git a/migrations/2_market_contracts.js b/migrations/2_market_contracts.js index d999a864..dcf7d817 100644 --- a/migrations/2_market_contracts.js +++ b/migrations/2_market_contracts.js @@ -3,7 +3,6 @@ const CollateralToken = artifacts.require('./tokens/CollateralToken.sol'); const MarketContractOraclize = artifacts.require('./oraclize/TestableMarketContractOraclize.sol'); const MarketCollateralPool = artifacts.require('./MarketCollateralPool.sol'); const MarketContractRegistry = artifacts.require('./MarketContractRegistry.sol'); -const MarketToken = artifacts.require('./tokens/MarketToken.sol'); module.exports = function (deployer, network) { if (network !== 'live') { @@ -14,20 +13,13 @@ module.exports = function (deployer, network) { ); return deployer.deploy(MarketCollateralPool).then(function () { - const marketTokenToLockForTrading = 0; // for testing purposes, require no loc - const marketTokenAmountForContractCreation = 0; //for testing purposes require no balance var gasLimit = web3.eth.getBlock('latest').gasLimit; - return MarketCollateralPool.deployed().then(function () { return deployer - .deploy(MarketToken, marketTokenToLockForTrading, marketTokenAmountForContractCreation) - .then(function () { - return deployer - .deploy(CollateralToken, 'CollateralToken', 'CTK', 10000, 18, { - gas: gasLimit, - from: web3.eth.accounts[0] - }) - }); + .deploy(CollateralToken, 'CollateralToken', 'CTK', 10000, 18, { + gas: gasLimit, + from: web3.eth.accounts[0] + }) }); }); }); diff --git a/migrations/3_oraclize_contracts.js b/migrations/3_oraclize_contracts.js index 9930f0a3..a00c21c4 100644 --- a/migrations/3_oraclize_contracts.js +++ b/migrations/3_oraclize_contracts.js @@ -1,7 +1,6 @@ const MathLib = artifacts.require('./libraries/MathLib.sol'); const CollateralToken = artifacts.require('./tokens/CollateralToken.sol'); const MarketContractRegistry = artifacts.require('./MarketContractRegistry.sol'); -const MarketToken = artifacts.require('./tokens/MarketToken.sol'); const MarketContractFactory = artifacts.require( './oraclize/TestableMarketContractFactoryOraclize.sol' ); @@ -22,7 +21,6 @@ module.exports = function (deployer, network) { .deploy( MarketContractFactory, registryInstance.address, - MarketToken.address, {gas: gasLimit, from: web3.eth.accounts[0]} ) .then(function (factory) { diff --git a/migrations/4_chainlink_contracts.js b/migrations/4_chainlink_contracts.js index 381dfba9..7437c74a 100644 --- a/migrations/4_chainlink_contracts.js +++ b/migrations/4_chainlink_contracts.js @@ -6,7 +6,6 @@ const OracleHub = artifacts.require('./chainlink/OracleHubChainLink.sol'); const CollateralToken = artifacts.require('./tokens/CollateralToken.sol'); const MarketContractRegistry = artifacts.require('./MarketContractRegistry.sol'); -const MarketToken = artifacts.require('./tokens/MarketToken.sol'); module.exports = function (deployer, network) { const gasLimit = web3.eth.getBlock('latest').gasLimit; @@ -20,7 +19,6 @@ module.exports = function (deployer, network) { return deployer.deploy( MarketContractFactory, registry.address, - MarketToken.address, {gas: gasLimit, from: web3.eth.accounts[0]} ).then(function (factory) { return registry.addFactoryAddress(factory.address).then(function () { From 4873de4b16b8d7f35cf24901716c87b248650c52 Mon Sep 17 00:00:00 2001 From: Phil Elsasser Date: Fri, 7 Dec 2018 10:44:10 -0700 Subject: [PATCH 2/3] fixes issues with migrations --- .../MarketContractFactoryChainLink.sol | 3 +- .../TestableMarketContractFactoryOraclize.sol | 13 +++--- migrations/3_oraclize_contracts.js | 45 +++++++++---------- migrations/4_chainlink_contracts.js | 3 +- 4 files changed, 29 insertions(+), 35 deletions(-) diff --git a/contracts/chainlink/MarketContractFactoryChainLink.sol b/contracts/chainlink/MarketContractFactoryChainLink.sol index 1f516ac2..ddbbebc5 100644 --- a/contracts/chainlink/MarketContractFactoryChainLink.sol +++ b/contracts/chainlink/MarketContractFactoryChainLink.sol @@ -29,8 +29,7 @@ contract MarketContractFactoryChainLink is Ownable { event MarketContractCreated(address indexed creator, address indexed contractAddress); constructor( - address registryAddress, - address mktTokenAddress + address registryAddress ) public { marketContractRegistry = registryAddress; } diff --git a/contracts/oraclize/TestableMarketContractFactoryOraclize.sol b/contracts/oraclize/TestableMarketContractFactoryOraclize.sol index 51d72073..d27dbae1 100644 --- a/contracts/oraclize/TestableMarketContractFactoryOraclize.sol +++ b/contracts/oraclize/TestableMarketContractFactoryOraclize.sol @@ -71,10 +71,11 @@ contract TestableMarketContractFactoryOraclize is Ownable { emit MarketContractCreated(msg.sender, mktContract); } - /// @dev allows for the owner to set the desired registry for contract creation. - /// @param registryAddress desired registry address. - function setRegistryAddress(address registryAddress) external onlyOwner { - require(registryAddress != address(0)); - marketContractRegistry = registryAddress; - } + // removing for time being due to OOG when deploying this contract. will fix later! +// /// @dev allows for the owner to set the desired registry for contract creation. +// /// @param registryAddress desired registry address. +// function setRegistryAddress(address registryAddress) external onlyOwner { +// require(registryAddress != address(0)); +// marketContractRegistry = registryAddress; +// } } diff --git a/migrations/3_oraclize_contracts.js b/migrations/3_oraclize_contracts.js index a00c21c4..1d71d20e 100644 --- a/migrations/3_oraclize_contracts.js +++ b/migrations/3_oraclize_contracts.js @@ -10,43 +10,38 @@ const MarketContractFactory = artifacts.require( module.exports = function (deployer, network) { if (network !== 'live') { - const marketContractExpiration = Math.floor(Date.now() / 1000) + 60 * 15; // expires in 15 minutes. var gasLimit = web3.eth.getBlock('latest').gasLimit; - return MarketContractRegistry.deployed().then(function (registryInstance) { - return deployer.link(MathLib, MarketContractFactory).then(function () { - // deploy the factories - return deployer - .deploy( - MarketContractFactory, - registryInstance.address, - {gas: gasLimit, from: web3.eth.accounts[0]} - ) - .then(function (factory) { - return registryInstance.addFactoryAddress(factory.address).then(function () { // white list the factory + deployer.link(MathLib, MarketContractFactory); + return deployer.deploy( + MarketContractFactory, + MarketContractRegistry.address, + {gas: gasLimit, from: web3.eth.accounts[0]} + ).then(function (factory) { + MarketContractRegistry.deployed().then(function (registryInstance) { + return registryInstance.addFactoryAddress(factory.address).then(function () { // white list the factory + return factory + .deployMarketContractOraclize( + 'ETHXBT', + CollateralToken.address, + [20155, 60465, 2, 10, marketContractExpiration], + 'URL', + 'json(https://api.kraken.com/0/public/Ticker?pair=ETHUSD).result.XETHZUSD.c.0', + {gas: gasLimit, from: web3.eth.accounts[0]} + ) + .then(function () { return factory .deployMarketContractOraclize( - 'ETHXBT', + 'ETHXBT-2', CollateralToken.address, [20155, 60465, 2, 10, marketContractExpiration], 'URL', 'json(https://api.kraken.com/0/public/Ticker?pair=ETHUSD).result.XETHZUSD.c.0', {gas: gasLimit, from: web3.eth.accounts[0]} ) - .then(function () { - return factory - .deployMarketContractOraclize( - 'ETHXBT-2', - CollateralToken.address, - [20155, 60465, 2, 10, marketContractExpiration], - 'URL', - 'json(https://api.kraken.com/0/public/Ticker?pair=ETHUSD).result.XETHZUSD.c.0', - {gas: gasLimit, from: web3.eth.accounts[0]} - ) - }); }); - }); + }); }); }); } diff --git a/migrations/4_chainlink_contracts.js b/migrations/4_chainlink_contracts.js index 7437c74a..9e77b180 100644 --- a/migrations/4_chainlink_contracts.js +++ b/migrations/4_chainlink_contracts.js @@ -12,10 +12,10 @@ module.exports = function (deployer, network) { const marketContractExpiration = Math.floor(Date.now() / 1000) + 60 * 15; // expires in 15 minutes. if (network !== 'live') { + deployer.link(MathLib, MarketContractFactory); return deployer.deploy(LinkToken).then(function (linkToken) { return deployer.deploy(ChainLinkOracle, LinkToken.address).then(function () { return MarketContractRegistry.deployed().then(function (registry) { - return deployer.link(MathLib, MarketContractFactory).then(function () { return deployer.deploy( MarketContractFactory, registry.address, @@ -54,6 +54,5 @@ module.exports = function (deployer, network) { }); }); }); - }); } }; From 6484be6278432b846224c644fc31874d8d47ae25 Mon Sep 17 00:00:00 2001 From: Phil Elsasser Date: Fri, 7 Dec 2018 11:24:19 -0700 Subject: [PATCH 3/3] removed unused event --- contracts/MarketCollateralPool.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/MarketCollateralPool.sol b/contracts/MarketCollateralPool.sol index ff2aadff..35f41918 100644 --- a/contracts/MarketCollateralPool.sol +++ b/contracts/MarketCollateralPool.sol @@ -39,7 +39,6 @@ contract MarketCollateralPool is Ownable { event TokensMinted(address indexed marketContract, address indexed user, uint qtyMinted, uint collateralLocked); event TokensRedeemed(address indexed marketContract, address indexed user, uint qtyRedeemed, uint collateralUnlocked, uint8 marketSide); - event FactoryAddressRemoved(address indexed factoryAddress); constructor() public { }