added function for imprtWithCollateral-polygon

This commit is contained in:
Richa-iitr 2022-05-05 22:49:52 +05:30
parent 7d117a52c3
commit 94490ef939
2 changed files with 29 additions and 1 deletions
contracts/polygon/connectors/aave/v3-import

View File

@ -224,6 +224,33 @@ contract AaveHelpers is Helper {
}
function _TransferAtokens(
uint256 _length,
AaveInterface aave,
ATokenInterface[] memory atokenContracts,
uint256[] memory amts,
address[] memory tokens,
address userAccount
) internal {
for (uint256 i = 0; i < _length; i++) {
if (amts[i] > 0) {
uint256 _amt = amts[i];
require(
atokenContracts[i].transferFrom(
userAccount,
address(this),
_amt
),
"allowance?"
);
if (!getIsColl(tokens[i], address(this))) {
aave.setUserUseReserveAsCollateral(tokens[i], true);
}
}
}
}
function _TransferAtokensWithCollateral(
uint256 _length,
AaveInterface aave,
ATokenInterface[] memory atokenContracts,

View File

@ -127,12 +127,13 @@ contract AaveV3ImportResolver is AaveHelpers {
);
// transfer atokens to this address;
_TransferAtokens(
_TransferAtokensWithCollateral(
data._supplyTokens.length,
aave,
data.aTokens,
data.supplyAmts,
data._supplyTokens,
enableCollateral,
userAccount
);