mirror of
https://github.com/Instadapp/smart-contract.git
synced 2024-07-29 22:08:07 +00:00
small edits
This commit is contained in:
parent
8cff3ddc2c
commit
ef15ee58ce
|
@ -264,11 +264,11 @@ contract MakerHelpers is Helpers {
|
||||||
tub.free(cup, ink);
|
tub.free(cup, ink);
|
||||||
|
|
||||||
setAllowance(peth, tubAddr);
|
setAllowance(peth, tubAddr);
|
||||||
|
|
||||||
tub.exit(ink);
|
tub.exit(ink);
|
||||||
uint freeJam = weth.balanceOf(address(this)); // withdraw possible previous stuck WETH as well
|
uint freeJam = weth.balanceOf(address(this)); // withdraw possible previous stuck WETH as well
|
||||||
weth.withdraw(freeJam);
|
weth.withdraw(freeJam);
|
||||||
|
|
||||||
emit LogFree(
|
emit LogFree(
|
||||||
cdpNum,
|
cdpNum,
|
||||||
freeJam,
|
freeJam,
|
||||||
|
@ -284,7 +284,7 @@ contract MakerHelpers is Helpers {
|
||||||
TubInterface tub = TubInterface(getSaiTubAddress());
|
TubInterface tub = TubInterface(getSaiTubAddress());
|
||||||
|
|
||||||
tub.draw(cup, _wad);
|
tub.draw(cup, _wad);
|
||||||
|
|
||||||
emit LogDraw(cdpNum, _wad, address(this));
|
emit LogDraw(cdpNum, _wad, address(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -356,9 +356,9 @@ contract GetDetails is MakerHelpers {
|
||||||
uint ethCol,
|
uint ethCol,
|
||||||
uint daiDebt,
|
uint daiDebt,
|
||||||
uint usdPerEth
|
uint usdPerEth
|
||||||
) internal view returns
|
) internal view returns
|
||||||
(
|
(
|
||||||
uint finalEthCol,
|
uint finalEthCol,
|
||||||
uint finalDaiDebt,
|
uint finalDaiDebt,
|
||||||
uint finalColToUSD,
|
uint finalColToUSD,
|
||||||
bool canSave
|
bool canSave
|
||||||
|
@ -397,9 +397,9 @@ contract GetDetails is MakerHelpers {
|
||||||
uint ethCol,
|
uint ethCol,
|
||||||
uint daiDebt,
|
uint daiDebt,
|
||||||
uint usdPerEth
|
uint usdPerEth
|
||||||
) internal view returns
|
) internal view returns
|
||||||
(
|
(
|
||||||
uint finalEthCol,
|
uint finalEthCol,
|
||||||
uint finalDaiDebt,
|
uint finalDaiDebt,
|
||||||
uint finalColToUSD,
|
uint finalColToUSD,
|
||||||
bool canLeverage
|
bool canLeverage
|
||||||
|
@ -432,9 +432,10 @@ contract Save is GetDetails {
|
||||||
function save(uint cdpID) public {
|
function save(uint cdpID) public {
|
||||||
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);
|
||||||
uint colToFree = wdiv(sub(colToUSD, minColNeeded), usdPerEth) - 10;
|
uint colToFree = sub(wdiv(sub(colToUSD, minColNeeded), usdPerEth), 10);
|
||||||
|
require(colToFree != 0, "No-collatral-to-free");
|
||||||
free(cdpID, colToFree);
|
free(cdpID, colToFree);
|
||||||
uint ethToSwap = wdiv(wmul(colToFree, 99750000000000000000), 100000000000000000000);
|
uint ethToSwap = wdiv(wmul(colToFree, 99750000000000000000), 100000000000000000000);
|
||||||
getAddressAdmin().transfer(sub(colToFree, ethToSwap));
|
getAddressAdmin().transfer(sub(colToFree, ethToSwap));
|
||||||
|
@ -453,14 +454,15 @@ contract Save is GetDetails {
|
||||||
function leverage(uint cdpID) public {
|
function leverage(uint cdpID) public {
|
||||||
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 maxDebtLimit = wdiv(colToUSD, 1500000000000000000) - 10;
|
uint maxDebtLimit = sub(wdiv(colToUSD, 1500000000000000000), 10);
|
||||||
uint debtToBorrow = sub(maxDebtLimit, daiDebt);
|
uint debtToBorrow = sub(maxDebtLimit, daiDebt);
|
||||||
|
require(debtToBorrow != 0, "No-debt-to-borrow");
|
||||||
draw(cdpID, debtToBorrow);
|
draw(cdpID, debtToBorrow);
|
||||||
uint destAmt = KyberInterface(getAddressKyber()).trade.value(0)(
|
uint destAmt = KyberInterface(getAddressKyber()).trade.value(0)(
|
||||||
getAddressETH(),
|
|
||||||
debtToBorrow,
|
|
||||||
getAddressDAI(),
|
getAddressDAI(),
|
||||||
|
debtToBorrow,
|
||||||
|
getAddressETH(),
|
||||||
address(this),
|
address(this),
|
||||||
2**255,
|
2**255,
|
||||||
0,
|
0,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user