Merge pull request #217 from Richa-iitr/aave-v3-import-fix

Aave v3 import fix
This commit is contained in:
0xPradyuman 2022-05-07 03:51:10 +05:30 committed by GitHub
commit 4aeed758fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 823 additions and 7 deletions

View File

@ -12,4 +12,14 @@ contract Events {
uint256[] supplyAmts,
uint256[] borrowAmts
);
event LogAaveV3ImportWithCollateral(
address indexed user,
address[] ctokens,
string[] supplyIds,
string[] borrowIds,
uint256[] flashLoanFees,
uint256[] supplyAmts,
uint256[] borrowAmts,
bool[] enableCollateral
);
}

View File

@ -250,6 +250,34 @@ contract AaveHelpers is Helper {
}
}
function _TransferAtokensWithCollateral(
uint256 _length,
AaveInterface aave,
ATokenInterface[] memory atokenContracts,
uint256[] memory amts,
address[] memory tokens,
bool[] memory colEnable,
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], colEnable[i]);
}
}
}
}
function _BorrowVariable(
uint256 _length,
AaveInterface aave,

View File

@ -91,6 +91,89 @@ contract AaveV3ImportResolver is AaveHelpers {
);
}
function _importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
internal
returns (string memory _eventName, bytes memory _eventParam)
{
require(
AccountInterface(address(this)).isAuth(userAccount),
"user-account-not-auth"
);
require(inputData.supplyTokens.length > 0, "0-length-not-allowed");
require(enableCollateral.length == inputData.supplyTokens.length, "lengths-not-same");
ImportData memory data;
AaveInterface aave = AaveInterface(aaveProvider.getPool());
data = getBorrowAmounts(userAccount, aave, inputData, data);
data = getSupplyAmounts(userAccount, inputData, data);
// payback borrowed amount;
_PaybackStable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.stableBorrowAmts,
userAccount
);
_PaybackVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.variableBorrowAmts,
userAccount
);
// transfer atokens to this address;
_TransferAtokensWithCollateral(
data._supplyTokens.length,
aave,
data.aTokens,
data.supplyAmts,
data._supplyTokens,
enableCollateral,
userAccount
);
// borrow assets after migrating position
if (data.convertStable) {
_BorrowVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.totalBorrowAmtsWithFee
);
} else {
_BorrowStable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.stableBorrowAmtsWithFee
);
_BorrowVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.variableBorrowAmtsWithFee
);
}
_eventName = "LogAaveV3ImportWithCollateral(address,bool,address[],address[],uint256[],uint256[],uint256[],uint256[],bool[])";
_eventParam = abi.encode(
userAccount,
inputData.convertStable,
inputData.supplyTokens,
inputData.borrowTokens,
inputData.flashLoanFees,
data.supplyAmts,
data.stableBorrowAmts,
data.variableBorrowAmts,
enableCollateral
);
}
/**
* @dev Import aave V3 position .
* @notice Import EOA's aave V3 position to DSA's aave v3 position
@ -104,8 +187,23 @@ contract AaveV3ImportResolver is AaveHelpers {
{
(_eventName, _eventParam) = _importAave(userAccount, inputData);
}
/**
* @dev Import aave V3 position (with collateral).
* @notice Import EOA's aave V3 position to DSA's aave v3 position
* @param userAccount The address of the EOA from which aave position will be imported
* @param inputData The struct containing all the neccessary input data
* @param enableCollateral The boolean array to enable selected collaterals in the imported position
*/
function importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
(_eventName, _eventParam) = _importAaveWithCollateral(userAccount, inputData, enableCollateral);
}
}
contract ConnectV2AaveV3ImportArbitrum is AaveV3ImportResolver {
string public constant name = "Aave-v3-import-v1";
string public constant name = "Aave-v3-import-v1.1";
}

View File

@ -5,11 +5,21 @@ pragma experimental ABIEncoderV2;
contract Events {
event LogAaveV3Import(
address indexed user,
address[] ctokens,
address[] atokens,
string[] supplyIds,
string[] borrowIds,
uint256[] flashLoanFees,
uint256[] supplyAmts,
uint256[] borrowAmts
);
event LogAaveV3ImportWithCollateral(
address indexed user,
address[] atokens,
string[] supplyIds,
string[] borrowIds,
uint256[] flashLoanFees,
uint256[] supplyAmts,
uint256[] borrowAmts,
bool[] enableCollateral
);
}

