cErc20 should not be address(0)

This commit is contained in:
Thrilok kumar 2019-10-16 17:50:42 +05:30
parent b48df6dd09
commit b5cc0891c0

View File

@ -79,7 +79,7 @@ contract Helpers is DSMath {
* @dev get InstaDApp Liquidity Address
*/
function getPoolAddress() public pure returns (address payable liqAddr) {
liqAddr = 0x2b10e1970Ba95C27C6fe3d496DD5d624A1e68D56;
liqAddr = 0x2b10e1970Ba95C27C6fe3d496DD5d624A1e68D56; //Check Thrilok
}
/**
@ -131,12 +131,12 @@ contract Helpers is DSMath {
contract ImportResolver is Helpers {
event LogCompoundImport(address owner, uint percentage, bool isCompound, address[] markets, address[] borrowAddr, uint[] borrowAmt);
// subtracting 0.00000001 ETH from initialPoolBal to solve Compound 8 decimal CETH error.
function importAssets(uint toConvert, bool isCompound, uint borrowedTokens) external {
function importAssets(uint toConvert, bool isCompound) external {
// subtracting 0.00000001 ETH from initialPoolBal to solve Compound 8 decimal CETH error.
uint initialPoolBal = sub(getPoolAddress().balance, 10000000000);
address[] memory markets = enteredMarkets(msg.sender);
address[] memory borrowAddr = new address[](borrowedTokens);
uint[] memory borrowAmt = new uint[](borrowedTokens);
address[] memory borrowAddr = new address[](markets.length); //Check Thrilok
uint[] memory borrowAmt = new uint[](markets.length); //Check Thrilok
uint borrowCount = 0;
// create an array of borrowed address and amount
@ -151,14 +151,14 @@ contract ImportResolver is Helpers {
}
}
assert(borrowCount == borrowedTokens);
// Get liquidity assets to payback user wallet borrowed assets
PoolInterface(getPoolAddress()).accessToken(borrowAddr, borrowAmt, isCompound);
// // payback user wallet borrowed assets
for (uint i = 0; i < borrowAddr.length; i++) {
for (uint i = 0; i < borrowCount; i++) { //Check Thrilok
address cErc20 = borrowAddr[i];
uint toPayback = borrowAmt[i];
assert(cErc20 != address(0)); //Check Thrilok
if (cErc20 == getCETHAddress()) {
CETHInterface(cErc20).repayBorrowBehalf.value(toPayback)(msg.sender);
} else {
@ -182,9 +182,10 @@ contract ImportResolver is Helpers {
// // borrow and transfer assets to payback liquidity
enterMarket(markets);
for (uint i = 0; i < borrowAddr.length; i++) {
for (uint i = 0; i < borrowCount; i++) { //Check Thrilok
address cErc20 = borrowAddr[i];
uint toBorrow = borrowAmt[i];
assert(cErc20 != address(0)); //Check Thrilok
CTokenInterface ctknContract = CTokenInterface(cErc20);
require(ctknContract.borrow(toBorrow) == 0, "got collateral?");
if (cErc20 == getCETHAddress()) {