From 96c222e4c7b3ae4742a7188622f477693c02d46b Mon Sep 17 00:00:00 2001 From: Samyak Jain <34437877+KaymasJain@users.noreply.github.com> Date: Tue, 13 Apr 2021 04:35:47 +0530 Subject: [PATCH] minor fixes --- contracts/senders/aave-v2-migrator/events.sol | 3 +++ contracts/senders/aave-v2-migrator/main.sol | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/contracts/senders/aave-v2-migrator/events.sol b/contracts/senders/aave-v2-migrator/events.sol index 336ec9d..707043f 100644 --- a/contracts/senders/aave-v2-migrator/events.sol +++ b/contracts/senders/aave-v2-migrator/events.sol @@ -23,4 +23,7 @@ contract Events { uint[] variableBorrowAmts, uint[] stableBorrowAmts ); + + event LogAddTokensSupport(address[] _tokens); + } \ No newline at end of file diff --git a/contracts/senders/aave-v2-migrator/main.sol b/contracts/senders/aave-v2-migrator/main.sol index f5eec61..beda5ca 100644 --- a/contracts/senders/aave-v2-migrator/main.sol +++ b/contracts/senders/aave-v2-migrator/main.sol @@ -26,7 +26,7 @@ contract LiquidityResolver is Helpers, Events { isSupportedToken[_tokens[i]] = true; } supportedTokens = _tokens; - // TODO: add event + emit LogAddTokensSupport(_tokens); } function spell(address _target, bytes memory _data) external { @@ -60,12 +60,14 @@ contract LiquidityResolver is Helpers, Events { if (_token == ethAddr) { require(msg.value == amts[i]); _amt = msg.value; - TokenInterface(wethAddr).deposit{value: msg.value}(); + TokenInterface(wethAddr).deposit{value: _amt}(); + TokenInterface(wethAddr).approve(address(aave), _amt); aave.deposit(wethAddr, _amt, address(this), 3288); } else { IERC20 tokenContract = IERC20(_token); _amt = amts[i] == uint(-1) ? tokenContract.balanceOf(msg.sender) : amts[i]; tokenContract.safeTransferFrom(msg.sender, address(this), _amt); + tokenContract.approve(address(aave), _amt); aave.deposit(_token, _amt, address(this), 3288); } @@ -128,6 +130,7 @@ contract LiquidityResolver is Helpers, Events { * @param _amts - array of token amounts to transfer to L2 receiver's contract */ function settle(address[] calldata _tokens, uint[] calldata _amts) external { + // TODO: Should we use dydx flashloan for easier settlement? AaveInterface aave = AaveInterface(aaveProvider.getLendingPool()); for (uint i = 0; i < supportedTokens.length; i++) { address _token = supportedTokens[i];