View File

@ -252,6 +252,34 @@ contract AaveHelpers is Helper {
}
}
function _TransferAtokensWithCollateral(
uint256 _length,
AaveInterface aave,
ATokenInterface[] memory atokenContracts,
uint256[] memory amts,
address[] memory tokens,
bool[] memory colEnable,
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], colEnable[i]);
}
}
}
}
function _BorrowVariable(
uint256 _length,
AaveInterface aave,

View File

@ -91,6 +91,89 @@ contract AaveV3ImportResolver is AaveHelpers {
);
}
function _importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
internal
returns (string memory _eventName, bytes memory _eventParam)
{
require(
AccountInterface(address(this)).isAuth(userAccount),
"user-account-not-auth"
);
require(inputData.supplyTokens.length > 0, "0-length-not-allowed");
require(enableCollateral.length == inputData.supplyTokens.length, "lengths-not-same");
ImportData memory data;
AaveInterface aave = AaveInterface(aaveProvider.getPool());
data = getBorrowAmounts(userAccount, aave, inputData, data);
data = getSupplyAmounts(userAccount, inputData, data);
// payback borrowed amount;
_PaybackStable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.stableBorrowAmts,
userAccount
);
_PaybackVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.variableBorrowAmts,
userAccount
);
// transfer atokens to this address;
_TransferAtokensWithCollateral(
data._supplyTokens.length,
aave,
data.aTokens,
data.supplyAmts,
data._supplyTokens,
enableCollateral,
userAccount
);
// borrow assets after migrating position
if (data.convertStable) {
_BorrowVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.totalBorrowAmtsWithFee
);
} else {
_BorrowStable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.stableBorrowAmtsWithFee
);
_BorrowVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.variableBorrowAmtsWithFee
);
}
_eventName = "LogAaveV3ImportWithCollateral(address,bool,address[],address[],uint256[],uint256[],uint256[],uint256[],bool[])";
_eventParam = abi.encode(
userAccount,
inputData.convertStable,
inputData.supplyTokens,
inputData.borrowTokens,
inputData.flashLoanFees,
data.supplyAmts,
data.stableBorrowAmts,
data.variableBorrowAmts,
enableCollateral
);
}
/**
* @dev Import aave V3 position .
* @notice Import EOA's aave V3 position to DSA's aave v3 position
@ -104,8 +187,23 @@ contract AaveV3ImportResolver is AaveHelpers {
{
(_eventName, _eventParam) = _importAave(userAccount, inputData);
}
/**
* @dev Import aave V3 position (with collateral).
* @notice Import EOA's aave V3 position to DSA's aave v3 position
* @param userAccount The address of the EOA from which aave position will be imported
* @param inputData The struct containing all the neccessary input data
* @param enableCollateral The boolean array to enable selected collaterals in the imported position
*/
function importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
(_eventName, _eventParam) = _importAaveWithCollateral(userAccount, inputData, enableCollateral);
}
}
contract ConnectV2AaveV3ImportAvalanche is AaveV3ImportResolver {
string public constant name = "Aave-v3-import-v1";
string public constant name = "Aave-v3-import-v1.1";
}

View File

@ -12,4 +12,14 @@ contract Events {
uint256[] supplyAmts,
uint256[] borrowAmts
);
event LogAaveV3ImportWithCollateral(
address indexed user,
address[] ctokens,
string[] supplyIds,
string[] borrowIds,
uint256[] flashLoanFees,
uint256[] supplyAmts,
uint256[] borrowAmts,
bool[] enableCollateral
);
}

View File

