mirror of
https://github.com/Instadapp/smart-contract.git
synced 2024-07-29 22:08:07 +00:00
added sub and add
This commit is contained in:
parent
0d383ee4d3
commit
f9a33dc7f6
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user