From 2905c91f87529505caa53c1dcac73b2be7ece307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alp=20G=C3=BCneysel?= Date: Mon, 9 Dec 2024 19:30:11 -0500 Subject: [PATCH] [NES-265] [N5] [Critical] ERC4626 preview function override is incorrect (#114) * use convertToAssets and convertToShares for previewMint and previewWithdraw functions * use convertToAssets and convertToShares functions for previewMint and previewWithdraw --- nest/src/ComponentToken.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nest/src/ComponentToken.sol b/nest/src/ComponentToken.sol index cb89485b..46a8babe 100644 --- a/nest/src/ComponentToken.sol +++ b/nest/src/ComponentToken.sol @@ -76,7 +76,7 @@ abstract contract ComponentToken is bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE"); /// @notice Base that is used to divide all price inputs in order to represent e.g. 1.000001 as 1000001e12 uint256 internal constant _BASE = 1e18; - + // Events /** @@ -527,7 +527,7 @@ abstract contract ComponentToken is if (_getComponentTokenStorage().asyncDeposit) { revert Unimplemented(); } - assets = super.previewDeposit(shares); + assets = convertToAssets(shares); } /** @@ -554,7 +554,7 @@ abstract contract ComponentToken is if (_getComponentTokenStorage().asyncRedeem) { revert Unimplemented(); } - shares = super.previewWithdraw(assets); + shares = convertToShares(assets); } /// @inheritdoc IERC7540