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
|
||||
* @param _userAccount address of the EOA's account to get the user's entered markets
|
||||
*/
|
||||
function enterMarket(address cToken) internal {
|
||||
address[] memory markets = troller.getAssetsIn(address(this));
|
||||
bool isEntered = false;
|
||||
function _enterMarkets(address _userAccount) internal {
|
||||
address[] memory markets = troller.getAssetsIn(_userAccount);
|
||||
for (uint i = 0; i < markets.length; i++) {
|
||||
if (markets[i] == cToken) {
|
||||
isEntered = true;
|
||||
}
|
||||
}
|
||||
if (!isEntered) {
|
||||
address[] memory toEnter = new address[](1);
|
||||
toEnter[0] = cToken;
|
||||
toEnter[0] = markets[i];
|
||||
troller.enterMarkets(toEnter);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,9 +35,7 @@ contract CompoundImportResolver is CompoundHelper {
|
|||
data = getBorrowAmounts(_importInputData, data);
|
||||
data = getSupplyAmounts(_importInputData, data);
|
||||
|
||||
for(uint i = 0; i < data.cTokens.length; i++){
|
||||
enterMarket(data.cTokens[i]);
|
||||
}
|
||||
_enterMarkets(_importInputData.userAccount);
|
||||
|
||||
// pay back user's debt using flash loan funds
|
||||
_repayUserDebt(_importInputData.userAccount, data.borrowCtokens, data.borrowAmts);
|
||||
|
|
Loading…
Reference in New Issue
Block a user