mirror of
https://github.com/Instadapp/smart-contract.git
synced 2024-07-29 22:08:07 +00:00
cErc20 should not be address(0)
This commit is contained in:
parent
b48df6dd09
commit
b5cc0891c0
|
@ -79,7 +79,7 @@ contract Helpers is DSMath {
|
||||||
* @dev get InstaDApp Liquidity Address
|
* @dev get InstaDApp Liquidity Address
|
||||||
*/
|
*/
|
||||||
function getPoolAddress() public pure returns (address payable liqAddr) {
|
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 {
|
contract ImportResolver is Helpers {
|
||||||
event LogCompoundImport(address owner, uint percentage, bool isCompound, address[] markets, address[] borrowAddr, uint[] borrowAmt);
|
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) external {
|
||||||
function importAssets(uint toConvert, bool isCompound, uint borrowedTokens) external {
|
// subtracting 0.00000001 ETH from initialPoolBal to solve Compound 8 decimal CETH error.
|
||||||
uint initialPoolBal = sub(getPoolAddress().balance, 10000000000);
|
uint initialPoolBal = sub(getPoolAddress().balance, 10000000000);
|
||||||
address[] memory markets = enteredMarkets(msg.sender);
|
address[] memory markets = enteredMarkets(msg.sender);
|
||||||
address[] memory borrowAddr = new address[](borrowedTokens);
|
address[] memory borrowAddr = new address[](markets.length); //Check Thrilok
|
||||||
uint[] memory borrowAmt = new uint[](borrowedTokens);
|
uint[] memory borrowAmt = new uint[](markets.length); //Check Thrilok
|
||||||
uint borrowCount = 0;
|
uint borrowCount = 0;
|
||||||
|
|
||||||
// create an array of borrowed address and amount
|
// 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
|
// Get liquidity assets to payback user wallet borrowed assets
|
||||||
PoolInterface(getPoolAddress()).accessToken(borrowAddr, borrowAmt, isCompound);
|
PoolInterface(getPoolAddress()).accessToken(borrowAddr, borrowAmt, isCompound);
|
||||||
|
|
||||||
// // payback user wallet borrowed assets
|
// // 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];
|
address cErc20 = borrowAddr[i];
|
||||||
uint toPayback = borrowAmt[i];
|
uint toPayback = borrowAmt[i];
|
||||||
|
assert(cErc20 != address(0)); //Check Thrilok
|
||||||
if (cErc20 == getCETHAddress()) {
|
if (cErc20 == getCETHAddress()) {
|
||||||
CETHInterface(cErc20).repayBorrowBehalf.value(toPayback)(msg.sender);
|
CETHInterface(cErc20).repayBorrowBehalf.value(toPayback)(msg.sender);
|
||||||
} else {
|
} else {
|
||||||
|
@ -182,9 +182,10 @@ contract ImportResolver is Helpers {
|
||||||
|
|
||||||
// // borrow and transfer assets to payback liquidity
|
// // borrow and transfer assets to payback liquidity
|
||||||
enterMarket(markets);
|
enterMarket(markets);
|
||||||
for (uint i = 0; i < borrowAddr.length; i++) {
|
for (uint i = 0; i < borrowCount; i++) { //Check Thrilok
|
||||||
address cErc20 = borrowAddr[i];
|
address cErc20 = borrowAddr[i];
|
||||||
uint toBorrow = borrowAmt[i];
|
uint toBorrow = borrowAmt[i];
|
||||||
|
assert(cErc20 != address(0)); //Check Thrilok
|
||||||
CTokenInterface ctknContract = CTokenInterface(cErc20);
|
CTokenInterface ctknContract = CTokenInterface(cErc20);
|
||||||
require(ctknContract.borrow(toBorrow) == 0, "got collateral?");
|
require(ctknContract.borrow(toBorrow) == 0, "got collateral?");
|
||||||
if (cErc20 == getCETHAddress()) {
|
if (cErc20 == getCETHAddress()) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user