few changes

This commit is contained in:
Samyak Jain 2019-08-10 03:11:04 +05:30
parent dafb529317
commit 697d6c2f9c

View File

@ -240,9 +240,9 @@ contract CompoundHelper is Helpers {
usdcAmt = cTokenContract.borrowBalanceCurrent(user); usdcAmt = cTokenContract.borrowBalanceCurrent(user);
} }
function getUsdcRemainBorrow(uint daiInEth) internal view returns (uint usdcAmt) { function getUsdcRemainBorrow(uint usdcInEth) internal view returns (uint usdcAmt) {
uint tokenPriceInEth = CompOracleInterface(getCompOracleAddress()).getUnderlyingPrice(getCUSDCAddress()); uint tokenPriceInEth = CompOracleInterface(getCompOracleAddress()).getUnderlyingPrice(getCUSDCAddress());
usdcAmt = sub(wdiv(daiInEth, tokenPriceInEth), 10); usdcAmt = sub(wdiv(usdcInEth, tokenPriceInEth), 10);
} }
} }
@ -339,16 +339,19 @@ contract CompoundSave is CompoundResolver {
wethContract.deposit.value(zrxEthAmt)(); wethContract.deposit.value(zrxEthAmt)();
wethContract.approve(getAddressZRXExchange(), zrxEthAmt); wethContract.approve(getAddressZRXExchange(), zrxEthAmt);
getAddressZRXExchange().call(calldataHexString); getAddressZRXExchange().call(calldataHexString);
KyberInterface(getAddressKyberProxy()).trade.value(address(this).balance)( if (address(this).balance > 0) {
getAddressETH(), KyberInterface(getAddressKyberProxy()).trade.value(address(this).balance)(
address(this).balance, getAddressETH(),
getAddressUSDC(), address(this).balance,
address(this), getAddressUSDC(),
2**255, address(this),
0, 2**255,
getAddressAdmin() 0,
); getAddressAdmin()
uint usdcBal = ERC20Interface(getAddressUSDC()).balanceOf(address(this)); );
}
ERC20Interface usdcContract = ERC20Interface(getAddressUSDC());
uint usdcBal = usdcContract.balanceOf(address(this));
repayUsdc(usdcBal); repayUsdc(usdcBal);
emit LogSaveCompoundUsdc(ethToSwap, usdcBal); emit LogSaveCompoundUsdc(ethToSwap, usdcBal);
} }
@ -369,17 +372,20 @@ contract CompoundSave is CompoundResolver {
borrow(usdcToSwap); borrow(usdcToSwap);
ERC20Interface usdcContract = ERC20Interface(getAddressUSDC()); ERC20Interface usdcContract = ERC20Interface(getAddressUSDC());
usdcContract.approve(getAddressZRXExchange(), zrxUsdcAmt); usdcContract.approve(getAddressZRXExchange(), zrxUsdcAmt);
getAddressZRXExchange().call(calldataHexString);
uint usdcBal = usdcContract.balanceOf(address(this)); uint usdcBal = usdcContract.balanceOf(address(this));
usdcContract.approve(getAddressKyberProxy(), usdcBal); if (usdcBal > 0) {
KyberInterface(getAddressKyberProxy()).trade.value(address(this).balance)( usdcContract.approve(getAddressKyberProxy(), usdcBal);
getAddressUSDC(), KyberInterface(getAddressKyberProxy()).trade.value(address(this).balance)(
address(this).balance, getAddressUSDC(),
getAddressETH(), address(this).balance,
address(this), getAddressETH(),
2**255, address(this),
0, 2**255,
getAddressAdmin() 0,
); getAddressAdmin()
);
}
ERC20Interface wethContract = ERC20Interface(getAddressWETH()); ERC20Interface wethContract = ERC20Interface(getAddressWETH());
uint wethBal = wethContract.balanceOf(address(this)); uint wethBal = wethContract.balanceOf(address(this));
wethContract.approve(getAddressWETH(), wethBal); wethContract.approve(getAddressWETH(), wethBal);