Skip to content

Commit

Permalink
Update MockUniswapFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
antoncoding committed Aug 7, 2020
1 parent f57b766 commit 281faf2
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 30 deletions.
37 changes: 37 additions & 0 deletions contracts/lib/MockUniswapFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pragma solidity 0.5.10;

contract MockUniswapFactory {

constructor () public {
}

address public exchangeTemplate;
uint256 public tokenCount;
mapping(uint256 => address) public idToToken;
mapping(address => address) public exchanges;
mapping(address => address) public tokens;
address public _exchange;

// Create Exchange
function createExchange(address token) external pure returns (address exchange) {
return token; // return random address.
}
// Get Exchange and Token Info
function getExchange(address token) external view returns (address exchange){
return exchanges[token];
}
function getToken(address exchange) external view returns (address token) {
return tokens[exchange];
}
function getTokenWithId(uint256 tokenId) external view returns (address token) {
return idToToken[tokenId];
}
function setTokenExchange(address token, address exchange) public {
exchanges[token] = exchange;
tokens[exchange] = token;
}
// Never use
function initializeFactory(address template) external {
}
}

83 changes: 53 additions & 30 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,69 @@ const OptionsFactory = artifacts.require('OptionsFactory.sol');
const StringComparator = artifacts.require('StringComparator.sol');
const OptionsExchange = artifacts.require('OptionsExchange.sol');
const MockCompoundOracle = artifacts.require('MockCompoundOracle');
const Oracle = artifacts.require('Oracle.sol');
const MockUniswapFactory = artifacts.require('MockUniswapFactory');

module.exports = function (deployer, network) {
module.exports = function(deployer, network) {
deployer.then(async () => {
var uniswapFactoryAddr;
var compoundOracleAddress;
var compoundOracle;
let uniswapFactoryAddr;
let compoundOracle;

if (network == "rinkeby") {
if (network == 'rinkeby') {
// Rinkeby
uniswapFactoryAddr = "0xf5D915570BC477f9B8D6C0E980aA81757A3AaC36";
compoundOracleAddress = "0x332b6e69f21acdba5fb3e8dac56ff81878527e06";
uniswapFactoryAddr = '0xf5D915570BC477f9B8D6C0E980aA81757A3AaC36';
compoundOracleAddress = '0x332b6e69f21acdba5fb3e8dac56ff81878527e06';
// compoundOracle = await deployer.deploy(Oracle, compoundOracleAddress);
compoundOracle = await deployer.deploy(MockCompoundOracle);
console.log("Oracle Address ", compoundOracle.address.toString());
console.log('Oracle Address ', compoundOracle.address.toString());

const optionsExchange = await deployer.deploy(OptionsExchange, uniswapFactoryAddr);
console.log("Options Exchange ", optionsExchange.address.toString());
await deployer.deploy(OptionsFactory, optionsExchange.address, compoundOracle.address);
console.log("Options Factory ", OptionsFactory.address.toString());
}
else if (network == "kovan") {
const optionsExchange = await deployer.deploy(
OptionsExchange,
uniswapFactoryAddr
);
console.log('Options Exchange ', optionsExchange.address.toString());
await deployer.deploy(
OptionsFactory,
optionsExchange.address,
compoundOracle.address
);
console.log('Options Factory ', OptionsFactory.address.toString());
} else if (network == 'kovan') {
await deployer.deploy(StringComparator);
await deployer.link(StringComparator, OptionsFactory);
// Kovan
uniswapFactoryAddr = "0xD3E51Ef092B2845f10401a0159B2B96e8B6c3D30";
compoundOracleAddress = "0x6998ed7daf969ea0950e01071aceeee54cccbab5";
uniswapFactoryAddr = '0xD3E51Ef092B2845f10401a0159B2B96e8B6c3D30';
compoundOracleAddress = '0x6998ed7daf969ea0950e01071aceeee54cccbab5';
// compoundOracle = await deployer.deploy(Oracle, compoundOracleAddress);
compoundOracle = await deployer.deploy(MockCompoundOracle);

const optionsExchange = await deployer.deploy(OptionsExchange, uniswapFactoryAddr);
await deployer.deploy(OptionsFactory, optionsExchange.address, compoundOracle.address);
}
else if (network == "ropsten") {
const optionsExchange = await deployer.deploy(
OptionsExchange,
uniswapFactoryAddr
);
await deployer.deploy(
OptionsFactory,
optionsExchange.address,
compoundOracle.address
);
} else if (network == 'ropsten') {
await deployer.deploy(StringComparator);
await deployer.link(StringComparator, OptionsFactory);
// Ropsten
uniswapFactoryAddr = "0x0865A608E75FbD2ba087d08A5C7cAabcd977C1aD";
compoundOracleAddress = "0xc7E20CF485b8E0Bcec3e2fCc23e3aD93b1b0cB39";
uniswapFactoryAddr = '0x0865A608E75FbD2ba087d08A5C7cAabcd977C1aD';
compoundOracleAddress = '0xc7E20CF485b8E0Bcec3e2fCc23e3aD93b1b0cB39';
// compoundOracle = await deployer.deploy(Oracle, compoundOracleAddress);
compoundOracle = await deployer.deploy(MockCompoundOracle);

const optionsExchange = await deployer.deploy(OptionsExchange, uniswapFactoryAddr);
await deployer.deploy(OptionsFactory, optionsExchange.address, compoundOracle.address);
} else if (network == "mainnet") {
const optionsExchange = await deployer.deploy(
OptionsExchange,
uniswapFactoryAddr
);
await deployer.deploy(
OptionsFactory,
optionsExchange.address,
compoundOracle.address
);
} else if (network == 'mainnet') {
// await deployer.deploy(StringComparator);
// await deployer.link(StringComparator, OptionsFactory);
// // Mainnet
Expand All @@ -56,7 +73,6 @@ module.exports = function (deployer, network) {
// compoundOracle = await deployer.deploy(Oracle, compoundOracleAddress);
// // compoundOracle = await Oracle.at('0x317166AB2bF19152D16871C8Cf1B33583e26932B');
// console.log("Oracle Address ", compoundOracle.address.toString());

// const optionsExchange = await deployer.deploy(OptionsExchange, uniswapFactoryAddr);
// console.log("Options Exchange ", optionsExchange.address.toString());
// await deployer.deploy(OptionsFactory, optionsExchange.address, compoundOracle.address);
Expand All @@ -70,8 +86,15 @@ module.exports = function (deployer, network) {
uniswapFactoryAddr = uniswapFactory.address;
compoundOracle = await deployer.deploy(MockCompoundOracle);

const optionsExchange = await deployer.deploy(OptionsExchange, uniswapFactoryAddr);
await deployer.deploy(OptionsFactory, optionsExchange.address, compoundOracle.address);
const optionsExchange = await deployer.deploy(
OptionsExchange,
uniswapFactoryAddr
);
await deployer.deploy(
OptionsFactory,
optionsExchange.address,
compoundOracle.address
);
}
})
});
};

0 comments on commit 281faf2

Please sign in to comment.