mirror of
https://github.com/Instadapp/InstaContract.git
synced 2024-07-29 22:47:45 +00:00
Fixed standard errors.
This commit is contained in:
parent
2901bb85cb
commit
cd87e4a868
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
|
||||||
contract AddressRegistry {
|
contract AddressRegistry {
|
||||||
|
|
||||||
event AddressChanged(string name, address target);
|
event AddressChanged(string name, address target);
|
||||||
|
|
|
@ -61,13 +61,13 @@ contract Registry {
|
||||||
|
|
||||||
contract GlobalVar is Registry {
|
contract GlobalVar is Registry {
|
||||||
|
|
||||||
address public WETH = 0xd0a1e359811322d97991e03f863a0c30c2cf029c;
|
address public weth = 0xd0a1e359811322d97991e03f863a0c30c2cf029c;
|
||||||
address public PETH = 0xf4d791139ce033ad35db2b2201435fad668b1b64;
|
address public peth = 0xf4d791139ce033ad35db2b2201435fad668b1b64;
|
||||||
address public MKR = 0xaaf64bfcc32d0f15873a02163e7e500671a4ffcd;
|
address public mkr = 0xaaf64bfcc32d0f15873a02163e7e500671a4ffcd;
|
||||||
address public DAI = 0xc4375b7de8af5a38a93548eb8453a498222c4ff2;
|
address public dai = 0xc4375b7de8af5a38a93548eb8453a498222c4ff2;
|
||||||
|
|
||||||
address public CDPAddr = 0xa71937147b55Deb8a530C7229C442Fd3F31b7db2;
|
address public cdpAddr = 0xa71937147b55Deb8a530C7229C442Fd3F31b7db2;
|
||||||
MakerCDP DAILoanMaster = MakerCDP(CDPAddr);
|
MakerCDP loanMaster = MakerCDP(cdpAddr);
|
||||||
|
|
||||||
mapping (address => bytes32) public borrowerCDPs; // borrower >>> CDP Bytes
|
mapping (address => bytes32) public borrowerCDPs; // borrower >>> CDP Bytes
|
||||||
|
|
||||||
|
@ -77,36 +77,36 @@ contract GlobalVar is Registry {
|
||||||
contract BorrowTasks is GlobalVar {
|
contract BorrowTasks is GlobalVar {
|
||||||
|
|
||||||
function openCDP() internal returns (bytes32) {
|
function openCDP() internal returns (bytes32) {
|
||||||
return DAILoanMaster.open();
|
return loanMaster.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
function ETH_WETH(uint weiAmt) internal {
|
function convertToWETH(uint weiAmt) internal {
|
||||||
WETHFace wethFunction = WETHFace(WETH);
|
WETHFace wethFunction = WETHFace(weth);
|
||||||
wethFunction.deposit.value(weiAmt)();
|
wethFunction.deposit.value(weiAmt)();
|
||||||
}
|
}
|
||||||
|
|
||||||
function WETH_PETH(uint weiAmt) internal {
|
function convertToPETH(uint weiAmt) internal {
|
||||||
DAILoanMaster.join(weiAmt);
|
loanMaster.join(weiAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function PETH_CDP(address borrower, uint weiAmt) internal {
|
function lockPETH(address borrower, uint weiAmt) internal {
|
||||||
DAILoanMaster.lock(borrowerCDPs[borrower], weiAmt);
|
loanMaster.lock(borrowerCDPs[borrower], weiAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function transferCDP(address nextOwner) public {
|
function transferCDP(address nextOwner) public {
|
||||||
require(nextOwner != 0, "Invalid Address.");
|
require(nextOwner != 0, "Invalid Address.");
|
||||||
DAILoanMaster.give(borrowerCDPs[msg.sender], nextOwner);
|
loanMaster.give(borrowerCDPs[msg.sender], nextOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ApproveERC20() public {
|
function approveERC20() public {
|
||||||
token WETHtkn = token(WETH);
|
token wethTkn = token(weth);
|
||||||
WETHtkn.approve(CDPAddr, 2**256 - 1);
|
wethTkn.approve(cdpAddr, 2**256 - 1);
|
||||||
token PETHtkn = token(PETH);
|
token pethTkn = token(peth);
|
||||||
PETHtkn.approve(CDPAddr, 2**256 - 1);
|
pethTkn.approve(cdpAddr, 2**256 - 1);
|
||||||
token MKRtkn = token(MKR);
|
token mkrTkn = token(mkr);
|
||||||
MKRtkn.approve(CDPAddr, 2**256 - 1);
|
mkrTkn.approve(cdpAddr, 2**256 - 1);
|
||||||
token DAItkn = token(DAI);
|
token daiTkn = token(dai);
|
||||||
DAItkn.approve(CDPAddr, 2**256 - 1);
|
daiTkn.approve(cdpAddr, 2**256 - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -132,22 +132,22 @@ contract Borrow is BorrowTasks {
|
||||||
address borrower,
|
address borrower,
|
||||||
uint lockETH,
|
uint lockETH,
|
||||||
uint loanDAI
|
uint loanDAI
|
||||||
) public securedResolver(borrower) {
|
) public securedResolver(borrower)
|
||||||
|
{
|
||||||
if (borrowerCDPs[borrower] == 0x0000000000000000000000000000000000000000000000000000000000000000) {
|
if (borrowerCDPs[borrower] == 0x0000000000000000000000000000000000000000000000000000000000000000) {
|
||||||
borrowerCDPs[borrower] = openCDP();
|
borrowerCDPs[borrower] = openCDP();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lockETH != 0) {
|
if (lockETH != 0) {
|
||||||
ETH_WETH(lockETH);
|
convertToWETH(lockETH);
|
||||||
WETH_PETH(lockETH - lockETH/1000);
|
convertToPETH(lockETH - lockETH/1000);
|
||||||
PETH_CDP(borrower, lockETH - lockETH/1000);
|
lockPETH(borrower, lockETH - lockETH/1000);
|
||||||
// event for locking ETH
|
// event for locking ETH
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loanDAI != 0) {
|
if (loanDAI != 0) {
|
||||||
DAILoanMaster.draw(borrowerCDPs[borrower], loanDAI);
|
loanMaster.draw(borrowerCDPs[borrower], loanDAI);
|
||||||
token tokenFunctions = token(DAI);
|
token tokenFunctions = token(dai);
|
||||||
tokenFunctions.transfer(getAddress("asset"), loanDAI);
|
tokenFunctions.transfer(getAddress("asset"), loanDAI);
|
||||||
// event for drawing DAI
|
// event for drawing DAI
|
||||||
}
|
}
|
||||||
|
@ -160,9 +160,9 @@ contract Borrow is BorrowTasks {
|
||||||
contract MoatMaker is Borrow {
|
contract MoatMaker is Borrow {
|
||||||
|
|
||||||
constructor() public {
|
constructor() public {
|
||||||
ApproveERC20();
|
approveERC20();
|
||||||
}
|
}
|
||||||
|
|
||||||
function () public payable {}
|
function () public payable {}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user