Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TODOs
OZ
L-01
Incomplete DocstringsEzEthWstEthSpotOracle.sol
andUniswapFlashswapDirectMintHandlerWithDust.sol
N-01
Incremental update in an unchecked blockN-02
Unused errorInvalidAmountIn
removedN-04
Security contract toRenzoLibrary.sol
N-06
TypoShieldify
UniswapOracleLibrary
potential truncation when castingezETH Library Changes
The main problem is that due to multiple truncating divisions, there may be a broad range of
ethAmountIn
that leads to the samemintAmountOut
. There are two goals to the ezETH library with regards to handling this rounding error induced by the Renzo math.mintAmountOut
at the lowest possibleethAmountIn
.Old Method vs. New Method Comparison
getEthAmountInForLstAmountOut
function that this PR modifies, which began by calculating theethAmountIn
withmintAmountOut - 1
, and subsequently incrementing theinflationPercentage
.getEthAmountInForLstAmountOut
function in this PR, which does a simple backcompute, and rounds up the finalethAmountIn
.1. Changes in the dust bound [Old vs. New]
_existingEzETHSupply
bounded between[1e18, 120Me18]
(120Me18 being an absurdly high existing ezETH supply).exchangeRate
bounded between[1e18, 3e18]
.minMintAmount
bounded between[1e9, _existingEzETHSupply]
(Assumes that no one mint amount is greater than the entire supply).old method dust < new method dust
.old method dust > new method dust
old method dust == new method dust
2. Changes in the
ethAmountIn
[Old vs. New]ethAmountIn
while minting at least the minimum amount out.old method ethAmountIn < new method ethAmountIn
old method ethAmountIn > new method ethAmountIn
old method ethAmountIn == new method ethAmountIn
ethAmountIn
.New Method Fuzz
1. Is the new backcompute always optimal for users?
ethAmountIn - 1
was always strictly less than the output ofethAmountIn
, showing that thisethAmountIn
was optimal.2. Is there an exact maximum dust bound?
Conclusion
ethAmountIn
is optimal.The new method simplifies logic and is shown to lower cost for users (with smaller ethAmountIn) and with lower dust (which doesn’t affect ‘cost’ as the dust gets deposited into user vaults, but reduces the non-exact behavior of the contract).