@ -250,6 +250,34 @@ contract AaveHelpers is Helper {
}
}
function _TransferAtokensWithCollateral(
uint256 _length,
AaveInterface aave,
ATokenInterface[] memory atokenContracts,
uint256[] memory amts,
address[] memory tokens,
bool[] memory colEnable,
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], colEnable[i]);
}
}
}
}
function _BorrowVariable(
uint256 _length,
AaveInterface aave,

View File

@ -92,6 +92,89 @@ contract AaveV3ImportResolver is AaveHelpers {
);
}
function _importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
internal
returns (string memory _eventName, bytes memory _eventParam)
{
require(
AccountInterface(address(this)).isAuth(userAccount),
"user-account-not-auth"
);
require(inputData.supplyTokens.length > 0, "0-length-not-allowed");
require(enableCollateral.length == inputData.supplyTokens.length, "lengths-not-same");
ImportData memory data;
AaveInterface aave = AaveInterface(aaveProvider.getPool());
data = getBorrowAmounts(userAccount, aave, inputData, data);
data = getSupplyAmounts(userAccount, inputData, data);
// payback borrowed amount;
_PaybackStable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.stableBorrowAmts,
userAccount
);
_PaybackVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.variableBorrowAmts,
userAccount
);
// transfer atokens to this address;
_TransferAtokensWithCollateral(
data._supplyTokens.length,
aave,
data.aTokens,
data.supplyAmts,
data._supplyTokens,
enableCollateral,
userAccount
);
// borrow assets after migrating position
if (data.convertStable) {
_BorrowVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.totalBorrowAmtsWithFee
);
} else {
_BorrowStable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.stableBorrowAmtsWithFee
);
_BorrowVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.variableBorrowAmtsWithFee
);
}
_eventName = "LogAaveV3ImportWithCollateral(address,bool,address[],address[],uint256[],uint256[],uint256[],uint256[],bool[])";
_eventParam = abi.encode(
userAccount,
inputData.convertStable,
inputData.supplyTokens,
inputData.borrowTokens,
inputData.flashLoanFees,
data.supplyAmts,
data.stableBorrowAmts,
data.variableBorrowAmts,
enableCollateral
);
}
/**
* @dev Import aave V3 position .
* @notice Import EOA's aave V3 position to DSA's aave v3 position
@ -105,8 +188,23 @@ contract AaveV3ImportResolver is AaveHelpers {
{
(_eventName, _eventParam) = _importAave(userAccount, inputData);
}
/**
* @dev Import aave V3 position (with collateral).
* @notice Import EOA's aave V3 position to DSA's aave v3 position
* @param userAccount The address of the EOA from which aave position will be imported
* @param inputData The struct containing all the neccessary input data
* @param enableCollateral The boolean array to enable selected collaterals in the imported position
*/
function importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
(_eventName, _eventParam) = _importAaveWithCollateral(userAccount, inputData, enableCollateral);
}
}
contract ConnectV2AaveV3ImportFantom is AaveV3ImportResolver {
string public constant name = "Aave-v3-import-v1";
string public constant name = "Aave-v3-import-v1.1";
}

View File

@ -12,4 +12,14 @@ contract Events {
uint256[] supplyAmts,
uint256[] borrowAmts
);
event LogAaveV3ImportWithCollateral(
address indexed user,
address[] atokens,
string[] supplyIds,
string[] borrowIds,
uint256[] flashLoanFees,
uint256[] supplyAmts,
uint256[] borrowAmts,
bool[] enableCollateral
);
}

View File

