Submitted by berndartmueller
The yVault.getPricePerFullShare() function calculates the price per share by multiplying with 1e18 token decimals with the assumption that the underlying token always has 18 decimals. yVault has the same amount of decimals as its underlying token see (yVault.decimals())
But tokens dont always have 1e18 decimals (e.g. USDC).
The price per share calculation does not return the correct price for underlying tokens that do not have 18 decimals. This could lead to paying out too little or too much and therefore to a loss for either the protocol or the user.
Following test will fail with the current implementation when the underlying vault token has 6 decimals:
NOTE: units() helper function was adapted to accept the desired decimals.
Fails with following error: AssertionError: Expected "2000000000000000000" to be equal 2000000
Use vault decimals() instead of hardcoded 1e18 decimals.
spaghettieth (JPEGd) disputed and commented:
LSDan (judge) decreased severity to Medium and commented:
