mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
changed logic for entering markets
This commit is contained in:
parent
b14f886365
commit
95e390ddef
|
@ -42,18 +42,13 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev enter compound market
|
* @dev enter compound market
|
||||||
|
* @param _userAccount address of the EOA's account to get the user's entered markets
|
||||||
*/
|
*/
|
||||||
function enterMarket(address cToken) internal {
|
function _enterMarkets(address _userAccount) internal {
|
||||||
address[] memory markets = troller.getAssetsIn(address(this));
|
address[] memory markets = troller.getAssetsIn(_userAccount);
|
||||||
bool isEntered = false;
|
|
||||||
for (uint i = 0; i < markets.length; i++) {
|
for (uint i = 0; i < markets.length; i++) {
|
||||||
if (markets[i] == cToken) {
|
|
||||||
isEntered = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isEntered) {
|
|
||||||
address[] memory toEnter = new address[](1);
|
address[] memory toEnter = new address[](1);
|
||||||
toEnter[0] = cToken;
|
toEnter[0] = markets[i];
|
||||||
troller.enterMarkets(toEnter);
|
troller.enterMarkets(toEnter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,7 @@ contract CompoundImportResolver is CompoundHelper {
|
||||||
data = getBorrowAmounts(_importInputData, data);
|
data = getBorrowAmounts(_importInputData, data);
|
||||||
data = getSupplyAmounts(_importInputData, data);
|
data = getSupplyAmounts(_importInputData, data);
|
||||||
|
|
||||||
for(uint i = 0; i < data.cTokens.length; i++){
|
_enterMarkets(_importInputData.userAccount);
|
||||||
enterMarket(data.cTokens[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// pay back user's debt using flash loan funds
|
// pay back user's debt using flash loan funds
|
||||||
_repayUserDebt(_importInputData.userAccount, data.borrowCtokens, data.borrowAmts);
|
_repayUserDebt(_importInputData.userAccount, data.borrowCtokens, data.borrowAmts);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user