From 11bfdbf7f41c55e4a92ba0d4c30b37c59a7c1874 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Wed, 21 Apr 2021 07:02:58 +0530 Subject: [PATCH] WETH fix --- contracts/senders/aave-v2-migrator/main.sol | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/contracts/senders/aave-v2-migrator/main.sol b/contracts/senders/aave-v2-migrator/main.sol index f64fcd6..2128123 100644 --- a/contracts/senders/aave-v2-migrator/main.sol +++ b/contracts/senders/aave-v2-migrator/main.sol @@ -89,7 +89,15 @@ contract LiquidityResolver is Helpers, Events { address _token = _tokens[i] == ethAddr ? wethAddr : _tokens[i]; aave.withdraw(_token, _amts[i], address(this)); IERC20(_token).safeApprove(erc20Predicate, _amts[i]); - rootChainManager.depositFor(polygonReceiver, _token, abi.encode(_amts[i])); + + if (_tokens[i] == ethAddr) { + TokenInterface wethContract = TokenInterface(wethAddr); + uint wethBal = wethContract.balanceOf(address(this)); + wethContract.approve(wethAddr, wethBal); + wethContract.withdraw(wethBal); + } + + rootChainManager.depositFor(polygonReceiver, _tokens[i], abi.encode(_amts[i])); isPositionSafe(); }