Merge pull request #10 from Instadapp/weth-fix

Weth fix
This commit is contained in:
Samyak Jain 2021-04-22 00:16:00 +05:30 committed by GitHub
commit 6dd516d40b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 6 deletions

View File

@ -56,6 +56,7 @@ contract MigrateResolver is Helpers, Events {
TokenInterface(wmaticAddr).deposit{value: address(this).balance}();
}
}
IERC20 _tokenContract = IERC20(_token);
uint _tokenBal = _tokenContract.balanceOf(address(this));
if (_tokenBal > 0) {
@ -108,7 +109,7 @@ contract AaveV2Migrator is MigrateResolver {
isPositionSafe();
emit LogAaveV2Migrate(dsa, supplyTokens, borrowTokens, supplyAmts, supplyAmts);
emit LogAaveV2Migrate(dsa, supplyTokens, borrowTokens, supplyAmts, borrowAmts);
}
function onStateReceive(uint256 stateId, bytes calldata receivedData) external {

View File

@ -36,7 +36,6 @@ contract Variables {
*/
InstaListInterface public constant instaList = InstaListInterface(0x839c2D3aDe63DF5b0b8F3E57D5e145057Ab41556);
/**
* @dev Matic StateReceiver contract
*/
@ -67,4 +66,4 @@ contract Variables {
* @dev last stateId from the onStateReceive
*/
uint256 internal lastStateId;
}
}

View File

@ -106,4 +106,5 @@ interface ChainLinkInterface {
interface RootChainManagerInterface {
function depositFor(address user, address token, bytes calldata depositData) external;
function depositEtherFor(address user) external payable;
}

View File

@ -88,8 +88,18 @@ contract LiquidityResolver is Helpers, Events {
for (uint i = 0; i < _tokens.length; i++) {
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 (_token == wethAddr) {
TokenInterface wethContract = TokenInterface(wethAddr);
uint wethBal = wethContract.balanceOf(address(this));
wethContract.approve(wethAddr, wethBal);
wethContract.withdraw(wethBal);
rootChainManager.depositEtherFor{value: _amts[i]}(polygonReceiver);
} else {
IERC20(_token).safeApprove(erc20Predicate, _amts[i]);
rootChainManager.depositFor(polygonReceiver, _tokens[i], abi.encode(_amts[i]));
}
isPositionSafe();
}
@ -191,4 +201,4 @@ contract InstaAaveV2MigratorSenderImplementation is MigrateResolver {
flashloanContract.initiateFlashLoan(data, ethAmt);
}
}
}