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) {
|
function checkCDP(bytes32 cup, uint ethAmt, uint daiAmt) internal returns (uint ethCol, uint daiDebt) {
|
||||||
TubInterface tub = TubInterface(getSaiTubAddress());
|
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 = tub.tab(cup);
|
||||||
daiDebt = daiAmt < daiDebt ? daiAmt : daiDebt; // if DAI amount > max debt. Set max debt
|
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
|
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) {
|
function repayDaiComp(uint tokenAmt) internal returns (uint wipeAmt) {
|
||||||
CERC20Interface cToken = CERC20Interface(getCDAIAddress());
|
CERC20Interface cToken = CERC20Interface(getCDAIAddress());
|
||||||
uint daiBorrowed = cToken.borrowBalanceCurrent(address(this));
|
uint daiBorrowed = cToken.borrowBalanceCurrent(address(this));
|
||||||
wipeAmt = tokenAmt;
|
wipeAmt = tokenAmt < daiBorrowed ? tokenAmt : daiBorrowed;
|
||||||
if (tokenAmt > daiBorrowed) {
|
|
||||||
wipeAmt = daiBorrowed;
|
|
||||||
}
|
|
||||||
LiquidityInterface(getLiquidityAddr()).borrowTknAndTransfer(getDAIAddress(), getCDAIAddress(), wipeAmt);
|
LiquidityInterface(getLiquidityAddr()).borrowTknAndTransfer(getDAIAddress(), getCDAIAddress(), wipeAmt);
|
||||||
setApproval(getDAIAddress(), wipeAmt, getCDAIAddress());
|
setApproval(getDAIAddress(), wipeAmt, getCDAIAddress());
|
||||||
require(cToken.repayBorrow(wipeAmt) == 0, "transfer approved?");
|
require(cToken.repayBorrow(wipeAmt) == 0, "transfer approved?");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user