Skip to content

Commit

Permalink
Merge d53ebf5 into 2709d30
Browse files Browse the repository at this point in the history
  • Loading branch information
perfectmak committed Dec 12, 2018
2 parents 2709d30 + d53ebf5 commit 521150a
Show file tree
Hide file tree
Showing 15 changed files with 840 additions and 361 deletions.
2 changes: 1 addition & 1 deletion contracts/MarketCollateralPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ contract MarketCollateralPool is Ownable {
/// long and short token address. If it didn't we could have spoofed contracts minting tokens with a
/// collateral token that wasn't the same as the intended token.
modifier onlyWhiteListedAddress(address marketContractAddress) {
require(MarketContractRegistryInterface(MARKET_CONTRACT_REGISTRY).isAddressWhiteListed(marketContractAddress));
require(MarketContractRegistryInterface(MARKET_CONTRACT_REGISTRY).isAddressWhiteListed(marketContractAddress), "Contract is not whitelisted");
_;
}
}
2 changes: 1 addition & 1 deletion migrations/1_initial_migration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Migrations = artifacts.require('./Migrations.sol');

module.exports = function (deployer) {
module.exports = function(deployer) {
deployer.deploy(Migrations);
};
20 changes: 9 additions & 11 deletions migrations/2_market_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,22 @@ const MarketContractOraclize = artifacts.require('./oraclize/MarketContractOracl
const MarketCollateralPool = artifacts.require('./MarketCollateralPool.sol');
const MarketContractRegistry = artifacts.require('./MarketContractRegistry.sol');

module.exports = function (deployer, network) {
module.exports = function(deployer, network) {
if (network !== 'live') {
deployer.deploy([MathLib, MarketContractRegistry]).then(function () {
deployer.deploy([MathLib, MarketContractRegistry]).then(function() {
deployer.link(MathLib, [MarketContractOraclize, MarketCollateralPool]);

deployer.link(MathLib,
[MarketContractOraclize, MarketCollateralPool]
);

return deployer.deploy(MarketCollateralPool, MarketContractRegistry.address).then(function () {
return deployer.deploy(MarketCollateralPool, MarketContractRegistry.address).then(function() {
var gasLimit = web3.eth.getBlock('latest').gasLimit;
return MarketCollateralPool.deployed().then(function () {
return MarketCollateralPool.deployed().then(function() {
return deployer
.deploy(CollateralToken, 'CollateralToken', 'CTK', 10000, 18, {
gas: gasLimit,
from: web3.eth.accounts[0]
}).then(function () {
return deployer.deploy(MarketToken, 0, 0); // deploy just for testing.
});
})
.then(function() {
return deployer.deploy(MarketToken, 0, 0); // deploy just for testing.
});
});
});
});
Expand Down
83 changes: 42 additions & 41 deletions migrations/3_oraclize_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,54 @@ const MarketContract = artifacts.require('./oraclize/MarketContractOraclize.sol'
const OracleHub = artifacts.require('./oraclize/OracleHubOraclize.sol');
const MarketCollateralPool = artifacts.require('./MarketCollateralPool.sol');

module.exports = function (deployer, network) {
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;

deployer.link(MathLib, [MarketContractFactory, MarketContract]);
return deployer.deploy(
MarketContractFactory,
MarketContractRegistry.address,
MarketCollateralPool.address,
{gas: gasLimit, from: web3.eth.accounts[0]}
).then(function (factory) {
return MarketContractRegistry.deployed().then(function (registryInstance) {
return registryInstance.addFactoryAddress(factory.address).then(function () { // white list the factory
return deployer.deploy(
OracleHub,
factory.address,
{gas: gasLimit, from: web3.eth.accounts[0], value: 1e18}
).then(function (oracleHub) {
return factory.setOracleHubAddress(
oracleHub.address,
{from: web3.eth.accounts[0]}
).then(function () {
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-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]}
)
});
})
})
return deployer
.deploy(MarketContractFactory, MarketContractRegistry.address, MarketCollateralPool.address, {
gas: gasLimit,
from: web3.eth.accounts[0]
})
.then(function(factory) {
return MarketContractRegistry.deployed().then(function(registryInstance) {
return registryInstance.addFactoryAddress(factory.address).then(function() {
// white list the factory
return deployer
.deploy(OracleHub, factory.address, {
gas: gasLimit,
from: web3.eth.accounts[0],
value: 1e18
})
.then(function(oracleHub) {
return factory
.setOracleHubAddress(oracleHub.address, { from: web3.eth.accounts[0] })
.then(function() {
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-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] }
);
});
});
});
});
});
});
});
}
};
74 changes: 36 additions & 38 deletions migrations/4_chainlink_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,51 @@ const CollateralToken = artifacts.require('./tokens/CollateralToken.sol');
const MarketCollateralPool = artifacts.require('./MarketCollateralPool.sol');
const MarketContractRegistry = artifacts.require('./MarketContractRegistry.sol');

module.exports = function (deployer, network) {
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, MarketContract]);
return deployer.deploy(LinkToken).then(function (linkToken) {
return deployer.deploy(ChainLinkOracle, LinkToken.address).then(function () {
return MarketContractRegistry.deployed().then(function (registry) {
return deployer.deploy(
MarketContractFactory,
registry.address,
MarketCollateralPool.address,
{gas: gasLimit, from: web3.eth.accounts[0]}
).then(function (factory) {
return registry.addFactoryAddress(factory.address).then(function () {
return deployer.deploy(
OracleHub,
factory.address,
LinkToken.address,
ChainLinkOracle.address,
{gas: gasLimit, from: web3.eth.accounts[0]}
).then(function (oracleHub) {
// set the oracle hub address in the factory to allow to request queries.
return factory.setOracleHubAddress(
oracleHub.address,
{from: web3.eth.accounts[0]}
).then(function () {
// transfer link token to hub to pay for queries.
return linkToken.transfer(oracleHub.address, 10e22).then(function () {
return factory.deployMarketContractChainLink(
'ETHXBT',
CollateralToken.address,
[20155, 60465, 2, 10, marketContractExpiration],
'https://api.kraken.com/0/public/Ticker?pair=ETHUSD',
'result.XETHZUSD.c.0',
'fakeSleepJobId',
'fakeOnDemandJobId',
{gas: gasLimit, from: web3.eth.accounts[0]}
);
});
return deployer.deploy(LinkToken).then(function(linkToken) {
return deployer.deploy(ChainLinkOracle, LinkToken.address).then(function() {
return MarketContractRegistry.deployed().then(function(registry) {
return deployer
.deploy(MarketContractFactory, registry.address, MarketCollateralPool.address, {
gas: gasLimit,
from: web3.eth.accounts[0]
})
.then(function(factory) {
return registry.addFactoryAddress(factory.address).then(function() {
return deployer
.deploy(OracleHub, factory.address, LinkToken.address, ChainLinkOracle.address, {
gas: gasLimit,
from: web3.eth.accounts[0]
})
.then(function(oracleHub) {
// set the oracle hub address in the factory to allow to request queries.
return factory
.setOracleHubAddress(oracleHub.address, { from: web3.eth.accounts[0] })
.then(function() {
// transfer link token to hub to pay for queries.
return linkToken.transfer(oracleHub.address, 10e22).then(function() {
return factory.deployMarketContractChainLink(
'ETHXBT',
CollateralToken.address,
[20155, 60465, 2, 10, marketContractExpiration],
'https://api.kraken.com/0/public/Ticker?pair=ETHUSD',
'result.XETHZUSD.c.0',
'fakeSleepJobId',
'fakeOnDemandJobId',
{ gas: gasLimit, from: web3.eth.accounts[0] }
);
});
});
});
});
});
});
});
});
});
});
}
};

0 comments on commit 521150a

Please sign in to comment.