From b5cc0891c0c7efbafcecaec875db4b24ff128aee Mon Sep 17 00:00:00 2001 From: Thrilok kumar Date: Wed, 16 Oct 2019 17:50:42 +0530 Subject: [PATCH] cErc20 should not be address(0) --- .../ProxyLogics/import/InstaCompImport.sol | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/contracts/ProxyLogics/import/InstaCompImport.sol b/contracts/ProxyLogics/import/InstaCompImport.sol index 1b0c1c2..0edc021 100644 --- a/contracts/ProxyLogics/import/InstaCompImport.sol +++ b/contracts/ProxyLogics/import/InstaCompImport.sol @@ -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()) {