added sub and add

This commit is contained in:
Samyak Jain 2019-05-06 21:09:38 +05:30
parent 0d383ee4d3
commit f9a33dc7f6

View File

@ -319,10 +319,10 @@ contract GetDetails is MakerHelpers {
function getMax(uint cdpID) public view returns (uint maxColToFree, uint maxDaiToDraw, uint ethInUSD) { function getMax(uint cdpID) public view returns (uint maxColToFree, uint maxDaiToDraw, uint ethInUSD) {
bytes32 cup = bytes32(cdpID); bytes32 cup = bytes32(cdpID);
(uint ethCol, uint daiDebt, uint usdPerEth) = getCDPStats(cup); (uint ethCol, uint daiDebt, uint usdPerEth) = getCDPStats(cup);
uint colToUSD = wmul(ethCol, usdPerEth) - 10; uint colToUSD = sub(wmul(ethCol, usdPerEth), 10);
uint minColNeeded = wmul(daiDebt, 1500000000000000000) + 10; uint minColNeeded = add(wmul(daiDebt, 1500000000000000000), 10);
maxColToFree = wdiv(sub(colToUSD, minColNeeded), usdPerEth); maxColToFree = wdiv(sub(colToUSD, minColNeeded), usdPerEth);
uint maxDebtLimit = wdiv(colToUSD, 1500000000000000000) - 10; uint maxDebtLimit = sub(wdiv(colToUSD, 1500000000000000000), 10);
maxDaiToDraw = sub(maxDebtLimit, daiDebt); maxDaiToDraw = sub(maxDebtLimit, daiDebt);
ethInUSD = usdPerEth; ethInUSD = usdPerEth;
} }
@ -371,8 +371,8 @@ contract GetDetails is MakerHelpers {
bool canSave bool canSave
) )
{ {
uint colToUSD = wmul(ethCol, usdPerEth) - 10; uint colToUSD = sub(wmul(ethCol, usdPerEth), 10);
uint minColNeeded = wmul(daiDebt, 1500000000000000000) + 10; uint minColNeeded = add(wmul(daiDebt, 1500000000000000000), 10);
uint colToFree = wdiv(sub(colToUSD, minColNeeded), usdPerEth); uint colToFree = wdiv(sub(colToUSD, minColNeeded), usdPerEth);
if (ethToSwap < colToFree) { if (ethToSwap < colToFree) {
colToFree = ethToSwap; colToFree = ethToSwap;
@ -405,8 +405,8 @@ contract GetDetails is MakerHelpers {
bool canLeverage bool canLeverage
) )
{ {
uint colToUSD = wmul(ethCol, usdPerEth) - 10; uint colToUSD = sub(wmul(ethCol, usdPerEth), 10);
uint maxDebtLimit = wdiv(colToUSD, 1500000000000000000) - 10; uint maxDebtLimit = sub(wdiv(colToUSD, 1500000000000000000), 10);
uint debtToBorrow = sub(maxDebtLimit, daiDebt); uint debtToBorrow = sub(maxDebtLimit, daiDebt);
if (daiToSwap < debtToBorrow) { if (daiToSwap < debtToBorrow) {
debtToBorrow = daiToSwap; debtToBorrow = daiToSwap;
@ -480,7 +480,7 @@ contract Save is GetDetails {
wipe(cdpID, destAmt); wipe(cdpID, destAmt);
if (thisBalance < address(this).balance) { if (thisBalance < address(this).balance) {
uint balToLock = address(this).balance - thisBalance; uint balToLock = sub(address(this).balance, thisBalance);
lock(cdpID, balToLock); lock(cdpID, balToLock);
} }