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

View File

@ -224,6 +224,33 @@ contract AaveHelpers is Helper {
} }
function _TransferAtokens( 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, uint256 _length,
AaveInterface aave, AaveInterface aave,
ATokenInterface[] memory atokenContracts, ATokenInterface[] memory atokenContracts,

View File

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