mirror of
https://github.com/Instadapp/InstaContract.git
synced 2024-07-29 22:47:45 +00:00
Implemented Proper SafeMath.
This commit is contained in:
parent
bc66c2452d
commit
1ae3b57d6a
|
@ -76,8 +76,8 @@ contract Trade is Registry {
|
||||||
uint ethQty;
|
uint ethQty;
|
||||||
uint feecut;
|
uint feecut;
|
||||||
if (fees > 0) {
|
if (fees > 0) {
|
||||||
feecut = div(srcAmt, fees);
|
feecut = srcAmt.div(fees);
|
||||||
sellQty = sub(srcAmt, feecut);
|
sellQty = srcAmt.sub(feecut);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch token & deduct fees
|
// fetch token & deduct fees
|
||||||
|
|
|
@ -79,7 +79,7 @@ contract IssueLoan is GlobalVar {
|
||||||
event OpenedNewCDP(address borrower, bytes32 cdpBytes);
|
event OpenedNewCDP(address borrower, bytes32 cdpBytes);
|
||||||
|
|
||||||
function pethPEReth(uint ethNum) public view returns (uint rPETH) {
|
function pethPEReth(uint ethNum) public view returns (uint rPETH) {
|
||||||
rPETH = div(mul(ethNum, 10 ** 27), loanMaster.per());
|
rPETH = (ethNum.mul(10 ** 27)).div(loanMaster.per());
|
||||||
}
|
}
|
||||||
|
|
||||||
function borrow(uint daiDraw) public payable {
|
function borrow(uint daiDraw) public payable {
|
||||||
|
@ -105,13 +105,13 @@ contract IssueLoan is GlobalVar {
|
||||||
loanMaster.draw(cdps[msg.sender], daiDraw);
|
loanMaster.draw(cdps[msg.sender], daiDraw);
|
||||||
uint feecut = deductFees(daiDraw);
|
uint feecut = deductFees(daiDraw);
|
||||||
IERC20 daiTkn = IERC20(getAddress("dai"));
|
IERC20 daiTkn = IERC20(getAddress("dai"));
|
||||||
daiTkn.transfer(msg.sender, sub(daiDraw, feecut));
|
daiTkn.transfer(msg.sender, daiDraw.sub(feecut));
|
||||||
emit LoanedDAI(msg.sender, daiDraw, feecut);
|
emit LoanedDAI(msg.sender, daiDraw, feecut);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deductFees(uint volume) internal returns(uint brokerage) {
|
function deductFees(uint volume) internal returns(uint brokerage) {
|
||||||
if (fees > 0) {
|
if (fees > 0) {
|
||||||
brokerage = div(volume, fees);
|
brokerage = volume.div(fees);
|
||||||
IERC20 daiTkn = IERC20(getAddress("dai"));
|
IERC20 daiTkn = IERC20(getAddress("dai"));
|
||||||
daiTkn.transfer(getAddress("admin"), brokerage);
|
daiTkn.transfer(getAddress("admin"), brokerage);
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ contract BorrowTasks is RepayLoan {
|
||||||
PriceInterface ethRate = PriceInterface(getAddress("price"));
|
PriceInterface ethRate = PriceInterface(getAddress("price"));
|
||||||
bytes32 ethrate;
|
bytes32 ethrate;
|
||||||
(ethrate, ) = ethRate.peek();
|
(ethrate, ) = ethRate.peek();
|
||||||
return div(uint(ethrate), 10**18);
|
return uint(ethrate).div(10**18);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCDPID(address borrower) public view returns (uint) {
|
function getCDPID(address borrower) public view returns (uint) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user