mirror of
https://github.com/Instadapp/smart-contract.git
synced 2024-07-29 22:08:07 +00:00
code refactoring
This commit is contained in:
parent
7bbfa509b7
commit
87c6f0da54
|
@ -436,7 +436,7 @@ contract MakerResolver is CompoundHelper {
|
|||
*/
|
||||
function checkCDP(bytes32 cup, uint ethAmt, uint daiAmt) internal returns (uint ethCol, uint daiDebt) {
|
||||
TubInterface tub = TubInterface(getSaiTubAddress());
|
||||
ethCol = rmul(tub.ink(cup), tub.per()); // get ETH col from PETH col
|
||||
ethCol = rmul(tub.ink(cup), tub.per()) - 1; // get ETH col from PETH col
|
||||
daiDebt = tub.tab(cup);
|
||||
daiDebt = daiAmt < daiDebt ? daiAmt : daiDebt; // if DAI amount > max debt. Set max debt
|
||||
ethCol = ethAmt < ethCol ? ethAmt : ethCol; // if ETH amount > max Col. Set max col
|
||||
|
@ -500,10 +500,7 @@ contract CompoundResolver is MakerResolver {
|
|||
function repayDaiComp(uint tokenAmt) internal returns (uint wipeAmt) {
|
||||
CERC20Interface cToken = CERC20Interface(getCDAIAddress());
|
||||
uint daiBorrowed = cToken.borrowBalanceCurrent(address(this));
|
||||
wipeAmt = tokenAmt;
|
||||
if (tokenAmt > daiBorrowed) {
|
||||
wipeAmt = daiBorrowed;
|
||||
}
|
||||
wipeAmt = tokenAmt < daiBorrowed ? tokenAmt : daiBorrowed;
|
||||
LiquidityInterface(getLiquidityAddr()).borrowTknAndTransfer(getDAIAddress(), getCDAIAddress(), wipeAmt);
|
||||
setApproval(getDAIAddress(), wipeAmt, getCDAIAddress());
|
||||
require(cToken.repayBorrow(wipeAmt) == 0, "transfer approved?");
|
||||
|
|
Loading…
Reference in New Issue
Block a user