Minor changes

This commit is contained in:
Mubaris NK 2021-04-02 10:50:25 +05:30
parent d9fdd17e3d
commit 33c5c8e0fd
No known key found for this signature in database
GPG Key ID: 9AC09AD0F8D68561

View File

@ -56,6 +56,7 @@ abstract contract AaveResolver is Helpers, Events {
contract AaveImportResolver is AaveResolver {
struct AaveData {
bool isFinal;
address targetDsa;
uint[] supplyAmts;
uint[] variableBorrowAmts;
uint[] stableBorrowAmts;
@ -63,20 +64,27 @@ contract AaveImportResolver is AaveResolver {
address[] borrowTokens;
}
mapping (address => AaveData) public records;
mapping (address => AaveData) public positions;
function migrate(
address targetDsa,
address[] calldata supplyTokens,
address[] calldata borrowTokens
) external payable returns (string memory _eventName, bytes memory _eventParam) {
require(AccountInterface(address(this)).isAuth(msg.sender), "user-account-not-auth");
require(supplyTokens.length > 0, "0-length-not-allowed");
require(targetDsa != address(0), "invalid-address");
AaveData memory data;
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
(,,,,,uint healthFactor) = aave.getUserAccountData(address(this));
require(healthFactor > 1e18, "position-not-safe");
data.supplyAmts = new uint[](supplyTokens.length);
data.supplyTokens = new address[](supplyTokens.length);
data.targetDsa = targetDsa;
for (uint i = 0; i < supplyTokens.length; i++) {
address _token = supplyTokens[i] == ethAddr ? wethAddr : supplyTokens[i];
@ -113,7 +121,7 @@ contract AaveImportResolver is AaveResolver {
_Withdraw(supplyTokens.length, aave, data.supplyTokens, data.supplyAmts);
records[msg.sender] = data;
positions[msg.sender] = data;
bytes memory positionData = abi.encode(msg.sender, data);
stateSender.syncState(polygonReceiver, positionData);