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;
|
||||
|
||||
|
||||
contract AddressRegistry {
|
||||
|
||||
event AddressChanged(string name, address target);
|
||||
|
|
|
@ -61,13 +61,13 @@ contract Registry {
|
|||
|
||||
contract GlobalVar is Registry {
|
||||
|
||||
address public WETH = 0xd0a1e359811322d97991e03f863a0c30c2cf029c;
|
||||
address public PETH = 0xf4d791139ce033ad35db2b2201435fad668b1b64;
|
||||
address public MKR = 0xaaf64bfcc32d0f15873a02163e7e500671a4ffcd;
|
||||
address public DAI = 0xc4375b7de8af5a38a93548eb8453a498222c4ff2;
|
||||
address public weth = 0xd0a1e359811322d97991e03f863a0c30c2cf029c;
|
||||
address public peth = 0xf4d791139ce033ad35db2b2201435fad668b1b64;
|
||||
address public mkr = 0xaaf64bfcc32d0f15873a02163e7e500671a4ffcd;
|
||||
address public dai = 0xc4375b7de8af5a38a93548eb8453a498222c4ff2;
|
||||
|
||||
address public CDPAddr = 0xa71937147b55Deb8a530C7229C442Fd3F31b7db2;
|
||||
MakerCDP DAILoanMaster = MakerCDP(CDPAddr);
|
||||
address public cdpAddr = 0xa71937147b55Deb8a530C7229C442Fd3F31b7db2;
|
||||
MakerCDP loanMaster = MakerCDP(cdpAddr);
|
||||
|
||||
mapping (address => bytes32) public borrowerCDPs; // borrower >>> CDP Bytes
|
||||
|
||||
|
@ -77,36 +77,36 @@ contract GlobalVar is Registry {
|
|||
contract BorrowTasks is GlobalVar {
|
||||
|
||||
function openCDP() internal returns (bytes32) {
|
||||
return DAILoanMaster.open();
|
||||
return loanMaster.open();
|
||||
}
|
||||
|
||||
function ETH_WETH(uint weiAmt) internal {
|
||||
WETHFace wethFunction = WETHFace(WETH);
|
||||
function convertToWETH(uint weiAmt) internal {
|
||||
WETHFace wethFunction = WETHFace(weth);
|
||||
wethFunction.deposit.value(weiAmt)();
|
||||
}
|
||||
|
||||
function WETH_PETH(uint weiAmt) internal {
|
||||
DAILoanMaster.join(weiAmt);
|
||||
function convertToPETH(uint weiAmt) internal {
|
||||
loanMaster.join(weiAmt);
|
||||
}
|
||||
|
||||
function PETH_CDP(address borrower, uint weiAmt) internal {
|
||||
DAILoanMaster.lock(borrowerCDPs[borrower], weiAmt);
|
||||
function lockPETH(address borrower, uint weiAmt) internal {
|
||||
loanMaster.lock(borrowerCDPs[borrower], weiAmt);
|
||||
}
|
||||
|
||||
function transferCDP(address nextOwner) public {
|
||||
require(nextOwner != 0, "Invalid Address.");
|
||||
DAILoanMaster.give(borrowerCDPs[msg.sender], nextOwner);
|
||||
loanMaster.give(borrowerCDPs[msg.sender], nextOwner);
|
||||
}
|
||||
|
||||
function ApproveERC20() public {
|
||||
token WETHtkn = token(WETH);
|
||||
WETHtkn.approve(CDPAddr, 2**256 - 1);
|
||||
token PETHtkn = token(PETH);
|
||||
PETHtkn.approve(CDPAddr, 2**256 - 1);
|
||||
token MKRtkn = token(MKR);
|
||||
MKRtkn.approve(CDPAddr, 2**256 - 1);
|
||||
token DAItkn = token(DAI);
|
||||
DAItkn.approve(CDPAddr, 2**256 - 1);
|
||||
function approveERC20() public {
|
||||
token wethTkn = token(weth);
|
||||
wethTkn.approve(cdpAddr, 2**256 - 1);
|
||||
token pethTkn = token(peth);
|
||||
pethTkn.approve(cdpAddr, 2**256 - 1);
|
||||
token mkrTkn = token(mkr);
|
||||
mkrTkn.approve(cdpAddr, 2**256 - 1);
|
||||
token daiTkn = token(dai);
|
||||
daiTkn.approve(cdpAddr, 2**256 - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -132,22 +132,22 @@ contract Borrow is BorrowTasks {
|
|||
address borrower,
|
||||
uint lockETH,
|
||||
uint loanDAI
|
||||
) public securedResolver(borrower) {
|
||||
|
||||
) public securedResolver(borrower)
|
||||
{
|
||||
if (borrowerCDPs[borrower] == 0x0000000000000000000000000000000000000000000000000000000000000000) {
|
||||
borrowerCDPs[borrower] = openCDP();
|
||||
}
|
||||
|
||||
if (lockETH != 0) {
|
||||
ETH_WETH(lockETH);
|
||||
WETH_PETH(lockETH - lockETH/1000);
|
||||
PETH_CDP(borrower, lockETH - lockETH/1000);
|
||||
convertToWETH(lockETH);
|
||||
convertToPETH(lockETH - lockETH/1000);
|
||||
lockPETH(borrower, lockETH - lockETH/1000);
|
||||
// event for locking ETH
|
||||
}
|
||||
|
||||
if (loanDAI != 0) {
|
||||
DAILoanMaster.draw(borrowerCDPs[borrower], loanDAI);
|
||||
token tokenFunctions = token(DAI);
|
||||
loanMaster.draw(borrowerCDPs[borrower], loanDAI);
|
||||
token tokenFunctions = token(dai);
|
||||
tokenFunctions.transfer(getAddress("asset"), loanDAI);
|
||||
// event for drawing DAI
|
||||
}
|
||||
|
@ -160,9 +160,9 @@ contract Borrow is BorrowTasks {
|
|||
contract MoatMaker is Borrow {
|
||||
|
||||
constructor() public {
|
||||
ApproveERC20();
|
||||
approveERC20();
|
||||
}
|
||||
|
||||
function () public payable {}
|
||||
function () public payable {}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user