Skip to content

Commit 98147be

Browse files
committed
feat: prevent minting against node operator fee
1 parent 46a9102 commit 98147be

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

contracts/0.8.25/vaults/Dashboard.sol

+3-3
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ contract Dashboard is Permissions {
166166
}
167167

168168
/**
169-
* @notice Returns the overall capacity of stETH shares that can be minted by the vault bound by valuation and vault share limit.
169+
* @notice Returns the overall capacity of stETH shares that can be minted by the vault bound by valuation, unmintable valuation and vault share limit.
170170
* @return The maximum number of mintable stETH shares not counting already minted ones.
171171
*/
172172
function totalMintableShares() public view returns (uint256) {
173-
return _totalMintableShares(stakingVault().valuation());
173+
return _totalMintableShares(stakingVault().valuation() - _unmintableValuation());
174174
}
175175

176176
/**
@@ -179,7 +179,7 @@ contract Dashboard is Permissions {
179179
* @return the maximum number of shares that can be minted by ether
180180
*/
181181
function projectedNewMintableShares(uint256 _etherToFund) external view returns (uint256) {
182-
uint256 _totalShares = _totalMintableShares(stakingVault().valuation() + _etherToFund);
182+
uint256 _totalShares = _totalMintableShares(stakingVault().valuation() + _etherToFund - _unmintableValuation());
183183
uint256 _sharesMinted = vaultSocket().sharesMinted;
184184

185185
if (_totalShares < _sharesMinted) return 0;

contracts/0.8.25/vaults/Delegation.sol

+4
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ contract Delegation is Dashboard {
217217
super._withdraw(_recipient, _ether);
218218
}
219219

220+
function _unmintableValuation() internal view override returns (uint256) {
221+
return nodeOperatorUnclaimedFee();
222+
}
223+
220224
/**
221225
* @dev Emitted when the node operator fee is set.
222226
* @param oldNodeOperatorFeeBP The old node operator fee.

contracts/0.8.25/vaults/Permissions.sol

+19
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ abstract contract Permissions is AccessControlConfirmable {
199199
*/
200200
function _mintShares(address _recipient, uint256 _shares) internal onlyRole(MINT_ROLE) {
201201
vaultHub.mintShares(address(stakingVault()), _recipient, _shares);
202+
_ensureUnmintableValuation();
202203
}
203204

204205
/**
@@ -286,6 +287,19 @@ abstract contract Permissions is AccessControlConfirmable {
286287
}
287288
}
288289

290+
function _unmintableValuation() internal view virtual returns (uint256) {
291+
return 0;
292+
}
293+
294+
function _ensureUnmintableValuation() internal view {
295+
uint256 locked = stakingVault().locked();
296+
uint256 valuation = stakingVault().valuation();
297+
298+
if (locked > valuation - _unmintableValuation()) {
299+
revert UnmintableValuationBreached(locked, valuation, _unmintableValuation());
300+
}
301+
}
302+
289303
/**
290304
* @notice Emitted when the contract is initialized
291305
*/
@@ -306,4 +320,9 @@ abstract contract Permissions is AccessControlConfirmable {
306320
* @param argument Name of the argument
307321
*/
308322
error ZeroArgument(string argument);
323+
324+
/**
325+
* @notice Error when unmintable valuation is breached
326+
*/
327+
error UnmintableValuationBreached(uint256 locked, uint256 valuation, uint256 unmintableValuation);
309328
}

0 commit comments

Comments
 (0)