Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
lykhonis committed Feb 22, 2024
2 parents d2928a6 + 5216b98 commit 9175739
Show file tree
Hide file tree
Showing 2 changed files with 185 additions and 188 deletions.
10 changes: 10 additions & 0 deletions src/pool/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ contract Vault is OwnableUnset, ReentrancyGuardUpgradeable, PausableUpgradeable
uint32 private constant _MIN_FEE = 0; // 0%
uint32 private constant _MAX_FEE = 15_000; // 15%
uint256 private constant _MAX_VALIDATORS_SUPPORTED = 1_000_000;
uint256 private constant _MINIMUM_REQUIRED_SHARES = 1e3;

error InvalidAmount(uint256 amount);
error WithdrawalFailed(address account, address beneficiary, uint256 amount);
Expand Down Expand Up @@ -265,6 +266,15 @@ contract Vault is OwnableUnset, ReentrancyGuardUpgradeable, PausableUpgradeable
revert DepositLimitExceeded(newTotalDeposits, depositLimit);
}
uint256 shares = _toShares(amount);
// burn minimum shares of first depositor to prevent share inflation and dust shares attacks.
if (totalShares == 0) {
if (shares < _MINIMUM_REQUIRED_SHARES) {
revert InvalidAmount(amount);
}
_shares[address(0)] = _MINIMUM_REQUIRED_SHARES;
totalShares += _MINIMUM_REQUIRED_SHARES;
shares -= _MINIMUM_REQUIRED_SHARES;
}
_shares[beneficiary] += shares;
totalShares += shares;
totalUnstaked += amount;
Expand Down
Loading

0 comments on commit 9175739

Please sign in to comment.