From 07b44ce236f18593dce76756bff8c09f74d26362 Mon Sep 17 00:00:00 2001 From: Shriya Tyagi Date: Wed, 17 Jan 2024 16:05:23 +0400 Subject: [PATCH] feat: update logic --- .../mainnet/connectors/basic-ERC4626/main.sol | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/contracts/mainnet/connectors/basic-ERC4626/main.sol b/contracts/mainnet/connectors/basic-ERC4626/main.sol index d39fe9e7..de9d2fc9 100644 --- a/contracts/mainnet/connectors/basic-ERC4626/main.sol +++ b/contracts/mainnet/connectors/basic-ERC4626/main.sol @@ -37,15 +37,15 @@ abstract contract BasicConnector is Events, DSMath, Basic { vaultTokenContract.asset() ); - if (_underlyingAmt == uint256(-1)) { - if (address(_underlyingTokenContract) == wethAddr) { - TokenInterface(wethAddr).deposit{value: address(this).balance}(); - } - _underlyingAmt = _underlyingTokenContract.balanceOf(address(this)); + bool _isEth = vaultToken == ethAddr; + + if (_isEth) { + _underlyingAmt = _underlyingAmt == uint256(-1) ? address(this).balance : _underlyingTokenContract.balanceOf(address(this)); + convertEthToWeth(_isEth, TokenInterface(wethAddr), _underlyingAmt); } else { - if (address(_underlyingTokenContract) == wethAddr) { - TokenInterface(wethAddr).deposit{value: _underlyingAmt}(); - } + _underlyingAmt = _underlyingAmt == uint256(-1) + ? _underlyingTokenContract.balanceOf(address(this)) + : _underlyingAmt; } // Returns final amount in token decimals.