Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
300 changes: 141 additions & 159 deletions contracts/DutchAuction.sol

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions contracts/ESOVToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "@openzeppelin/contracts/GSN/Context.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
//import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";

//import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/GSN/Context.sol";
//import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol";
Expand Down
15 changes: 15 additions & 0 deletions contracts/mocks/sbtc.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pragma solidity ^0.6.2;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract SBTC is ERC20 {
// uint8 decimals = 18;

constructor() public ERC20("Synth sBTC", "SBTC") {
// _setupDecimals(decimals);
}

// faucet for testing
function faucet(address to, uint256 amount) external {
_mint(to, amount);
}
}
15 changes: 15 additions & 0 deletions contracts/mocks/wbtc.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pragma solidity ^0.6.2;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract WBTC is ERC20 {
uint8 decimals_ = 8;

constructor() public ERC20("Wrapped BTC", "WBTC") {
_setupDecimals(decimals_);
}

// faucet for testing
function faucet(address to, uint amount) external {
_mint(to, amount);
}
}
48 changes: 34 additions & 14 deletions migrations/2_deploy_dutchauction.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ const ESOVToken = artifacts.require("ESOVToken");
const esovAdmin = '0x763e73385c790f2fe2354d877ff98431ee586e4e'; // account9
const SovrynAddr = '0xfa201a6fccbd9332a49ac71b646be88503dc6696'; // account8

/*const adminWallet = '0xE8276A1680CB970c2334B3201044Ddf7c492F52A';
const NFTs = ['0x78c0D49d003bf0A88EA6dF729B7a2AD133B9Ae25','0x420fECFda0975c49Fd0026f076B302064ED9C6Ff','0xC5452Dbb2E3956C1161cB9C2d6DB53C2b60E7805'];
*/
let dutchAddr;
let ESOVAddress;

module.exports = async function (deployer) {
ESOVTokenInstance = await deployToken(deployer);
dutch = await deployDutch(deployer);
// await CSOVTokenInstance.setSaleAdmin(crowdsale.address);
// console.log(
// "Token Balance of crowdsale smart contract: " +
// await CSOVTokenInstance.balanceOf(crowdsale.address));
// crowdsale.start(86400*3, 50000, web3.utils.toWei('0.001', 'ether'), web3.utils.toWei('2000000', 'ether'));
await ESOVTokenInstance.setSaleAdmin(dutch.address, {from: esovAdmin});
console.log(
"Token Balance of crowdsale smart contract: " +
await ESOVTokenInstance.balanceOf(dutch.address));
await dutch.setup(ESOVAddress, esovAdmin);
console.log("dutch owner: " + await dutch.owner());
console.log("ESOV owner: " + await ESOVTokenInstance.owner());
}

async function deployToken(deployer){
Expand All @@ -27,13 +29,31 @@ async function deployToken(deployer){
}

async function deployDutch(deployer){
const ceiling = 1000;
const priceFactor = 2;

console.log("SovrynAddr: " + SovrynAddr + " " + "ceiling: " + ceiling + " " + "priceFactor: " + priceFactor)
await deployer.deploy(DutchAuction,SovrynAddr, ceiling, priceFactor);
const ceiling = web3.utils.toWei('10');
const duration = 100000;
/// Price param setup adjusted to start price @2500 sats per ESOV token,
/// semi-linear 10% price reduction over 20 blocks
const priceFactorNumerator = '45';
const priceFactorDenominator = '10000';
const priceConst = '180';

console.log(
"SovrynAddr: " + SovrynAddr + " " +
"ceiling: " + ceiling + " " +
"priceFactorNumerator: " + priceFactorNumerator + " " +
"priceFactorDenominator: " + priceFactorDenominator + " " +
"priceConst: " + priceConst + " " +
"duration: " + duration);
await deployer.deploy(
DutchAuction,
SovrynAddr,
ceiling,
priceFactorNumerator,
priceFactorDenominator,
priceConst,
duration);
let dutch = await DutchAuction.deployed();
let dutchAddr = await dutch.address;
dutchAddr = await dutch.address;
console.log("DutchAuction address: " + dutchAddr);
return dutch;
}
52 changes: 52 additions & 0 deletions migrations/3_deploy_mockERC20.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//const DutchAuction = artifacts.require("DutchAuction");
//const ESOVToken = artifacts.require("ESOVToken");
const Wbtc = artifacts.require('mocks/WBTC.sol');
const Sbtc = artifacts.require('mocks/SBTC.sol');

const esovAdmin = '0x763e73385c790f2fe2354d877ff98431ee586e4e'; // account9
const SovrynAddr = '0xfa201a6fccbd9332a49ac71b646be88503dc6696'; // account8

let dutchAddress = "0x1824Fb64Ea610f681eD255703190dE828050F899"; // only debug address
let ESOVAddress;
let wbtc, sbtc;

const investor1 = '0xe04c7301eb08b4cba478a2eaee48dbea7a9138dd';
const investor2 = '0xd428b98b65f1f607ccffd5428de0b2b5fb7d0219';

module.exports = async function (deployer) {
const [WBTC, SBTC] = ['WBTC', 'SBTC']
.map(ticker => web3.utils.fromAscii(ticker));

([wbtc, sbtc] = await Promise.all([
Wbtc.new(),
Sbtc.new()
]));

const amount = web3.utils.toWei('2');
// Declare a function that:
// 1. Faucet the trader account
const seedTokenBalance = async (token, investor) => {
await token.faucet(investor, amount, { from: esovAdmin });
// let bal =
// console.log("investor1 SBTC balance: " + await token.balanceOf(investor1));
// console.log(token + investor + )
await token.approve(
dutchAddress,
amount,
{from: investor}
);
};
// Call the seedTokenBalance function
await Promise.all(
[wbtc, sbtc].map(
token => seedTokenBalance(token, investor1)
)
);
await Promise.all(
[wbtc, sbtc].map(
token => seedTokenBalance(token, investor2)
)
);
};


Loading