Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enforce a min value for initial deposit #64

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/ynLSD.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ contract ynLSD is IynLSD, ynBase, ReentrancyGuardUpgradeable, IynLSDEvents {
error NoBeaconImplementationExists();
error TooManyStakingNodes(uint256 maxNodeCount);
error NotLSDStakingNode(address sender, uint256 nodeId);
error InsufficientBoostrapAmount(address asset, uint256 amount, uint256 valueInETH);

//--------------------------------------------------------------------------------------
//---------------------------------- ROLES -------------------------------------------
Expand Down Expand Up @@ -104,7 +105,7 @@ contract ynLSD is IynLSD, ynBase, ReentrancyGuardUpgradeable, IynLSDEvents {
address depositBootstrapper;
}

function initialize(Init memory init)
function initialize(Init calldata init)
public
notZeroAddress(address(init.strategyManager))
notZeroAddress(address(init.oracle))
Expand Down Expand Up @@ -139,7 +140,19 @@ contract ynLSD is IynLSD, ynBase, ReentrancyGuardUpgradeable, IynLSDEvents {
_setTransfersPaused(true); // transfers are initially paused
_updatePauseWhitelist(init.pauseWhitelist, true);

_deposit(assets[0], BOOTSTRAP_AMOUNT_UNITS * (10 ** (IERC20Metadata(address(assets[0])).decimals())), init.depositBootstrapper, init.depositBootstrapper);
initializeBoostrapDeposit(init);
}

function initializeBoostrapDeposit(Init calldata init) internal {
// deposit boostrap amount to avoid share inflation attacks
uint256 bootstrapAmount = BOOTSTRAP_AMOUNT_UNITS * (10 ** (IERC20Metadata(address(assets[0])).decimals()));
uint256 bootstrapAmountInETH = convertToETH(assets[0], bootstrapAmount);

if (bootstrapAmountInETH < 1 ether) {
revert InsufficientBoostrapAmount(address(assets[0]), bootstrapAmount, bootstrapAmountInETH);
}

_deposit(assets[0], bootstrapAmount, init.depositBootstrapper, init.depositBootstrapper);
}

//--------------------------------------------------------------------------------------
Expand Down
Loading