Fixed standard errors.

This commit is contained in:
Sowmayjain 2018-10-28 09:43:36 +05:30
parent 2c975d4af8
commit 831101d965

View File

@ -88,7 +88,7 @@ contract GlobalVar is Registry {
address public cdpAddr = 0xa71937147b55Deb8a530C7229C442Fd3F31b7db2; address public cdpAddr = 0xa71937147b55Deb8a530C7229C442Fd3F31b7db2;
MakerCDP loanMaster = MakerCDP(cdpAddr); MakerCDP loanMaster = MakerCDP(cdpAddr);
mapping (address => bytes32) public CDPs; // borrower >>> CDP Bytes mapping (address => bytes32) public cdps; // borrower >>> CDP Bytes
} }
@ -97,16 +97,17 @@ contract IssueLoan is GlobalVar {
event LockedETH(address borrower, uint lockETH, uint lockPETH); event LockedETH(address borrower, uint lockETH, uint lockPETH);
event LoanedDAI(address borrower, uint loanDAI, uint fees); event LoanedDAI(address borrower, uint loanDAI, uint fees);
event OpenedNewCDP(address borrower, bytes32 CDPBytes); event OpenedNewCDP(address borrower, bytes32 cdpBytes);
function borrow( function borrow(
address borrower, address borrower,
uint ethLock, uint ethLock,
uint daiDraw uint daiDraw
) public payable onlyUserOrResolver(borrower) { ) public payable onlyUserOrResolver(borrower)
if (CDPs[borrower] == 0x0000000000000000000000000000000000000000000000000000000000000000) { {
CDPs[borrower] = loanMaster.open(); if (cdps[borrower] == 0x0000000000000000000000000000000000000000000000000000000000000000) {
emit OpenedNewCDP(borrower, CDPs[borrower]); cdps[borrower] = loanMaster.open();
emit OpenedNewCDP(borrower, cdps[borrower]);
} }
if (ethLock > 0) { if (ethLock > 0) {
lockETH(borrower, ethLock); lockETH(borrower, ethLock);
@ -121,12 +122,12 @@ contract IssueLoan is GlobalVar {
wethFunction.deposit.value(ethLock)(); // ETH to WETH wethFunction.deposit.value(ethLock)(); // ETH to WETH
uint pethToLock = ratioedPETH(ethLock); uint pethToLock = ratioedPETH(ethLock);
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(borrower, ethLock, pethToLock); emit LockedETH(borrower, ethLock, pethToLock);
} }
function drawDAI(address borrower, uint daiDraw) public onlyUserOrResolver(borrower) { function drawDAI(address borrower, uint daiDraw) public onlyUserOrResolver(borrower) {
loanMaster.draw(CDPs[borrower], daiDraw); loanMaster.draw(cdps[borrower], daiDraw);
uint fees = deductFees(daiDraw); uint fees = deductFees(daiDraw);
token tokenFunctions = token(dai); token tokenFunctions = token(dai);
tokenFunctions.transfer(getAddress("resolver"), daiDraw - fees); tokenFunctions.transfer(getAddress("resolver"), daiDraw - fees);
@ -159,25 +160,26 @@ contract RepayLoan is IssueLoan {
address borrower, address borrower,
uint daiWipe, uint daiWipe,
uint ethFree uint ethFree
) public onlyUserOrResolver(borrower) { ) public onlyUserOrResolver(borrower)
{
if (daiWipe > 0) { if (daiWipe > 0) {
wipeDAI(borrower, daiWipe); wipeDAI(borrower, daiWipe);
} }
if (ethFree > 0) { if (ethFree > 0) {
UnlockETH(borrower, ethFree); unlockETH(borrower, ethFree);
} }
} }
function wipeDAI(address borrower, uint daiWipe) public { function wipeDAI(address borrower, uint daiWipe) public {
token tokenFunction = token(dai); token tokenFunction = token(dai);
tokenFunction.transferFrom(msg.sender, address(this), daiWipe); tokenFunction.transferFrom(msg.sender, address(this), daiWipe);
loanMaster.wipe(CDPs[borrower], daiWipe); loanMaster.wipe(cdps[borrower], daiWipe);
emit WipedDAI(borrower, daiWipe); emit WipedDAI(borrower, daiWipe);
} }
function UnlockETH(address borrower, uint ethFree) public onlyUserOrResolver(borrower) { function unlockETH(address borrower, uint ethFree) public onlyUserOrResolver(borrower) {
uint pethToUnlock = ratioedPETH(ethFree); uint pethToUnlock = ratioedPETH(ethFree);
loanMaster.free(CDPs[borrower], pethToUnlock); // CDP to PETH loanMaster.free(cdps[borrower], pethToUnlock); // CDP to PETH
loanMaster.exit(pethToUnlock); // PETH to WETH loanMaster.exit(pethToUnlock); // PETH to WETH
WETHFace wethFunction = WETHFace(weth); WETHFace wethFunction = WETHFace(weth);
wethFunction.withdraw(ethFree); // WETH to ETH wethFunction.withdraw(ethFree); // WETH to ETH
@ -190,13 +192,14 @@ contract RepayLoan is IssueLoan {
} }
contract BorrowTasks is RepayLoan { contract BorrowTasks is RepayLoan {
// transfer existing CDP 2 txn process // transfer existing CDP 2 txn process
function claimCDP(address nextOwner) public { function claimCDP(address nextOwner) public {
require(nextOwner != 0, "Invalid Address."); require(nextOwner != 0, "Invalid Address.");
loanMaster.give(CDPs[msg.sender], nextOwner); loanMaster.give(cdps[msg.sender], nextOwner);
} }
function approveERC20() public { function approveERC20() public {