EtherFiLibrary

Git Source

A helper library for EtherFi-related conversions.

Functions

getEthAmountInForLstAmountOut

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.

function getEthAmountInForLstAmountOut(IWeEth weEth, uint256 lrtAmount) internal view returns (uint256);

Parameters

NameTypeDescription

weEth

IWeEth

contract.

lrtAmount

uint256

Desired amount of weETH. [WAD]

Returns

NameTypeDescription

<none>

uint256

Amount of ETH required to obtain the given amount of weETH. [WAD]

getLstAmountOutForEthAmountIn

Returns the amount of weETH that will be obtained from a given amount of ETH.

function getLstAmountOutForEthAmountIn(IWeEth weEth, uint256 ethAmount) internal view returns (uint256);

Parameters

NameTypeDescription

weEth

IWeEth

contract.

ethAmount

uint256

Amount of ETH to deposit. [WAD]

Returns

NameTypeDescription

<none>

uint256

Amount of weETH that will be obtained. [WAD]

_getLstAmountOutForEthAmountIn

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.

function _getLstAmountOutForEthAmountIn(
    uint256 totalPooledEther,
    uint256 totalShares,
    uint256 ethAmount
)
    internal
    pure
    returns (uint256);

Parameters

NameTypeDescription

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

NameTypeDescription

<none>

uint256

Amount of weETH that will be obtained. [WAD]

depositForLrt

Deposits a given amount of ETH into the Ether Fi pool and then uses the received eETH to mint weETH.

function depositForLrt(IWeEth weEth, uint256 ethAmount) internal returns (uint256);

Parameters

NameTypeDescription

weEth

IWeEth

contract.

ethAmount

uint256

Amount of ETH to deposit. [WAD]

Returns

NameTypeDescription

<none>

uint256

Amount of weETH that was obtained. [WAD]

_sharesForAmount

An internal helper function to calculate the amount of shares from amount.

Useful for avoiding external calls when the function arguments are already known.

function _sharesForAmount(
    uint256 totalPooledEther,
    uint256 totalShares,
    uint256 _depositAmount
)
    internal
    pure
    returns (uint256);

Parameters

NameTypeDescription

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]

_amountForShares

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.

function _amountForShares(
    uint256 totalPooledEther,
    uint256 totalShares,
    uint256 _shares
)
    internal
    pure
    returns (uint256);

Parameters

NameTypeDescription

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]

Errors

NoAmountInFound

error NoAmountInFound();