WETH fix on receiver

This commit is contained in:
Thrilok Kumar 2021-04-21 07:04:11 +05:30
parent 11bfdbf7f4
commit 2ac09aea58
3 changed files with 27 additions and 4 deletions

View File

@ -100,4 +100,9 @@ interface AaveInterface {
interface InstaListInterface { interface InstaListInterface {
function accountID(address) external view returns (uint); function accountID(address) external view returns (uint);
} }
interface WETHTokenInterface {
function deposit(address user, bytes memory depositData) external payable;
}

View File

@ -4,7 +4,7 @@ pragma experimental ABIEncoderV2;
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { TokenInterface } from "../../common/interfaces.sol"; import { TokenInterface } from "../../common/interfaces.sol";
import { AccountInterface, AaveData, AaveInterface, IndexInterface } from "./interfaces.sol"; import { AccountInterface, AaveData, AaveInterface, IndexInterface, WETHTokenInterface } from "./interfaces.sol";
import { Events } from "./events.sol"; import { Events } from "./events.sol";
import { Helpers } from "./helpers.sol"; import { Helpers } from "./helpers.sol";
@ -56,6 +56,14 @@ contract MigrateResolver is Helpers, Events {
TokenInterface(wmaticAddr).deposit{value: address(this).balance}(); TokenInterface(wmaticAddr).deposit{value: address(this).balance}();
} }
} }
if (_token == wethAddr) {
TokenInterface wethPosContract = TokenInterface(wethPosAddr);
if (wethPosContract.balanceOf(address(this)) > 0) {
WETHTokenInterface(wethAddr).deposit(address(this), abi.encode(wethPosContract.balanceOf(address(this))));
}
}
IERC20 _tokenContract = IERC20(_token); IERC20 _tokenContract = IERC20(_token);
uint _tokenBal = _tokenContract.balanceOf(address(this)); uint _tokenBal = _tokenContract.balanceOf(address(this));
if (_tokenBal > 0) { if (_tokenBal > 0) {
@ -108,7 +116,7 @@ contract AaveV2Migrator is MigrateResolver {
isPositionSafe(); isPositionSafe();
emit LogAaveV2Migrate(dsa, supplyTokens, borrowTokens, supplyAmts, supplyAmts); emit LogAaveV2Migrate(dsa, supplyTokens, borrowTokens, supplyAmts, borrowAmts);
} }
function onStateReceive(uint256 stateId, bytes calldata receivedData) external { function onStateReceive(uint256 stateId, bytes calldata receivedData) external {

View File

@ -36,12 +36,22 @@ contract Variables {
*/ */
InstaListInterface public constant instaList = InstaListInterface(0x839c2D3aDe63DF5b0b8F3E57D5e145057Ab41556); InstaListInterface public constant instaList = InstaListInterface(0x839c2D3aDe63DF5b0b8F3E57D5e145057Ab41556);
/** /**
* @dev Matic StateReceiver contract * @dev Matic StateReceiver contract
*/ */
address public constant maticReceiver = 0x0000000000000000000000000000000000001001; address public constant maticReceiver = 0x0000000000000000000000000000000000001001;
/**
* @dev WETH POS address
*/
address public constant wethPosAddr = 0xAe740d42E4ff0C5086b2b5b5d149eB2F9e1A754F;
/**
* @dev WETH address
*/
address public constant wethAddr = 0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619;
// Storage variables // // Storage variables //