Added depositEtherFor func

This commit is contained in:
Thrilok Kumar 2021-04-21 10:04:40 +05:30
parent 2ac09aea58
commit 87f884ce48
2 changed files with 5 additions and 2 deletions

View File

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

View File

@ -88,16 +88,18 @@ contract LiquidityResolver is Helpers, Events {
for (uint i = 0; i < _tokens.length; i++) { for (uint i = 0; i < _tokens.length; i++) {
address _token = _tokens[i] == ethAddr ? wethAddr : _tokens[i]; address _token = _tokens[i] == ethAddr ? wethAddr : _tokens[i];
aave.withdraw(_token, _amts[i], address(this)); aave.withdraw(_token, _amts[i], address(this));
IERC20(_token).safeApprove(erc20Predicate, _amts[i]);
if (_tokens[i] == ethAddr) { if (_tokens[i] == ethAddr) {
TokenInterface wethContract = TokenInterface(wethAddr); TokenInterface wethContract = TokenInterface(wethAddr);
uint wethBal = wethContract.balanceOf(address(this)); uint wethBal = wethContract.balanceOf(address(this));
wethContract.approve(wethAddr, wethBal); wethContract.approve(wethAddr, wethBal);
wethContract.withdraw(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]));
} }
rootChainManager.depositFor(polygonReceiver, _tokens[i], abi.encode(_amts[i]));
isPositionSafe(); isPositionSafe();
} }