dsa-connectors/contracts/mainnet/connectors/morpho-aave/helpers.sol

38 lines
1018 B
Solidity
Raw Normal View History

2022-10-05 01:49:52 +00:00
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
import "./interface.sol";
import "../../common/stores.sol";
import "../../common/basic.sol";
import "../../common/interfaces.sol";
abstract contract Helpers is Stores, Basic {
2022-10-15 04:17:36 +00:00
IMorphoCore public constant MORPHO_AAVE =
2022-10-05 01:49:52 +00:00
IMorphoCore(0x777777c9898D384F785Ee44Acfe945efDFf5f3E0);
2022-10-15 04:17:36 +00:00
IMorphoAaveLens public constant MORPHO_AAVE_LENS =
2022-10-12 02:27:45 +00:00
IMorphoAaveLens(0x507fA343d0A90786d86C7cd885f5C49263A91FF4);
2022-10-15 04:17:36 +00:00
function _performEthToWethConversion(
address _tokenAddress,
uint256 _amount,
uint256 _getId
) internal returns (TokenInterface _tokenContract, uint256 _amt) {
_amt = getUint(_getId, _amount);
bool _isETH = _tokenAddress == ethAddr;
_tokenContract = _isETH
? TokenInterface(wethAddr)
: TokenInterface(_tokenAddress);
if (_amt == uint256(-1)) {
_amt = _isETH
? address(this).balance
: _tokenContract.balanceOf(address(this));
}
if (_isETH) convertEthToWeth(_isETH, _tokenContract, _amt);
}
2022-10-05 01:49:52 +00:00
}