mirror of
https://github.com/Instadapp/InstaContract.git
synced 2024-07-29 22:47:45 +00:00
Implemented SafeMath.
This commit is contained in:
parent
399c068e54
commit
bc66c2452d
|
@ -76,8 +76,8 @@ contract Trade is Registry {
|
||||||
uint ethQty;
|
uint ethQty;
|
||||||
uint feecut;
|
uint feecut;
|
||||||
if (fees > 0) {
|
if (fees > 0) {
|
||||||
feecut = srcAmt / fees;
|
feecut = div(srcAmt, fees);
|
||||||
sellQty = srcAmt - feecut;
|
sellQty = sub(srcAmt, 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 = ethNum * (10 ** 27) / loanMaster.per();
|
rPETH = div(mul(ethNum, 10 ** 27), 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, daiDraw - feecut);
|
daiTkn.transfer(msg.sender, sub(daiDraw, 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 = volume / fees;
|
brokerage = div(volume, 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 (uint(ethrate) / 10**18);
|
return div(uint(ethrate), 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