mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
fixed DSA v2 to v3 import logic
This commit is contained in:
parent
ae6598b2f6
commit
22728d776a
|
@ -3,6 +3,7 @@ pragma solidity ^0.7.0;
|
||||||
contract Events {
|
contract Events {
|
||||||
event LogAaveV2ImportToV3(
|
event LogAaveV2ImportToV3(
|
||||||
address indexed user,
|
address indexed user,
|
||||||
|
bool doImport,
|
||||||
bool convertStable,
|
bool convertStable,
|
||||||
address[] supplyTokens,
|
address[] supplyTokens,
|
||||||
address[] borrowTokens,
|
address[] borrowTokens,
|
||||||
|
|
|
@ -7,14 +7,21 @@ import "./helpers.sol";
|
||||||
import "./events.sol";
|
import "./events.sol";
|
||||||
|
|
||||||
contract _AaveV2ToV3MigrationResolver is _AaveHelper {
|
contract _AaveV2ToV3MigrationResolver is _AaveHelper {
|
||||||
function _importAave(address userAccount, ImportInputData memory inputData)
|
function _importAave(
|
||||||
|
address userAccount,
|
||||||
|
ImportInputData memory inputData,
|
||||||
|
bool doImport
|
||||||
|
)
|
||||||
internal
|
internal
|
||||||
returns (string memory _eventName, bytes memory _eventParam)
|
returns (string memory _eventName, bytes memory _eventParam)
|
||||||
{
|
{
|
||||||
require(
|
if (doImport) {
|
||||||
AccountInterface(address(this)).isAuth(userAccount),
|
// check only when we are importing from user's address
|
||||||
"user-account-not-auth"
|
require(
|
||||||
);
|
AccountInterface(address(this)).isAuth(userAccount),
|
||||||
|
"user-account-not-auth"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
require(inputData.supplyTokens.length > 0, "0-length-not-allowed");
|
require(inputData.supplyTokens.length > 0, "0-length-not-allowed");
|
||||||
|
|
||||||
|
@ -44,15 +51,17 @@ contract _AaveV2ToV3MigrationResolver is _AaveHelper {
|
||||||
userAccount
|
userAccount
|
||||||
);
|
);
|
||||||
|
|
||||||
// transfer atokens to this address;
|
if (doImport) {
|
||||||
_TransferAtokens(
|
// transfer atokens to user's DSA address;
|
||||||
data._supplyTokens.length,
|
_TransferAtokens(
|
||||||
aaveV2,
|
data._supplyTokens.length,
|
||||||
data.aTokens,
|
aaveV2,
|
||||||
data.supplyAmts,
|
data.aTokens,
|
||||||
data._supplyTokens,
|
data.supplyAmts,
|
||||||
userAccount
|
data._supplyTokens,
|
||||||
);
|
userAccount
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// withdraw v2 supplied tokens
|
// withdraw v2 supplied tokens
|
||||||
_WithdrawTokensFromV2(
|
_WithdrawTokensFromV2(
|
||||||
|
@ -92,9 +101,10 @@ contract _AaveV2ToV3MigrationResolver is _AaveHelper {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventName = "LogAaveV2ImportToV3(address,bool,address[],address[],uint256,uint256[],uint256[],uint256[])";
|
_eventName = "LogAaveV2ImportToV3(address,bool,bool,address[],address[],uint256[],uint256[],uint256[],uint256[])";
|
||||||
_eventParam = abi.encode(
|
_eventParam = abi.encode(
|
||||||
userAccount,
|
userAccount,
|
||||||
|
doImport,
|
||||||
inputData.convertStable,
|
inputData.convertStable,
|
||||||
inputData.supplyTokens,
|
inputData.supplyTokens,
|
||||||
inputData.borrowTokens,
|
inputData.borrowTokens,
|
||||||
|
@ -113,7 +123,7 @@ contract _AaveV2ToV3MigrationResolver is _AaveHelper {
|
||||||
payable
|
payable
|
||||||
returns (string memory _eventName, bytes memory _eventParam)
|
returns (string memory _eventName, bytes memory _eventParam)
|
||||||
{
|
{
|
||||||
(_eventName, _eventParam) = _importAave(userAccount, inputData);
|
(_eventName, _eventParam) = _importAave(userAccount, inputData, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function migrateAaveV2ToV3(ImportInputData memory inputData)
|
function migrateAaveV2ToV3(ImportInputData memory inputData)
|
||||||
|
@ -121,7 +131,7 @@ contract _AaveV2ToV3MigrationResolver is _AaveHelper {
|
||||||
payable
|
payable
|
||||||
returns (string memory _eventName, bytes memory _eventParam)
|
returns (string memory _eventName, bytes memory _eventParam)
|
||||||
{
|
{
|
||||||
(_eventName, _eventParam) = _importAave(msg.sender, inputData);
|
(_eventName, _eventParam) = _importAave(msg.sender, inputData, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user