@@ -6,6 +6,7 @@ import {ERC1363Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC2
66import {IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol " ;
77import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol " ;
88import {ERC4626 , IERC4626 } from "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol " ;
9+ import {IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol " ;
910import {IERC20Permit } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol " ;
1011import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol " ;
1112import {Math} from "@openzeppelin/contracts/utils/math/Math.sol " ;
@@ -38,6 +39,7 @@ contract OperatorStaking is ERC1363Upgradeable, ReentrancyGuardTransient, UUPSUp
3839 IERC20 _asset;
3940 address _rewarder;
4041 uint256 _totalSharesInRedemption;
42+ uint8 _underlyingDecimals;
4143 mapping (address controller = > uint256 sharesReleased ) _sharesReleased;
4244 mapping (address controller = > Checkpoints.Trace208 redeemRequests ) _redeemRequests;
4345 mapping (address controller = > mapping (address operator = > bool approved )) _operator;
@@ -130,6 +132,10 @@ contract OperatorStaking is ERC1363Upgradeable, ReentrancyGuardTransient, UUPSUp
130132 $._asset = IERC20 (protocolStaking_.stakingToken ());
131133 $._protocolStaking = protocolStaking_;
132134
135+ // Follow ERC4626 pattern but no need to use `_tryGetAssetDecimals` as the implementation
136+ // used to deploy the asset does expose the `decimals` function.
137+ $._underlyingDecimals = IERC20Metadata (asset ()).decimals ();
138+
133139 IERC20 (asset ()).approve (address (protocolStaking_), type (uint256 ).max);
134140
135141 OperatorRewarder rewarder_ = new OperatorRewarder (
@@ -428,6 +434,16 @@ contract OperatorStaking is ERC1363Upgradeable, ReentrancyGuardTransient, UUPSUp
428434 return _getOperatorStakingStorage ()._operator[controller][operator];
429435 }
430436
437+ /**
438+ * @notice Returns the decimals of the shares following the ERC4626 pattern.
439+ * @dev The decimals of the shares is the sum of the decimals of the underlying asset and the
440+ * decimal offset.
441+ * @return The decimals of the shares following the ERC4626 pattern.
442+ */
443+ function decimals () public view virtual override returns (uint8 ) {
444+ return _getOperatorStakingStorage ()._underlyingDecimals + _decimalsOffset ();
445+ }
446+
431447 function _doTransferOut (address to , uint256 amount ) internal virtual {
432448 IERC20 asset_ = IERC20 (asset ());
433449 if (amount > asset_.balanceOf (address (this ))) {
0 commit comments