mirror of
https://github.com/Instadapp/InstaContract.git
synced 2024-07-29 22:47:45 +00:00
commit
61b18ec874
|
@ -34,4 +34,4 @@ jobs:
|
||||||
key: v1-dependencies-{{ checksum "package.json" }}
|
key: v1-dependencies-{{ checksum "package.json" }}
|
||||||
|
|
||||||
# run tests!
|
# run tests!
|
||||||
- run: npm run test-ci
|
- run: npm run test-ci
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pragma solidity 0.4.24;
|
pragma solidity ^0.5.0;
|
||||||
|
|
||||||
/* solium-disable mixedcase */
|
/* solium-disable mixedcase */
|
||||||
contract Migrations {
|
contract Migrations {
|
||||||
|
@ -6,13 +6,10 @@ contract Migrations {
|
||||||
uint public last_completed_migration;
|
uint public last_completed_migration;
|
||||||
|
|
||||||
modifier restricted() {
|
modifier restricted() {
|
||||||
if (msg.sender == owner)
|
if (msg.sender == owner) _;
|
||||||
_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor()
|
constructor() public {
|
||||||
public
|
|
||||||
{
|
|
||||||
owner = msg.sender;
|
owner = msg.sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,4 +23,5 @@ contract Migrations {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* solium-enable mixedcase */
|
/* solium-enable mixedcase */
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pragma solidity 0.4.24;
|
pragma solidity ^0.5.0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,4 +36,4 @@ contract Ownable {
|
||||||
emit OwnershipTransferred(owner, newOwner);
|
emit OwnershipTransferred(owner, newOwner);
|
||||||
owner = newOwner;
|
owner = newOwner;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.5.0;
|
||||||
|
|
||||||
|
|
||||||
contract AddressRegistry {
|
contract AddressRegistry {
|
||||||
|
|
||||||
event AddressSet(string name, address addr);
|
event AddressSet(string name, address addr);
|
||||||
mapping(bytes32 => address) registry;
|
mapping(bytes32 => address) registry;
|
||||||
|
|
||||||
|
@ -10,18 +9,14 @@ contract AddressRegistry {
|
||||||
registry[keccak256(abi.encodePacked("admin"))] = msg.sender;
|
registry[keccak256(abi.encodePacked("admin"))] = msg.sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAddr(string name) public view returns(address) {
|
function getAddr(string memory name) public view returns (address) {
|
||||||
return registry[keccak256(abi.encodePacked(name))];
|
return registry[keccak256(abi.encodePacked(name))];
|
||||||
}
|
}
|
||||||
|
|
||||||
function setAddr(string name, address addr) public {
|
function setAddr(string memory name, address addr) public {
|
||||||
require(
|
require(msg.sender == getAddr("admin") || msg.sender == getAddr("owner"), "Permission Denied");
|
||||||
msg.sender == getAddr("admin") ||
|
|
||||||
msg.sender == getAddr("owner"),
|
|
||||||
"Permission Denied"
|
|
||||||
);
|
|
||||||
registry[keccak256(abi.encodePacked(name))] = addr;
|
registry[keccak256(abi.encodePacked(name))] = addr;
|
||||||
emit AddressSet(name, addr);
|
emit AddressSet(name, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.5.0;
|
||||||
|
|
||||||
|
|
||||||
library SafeMath {
|
library SafeMath {
|
||||||
|
|
||||||
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
if (a == 0) {
|
if (a == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -11,7 +10,7 @@ library SafeMath {
|
||||||
require(c / a == b, "Assertion Failed");
|
require(c / a == b, "Assertion Failed");
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
require(b > 0, "Assertion Failed");
|
require(b > 0, "Assertion Failed");
|
||||||
uint256 c = a / b;
|
uint256 c = a / b;
|
||||||
|
@ -28,7 +27,7 @@ interface IERC20 {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AddressRegistry {
|
interface AddressRegistry {
|
||||||
function getAddr(string name) external view returns(address);
|
function getAddr(string calldata name) external view returns (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Kyber {
|
interface Kyber {
|
||||||
|
@ -42,24 +41,17 @@ interface Kyber {
|
||||||
address walletId
|
address walletId
|
||||||
) external payable returns (uint);
|
) external payable returns (uint);
|
||||||
|
|
||||||
function getExpectedRate(
|
function getExpectedRate(address src, address dest, uint srcQty) external view returns (uint, uint);
|
||||||
address src,
|
|
||||||
address dest,
|
|
||||||
uint srcQty
|
|
||||||
) external view returns (uint, uint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract Registry {
|
contract Registry {
|
||||||
address public addressRegistry;
|
address public addressRegistry;
|
||||||
modifier onlyAdmin() {
|
modifier onlyAdmin() {
|
||||||
require(
|
require(msg.sender == getAddress("admin"), "Permission Denied");
|
||||||
msg.sender == getAddress("admin"),
|
|
||||||
"Permission Denied"
|
|
||||||
);
|
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
function getAddress(string name) internal view returns(address) {
|
function getAddress(string memory name) internal view returns (address) {
|
||||||
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
||||||
return addrReg.getAddr(name);
|
return addrReg.getAddr(name);
|
||||||
}
|
}
|
||||||
|
@ -68,37 +60,21 @@ contract Registry {
|
||||||
|
|
||||||
|
|
||||||
contract Trade is Registry {
|
contract Trade is Registry {
|
||||||
|
|
||||||
using SafeMath for uint;
|
using SafeMath for uint;
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
event KyberTrade(
|
event KyberTrade(address src, uint srcAmt, address dest, uint destAmt, address beneficiary, uint minConversionRate, address affiliate);
|
||||||
address src,
|
|
||||||
uint srcAmt,
|
|
||||||
address dest,
|
|
||||||
uint destAmt,
|
|
||||||
address beneficiary,
|
|
||||||
uint minConversionRate,
|
|
||||||
address affiliate
|
|
||||||
);
|
|
||||||
|
|
||||||
function getExpectedPrice(
|
function getExpectedPrice(address src, address dest, uint srcAmt) public view returns (uint, uint) {
|
||||||
address src,
|
|
||||||
address dest,
|
|
||||||
uint srcAmt
|
|
||||||
) public view returns (uint, uint)
|
|
||||||
{
|
|
||||||
Kyber kyberFunctions = Kyber(getAddress("kyber"));
|
Kyber kyberFunctions = Kyber(getAddress("kyber"));
|
||||||
return kyberFunctions.getExpectedRate(
|
return kyberFunctions.getExpectedRate(src, dest, srcAmt);
|
||||||
src, dest, srcAmt
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function approveKyber(address[] tokenArr) public {
|
function approveKyber(address[] memory tokenArr) public {
|
||||||
address kyberProxy = getAddress("kyber");
|
address kyberProxy = getAddress("kyber");
|
||||||
for (uint i = 0; i < tokenArr.length; i++) {
|
for (uint i = 0; i < tokenArr.length; i++) {
|
||||||
IERC20 tokenFunctions = IERC20(tokenArr[i]);
|
IERC20 tokenFunctions = IERC20(tokenArr[i]);
|
||||||
tokenFunctions.approve(kyberProxy, 2**256 - 1);
|
tokenFunctions.approve(kyberProxy, 2 ** 256 - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,14 +84,19 @@ contract Trade is Registry {
|
||||||
uint srcAmt, // amount of token for sell
|
uint srcAmt, // amount of token for sell
|
||||||
uint minConversionRate, // minimum slippage rate
|
uint minConversionRate, // minimum slippage rate
|
||||||
uint maxDestAmt // max amount of dest token
|
uint maxDestAmt // max amount of dest token
|
||||||
) public payable returns (uint destAmt)
|
)
|
||||||
|
public
|
||||||
|
payable
|
||||||
|
returns (uint destAmt)
|
||||||
{
|
{
|
||||||
|
|
||||||
address eth = getAddress("eth");
|
address eth = getAddress("eth");
|
||||||
uint ethQty = getToken(
|
uint ethQty = getToken(
|
||||||
msg.sender, src, srcAmt, eth
|
msg.sender,
|
||||||
|
src,
|
||||||
|
srcAmt,
|
||||||
|
eth
|
||||||
);
|
);
|
||||||
|
|
||||||
// Interacting with Kyber Proxy Contract
|
// Interacting with Kyber Proxy Contract
|
||||||
Kyber kyberFunctions = Kyber(getAddress("kyber"));
|
Kyber kyberFunctions = Kyber(getAddress("kyber"));
|
||||||
destAmt = kyberFunctions.trade.value(ethQty)(
|
destAmt = kyberFunctions.trade.value(ethQty)(
|
||||||
|
@ -131,7 +112,8 @@ contract Trade is Registry {
|
||||||
// maxDestAmt usecase implementated
|
// maxDestAmt usecase implementated
|
||||||
if (src == eth && address(this).balance > 0) {
|
if (src == eth && address(this).balance > 0) {
|
||||||
msg.sender.transfer(address(this).balance);
|
msg.sender.transfer(address(this).balance);
|
||||||
} else if (src != eth) { // as there is no balanceOf of eth
|
} else if (src != eth) {
|
||||||
|
// as there is no balanceOf of eth
|
||||||
IERC20 srcTkn = IERC20(src);
|
IERC20 srcTkn = IERC20(src);
|
||||||
uint srcBal = srcTkn.balanceOf(address(this));
|
uint srcBal = srcTkn.balanceOf(address(this));
|
||||||
if (srcBal > 0) {
|
if (srcBal > 0) {
|
||||||
|
@ -140,7 +122,13 @@ contract Trade is Registry {
|
||||||
}
|
}
|
||||||
|
|
||||||
emit KyberTrade(
|
emit KyberTrade(
|
||||||
src, srcAmt, dest, destAmt, msg.sender, minConversionRate, getAddress("admin")
|
src,
|
||||||
|
srcAmt,
|
||||||
|
dest,
|
||||||
|
destAmt,
|
||||||
|
msg.sender,
|
||||||
|
minConversionRate,
|
||||||
|
getAddress("admin")
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -150,7 +138,9 @@ contract Trade is Registry {
|
||||||
address src,
|
address src,
|
||||||
uint srcAmt,
|
uint srcAmt,
|
||||||
address eth
|
address eth
|
||||||
) internal returns (uint ethQty)
|
)
|
||||||
|
internal
|
||||||
|
returns (uint ethQty)
|
||||||
{
|
{
|
||||||
if (src == eth) {
|
if (src == eth) {
|
||||||
require(msg.value == srcAmt, "Invalid Operation");
|
require(msg.value == srcAmt, "Invalid Operation");
|
||||||
|
@ -161,16 +151,14 @@ contract Trade is Registry {
|
||||||
ethQty = 0;
|
ethQty = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract InstaKyber is Trade {
|
contract InstaKyber is Trade {
|
||||||
|
|
||||||
constructor(address rAddr) public {
|
constructor(address rAddr) public {
|
||||||
addressRegistry = rAddr;
|
addressRegistry = rAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function () public payable {}
|
function() external payable {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
pragma solidity 0.4.24;
|
pragma solidity ^0.5.0;
|
||||||
|
|
||||||
|
|
||||||
library SafeMath {
|
library SafeMath {
|
||||||
|
|
||||||
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
if (a == 0) {
|
if (a == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -11,7 +10,7 @@ library SafeMath {
|
||||||
require(c / a == b, "Assertion Failed");
|
require(c / a == b, "Assertion Failed");
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
require(b > 0, "Assertion Failed");
|
require(b > 0, "Assertion Failed");
|
||||||
uint256 c = a / b;
|
uint256 c = a / b;
|
||||||
|
@ -28,7 +27,7 @@ interface IERC20 {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AddressRegistry {
|
interface AddressRegistry {
|
||||||
function getAddr(string name) external view returns(address);
|
function getAddr(string calldata name) external view returns (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MakerCDP {
|
interface MakerCDP {
|
||||||
|
@ -53,57 +52,48 @@ interface WETHFace {
|
||||||
function withdraw(uint wad) external;
|
function withdraw(uint wad) external;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface InstaKyber {
|
interface InstaKyber {
|
||||||
function executeTrade(
|
function executeTrade(
|
||||||
address src,
|
address src,
|
||||||
address dest,
|
address dest,
|
||||||
uint srcAmt,
|
uint srcAmt,
|
||||||
uint minConversionRate,
|
uint minConversionRate,
|
||||||
uint maxDestAmt
|
uint maxDestAmt
|
||||||
) external payable returns (uint destAmt);
|
)
|
||||||
|
external
|
||||||
|
payable
|
||||||
|
returns (uint destAmt);
|
||||||
|
|
||||||
function getExpectedPrice(
|
function getExpectedPrice(address src, address dest, uint srcAmt) external view returns (uint, uint);
|
||||||
address src,
|
}
|
||||||
address dest,
|
|
||||||
uint srcAmt
|
|
||||||
) external view returns (uint, uint);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
contract Registry {
|
contract Registry {
|
||||||
|
|
||||||
address public addressRegistry;
|
address public addressRegistry;
|
||||||
modifier onlyAdmin() {
|
modifier onlyAdmin() {
|
||||||
require(
|
require(msg.sender == getAddress("admin"), "Permission Denied");
|
||||||
msg.sender == getAddress("admin"),
|
|
||||||
"Permission Denied"
|
|
||||||
);
|
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAddress(string name) internal view returns(address) {
|
function getAddress(string memory name) internal view returns (address) {
|
||||||
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
||||||
return addrReg.getAddr(name);
|
return addrReg.getAddr(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract GlobalVar is Registry {
|
contract GlobalVar is Registry {
|
||||||
|
|
||||||
using SafeMath for uint;
|
using SafeMath for uint;
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
bytes32 blankCDP = 0x0000000000000000000000000000000000000000000000000000000000000000;
|
bytes32 blankCDP = 0x0000000000000000000000000000000000000000000000000000000000000000;
|
||||||
address cdpAddr; // cups
|
address cdpAddr; // cups
|
||||||
mapping (address => bytes32) cdps; // borrower >>> CDP Bytes
|
mapping(address => bytes32) cdps; // borrower >>> CDP Bytes
|
||||||
bool public freezed;
|
bool public freezed;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract IssueLoan is GlobalVar {
|
contract IssueLoan is GlobalVar {
|
||||||
|
|
||||||
event LockedETH(address borrower, uint lockETH, uint lockPETH, address lockedBy);
|
event LockedETH(address borrower, uint lockETH, uint lockPETH, address lockedBy);
|
||||||
event LoanedDAI(address borrower, uint loanDAI, address payTo);
|
event LoanedDAI(address borrower, uint loanDAI, address payTo);
|
||||||
event NewCDP(address borrower, bytes32 cdpBytes);
|
event NewCDP(address borrower, bytes32 cdpBytes);
|
||||||
|
@ -114,8 +104,12 @@ contract IssueLoan is GlobalVar {
|
||||||
}
|
}
|
||||||
|
|
||||||
function borrow(uint daiDraw, address beneficiary) public payable {
|
function borrow(uint daiDraw, address beneficiary) public payable {
|
||||||
if (msg.value > 0) {lockETH(msg.sender);}
|
if (msg.value > 0) {
|
||||||
if (daiDraw > 0) {drawDAI(daiDraw, beneficiary);}
|
lockETH(msg.sender);
|
||||||
|
}
|
||||||
|
if (daiDraw > 0) {
|
||||||
|
drawDAI(daiDraw, beneficiary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function lockETH(address borrower) public payable {
|
function lockETH(address borrower) public payable {
|
||||||
|
@ -130,8 +124,12 @@ contract IssueLoan is GlobalVar {
|
||||||
uint pethToLock = pethPEReth(msg.value);
|
uint pethToLock = pethPEReth(msg.value);
|
||||||
loanMaster.join(pethToLock); // WETH to PETH
|
loanMaster.join(pethToLock); // WETH to PETH
|
||||||
loanMaster.lock(cdps[borrower], pethToLock); // PETH to CDP
|
loanMaster.lock(cdps[borrower], pethToLock); // PETH to CDP
|
||||||
|
|
||||||
emit LockedETH(
|
emit LockedETH(
|
||||||
borrower, msg.value, pethToLock, msg.sender
|
borrower,
|
||||||
|
msg.value,
|
||||||
|
pethToLock,
|
||||||
|
msg.sender
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,18 +145,20 @@ contract IssueLoan is GlobalVar {
|
||||||
daiTkn.transfer(payTo, daiDraw);
|
daiTkn.transfer(payTo, daiDraw);
|
||||||
emit LoanedDAI(msg.sender, daiDraw, payTo);
|
emit LoanedDAI(msg.sender, daiDraw, payTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract RepayLoan is IssueLoan {
|
contract RepayLoan is IssueLoan {
|
||||||
|
|
||||||
event WipedDAI(address borrower, uint daiWipe, uint mkrCharged, address wipedBy);
|
event WipedDAI(address borrower, uint daiWipe, uint mkrCharged, address wipedBy);
|
||||||
event UnlockedETH(address borrower, uint ethFree);
|
event UnlockedETH(address borrower, uint ethFree);
|
||||||
|
|
||||||
function repay(uint daiWipe, uint ethFree) public payable {
|
function repay(uint daiWipe, uint ethFree) public payable {
|
||||||
if (daiWipe > 0) {wipeDAI(daiWipe, msg.sender);}
|
if (daiWipe > 0) {
|
||||||
if (ethFree > 0) {unlockETH(ethFree);}
|
wipeDAI(daiWipe, msg.sender);
|
||||||
|
}
|
||||||
|
if (ethFree > 0) {
|
||||||
|
unlockETH(ethFree);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function wipeDAI(uint daiWipe, address borrower) public payable {
|
function wipeDAI(uint daiWipe, address borrower) public payable {
|
||||||
|
@ -176,16 +176,24 @@ contract RepayLoan is IssueLoan {
|
||||||
uint mkrCharged = contractMKR - mkrTkn.balanceOf(address(this)); // MKR fee = before wiping bal - after wiping bal
|
uint mkrCharged = contractMKR - mkrTkn.balanceOf(address(this)); // MKR fee = before wiping bal - after wiping bal
|
||||||
|
|
||||||
// claiming paid MKR back
|
// claiming paid MKR back
|
||||||
if (msg.value > 0) { // Interacting with Kyber to swap ETH with MKR
|
if (msg.value > 0) {
|
||||||
|
// Interacting with Kyber to swap ETH with MKR
|
||||||
swapETHMKR(
|
swapETHMKR(
|
||||||
eth, mkr, mkrCharged, msg.value
|
eth,
|
||||||
|
mkr,
|
||||||
|
mkrCharged,
|
||||||
|
msg.value
|
||||||
);
|
);
|
||||||
} else { // take MKR directly from address
|
} else {
|
||||||
|
// take MKR directly from address
|
||||||
mkrTkn.transferFrom(msg.sender, address(this), mkrCharged); // user paying MKR fees
|
mkrTkn.transferFrom(msg.sender, address(this), mkrCharged); // user paying MKR fees
|
||||||
}
|
}
|
||||||
|
|
||||||
emit WipedDAI(
|
emit WipedDAI(
|
||||||
borrower, daiWipe, mkrCharged, msg.sender
|
borrower,
|
||||||
|
daiWipe,
|
||||||
|
mkrCharged,
|
||||||
|
msg.sender
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,30 +214,33 @@ contract RepayLoan is IssueLoan {
|
||||||
address mkr,
|
address mkr,
|
||||||
uint mkrCharged,
|
uint mkrCharged,
|
||||||
uint ethQty
|
uint ethQty
|
||||||
) internal
|
)
|
||||||
{
|
internal
|
||||||
|
{
|
||||||
InstaKyber instak = InstaKyber(getAddress("InstaKyber"));
|
InstaKyber instak = InstaKyber(getAddress("InstaKyber"));
|
||||||
uint minRate;
|
uint minRate;
|
||||||
(, minRate) = instak.getExpectedPrice(eth, mkr, ethQty);
|
(, minRate) = instak.getExpectedPrice(eth, mkr, ethQty);
|
||||||
uint mkrBought = instak.executeTrade.value(ethQty)(
|
uint mkrBought = instak.executeTrade.value(ethQty)(
|
||||||
eth, mkr, ethQty, minRate, mkrCharged
|
eth,
|
||||||
|
mkr,
|
||||||
|
ethQty,
|
||||||
|
minRate,
|
||||||
|
mkrCharged
|
||||||
);
|
);
|
||||||
require(mkrCharged == mkrBought, "ETH not sufficient to cover the MKR fees.");
|
require(mkrCharged == mkrBought, "ETH not sufficient to cover the MKR fees.");
|
||||||
if (address(this).balance > 0) {
|
if (address(this).balance > 0) {
|
||||||
msg.sender.transfer(address(this).balance);
|
msg.sender.transfer(address(this).balance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract BorrowTasks is RepayLoan {
|
contract BorrowTasks is RepayLoan {
|
||||||
|
|
||||||
event TranferCDP(bytes32 cdp, address owner, address nextOwner);
|
event TranferCDP(bytes32 cdp, address owner, address nextOwner);
|
||||||
event CDPClaimed(bytes32 cdp, address owner);
|
event CDPClaimed(bytes32 cdp, address owner);
|
||||||
|
|
||||||
function transferCDP(address nextOwner) public {
|
function transferCDP(address nextOwner) public {
|
||||||
require(nextOwner != 0, "Invalid Address.");
|
require(nextOwner != address(0), "Invalid Address.");
|
||||||
MakerCDP loanMaster = MakerCDP(cdpAddr);
|
MakerCDP loanMaster = MakerCDP(cdpAddr);
|
||||||
loanMaster.give(cdps[msg.sender], nextOwner);
|
loanMaster.give(cdps[msg.sender], nextOwner);
|
||||||
cdps[msg.sender] = blankCDP;
|
cdps[msg.sender] = blankCDP;
|
||||||
|
@ -258,20 +269,19 @@ contract BorrowTasks is RepayLoan {
|
||||||
|
|
||||||
function approveERC20() public {
|
function approveERC20() public {
|
||||||
IERC20 wethTkn = IERC20(getAddress("weth"));
|
IERC20 wethTkn = IERC20(getAddress("weth"));
|
||||||
wethTkn.approve(cdpAddr, 2**256 - 1);
|
wethTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
IERC20 pethTkn = IERC20(getAddress("peth"));
|
IERC20 pethTkn = IERC20(getAddress("peth"));
|
||||||
pethTkn.approve(cdpAddr, 2**256 - 1);
|
pethTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
IERC20 mkrTkn = IERC20(getAddress("mkr"));
|
IERC20 mkrTkn = IERC20(getAddress("mkr"));
|
||||||
mkrTkn.approve(cdpAddr, 2**256 - 1);
|
mkrTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
IERC20 daiTkn = IERC20(getAddress("dai"));
|
IERC20 daiTkn = IERC20(getAddress("dai"));
|
||||||
daiTkn.approve(cdpAddr, 2**256 - 1);
|
daiTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract InstaMaker is BorrowTasks {
|
contract InstaMaker is BorrowTasks {
|
||||||
|
|
||||||
event MKRCollected(uint amount);
|
event MKRCollected(uint amount);
|
||||||
|
|
||||||
constructor(address rAddr) public {
|
constructor(address rAddr) public {
|
||||||
|
@ -280,7 +290,7 @@ contract InstaMaker is BorrowTasks {
|
||||||
approveERC20();
|
approveERC20();
|
||||||
}
|
}
|
||||||
|
|
||||||
function () public payable {}
|
function() external payable {}
|
||||||
|
|
||||||
function freeze(bool stop) public onlyAdmin {
|
function freeze(bool stop) public onlyAdmin {
|
||||||
freezed = stop;
|
freezed = stop;
|
||||||
|
@ -293,4 +303,4 @@ contract InstaMaker is BorrowTasks {
|
||||||
emit MKRCollected(amount);
|
emit MKRCollected(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
// Resolver to Wipe & Coll any CDP
|
// Resolver to Wipe & Coll any CDP
|
||||||
pragma solidity 0.4.24;
|
pragma solidity ^0.5.0;
|
||||||
|
|
||||||
|
|
||||||
library SafeMath {
|
library SafeMath {
|
||||||
|
|
||||||
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
if (a == 0) {
|
if (a == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -12,7 +11,7 @@ library SafeMath {
|
||||||
require(c / a == b, "Assertion Failed");
|
require(c / a == b, "Assertion Failed");
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
require(b > 0, "Assertion Failed");
|
require(b > 0, "Assertion Failed");
|
||||||
uint256 c = a / b;
|
uint256 c = a / b;
|
||||||
|
@ -29,7 +28,7 @@ interface IERC20 {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AddressRegistry {
|
interface AddressRegistry {
|
||||||
function getAddr(string name) external view returns(address);
|
function getAddr(string calldata name) external view returns (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MakerCDP {
|
interface MakerCDP {
|
||||||
|
@ -55,28 +54,23 @@ interface InstaKyber {
|
||||||
uint srcAmt,
|
uint srcAmt,
|
||||||
uint minConversionRate,
|
uint minConversionRate,
|
||||||
uint maxDestAmt
|
uint maxDestAmt
|
||||||
) external payable returns (uint destAmt);
|
)
|
||||||
|
external
|
||||||
|
payable
|
||||||
|
returns (uint destAmt);
|
||||||
|
|
||||||
function getExpectedPrice(
|
function getExpectedPrice(address src, address dest, uint srcAmt) external view returns (uint, uint);
|
||||||
address src,
|
|
||||||
address dest,
|
|
||||||
uint srcAmt
|
|
||||||
) external view returns (uint, uint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract Registry {
|
contract Registry {
|
||||||
|
|
||||||
address public addressRegistry;
|
address public addressRegistry;
|
||||||
modifier onlyAdmin() {
|
modifier onlyAdmin() {
|
||||||
require(
|
require(msg.sender == getAddress("admin"), "Permission Denied");
|
||||||
msg.sender == getAddress("admin"),
|
|
||||||
"Permission Denied"
|
|
||||||
);
|
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAddress(string name) internal view returns(address) {
|
function getAddress(string memory name) internal view returns (address) {
|
||||||
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
||||||
return addrReg.getAddr(name);
|
return addrReg.getAddr(name);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +79,6 @@ contract Registry {
|
||||||
|
|
||||||
|
|
||||||
contract Helper is Registry {
|
contract Helper is Registry {
|
||||||
|
|
||||||
using SafeMath for uint;
|
using SafeMath for uint;
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
|
@ -107,7 +100,12 @@ contract Helper is Registry {
|
||||||
|
|
||||||
contract Lock is Helper {
|
contract Lock is Helper {
|
||||||
|
|
||||||
event LockedETH(uint cdpNum, address lockedBy, uint lockETH, uint lockPETH);
|
event LockedETH(
|
||||||
|
uint cdpNum,
|
||||||
|
address lockedBy,
|
||||||
|
uint lockETH,
|
||||||
|
uint lockPETH
|
||||||
|
);
|
||||||
|
|
||||||
function lockETH(uint cdpNum) public payable {
|
function lockETH(uint cdpNum) public payable {
|
||||||
MakerCDP loanMaster = MakerCDP(cdpAddr);
|
MakerCDP loanMaster = MakerCDP(cdpAddr);
|
||||||
|
@ -116,16 +114,18 @@ contract Lock is Helper {
|
||||||
uint pethToLock = pethPEReth(msg.value);
|
uint pethToLock = pethPEReth(msg.value);
|
||||||
loanMaster.join(pethToLock); // WETH to PETH
|
loanMaster.join(pethToLock); // WETH to PETH
|
||||||
loanMaster.lock(bytes32(cdpNum), pethToLock); // PETH to CDP
|
loanMaster.lock(bytes32(cdpNum), pethToLock); // PETH to CDP
|
||||||
|
|
||||||
emit LockedETH(
|
emit LockedETH(
|
||||||
cdpNum, msg.sender, msg.value, pethToLock
|
cdpNum,
|
||||||
|
msg.sender,
|
||||||
|
msg.value,
|
||||||
|
pethToLock
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract Wipe is Lock {
|
contract Wipe is Lock {
|
||||||
|
|
||||||
event WipedDAI(uint cdpNum, address wipedBy, uint daiWipe, uint mkrCharged);
|
event WipedDAI(uint cdpNum, address wipedBy, uint daiWipe, uint mkrCharged);
|
||||||
|
|
||||||
function wipeDAI(uint cdpNum, uint daiWipe) public payable {
|
function wipeDAI(uint cdpNum, uint daiWipe) public payable {
|
||||||
|
@ -139,57 +139,58 @@ contract Wipe is Lock {
|
||||||
uint mkrCharged = contractMKR - mkrTkn.balanceOf(address(this)); // MKR fee = before wiping bal - after wiping bal
|
uint mkrCharged = contractMKR - mkrTkn.balanceOf(address(this)); // MKR fee = before wiping bal - after wiping bal
|
||||||
|
|
||||||
// claiming paid MKR back
|
// claiming paid MKR back
|
||||||
if (msg.value > 0) { // Interacting with Kyber to swap ETH with MKR
|
if (msg.value > 0) {
|
||||||
swapETHMKR(
|
// Interacting with Kyber to swap ETH with MKR
|
||||||
mkrCharged, msg.value
|
swapETHMKR(mkrCharged, msg.value);
|
||||||
);
|
} else {
|
||||||
} else { // take MKR directly from address
|
// take MKR directly from address
|
||||||
mkrTkn.transferFrom(msg.sender, address(this), mkrCharged); // user paying MKR fees
|
mkrTkn.transferFrom(msg.sender, address(this), mkrCharged); // user paying MKR fees
|
||||||
}
|
}
|
||||||
|
|
||||||
emit WipedDAI(
|
emit WipedDAI(
|
||||||
cdpNum, msg.sender, daiWipe, mkrCharged
|
cdpNum,
|
||||||
|
msg.sender,
|
||||||
|
daiWipe,
|
||||||
|
mkrCharged
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function swapETHMKR(
|
function swapETHMKR(uint mkrCharged, uint ethQty) internal {
|
||||||
uint mkrCharged,
|
|
||||||
uint ethQty
|
|
||||||
) internal
|
|
||||||
{
|
|
||||||
InstaKyber instak = InstaKyber(kyber);
|
InstaKyber instak = InstaKyber(kyber);
|
||||||
uint minRate;
|
uint minRate;
|
||||||
(, minRate) = instak.getExpectedPrice(eth, mkr, ethQty);
|
(, minRate) = instak.getExpectedPrice(eth, mkr, ethQty);
|
||||||
|
|
||||||
uint mkrBought = instak.executeTrade.value(ethQty)(
|
uint mkrBought = instak.executeTrade.value(ethQty)(
|
||||||
eth, mkr, ethQty, minRate, mkrCharged
|
eth,
|
||||||
|
mkr,
|
||||||
|
ethQty,
|
||||||
|
minRate,
|
||||||
|
mkrCharged
|
||||||
);
|
);
|
||||||
|
|
||||||
require(mkrCharged == mkrBought, "ETH not sufficient to cover the MKR fees.");
|
require(mkrCharged == mkrBought, "ETH not sufficient to cover the MKR fees.");
|
||||||
if (address(this).balance > 0) {
|
if (address(this).balance > 0) {
|
||||||
msg.sender.transfer(address(this).balance);
|
msg.sender.transfer(address(this).balance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract ApproveTkn is Wipe {
|
contract ApproveTkn is Wipe {
|
||||||
|
|
||||||
function approveERC20() public {
|
function approveERC20() public {
|
||||||
IERC20 wethTkn = IERC20(weth);
|
IERC20 wethTkn = IERC20(weth);
|
||||||
wethTkn.approve(cdpAddr, 2**256 - 1);
|
wethTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
IERC20 pethTkn = IERC20(peth);
|
IERC20 pethTkn = IERC20(peth);
|
||||||
pethTkn.approve(cdpAddr, 2**256 - 1);
|
pethTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
IERC20 mkrTkn = IERC20(mkr);
|
IERC20 mkrTkn = IERC20(mkr);
|
||||||
mkrTkn.approve(cdpAddr, 2**256 - 1);
|
mkrTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
IERC20 daiTkn = IERC20(dai);
|
IERC20 daiTkn = IERC20(dai);
|
||||||
daiTkn.approve(cdpAddr, 2**256 - 1);
|
daiTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract PublicCDP is ApproveTkn {
|
contract PublicCDP is ApproveTkn {
|
||||||
|
|
||||||
event MKRCollected(uint amount);
|
event MKRCollected(uint amount);
|
||||||
|
|
||||||
constructor(address rAddr) public {
|
constructor(address rAddr) public {
|
||||||
|
@ -204,7 +205,7 @@ contract PublicCDP is ApproveTkn {
|
||||||
approveERC20();
|
approveERC20();
|
||||||
}
|
}
|
||||||
|
|
||||||
function () public payable {}
|
function() external payable {}
|
||||||
|
|
||||||
// collecting MKR token kept as balance to pay fees
|
// collecting MKR token kept as balance to pay fees
|
||||||
function collectMKR(uint amount) public onlyAdmin {
|
function collectMKR(uint amount) public onlyAdmin {
|
||||||
|
@ -212,5 +213,4 @@ contract PublicCDP is ApproveTkn {
|
||||||
mkrTkn.transfer(msg.sender, amount);
|
mkrTkn.transfer(msg.sender, amount);
|
||||||
emit MKRCollected(amount);
|
emit MKRCollected(amount);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
pragma solidity 0.4.24;
|
pragma solidity ^0.5.0;
|
||||||
|
|
||||||
|
|
||||||
library SafeMath {
|
library SafeMath {
|
||||||
|
|
||||||
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
if (a == 0) {
|
if (a == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -11,7 +10,7 @@ library SafeMath {
|
||||||
require(c / a == b, "Assertion Failed");
|
require(c / a == b, "Assertion Failed");
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
require(b > 0, "Assertion Failed");
|
require(b > 0, "Assertion Failed");
|
||||||
uint256 c = a / b;
|
uint256 c = a / b;
|
||||||
|
@ -21,7 +20,7 @@ library SafeMath {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AddressRegistry {
|
interface AddressRegistry {
|
||||||
function getAddr(string name) external view returns(address);
|
function getAddr(string calldata name) external view returns (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MakerCDP {
|
interface MakerCDP {
|
||||||
|
@ -31,7 +30,6 @@ interface MakerCDP {
|
||||||
|
|
||||||
|
|
||||||
contract UniqueCDP {
|
contract UniqueCDP {
|
||||||
|
|
||||||
address public deployer;
|
address public deployer;
|
||||||
address public cdpAddr;
|
address public cdpAddr;
|
||||||
|
|
||||||
|
@ -53,4 +51,4 @@ contract UniqueCDP {
|
||||||
loanMaster.give(bytes32(cdpNum), nextOwner);
|
loanMaster.give(bytes32(cdpNum), nextOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.5.0;
|
||||||
|
|
||||||
interface IERC20 {
|
interface IERC20 {
|
||||||
function balanceOf(address who) external view returns (uint256);
|
function balanceOf(address who) external view returns (uint256);
|
||||||
|
@ -6,7 +6,7 @@ interface IERC20 {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AddressRegistry {
|
interface AddressRegistry {
|
||||||
function getAddr(string name) external view returns(address);
|
function getAddr(string calldata name) external view returns (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Kyber {
|
interface Kyber {
|
||||||
|
@ -20,24 +20,17 @@ interface Kyber {
|
||||||
address walletId
|
address walletId
|
||||||
) external payable returns (uint);
|
) external payable returns (uint);
|
||||||
|
|
||||||
function getExpectedRate(
|
function getExpectedRate(address src, address dest, uint srcQty) external view returns (uint, uint);
|
||||||
address src,
|
|
||||||
address dest,
|
|
||||||
uint srcQty
|
|
||||||
) external view returns (uint, uint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract Registry {
|
contract Registry {
|
||||||
address public addressRegistry;
|
address public addressRegistry;
|
||||||
modifier onlyAdmin() {
|
modifier onlyAdmin() {
|
||||||
require(
|
require(msg.sender == getAddress("admin"), "Permission Denied");
|
||||||
msg.sender == getAddress("admin"),
|
|
||||||
"Permission Denied"
|
|
||||||
);
|
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
function getAddress(string name) internal view returns(address) {
|
function getAddress(string memory name) internal view returns (address) {
|
||||||
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
||||||
return addrReg.getAddr(name);
|
return addrReg.getAddr(name);
|
||||||
}
|
}
|
||||||
|
@ -45,19 +38,11 @@ contract Registry {
|
||||||
|
|
||||||
|
|
||||||
contract Trade is Registry {
|
contract Trade is Registry {
|
||||||
|
event KyberTrade(address src, uint srcAmt, address dest, uint destAmt, address beneficiary, uint minConversionRate);
|
||||||
event KyberTrade(
|
|
||||||
address src,
|
|
||||||
uint srcAmt,
|
|
||||||
address dest,
|
|
||||||
uint destAmt,
|
|
||||||
address beneficiary,
|
|
||||||
uint minConversionRate
|
|
||||||
);
|
|
||||||
|
|
||||||
function approveDAIKyber() public {
|
function approveDAIKyber() public {
|
||||||
IERC20 tokenFunctions = IERC20(getAddress("dai"));
|
IERC20 tokenFunctions = IERC20(getAddress("dai"));
|
||||||
tokenFunctions.approve(getAddress("kyber"), 2**255);
|
tokenFunctions.approve(getAddress("kyber"), 2 ** 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
function expectedETH(uint srcDAI) public view returns (uint, uint) {
|
function expectedETH(uint srcDAI) public view returns (uint, uint) {
|
||||||
|
@ -73,32 +58,34 @@ contract Trade is Registry {
|
||||||
|
|
||||||
// Interacting with Kyber Proxy Contract
|
// Interacting with Kyber Proxy Contract
|
||||||
Kyber kyberFunctions = Kyber(getAddress("kyber"));
|
Kyber kyberFunctions = Kyber(getAddress("kyber"));
|
||||||
|
|
||||||
destAmt = kyberFunctions.trade.value(0)(
|
destAmt = kyberFunctions.trade.value(0)(
|
||||||
src,
|
src,
|
||||||
srcDAI,
|
srcDAI,
|
||||||
dest,
|
dest,
|
||||||
msg.sender,
|
msg.sender,
|
||||||
2**255,
|
2 ** 255,
|
||||||
minConversionRate,
|
minConversionRate,
|
||||||
getAddress("admin")
|
getAddress("admin")
|
||||||
);
|
);
|
||||||
|
|
||||||
emit KyberTrade(
|
emit KyberTrade(
|
||||||
src, srcDAI, dest, destAmt, msg.sender, minConversionRate
|
src,
|
||||||
|
srcDAI,
|
||||||
|
dest,
|
||||||
|
destAmt,
|
||||||
|
msg.sender,
|
||||||
|
minConversionRate
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract DAI2ETH is Trade {
|
contract DAI2ETH is Trade {
|
||||||
|
|
||||||
constructor(address rAddr) public {
|
constructor(address rAddr) public {
|
||||||
addressRegistry = rAddr;
|
addressRegistry = rAddr;
|
||||||
approveDAIKyber();
|
approveDAIKyber();
|
||||||
}
|
}
|
||||||
|
|
||||||
function () public payable {}
|
function() external payable {}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//// SMART CONTARCT
|
//// SMART CONTARCT
|
||||||
// mapping of SendWyre address
|
// mapping of SendWyre address
|
||||||
|
|
||||||
//// DAPP
|
//// DAPP
|
||||||
// check isAddress (and every important variable) before executing any contract function
|
// check isAddress (and every important variable) before executing any contract function
|
||||||
|
@ -10,11 +10,10 @@
|
||||||
//// RAVINDRA
|
//// RAVINDRA
|
||||||
// How can we create a global variable for "loanMaster"?
|
// How can we create a global variable for "loanMaster"?
|
||||||
|
|
||||||
pragma solidity 0.4.24;
|
pragma solidity ^0.5.0;
|
||||||
|
|
||||||
|
|
||||||
library SafeMath {
|
library SafeMath {
|
||||||
|
|
||||||
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
if (a == 0) {
|
if (a == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -23,7 +22,7 @@ library SafeMath {
|
||||||
require(c / a == b, "Assertion Failed");
|
require(c / a == b, "Assertion Failed");
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
require(b > 0, "Assertion Failed");
|
require(b > 0, "Assertion Failed");
|
||||||
uint256 c = a / b;
|
uint256 c = a / b;
|
||||||
|
@ -40,7 +39,7 @@ interface IERC20 {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AddressRegistry {
|
interface AddressRegistry {
|
||||||
function getAddr(string name) external view returns(address);
|
function getAddr(string calldata name) external view returns (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MakerCDP {
|
interface MakerCDP {
|
||||||
|
@ -73,50 +72,43 @@ interface WETHFace {
|
||||||
function withdraw(uint wad) external;
|
function withdraw(uint wad) external;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface InstaKyber {
|
interface InstaKyber {
|
||||||
function executeTrade(
|
function executeTrade(
|
||||||
address src,
|
address src,
|
||||||
address dest,
|
address dest,
|
||||||
uint srcAmt,
|
uint srcAmt,
|
||||||
uint minConversionRate,
|
uint minConversionRate,
|
||||||
uint maxDestAmt
|
uint maxDestAmt
|
||||||
) external payable returns (uint destAmt);
|
)
|
||||||
|
external
|
||||||
|
payable
|
||||||
|
returns (uint destAmt);
|
||||||
|
|
||||||
function getExpectedPrice(
|
function getExpectedPrice(address src, address dest, uint srcAmt) external view returns (uint, uint);
|
||||||
address src,
|
|
||||||
address dest,
|
|
||||||
uint srcAmt
|
|
||||||
) external view returns (uint, uint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract Registry {
|
contract Registry {
|
||||||
|
|
||||||
address public addressRegistry;
|
address public addressRegistry;
|
||||||
modifier onlyAdmin() {
|
modifier onlyAdmin() {
|
||||||
require(
|
require(msg.sender == getAddress("admin"), "Permission Denied");
|
||||||
msg.sender == getAddress("admin"),
|
|
||||||
"Permission Denied"
|
|
||||||
);
|
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAddress(string name) internal view returns(address) {
|
function getAddress(string memory name) internal view returns (address) {
|
||||||
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
||||||
return addrReg.getAddr(name);
|
return addrReg.getAddr(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract GlobalVar is Registry {
|
contract GlobalVar is Registry {
|
||||||
|
|
||||||
using SafeMath for uint;
|
using SafeMath for uint;
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
address cdpAddr; // SaiTub
|
address cdpAddr; // SaiTub
|
||||||
mapping (uint => address) cdps; // CDP Number >>> Borrower
|
mapping(uint => address) cdps; // CDP Number >>> Borrower
|
||||||
mapping (address => bool) resolvers;
|
mapping(address => bool) resolvers;
|
||||||
bool public freezed;
|
bool public freezed;
|
||||||
|
|
||||||
modifier isFreezed() {
|
modifier isFreezed() {
|
||||||
|
@ -125,9 +117,7 @@ contract GlobalVar is Registry {
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier isCupOwner(uint cdpNum) {
|
modifier isCupOwner(uint cdpNum) {
|
||||||
require(
|
require(cdps[cdpNum] == msg.sender || cdps[cdpNum] == address(0x0) || cdpNum == 0, "Permission Denied");
|
||||||
cdps[cdpNum] == msg.sender || cdps[cdpNum] == address(0x0) || cdpNum == 0,
|
|
||||||
"Permission Denied");
|
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,12 +125,10 @@ contract GlobalVar is Registry {
|
||||||
MakerCDP loanMaster = MakerCDP(cdpAddr);
|
MakerCDP loanMaster = MakerCDP(cdpAddr);
|
||||||
rPETH = (ethNum.mul(10 ** 27)).div(loanMaster.per());
|
rPETH = (ethNum.mul(10 ** 27)).div(loanMaster.per());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract BorrowLoan is GlobalVar {
|
contract BorrowLoan is GlobalVar {
|
||||||
|
|
||||||
// uint cdpNum
|
// uint cdpNum
|
||||||
event LockedETH(uint cdpNum, address borrower, uint lockETH, uint lockPETH);
|
event LockedETH(uint cdpNum, address borrower, uint lockETH, uint lockPETH);
|
||||||
event LoanedDAI(uint cdpNum, address borrower, uint loanDAI, address payTo);
|
event LoanedDAI(uint cdpNum, address borrower, uint loanDAI, address payTo);
|
||||||
|
@ -166,7 +154,10 @@ contract BorrowLoan is GlobalVar {
|
||||||
loanMaster.join(pethToLock); // WETH to PETH
|
loanMaster.join(pethToLock); // WETH to PETH
|
||||||
loanMaster.lock(cup, pethToLock); // PETH to CDP
|
loanMaster.lock(cup, pethToLock); // PETH to CDP
|
||||||
emit LockedETH(
|
emit LockedETH(
|
||||||
uint(cup), msg.sender, msg.value, pethToLock
|
uint(cup),
|
||||||
|
msg.sender,
|
||||||
|
msg.value,
|
||||||
|
pethToLock
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,17 +170,19 @@ contract BorrowLoan is GlobalVar {
|
||||||
payTo = msg.sender;
|
payTo = msg.sender;
|
||||||
}
|
}
|
||||||
daiTkn.transfer(payTo, daiDraw);
|
daiTkn.transfer(payTo, daiDraw);
|
||||||
|
|
||||||
emit LoanedDAI(
|
emit LoanedDAI(
|
||||||
uint(cup), msg.sender, daiDraw, payTo
|
uint(cup),
|
||||||
|
msg.sender,
|
||||||
|
daiDraw,
|
||||||
|
payTo
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract RepayLoan is BorrowLoan {
|
contract RepayLoan is BorrowLoan {
|
||||||
|
|
||||||
event WipedDAI(uint cdpNum, address borrower, uint daiWipe, uint mkrCharged);
|
event WipedDAI(uint cdpNum, address borrower, uint daiWipe, uint mkrCharged);
|
||||||
event FreedETH(uint cdpNum, address borrower, uint ethFree);
|
event FreedETH(uint cdpNum, address borrower, uint ethFree);
|
||||||
event ShutCDP(uint cdpNum, address borrower, uint daiWipe, uint ethFree);
|
event ShutCDP(uint cdpNum, address borrower, uint daiWipe, uint ethFree);
|
||||||
|
@ -211,15 +204,20 @@ contract RepayLoan is BorrowLoan {
|
||||||
if (msg.value > 0) {
|
if (msg.value > 0) {
|
||||||
// [UniSwap] claiming paid MKR back ETH <> DAI
|
// [UniSwap] claiming paid MKR back ETH <> DAI
|
||||||
return;
|
return;
|
||||||
} else { // take MKR directly from address
|
} else {
|
||||||
|
// take MKR directly from address
|
||||||
mkrTkn.transferFrom(msg.sender, address(this), mkrCharged); // user paying MKR fees
|
mkrTkn.transferFrom(msg.sender, address(this), mkrCharged); // user paying MKR fees
|
||||||
}
|
}
|
||||||
|
|
||||||
emit WipedDAI(
|
emit WipedDAI(
|
||||||
cdpNum, msg.sender, daiWipe, mkrCharged
|
cdpNum,
|
||||||
|
msg.sender,
|
||||||
|
daiWipe,
|
||||||
|
mkrCharged
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO => send pethFree from frontend instead of ethFree
|
// TODO => send pethFree from frontend instead of ethFree
|
||||||
function unlockETH(uint cdpNum, uint ethFree) public isFreezed isCupOwner(cdpNum) {
|
function unlockETH(uint cdpNum, uint ethFree) public isFreezed isCupOwner(cdpNum) {
|
||||||
require(!freezed, "Operation Disabled");
|
require(!freezed, "Operation Disabled");
|
||||||
bytes32 cup = bytes32(cdpNum);
|
bytes32 cup = bytes32(cdpNum);
|
||||||
|
@ -234,7 +232,9 @@ contract RepayLoan is BorrowLoan {
|
||||||
}
|
}
|
||||||
|
|
||||||
function shut(uint cdpNum, uint daiDebt) public payable isFreezed isCupOwner(cdpNum) {
|
function shut(uint cdpNum, uint daiDebt) public payable isFreezed isCupOwner(cdpNum) {
|
||||||
if (daiDebt > 0) {wipeDAI(cdpNum, daiDebt);}
|
if (daiDebt > 0) {
|
||||||
|
wipeDAI(cdpNum, daiDebt);
|
||||||
|
}
|
||||||
MakerCDP loanMaster = MakerCDP(cdpAddr);
|
MakerCDP loanMaster = MakerCDP(cdpAddr);
|
||||||
loanMaster.shut(bytes32(cdpNum));
|
loanMaster.shut(bytes32(cdpNum));
|
||||||
|
|
||||||
|
@ -250,15 +250,16 @@ contract RepayLoan is BorrowLoan {
|
||||||
cdps[cdpNum] = address(0x0);
|
cdps[cdpNum] = address(0x0);
|
||||||
|
|
||||||
emit ShutCDP(
|
emit ShutCDP(
|
||||||
cdpNum, msg.sender, daiDebt, wethBal
|
cdpNum,
|
||||||
|
msg.sender,
|
||||||
|
daiDebt,
|
||||||
|
wethBal
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract MiscTask is RepayLoan {
|
contract MiscTask is RepayLoan {
|
||||||
|
|
||||||
event TranferInternal(uint cdpNum, address owner, address nextOwner);
|
event TranferInternal(uint cdpNum, address owner, address nextOwner);
|
||||||
event TranferExternal(uint cdpNum, address owner, address nextOwner);
|
event TranferExternal(uint cdpNum, address owner, address nextOwner);
|
||||||
event CDPClaimed(uint cdpNum, address owner);
|
event CDPClaimed(uint cdpNum, address owner);
|
||||||
|
@ -298,7 +299,6 @@ contract MiscTask is RepayLoan {
|
||||||
loanMaster.give(bytes32(cdpNum), resolverAddress);
|
loanMaster.give(bytes32(cdpNum), resolverAddress);
|
||||||
resolverAct.initAct(cdpNum);
|
resolverAct.initAct(cdpNum);
|
||||||
emit ResolverTwoWay(cdpNum, msg.sender, resolverAddress);
|
emit ResolverTwoWay(cdpNum, msg.sender, resolverAddress);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function claimCDP(uint cdpNum) public {
|
function claimCDP(uint cdpNum) public {
|
||||||
|
@ -322,20 +322,18 @@ contract MiscTask is RepayLoan {
|
||||||
|
|
||||||
function approveERC20() public {
|
function approveERC20() public {
|
||||||
IERC20 wethTkn = IERC20(getAddress("weth"));
|
IERC20 wethTkn = IERC20(getAddress("weth"));
|
||||||
wethTkn.approve(cdpAddr, 2**256 - 1);
|
wethTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
IERC20 pethTkn = IERC20(getAddress("peth"));
|
IERC20 pethTkn = IERC20(getAddress("peth"));
|
||||||
pethTkn.approve(cdpAddr, 2**256 - 1);
|
pethTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
IERC20 mkrTkn = IERC20(getAddress("mkr"));
|
IERC20 mkrTkn = IERC20(getAddress("mkr"));
|
||||||
mkrTkn.approve(cdpAddr, 2**256 - 1);
|
mkrTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
IERC20 daiTkn = IERC20(getAddress("dai"));
|
IERC20 daiTkn = IERC20(getAddress("dai"));
|
||||||
daiTkn.approve(cdpAddr, 2**256 - 1);
|
daiTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract InstaBank is MiscTask {
|
contract InstaBank is MiscTask {
|
||||||
|
|
||||||
event MKRCollected(uint amount);
|
event MKRCollected(uint amount);
|
||||||
|
|
||||||
constructor(address rAddr) public {
|
constructor(address rAddr) public {
|
||||||
|
@ -344,7 +342,7 @@ contract InstaBank is MiscTask {
|
||||||
approveERC20();
|
approveERC20();
|
||||||
}
|
}
|
||||||
|
|
||||||
function () public payable {}
|
function() external payable {}
|
||||||
|
|
||||||
function freeze(bool stop) public onlyAdmin {
|
function freeze(bool stop) public onlyAdmin {
|
||||||
freezed = stop;
|
freezed = stop;
|
||||||
|
@ -360,5 +358,4 @@ contract InstaBank is MiscTask {
|
||||||
mkrTkn.transfer(msg.sender, amount);
|
mkrTkn.transfer(msg.sender, amount);
|
||||||
emit MKRCollected(amount);
|
emit MKRCollected(amount);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
pragma solidity 0.4.24;
|
pragma solidity ^0.5.0;
|
||||||
|
|
||||||
|
|
||||||
library SafeMath {
|
library SafeMath {
|
||||||
|
|
||||||
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
if (a == 0) {
|
if (a == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -26,7 +25,7 @@ interface IERC20 {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AddressRegistry {
|
interface AddressRegistry {
|
||||||
function getAddr(string name) external view returns(address);
|
function getAddr(string calldata name) external view returns (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MakerCDP {
|
interface MakerCDP {
|
||||||
|
@ -59,13 +58,10 @@ interface InstaBank {
|
||||||
contract Registry {
|
contract Registry {
|
||||||
address public addressRegistry;
|
address public addressRegistry;
|
||||||
modifier onlyAdmin() {
|
modifier onlyAdmin() {
|
||||||
require(
|
require(msg.sender == getAddress("admin"), "Permission Denied");
|
||||||
msg.sender == getAddress("admin"),
|
|
||||||
"Permission Denied"
|
|
||||||
);
|
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
function getAddress(string name) internal view returns(address) {
|
function getAddress(string memory name) internal view returns (address) {
|
||||||
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
||||||
return addrReg.getAddr(name);
|
return addrReg.getAddr(name);
|
||||||
}
|
}
|
||||||
|
@ -73,7 +69,6 @@ contract Registry {
|
||||||
|
|
||||||
|
|
||||||
contract GlobalVar is Registry {
|
contract GlobalVar is Registry {
|
||||||
|
|
||||||
using SafeMath for uint;
|
using SafeMath for uint;
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
|
@ -89,20 +84,19 @@ contract GlobalVar is Registry {
|
||||||
|
|
||||||
function approveERC20() public {
|
function approveERC20() public {
|
||||||
IERC20 wethTkn = IERC20(getAddress("weth"));
|
IERC20 wethTkn = IERC20(getAddress("weth"));
|
||||||
wethTkn.approve(cdpAddr, 2**256 - 1);
|
wethTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
IERC20 pethTkn = IERC20(getAddress("peth"));
|
IERC20 pethTkn = IERC20(getAddress("peth"));
|
||||||
pethTkn.approve(cdpAddr, 2**256 - 1);
|
pethTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
IERC20 mkrTkn = IERC20(getAddress("mkr"));
|
IERC20 mkrTkn = IERC20(getAddress("mkr"));
|
||||||
mkrTkn.approve(cdpAddr, 2**256 - 1);
|
mkrTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
IERC20 daiTkn = IERC20(getAddress("dai"));
|
IERC20 daiTkn = IERC20(getAddress("dai"));
|
||||||
daiTkn.approve(cdpAddr, 2**256 - 1);
|
daiTkn.approve(cdpAddr, 2 ** 256 - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract LoopNewCDP is GlobalVar {
|
contract LoopNewCDP is GlobalVar {
|
||||||
|
|
||||||
event LevNewCDP(uint cdpNum, uint ethLocked, uint daiMinted);
|
event LevNewCDP(uint cdpNum, uint ethLocked, uint daiMinted);
|
||||||
|
|
||||||
function pethPEReth(uint ethNum) public view returns (uint rPETH) {
|
function pethPEReth(uint ethNum) public view returns (uint rPETH) {
|
||||||
|
@ -138,9 +132,11 @@ contract LoopNewCDP is GlobalVar {
|
||||||
}
|
}
|
||||||
require(contractETHBal == address(this).balance, "No Refund of Contract ETH");
|
require(contractETHBal == address(this).balance, "No Refund of Contract ETH");
|
||||||
|
|
||||||
if (isCDP2Sender) { // CDP >>> msg.sender
|
if (isCDP2Sender) {
|
||||||
|
// CDP >>> msg.sender
|
||||||
loanMaster.give(cup, msg.sender);
|
loanMaster.give(cup, msg.sender);
|
||||||
} else { // CDP >>> InstaBank
|
} else {
|
||||||
|
// CDP >>> InstaBank
|
||||||
InstaBank resolveBank = InstaBank(getAddress("bankv2"));
|
InstaBank resolveBank = InstaBank(getAddress("bankv2"));
|
||||||
resolveBank.claimCDP(uint(cup));
|
resolveBank.claimCDP(uint(cup));
|
||||||
resolveBank.transferCDPInternal(uint(cup), msg.sender);
|
resolveBank.transferCDPInternal(uint(cup), msg.sender);
|
||||||
|
@ -153,14 +149,13 @@ contract LoopNewCDP is GlobalVar {
|
||||||
|
|
||||||
|
|
||||||
contract LeverageCDP is LoopNewCDP {
|
contract LeverageCDP is LoopNewCDP {
|
||||||
|
|
||||||
constructor(address rAddr) public {
|
constructor(address rAddr) public {
|
||||||
addressRegistry = rAddr;
|
addressRegistry = rAddr;
|
||||||
cdpAddr = getAddress("cdp");
|
cdpAddr = getAddress("cdp");
|
||||||
approveERC20();
|
approveERC20();
|
||||||
}
|
}
|
||||||
|
|
||||||
function () public payable {}
|
function() external payable {}
|
||||||
|
|
||||||
function collectETH(uint ethQty) public onlyAdmin {
|
function collectETH(uint ethQty) public onlyAdmin {
|
||||||
msg.sender.transfer(ethQty);
|
msg.sender.transfer(ethQty);
|
||||||
|
@ -170,4 +165,4 @@ contract LeverageCDP is LoopNewCDP {
|
||||||
freezed = stop;
|
freezed = stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
36
package.json
36
package.json
|
@ -22,14 +22,14 @@
|
||||||
"build": "npm run clean:contracts && truffle compile"
|
"build": "npm run clean:contracts && truffle compile"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"web3": "^1.0.0-beta.36",
|
|
||||||
"bn.js": "^4.11.8",
|
"bn.js": "^4.11.8",
|
||||||
"dotenv": "^6.1.0",
|
"dotenv": "^6.2.0",
|
||||||
"openzeppelin-solidity": "^2.0.0",
|
"ethereumjs-wallet": "^0.6.3",
|
||||||
"prettier": "^1.14.3",
|
"openzeppelin-solidity": "^2.1.2",
|
||||||
"truffle": "^5.0.0-beta.0",
|
"truffle": "^5.0.2",
|
||||||
"webpack": "^4.23.1",
|
"truffle-hdwallet-provider": "^1.0.2",
|
||||||
"truffle-hdwallet-provider": "^1.0.0-web3one.0"
|
"web3": "^1.0.0-beta.39",
|
||||||
|
"webpack": "^4.29.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-cli": "^6.26.0",
|
"babel-cli": "^6.26.0",
|
||||||
|
@ -42,24 +42,26 @@
|
||||||
"babel-register": "6.26.0",
|
"babel-register": "6.26.0",
|
||||||
"chai": "4.2.0",
|
"chai": "4.2.0",
|
||||||
"chai-as-promised": "7.1.1",
|
"chai-as-promised": "7.1.1",
|
||||||
"chai-bignumber": "2.0.2",
|
"chai-bignumber": "3.0.0",
|
||||||
"coveralls": "3.0.2",
|
"coveralls": "3.0.2",
|
||||||
"eslint": "5.8.0",
|
"eslint": "5.12.1",
|
||||||
"eslint-config-prettier": "^3.1.0",
|
"eslint-config-prettier": "^4.0.0",
|
||||||
"eslint-config-standard": "^12.0.0",
|
"eslint-config-standard": "^12.0.0",
|
||||||
"eslint-plugin-babel": "^5.2.1",
|
"eslint-plugin-babel": "^5.3.0",
|
||||||
"eslint-plugin-compat": "^2.6.2",
|
"eslint-plugin-compat": "^2.6.3",
|
||||||
"eslint-plugin-import": "2.14.0",
|
"eslint-plugin-import": "2.15.0",
|
||||||
"eslint-plugin-node": "8.0.0",
|
"eslint-plugin-node": "8.0.1",
|
||||||
"eslint-plugin-prettier": "^3.0.0",
|
"eslint-plugin-prettier": "^3.0.1",
|
||||||
"eslint-plugin-promise": "4.0.1",
|
"eslint-plugin-promise": "4.0.1",
|
||||||
"eslint-plugin-security": "^1.4.0",
|
"eslint-plugin-security": "^1.4.0",
|
||||||
"eslint-plugin-standard": "^4.0.0",
|
"eslint-plugin-standard": "^4.0.0",
|
||||||
"eth-gas-reporter": "^0.1.12",
|
"eth-gas-reporter": "^0.1.12",
|
||||||
"ganache-cli": "^6.1.8",
|
"ganache-cli": "^6.2.5",
|
||||||
"mocha-junit-reporter": "^1.18.0",
|
"mocha-junit-reporter": "^1.18.0",
|
||||||
"mocha-multi-reporters": "^1.1.7",
|
"mocha-multi-reporters": "^1.1.7",
|
||||||
|
"prettier": "^1.16.1",
|
||||||
|
"prettier-plugin-solidity-refactor": "^1.0.0-alpha.14",
|
||||||
"solidity-coverage": "0.5.11",
|
"solidity-coverage": "0.5.11",
|
||||||
"solium": "1.1.8"
|
"solium": "1.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,4 @@ contract('Ownable', accounts => {
|
||||||
assert.isTrue(owner !== other)
|
assert.isTrue(owner !== other)
|
||||||
await assertRevert(ownable.transferOwnership(other, { from: other }))
|
await assertRevert(ownable.transferOwnership(other, { from: other }))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should guard ownership against stuck state', async () => {
|
|
||||||
const originalOwner = await ownable.owner()
|
|
||||||
await assertRevert(ownable.transferOwnership(null, { from: originalOwner }))
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
require('dotenv').config()
|
require('dotenv').config()
|
||||||
const HDWalletProvider = require('truffle-hdwallet-provider')
|
const HDWalletProvider = require('truffle-hdwallet-provider')
|
||||||
const Wallet = require('ethereumjs-wallet')
|
|
||||||
|
|
||||||
const rinkebyPrivateKey = new Buffer(process.env['RINKEBY_PRIVATE_KEY'], 'hex')
|
const rinkebyWallet =
|
||||||
const rinkebyWallet = Wallet.fromPrivateKey(rinkebyPrivateKey)
|
'candy maple cake sugar pudding cream honey rich smooth crumble sweet treat'
|
||||||
const rinkebyProvider = new HDWalletProvider(
|
const rinkebyProvider = new HDWalletProvider(
|
||||||
rinkebyWallet,
|
rinkebyWallet,
|
||||||
'https://rinkeby.infura.io/'
|
'https://rinkeby.infura.io/'
|
||||||
)
|
)
|
||||||
|
|
||||||
const ropstenPrivateKey = new Buffer(process.env['ROPSTEN_PRIVATE_KEY'], 'hex')
|
const ropstenWallet =
|
||||||
const ropstenWallet = Wallet.fromPrivateKey(ropstenPrivateKey)
|
'candy maple cake sugar pudding cream honey rich smooth crumble sweet treat'
|
||||||
const ropstenProvider = new HDWalletProvider(
|
const ropstenProvider = new HDWalletProvider(
|
||||||
ropstenWallet,
|
ropstenWallet,
|
||||||
'https://ropsten.infura.io/'
|
'https://ropsten.infura.io/'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user