@ -250,6 +250,34 @@ contract AaveHelpers is Helper {
}
}
function _TransferAtokensWithCollateral(
uint256 _length,
AaveInterface aave,
ATokenInterface[] memory atokenContracts,
uint256[] memory amts,
address[] memory tokens,
bool[] memory colEnable,
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], colEnable[i]);
}
}
}
}
function _BorrowVariable(
uint256 _length,
AaveInterface aave,

View File

@ -91,6 +91,89 @@ contract AaveV3ImportResolver is AaveHelpers {
);
}
function _importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
internal
returns (string memory _eventName, bytes memory _eventParam)
{
require(
AccountInterface(address(this)).isAuth(userAccount),
"user-account-not-auth"
);
require(inputData.supplyTokens.length > 0, "0-length-not-allowed");
require(enableCollateral.length == inputData.supplyTokens.length, "lengths-not-same");
ImportData memory data;
AaveInterface aave = AaveInterface(aaveProvider.getPool());
data = getBorrowAmounts(userAccount, aave, inputData, data);
data = getSupplyAmounts(userAccount, inputData, data);
// payback borrowed amount;
_PaybackStable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.stableBorrowAmts,
userAccount
);
_PaybackVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.variableBorrowAmts,
userAccount
);
// transfer atokens to this address;
_TransferAtokensWithCollateral(
data._supplyTokens.length,
aave,
data.aTokens,
data.supplyAmts,
data._supplyTokens,
enableCollateral,
userAccount
);
// borrow assets after migrating position
if (data.convertStable) {
_BorrowVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.totalBorrowAmtsWithFee
);
} else {
_BorrowStable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.stableBorrowAmtsWithFee
);
_BorrowVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.variableBorrowAmtsWithFee
);
}
_eventName = "LogAaveV3ImportWithCollateral(address,bool,address[],address[],uint256[],uint256[],uint256[],uint256[],bool[])";
_eventParam = abi.encode(
userAccount,
inputData.convertStable,
inputData.supplyTokens,
inputData.borrowTokens,
inputData.flashLoanFees,
data.supplyAmts,
data.stableBorrowAmts,
data.variableBorrowAmts,
enableCollateral
);
}
/**
* @dev Import aave V3 position .
* @notice Import EOA's aave V3 position to DSA's aave v3 position
@ -104,8 +187,23 @@ contract AaveV3ImportResolver is AaveHelpers {
{
(_eventName, _eventParam) = _importAave(userAccount, inputData);
}
/**
* @dev Import aave V3 position (with collateral).
* @notice Import EOA's aave V3 position to DSA's aave v3 position
* @param userAccount The address of the EOA from which aave position will be imported
* @param inputData The struct containing all the neccessary input data
* @param enableCollateral The boolean array to enable selected collaterals in the imported position
*/
function importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
(_eventName, _eventParam) = _importAaveWithCollateral(userAccount, inputData, enableCollateral);
}
}
contract ConnectV2AaveV3Import is AaveV3ImportResolver {
string public constant name = "Aave-v3-import-v1";
string public constant name = "Aave-v3-import-v1.1";
}

View File

@ -12,4 +12,14 @@ contract Events {
uint256[] supplyAmts,
uint256[] borrowAmts
);
event LogAaveV3ImportWithCollateral(
address indexed user,
address[] ctokens,
string[] supplyIds,
string[] borrowIds,
uint256[] flashLoanFees,
uint256[] supplyAmts,
uint256[] borrowAmts,
bool[] enableCollateral
);
}

View File

@ -250,6 +250,34 @@ contract AaveHelpers is Helper {
}
}
function _TransferAtokensWithCollateral(
uint256 _length,
AaveInterface aave,
ATokenInterface[] memory atokenContracts,
uint256[] memory amts,
address[] memory tokens,
bool[] memory colEnable,
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], colEnable[i]);
}
}
}
}
function _BorrowVariable(
uint256 _length,
AaveInterface aave,

View File

@ -91,6 +91,89 @@ contract AaveV3ImportResolver is AaveHelpers {
);
}
function _importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
internal
returns (string memory _eventName, bytes memory _eventParam)
{
require(
AccountInterface(address(this)).isAuth(userAccount),
"user-account-not-auth"
);
require(inputData.supplyTokens.length > 0, "0-length-not-allowed");
require(enableCollateral.length == inputData.supplyTokens.length, "lengths-not-same");
ImportData memory data;
AaveInterface aave = AaveInterface(aaveProvider.getPool());
data = getBorrowAmounts(userAccount, aave, inputData, data);
data = getSupplyAmounts(userAccount, inputData, data);
// payback borrowed amount;
_PaybackStable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.stableBorrowAmts,
userAccount
);
_PaybackVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.variableBorrowAmts,
userAccount
);
// transfer atokens to this address;
_TransferAtokensWithCollateral(
data._supplyTokens.length,
aave,
data.aTokens,
data.supplyAmts,
data._supplyTokens,
enableCollateral,
userAccount
);
// borrow assets after migrating position
if (data.convertStable) {
_BorrowVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.totalBorrowAmtsWithFee
);
} else {
_BorrowStable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.stableBorrowAmtsWithFee
);
_BorrowVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.variableBorrowAmtsWithFee
);
}
_eventName = "LogAaveV3ImportWithCollateral(address,bool,address[],address[],uint256[],uint256[],uint256[],uint256[],bool[])";
_eventParam = abi.encode(
userAccount,
inputData.convertStable,
inputData.supplyTokens,
inputData.borrowTokens,
inputData.flashLoanFees,
data.supplyAmts,
data.stableBorrowAmts,
data.variableBorrowAmts,
enableCollateral
);
}
/**
* @dev Import aave V3 position .
* @notice Import EOA's aave V3 position to DSA's aave v3 position
@ -104,8 +187,23 @@ contract AaveV3ImportResolver is AaveHelpers {
{
(_eventName, _eventParam) = _importAave(userAccount, inputData);
}
/**
* @dev Import aave V3 position (with collateral).
* @notice Import EOA's aave V3 position to DSA's aave v3 position
* @param userAccount The address of the EOA from which aave position will be imported
* @param inputData The struct containing all the neccessary input data
* @param enableCollateral The boolean array to enable selected collaterals in the imported position
*/
function importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
(_eventName, _eventParam) = _importAaveWithCollateral(userAccount, inputData, enableCollateral);
}
}
contract ConnectV2AaveV3ImportOptimism is AaveV3ImportResolver {
string public constant name = "Aave-v3-import-v1";
string public constant name = "Aave-v3-import-v1.1";
}

