A helper library for EtherFi-related conversions.
Returns the amount of ETH required to obtain a given amount of weETH.
Performing the calculations seems to potentially yield a rounding error of 1-2 wei. In order to ensure that the correct value is returned, both versions are tested and the correct one is returned. Should a correct version ever not be found, any contracts using the library should halt execution.
Parameters
weEth
IWeEth
contract.
lrtAmount
uint256
Desired amount of weETH. [WAD]
Returns
<none>
uint256
Amount of ETH required to obtain the given amount of weETH. [WAD]
Returns the amount of weETH that will be obtained from a given amount of ETH.
Parameters
weEth
IWeEth
contract.
ethAmount
uint256
Amount of ETH to deposit. [WAD]
Returns
<none>
uint256
Amount of weETH that will be obtained. [WAD]
An internal helper function to calculate the amount of weETH that will be obtained from a given amount of ETH.
This is useful if the function arguments are already known so that additional external calls can be avoided.
Parameters
totalPooledEther
uint256
Total pooled ether in the Ether Fi pool. [WAD]
totalShares
uint256
Total amount of minted shares. [WAD]
ethAmount
uint256
Amount of ETH to deposit. [WAD]
Returns
<none>
uint256
Amount of weETH that will be obtained. [WAD]
Deposits a given amount of ETH into the Ether Fi pool and then uses the received eETH to mint weETH.
Parameters
weEth
IWeEth
contract.
ethAmount
uint256
Amount of ETH to deposit. [WAD]
Returns
<none>
uint256
Amount of weETH that was obtained. [WAD]
An internal helper function to calculate the amount of shares from amount.
Useful for avoiding external calls when the function arguments are already known.
Parameters
totalPooledEther
uint256
Total pooled ether in the Ether Fi pool. [WAD]
totalShares
uint256
Total amount of minted shares. [WAD]
_depositAmount
uint256
Amount of ETH. [WAD]
An internal helper function to calculate the amount from given amount of shares.
Useful for avoiding external calls when the function arguments are already known.
Parameters
totalPooledEther
uint256
Total pooled ether in the Ether Fi pool. [WAD]
totalShares
uint256
Total amount of minted shares. [WAD]
_shares
uint256
Amount of shares. [WAD]