Revert "fantom"

This reverts commit c2fdf4e225.
This commit is contained in:
Richa-iitr 2022-06-02 14:04:44 +05:30
parent c2fdf4e225
commit 6c526ea8a3
4 changed files with 46 additions and 177 deletions

View File

@ -1,6 +1,5 @@
//SPDX-License-Identifier: MIT //SPDX-License-Identifier: MIT
pragma solidity ^0.7.0; pragma solidity ^0.7.0;
pragma abicoder v2;
interface TokenInterface { interface TokenInterface {
function approve(address, uint256) external; function approve(address, uint256) external;
@ -34,14 +33,4 @@ interface AccountInterface {
function disable(address) external; function disable(address) external;
function isAuth(address) external view returns (bool); function isAuth(address) external view returns (bool);
function cast(
string[] calldata _targetNames,
bytes[] calldata _datas,
address _origin
) external payable returns (bytes32[] memory responses);
}
interface ListInterface {
function accountID(address) external returns (uint64);
} }

View File

@ -5,7 +5,7 @@ pragma experimental ABIEncoderV2;
contract Events { contract Events {
event LogAaveV3Import( event LogAaveV3Import(
address indexed user, address indexed user,
address[] atokens, address[] ctokens,
string[] supplyIds, string[] supplyIds,
string[] borrowIds, string[] borrowIds,
uint256[] flashLoanFees, uint256[] flashLoanFees,
@ -14,7 +14,7 @@ contract Events {
); );
event LogAaveV3ImportWithCollateral( event LogAaveV3ImportWithCollateral(
address indexed user, address indexed user,
address[] atokens, address[] ctokens,
string[] supplyIds, string[] supplyIds,
string[] borrowIds, string[] borrowIds,
uint256[] flashLoanFees, uint256[] flashLoanFees,

View File

@ -1,10 +1,9 @@
//SPDX-License-Identifier: MIT //SPDX-License-Identifier: MIT
pragma solidity ^0.7.0; pragma solidity ^0.7.0;
pragma abicoder v2;
import { DSMath } from "../../../common/math.sol"; import { DSMath } from "../../../common/math.sol";
import { Basic } from "../../../common/basic.sol"; import { Basic } from "../../../common/basic.sol";
import { TokenInterface, AccountInterface, ListInterface } from "../../../common/interfaces.sol"; import { TokenInterface, AccountInterface } from "../../../common/interfaces.sol";
import { AaveInterface, AavePoolProviderInterface, AaveDataProviderInterface } from "./interface.sol"; import { AaveInterface, AavePoolProviderInterface, AaveDataProviderInterface } from "./interface.sol";
import "./events.sol"; import "./events.sol";
import "./interface.sol"; import "./interface.sol";
@ -27,12 +26,6 @@ abstract contract Helper is DSMath, Basic {
AaveDataProviderInterface internal constant aaveData = AaveDataProviderInterface internal constant aaveData =
AaveDataProviderInterface(0x69FA688f1Dc47d4B5d8029D5a35FB7a548310654); AaveDataProviderInterface(0x69FA688f1Dc47d4B5d8029D5a35FB7a548310654);
/**
* @dev InstaList
*/
ListInterface internal constant instaList =
ListInterface(0x10e166c3FAF887D8a61dE6c25039231eE694E926);
function getIsColl(address token, address user) function getIsColl(address token, address user)
internal internal
view view
@ -238,60 +231,20 @@ contract AaveHelpers is Helper {
address[] memory tokens, address[] memory tokens,
address userAccount address userAccount
) internal { ) internal {
if (instaList.accountID(userAccount) == 0) { for (uint256 i = 0; i < _length; i++) {
for (uint256 i = 0; i < _length; i++) { if (amts[i] > 0) {
if (amts[i] > 0) { uint256 _amt = amts[i];
uint256 _amt = amts[i]; require(
require( atokenContracts[i].transferFrom(
atokenContracts[i].transferFrom( userAccount,
userAccount,
address(this),
_amt
),
"allowance?"
);
if (!getIsColl(tokens[i], address(this))) {
aave.setUserUseReserveAsCollateral(tokens[i], true);
}
}
}
} else {
uint256 _len = 0;
uint256 _cntr = 0;
for (uint256 i = 0; i < _length; i++) {
if (amts[i] > 0) {
_len++;
}
}
string[] memory _targets = new string[](_len);
bytes[] memory _data = new bytes[](_len);
address[] memory _tokens = new address[](_len);
bytes4 basicWithdraw = bytes4(
keccak256("withdraw(address,uint256,address,uint256,uint256)")
);
for (uint256 i = 0; i < _length; i++) {
if (amts[i] > 0) {
uint256 _amt = amts[i];
address _token = address(atokenContracts[i]);
_targets[_cntr] = "BASIC-A";
_data[_cntr] = abi.encodeWithSelector(
basicWithdraw,
_token,
_amt,
address(this), address(this),
0, _amt
0 ),
); "allowance?"
_tokens[_cntr] = tokens[i]; );
_cntr++;
}
}
AccountInterface(userAccount).cast(_targets, _data, address(this)); if (!getIsColl(tokens[i], address(this))) {
for (uint256 i = 0; i < _len; i++) { aave.setUserUseReserveAsCollateral(tokens[i], true);
if (!getIsColl(_tokens[i], address(this))) {
aave.setUserUseReserveAsCollateral(_tokens[i], true);
} }
} }
} }
@ -306,67 +259,20 @@ contract AaveHelpers is Helper {
bool[] memory colEnable, bool[] memory colEnable,
address userAccount address userAccount
) internal { ) internal {
if (instaList.accountID(userAccount) == 0) { for (uint256 i = 0; i < _length; i++) {
for (uint256 i = 0; i < _length; i++) { if (amts[i] > 0) {
if (amts[i] > 0) { uint256 _amt = amts[i];
uint256 _amt = amts[i]; require(
require( atokenContracts[i].transferFrom(
atokenContracts[i].transferFrom( userAccount,
userAccount,
address(this),
_amt
),
"allowance?"
);
if (!getIsColl(tokens[i], address(this))) {
aave.setUserUseReserveAsCollateral(
tokens[i],
colEnable[i]
);
}
}
}
} else {
uint256 _len = 0;
uint256 _cntr = 0;
for (uint256 i = 0; i < _length; i++) {
if (amts[i] > 0) {
_len++;
}
}
string[] memory _targets = new string[](_len);
bytes[] memory _data = new bytes[](_len);
address[] memory _tokens = new address[](_len);
bytes4 basicWithdraw = bytes4(
keccak256("withdraw(address,uint256,address,uint256,uint256)")
);
for (uint256 i = 0; i < _length; i++) {
if (amts[i] > 0) {
uint256 _amt = amts[i];
address _token = address(atokenContracts[i]);
_targets[_cntr] = "BASIC-A";
_data[_cntr] = abi.encodeWithSelector(
basicWithdraw,
_token,
_amt,
address(this), address(this),
0, _amt
0 ),
); "allowance?"
_tokens[_cntr] = tokens[i]; );
_cntr++;
}
}
AccountInterface(userAccount).cast(_targets, _data, address(this)); if (!getIsColl(tokens[i], address(this))) {
for (uint256 i = 0; i < _len; i++) { aave.setUserUseReserveAsCollateral(tokens[i], colEnable[i]);
if (!getIsColl(_tokens[i], address(this))) {
aave.setUserUseReserveAsCollateral(
_tokens[i],
colEnable[i]
);
} }
} }
} }

View File

@ -3,7 +3,7 @@ pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2; pragma experimental ABIEncoderV2;
/** /**
* @title Aave v3 import connector . * @title Aave v3 import connector .
* @dev Import EOA's / External DSA's aave V3 position to DSA's aave v3 position * @dev Import EOA's aave V3 position to DSA's aave v3 position
*/ */
import { TokenInterface, AccountInterface } from "../../../common/interfaces.sol"; import { TokenInterface, AccountInterface } from "../../../common/interfaces.sol";
@ -16,17 +16,10 @@ contract AaveV3ImportResolver is AaveHelpers {
internal internal
returns (string memory _eventName, bytes memory _eventParam) returns (string memory _eventName, bytes memory _eventParam)
{ {
if (instaList.accountID(userAccount) == 0) { require(
require( AccountInterface(address(this)).isAuth(userAccount),
AccountInterface(address(this)).isAuth(userAccount), "user-account-not-auth"
"user-account-not-auth" );
);
} else {
require(
AccountInterface(userAccount).isAuth(address(this)),
"user-account-not-auth"
);
}
require(inputData.supplyTokens.length > 0, "0-length-not-allowed"); require(inputData.supplyTokens.length > 0, "0-length-not-allowed");
@ -99,29 +92,18 @@ contract AaveV3ImportResolver is AaveHelpers {
); );
} }
function _importAaveWithCollateral( function _importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
address userAccount, internal
ImportInputData memory inputData, returns (string memory _eventName, bytes memory _eventParam)
bool[] memory enableCollateral {
) internal returns (string memory _eventName, bytes memory _eventParam) {
if (instaList.accountID(userAccount) == 0) {
require(
AccountInterface(address(this)).isAuth(userAccount),
"user-account-not-auth"
);
} else {
require(
AccountInterface(userAccount).isAuth(address(this)),
"user-account-not-auth"
);
}
require(inputData.supplyTokens.length > 0, "0-length-not-allowed");
require( require(
enableCollateral.length == inputData.supplyTokens.length, AccountInterface(address(this)).isAuth(userAccount),
"lengths-not-same" "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; ImportData memory data;
AaveInterface aave = AaveInterface(aaveProvider.getPool()); AaveInterface aave = AaveInterface(aaveProvider.getPool());
@ -196,7 +178,7 @@ contract AaveV3ImportResolver is AaveHelpers {
/** /**
* @dev Import aave V3 position . * @dev Import aave V3 position .
* @notice Import EOA's aave V3 position to DSA's aave v3 position * @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 or the address of the DSA to which the DSA's Aave position will be merged * @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 inputData The struct containing all the neccessary input data
*/ */
function importAave(address userAccount, ImportInputData memory inputData) function importAave(address userAccount, ImportInputData memory inputData)
@ -210,27 +192,19 @@ contract AaveV3ImportResolver is AaveHelpers {
/** /**
* @dev Import aave V3 position (with collateral). * @dev Import aave V3 position (with collateral).
* @notice Import EOA's aave V3 position to DSA's aave v3 position * @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 or the address of the DSA to which the DSA's Aave position will be merged * @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 inputData The struct containing all the neccessary input data
* @param enableCollateral The boolean array to enable selected collaterals in the imported position * @param enableCollateral The boolean array to enable selected collaterals in the imported position
*/ */
function importAaveWithCollateral( function importAaveWithCollateral(address userAccount, ImportInputData memory inputData, bool[] memory enableCollateral)
address userAccount,
ImportInputData memory inputData,
bool[] memory enableCollateral
)
external external
payable payable
returns (string memory _eventName, bytes memory _eventParam) returns (string memory _eventName, bytes memory _eventParam)
{ {
(_eventName, _eventParam) = _importAaveWithCollateral( (_eventName, _eventParam) = _importAaveWithCollateral(userAccount, inputData, enableCollateral);
userAccount,
inputData,
enableCollateral
);
} }
} }
contract ConnectV2AaveV3ImportFantom is AaveV3ImportResolver { contract ConnectV2AaveV3ImportFantom is AaveV3ImportResolver {
string public constant name = "Aave-v3-import-v1.2"; string public constant name = "Aave-v3-import-v1.1";
} }