Skip to content

Commit

Permalink
Merge 6484be6 into 3470d96
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Elsasser committed Dec 7, 2018
2 parents 3470d96 + 6484be6 commit 1394411
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 76 deletions.
1 change: 0 additions & 1 deletion contracts/MarketCollateralPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }

Expand Down
11 changes: 1 addition & 10 deletions contracts/chainlink/MarketContractFactoryChainLink.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,19 @@ pragma solidity ^0.4.24;
import "./MarketContractChainLink.sol";
import "./OracleHubChainLink.sol";
import "../MarketContractRegistryInterface.sol";
import "../tokens/MarketToken.sol";


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(
address registryAddress,
address mktTokenAddress
address registryAddress
) public {
marketContractRegistry = registryAddress;
MKT_TOKEN_ADDRESS = mktTokenAddress;
MKT_TOKEN = MarketToken(mktTokenAddress);
}

/// @param contractName viewable name of this contract (BTC/ETH, LTC/ETH, etc)
Expand All @@ -64,8 +57,6 @@ contract MarketContractFactoryChainLink is Ownable {
bytes32 onDemandJobId
) external
{
require(MKT_TOKEN.isBalanceSufficientForContractCreation(msg.sender)); // creator must be MKT holder

MarketContractChainLink mktContract = new MarketContractChainLink(
contractName,
[
Expand Down
9 changes: 1 addition & 8 deletions contracts/oraclize/MarketContractFactoryOraclize.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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.
Expand All @@ -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,
[
Expand Down
22 changes: 8 additions & 14 deletions contracts/oraclize/TestableMarketContractFactoryOraclize.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,20 @@ import "./TestableMarketContractOraclize.sol";
import "../MarketContractRegistryInterface.sol";

import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "../tokens/MarketToken.sol";


/// @title TestableMarketContractFactoryOraclize
/// @author Phil Elsasser <phil@marketprotocol.io>
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.
Expand All @@ -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,
[
Expand All @@ -78,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;
// }
}
16 changes: 4 additions & 12 deletions migrations/2_market_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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]
})
});
});
});
Expand Down
47 changes: 20 additions & 27 deletions migrations/3_oraclize_contracts.js
Original file line number Diff line number Diff line change
@@ -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'
);
Expand All @@ -11,44 +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,
MarketToken.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]}
)
});
});
});
});
});
});
}
Expand Down
5 changes: 1 addition & 4 deletions migrations/4_chainlink_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@ 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;
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,
MarketToken.address,
{gas: gasLimit, from: web3.eth.accounts[0]}
).then(function (factory) {
return registry.addFactoryAddress(factory.address).then(function () {
Expand Down Expand Up @@ -56,6 +54,5 @@ module.exports = function (deployer, network) {
});
});
});
});
}
};

0 comments on commit 1394411

Please sign in to comment.