View File

@ -12,4 +12,14 @@ contract Events {
uint256[] supplyAmts,
uint256[] borrowAmts
);
event LogAaveV3ImportWithCollateral(
address indexed user,
address[] ctokens,
string[] supplyIds,
string[] borrowIds,
uint256[] flashLoanFees,
uint256[] supplyAmts,
uint256[] borrowAmts,
bool[] enableCollateral
);
}

View File

@ -250,6 +250,34 @@ contract AaveHelpers is Helper {
}
}
function _TransferAtokensWithCollateral(
uint256 _length,
AaveInterface aave,
ATokenInterface[] memory atokenContracts,
uint256[] memory amts,
address[] memory tokens,
bool[] memory colEnable,
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], colEnable[i]);
}
}
}
}
function _BorrowVariable(
uint256 _length,
AaveInterface aave,

View File

@ -92,6 +92,89 @@ contract AaveV3ImportResolver is AaveHelpers {
);
}
function _importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
internal
returns (string memory _eventName, bytes memory _eventParam)
{
require(
AccountInterface(address(this)).isAuth(userAccount),
"user-account-not-auth"
);
require(inputData.supplyTokens.length > 0, "0-length-not-allowed");
require(enableCollateral.length == inputData.supplyTokens.length, "lengths-not-same");
ImportData memory data;
AaveInterface aave = AaveInterface(aaveProvider.getPool());
data = getBorrowAmounts(userAccount, aave, inputData, data);
data = getSupplyAmounts(userAccount, inputData, data);
// payback borrowed amount;
_PaybackStable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.stableBorrowAmts,
userAccount
);
_PaybackVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.variableBorrowAmts,
userAccount
);
// transfer atokens to this address;
_TransferAtokensWithCollateral(
data._supplyTokens.length,
aave,
data.aTokens,
data.supplyAmts,
data._supplyTokens,
enableCollateral,
userAccount
);
// borrow assets after migrating position
if (data.convertStable) {
_BorrowVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.totalBorrowAmtsWithFee
);
} else {
_BorrowStable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.stableBorrowAmtsWithFee
);
_BorrowVariable(
data._borrowTokens.length,
aave,
data._borrowTokens,
data.variableBorrowAmtsWithFee
);
}
_eventName = "LogAaveV3ImportWithCollateral(address,bool,address[],address[],uint256[],uint256[],uint256[],uint256[],bool[])";
_eventParam = abi.encode(
userAccount,
inputData.convertStable,
inputData.supplyTokens,
inputData.borrowTokens,
inputData.flashLoanFees,
data.supplyAmts,
data.stableBorrowAmts,
data.variableBorrowAmts,
enableCollateral
);
}
/**
* @dev Import aave V3 position .
* @notice Import EOA's aave V3 position to DSA's aave v3 position
@ -105,8 +188,23 @@ contract AaveV3ImportResolver is AaveHelpers {
{
(_eventName, _eventParam) = _importAave(userAccount, inputData);
}
/**
* @dev Import aave V3 position (with collateral).
* @notice Import EOA's aave V3 position to DSA's aave v3 position
* @param userAccount The address of the EOA from which aave position will be imported
* @param inputData The struct containing all the neccessary input data
* @param enableCollateral The boolean array to enable selected collaterals in the imported position
*/
function importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
(_eventName, _eventParam) = _importAaveWithCollateral(userAccount, inputData, enableCollateral);
}
}
contract ConnectV2AaveV3ImportPolygon is AaveV3ImportResolver {
string public constant name = "Aave-v3-import-v1";
string public constant name = "Aave-v3-import-v1.1";
}