@@ -308,320 +308,6 @@ contract StrategyManagerUnitTests_depositIntoStrategy is StrategyManagerUnitTest
308
308
testFuzz_depositIntoStrategySuccessfully (staker, amount);
309
309
}
310
310
311
- // TODO: test depositing into multiple strategies
312
- // function testFuzz_depositIntoStrategy_MultipleStrategies()
313
- // /// @notice deploys 'numStratsToAdd' strategies using '_testAddStrategy' and then deposits '1e18' to each of them from 'getOperatorAddress(0)'
314
- // /// @param numStratsToAdd is the number of strategies being added and deposited into
315
- // function testDepositStrategies(uint8 numStratsToAdd) public {
316
- // _testDepositStrategies(getOperatorAddress(0), 1e18, numStratsToAdd);
317
- // }
318
-
319
- // TODO: fix old stETH fork test
320
- // /// @notice Shadow-forks mainnet and tests depositing stETH tokens into a "StrategyBase" contract.
321
- // function testForkMainnetDepositSteth() public {
322
- // // hard-coded inputs
323
- // // address sender = address(this);
324
- // uint64 amountToDeposit = 1e12;
325
-
326
- // // shadow-fork mainnet
327
- // try cheats.createFork("mainnet") returns (uint256 forkId) {
328
- // cheats.selectFork(forkId);
329
- // // If RPC_MAINNET ENV not set, default to this mainnet RPC endpoint
330
- // } catch {
331
- // cheats.createSelectFork("https://eth.llamarpc.com");
332
- // }
333
-
334
- // // cast mainnet stETH address to IERC20 interface
335
- // // IERC20 steth = IERC20(0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84);
336
- // IERC20 underlyingToken = IERC20(0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84);
337
-
338
- // // deploy necessary contracts on the shadow-forked network
339
- // // deploy proxy admin for ability to upgrade proxy contracts
340
- // eigenLayerProxyAdmin = new ProxyAdmin();
341
- // //deploy pauser registry
342
- // address[] memory pausers = new address[](1);
343
- // pausers[0] = pauser;
344
- // eigenLayerPauserReg = new PauserRegistry(pausers, unpauser);
345
- // /**
346
- // * First, deploy upgradeable proxy contracts that **will point** to the implementations. Since the implementation contracts are
347
- // * not yet deployed, we give these proxies an empty contract as the initial implementation, to act as if they have no code.
348
- // */
349
- // emptyContract = new EmptyContract();
350
- // delegation = DelegationManager(
351
- // address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
352
- // );
353
- // strategyManager = StrategyManager(
354
- // address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
355
- // );
356
- // eigenPodManager = EigenPodManager(
357
- // address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
358
- // );
359
-
360
- // ethPOSDeposit = new ETHPOSDepositMock();
361
- // pod = new EigenPod(ethPOSDeposit, eigenPodManager, GOERLI_GENESIS_TIME);
362
-
363
- // eigenPodBeacon = new UpgradeableBeacon(address(pod));
364
- // // Second, deploy the *implementation* contracts, using the *proxy contracts* as inputs
365
- // DelegationManager delegationImplementation = new DelegationManager(avsDirectory, strategyManager, eigenPodManager, allocationManager, MIN_WITHDRAWAL_DELAY);
366
- // StrategyManager strategyManagerImplementation = new StrategyManager(delegation);
367
- // EigenPodManager eigenPodManagerImplementation = new EigenPodManager(ethPOSDeposit, eigenPodBeacon, strategyManager, delegation);
368
- // // Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
369
- // eigenLayerProxyAdmin.upgradeAndCall(
370
- // ITransparentUpgradeableProxy(payable(address(delegation))),
371
- // address(delegationImplementation),
372
- // abi.encodeWithSelector(
373
- // DelegationManager.initialize.selector,
374
- // eigenLayerReputedMultisig,
375
- // eigenLayerPauserReg,
376
- // 0 /*initialPausedStatus*/,
377
- // minWithdrawalDelayBlocks,
378
- // initializeStrategiesToSetDelayBlocks,
379
- // initializeWithdrawalDelayBlocks
380
- // )
381
- // );
382
- // eigenLayerProxyAdmin.upgradeAndCall(
383
- // ITransparentUpgradeableProxy(payable(address(strategyManager))),
384
- // address(strategyManagerImplementation),
385
- // abi.encodeWithSelector(
386
- // StrategyManager.initialize.selector,
387
- // eigenLayerReputedMultisig,
388
- // eigenLayerReputedMultisig,
389
- // eigenLayerPauserReg,
390
- // 0/*initialPausedStatus*/
391
- // )
392
- // );
393
- // eigenLayerProxyAdmin.upgradeAndCall(
394
- // ITransparentUpgradeableProxy(payable(address(eigenPodManager))),
395
- // address(eigenPodManagerImplementation),
396
- // abi.encodeWithSelector(
397
- // EigenPodManager.initialize.selector,
398
- // eigenLayerReputedMultisig,
399
- // eigenLayerPauserReg,
400
- // 0/*initialPausedStatus*/
401
- // )
402
- // );
403
-
404
- // // cheat a bunch of ETH to this address
405
- // cheats.deal(address(this), 1e20);
406
- // // deposit a huge amount of ETH to get ample stETH
407
- // {
408
- // (bool success, bytes memory returnData) = address(underlyingToken).call{value: 1e20}("");
409
- // require(success, "depositing stETH failed");
410
- // returnData;
411
- // }
412
-
413
- // // deploy StrategyBase contract implementation, then create upgradeable proxy that points to implementation and initialize it
414
- // baseStrategyImplementation = new StrategyBase(strategyManager);
415
- // IStrategy stethStrategy = StrategyBase(
416
- // address(
417
- // new TransparentUpgradeableProxy(
418
- // address(baseStrategyImplementation),
419
- // address(eigenLayerProxyAdmin),
420
- // abi.encodeWithSelector(StrategyBase.initialize.selector, underlyingToken, eigenLayerPauserReg)
421
- // )
422
- // )
423
- // );
424
-
425
- // // REMAINDER OF CODE ADAPTED FROM `_testDepositToStrategy`
426
- // // _testDepositToStrategy(sender, amountToDeposit, underlyingToken, stethStrategy);
427
-
428
- // // whitelist the strategy for deposit, in case it wasn't before
429
- // {
430
- // cheats.startPrank(strategyManager.strategyWhitelister());
431
- // IStrategy[] memory _strategy = new IStrategy[](1);
432
- // _strategy[0] = stethStrategy;
433
- // strategyManager.addStrategiesToDepositWhitelist(_strategy);
434
- // cheats.stopPrank();
435
- // }
436
-
437
- // uint256 operatorSharesBefore = strategyManager.stakerDepositShares(address(this), stethStrategy);
438
- // // check the expected output
439
- // uint256 expectedSharesOut = stethStrategy.underlyingToShares(amountToDeposit);
440
-
441
- // underlyingToken.transfer(address(this), amountToDeposit);
442
- // cheats.startPrank(address(this));
443
- // underlyingToken.approve(address(strategyManager), type(uint256).max);
444
- // strategyManager.depositIntoStrategy(stethStrategy, underlyingToken, amountToDeposit);
445
-
446
- // //check if depositor has never used this strat, that it is added correctly to stakerStrategyList array.
447
- // if (operatorSharesBefore == 0) {
448
- // // check that strategy is appropriately added to dynamic array of all of sender's strategies
449
- // assertTrue(
450
- // strategyManager.stakerStrategyList(address(this), strategyManager.stakerStrategyListLength(address(this)) - 1)
451
- // == stethStrategy,
452
- // "_testDepositToStrategy: stakerStrategyList array updated incorrectly"
453
- // );
454
- // }
455
- // // check that the shares out match the expected amount out
456
- // // the actual transfer in will be lower by 1-2 wei than expected due to stETH's internal rounding
457
- // // to account for this we check approximate rather than strict equivalence here
458
- // {
459
- // uint256 actualSharesOut = strategyManager.stakerDepositShares(address(this), stethStrategy) - operatorSharesBefore;
460
- // require(actualSharesOut >= expectedSharesOut, "too few shares");
461
- // require((actualSharesOut * 1000) / expectedSharesOut < 1003, "too many shares");
462
-
463
- // // additional sanity check for deposit not increasing in value
464
- // require(stethStrategy.sharesToUnderlying(actualSharesOut) <= amountToDeposit, "value cannot have increased");
465
- // // slippage check
466
- // require((stethStrategy.sharesToUnderlying(actualSharesOut) * 1e6) / amountToDeposit >= (1e6 - 1), "bad slippage on first deposit");
467
- // }
468
- // cheats.stopPrank();
469
- // }
470
-
471
- // TODO: fix old frontrun depositor test
472
- // function testFrontrunFirstDepositor(/*uint256 depositAmount*/) public {
473
-
474
- // //setup addresses
475
- // address attacker = address(100);
476
- // address user = address(200);
477
-
478
- // //give 2 ether to attacker and user
479
- // weth.transfer(attacker,2 ether);
480
- // weth.transfer(user,2 ether);
481
-
482
- // //attacker FRONTRUN: deposit 1 wei (receive 1 share)
483
- // StrategyManager _strategyManager = _whitelistStrategy(strategyManager, wethStrat);
484
-
485
- // cheats.startPrank(attacker);
486
- // weth.approve(address(strategyManager), type(uint256).max);
487
- // _strategyManager.depositIntoStrategy(wethStrat, weth, 1 wei);
488
- // cheats.stopPrank();
489
-
490
- // //attacker FRONTRUN: transfer 1 ether into strategy directly to manipulate the value of shares
491
- // cheats.prank(attacker);
492
- // weth.transfer(address(wethStrat),1 ether);
493
-
494
- // //user deposits 2 eth into strategy - only gets 1 share due to rounding
495
- // cheats.startPrank(user);
496
- // weth.approve(address(_strategyManager), type(uint256).max);
497
- // _strategyManager.depositIntoStrategy(wethStrat, weth, 2 ether);
498
- // cheats.stopPrank();
499
-
500
- // //attacker deposited 1 ether and 1 wei - received 1 share
501
- // //user deposited 2 ether - received X shares
502
- // //user has lost 0.5 ether?
503
- // (, uint256[] memory shares) = _strategyManager.getDeposits(attacker);
504
- // uint256 attackerValueWeth = wethStrat.sharesToUnderlyingView(shares[0]);
505
- // require(attackerValueWeth >= (1), "attacker got zero shares");
506
-
507
- // (, shares) = _strategyManager.getDeposits(user);
508
- // uint256 userValueWeth = wethStrat.sharesToUnderlyingView(shares[0]);
509
- // require(userValueWeth >= (1900000000000000000), "user has lost more than 0.1 eth from frontrunning");
510
-
511
- // uint256 attackerLossesWeth = (2 ether + 1 wei) - attackerValueWeth;
512
- // uint256 userLossesWeth = 2 ether - userValueWeth;
513
- // require(attackerLossesWeth > userLossesWeth, "griefing attack deals more damage than cost");
514
- // }
515
-
516
- // TODO: fix old testFrontrunFirstDepositorFuzzed
517
- // function testFrontrunFirstDepositorFuzzed(uint96 firstDepositAmount, uint96 donationAmount, uint96 secondDepositAmount) public {
518
- // // want to only use nonzero amounts or else we'll get reverts
519
- // cheats.assume(firstDepositAmount != 0 && secondDepositAmount != 0);
520
-
521
- // // setup addresses
522
- // address attacker = address(100);
523
- // address user = address(200);
524
-
525
- // // attacker makes first deposit
526
- // _testDepositToStrategy(attacker, firstDepositAmount, weth, wethStrat);
527
-
528
- // // transfer tokens into strategy directly to manipulate the value of shares
529
- // weth.transfer(address(wethStrat), donationAmount);
530
-
531
- // // filter out calls that would revert for minting zero shares
532
- // cheats.assume(wethStrat.underlyingToShares(secondDepositAmount) != 0);
533
-
534
- // // user makes 2nd deposit into strategy - gets diminished shares due to rounding
535
- // _testDepositToStrategy(user, secondDepositAmount, weth, wethStrat);
536
-
537
- // // check for griefing
538
- // (, uint256[] memory shares) = strategyManager.getDeposits(attacker);
539
- // uint256 attackerValueWeth = wethStrat.sharesToUnderlyingView(shares[0]);
540
- // (, shares) = strategyManager.getDeposits(user);
541
- // uint256 userValueWeth = wethStrat.sharesToUnderlyingView(shares[0]);
542
-
543
- // uint256 attackerCost = uint256(firstDepositAmount) + uint256(donationAmount);
544
- // require(attackerCost >= attackerValueWeth, "attacker gained value?");
545
- // // uint256 attackerLossesWeth = attackerValueWeth > attackerCost ? 0 : (attackerCost - attackerValueWeth);
546
- // uint256 attackerLossesWeth = attackerCost - attackerValueWeth;
547
- // uint256 userLossesWeth = secondDepositAmount - userValueWeth;
548
-
549
- // emit log_named_uint("attackerLossesWeth", attackerLossesWeth);
550
- // emit log_named_uint("userLossesWeth", userLossesWeth);
551
-
552
- // // use '+1' here to account for rounding. given the attack will cost ETH in the form of gas, this is fine.
553
- // require(attackerLossesWeth + 1 >= userLossesWeth, "griefing attack deals more damage than cost");
554
- // }
555
-
556
- // TODO: testDepositTokenWithOneWeiFeeOnTransfer
557
- // function testDepositTokenWithOneWeiFeeOnTransfer(address sender, uint64 amountToDeposit) public fuzzedAddress(sender) {
558
- // cheats.assume(amountToDeposit != 0);
559
-
560
- // IERC20 underlyingToken;
561
-
562
- // {
563
- // uint256 initSupply = 1e50;
564
- // address initOwner = address(this);
565
- // ERC20_OneWeiFeeOnTransfer oneWeiFeeOnTransferToken = new ERC20_OneWeiFeeOnTransfer(initSupply, initOwner);
566
- // underlyingToken = IERC20(address(oneWeiFeeOnTransferToken));
567
- // }
568
-
569
- // // need to transfer extra here because otherwise the `sender` won't have enough tokens
570
- // underlyingToken.transfer(sender, 1000);
571
-
572
- // IStrategy oneWeiFeeOnTransferTokenStrategy = StrategyBase(
573
- // address(
574
- // new TransparentUpgradeableProxy(
575
- // address(baseStrategyImplementation),
576
- // address(eigenLayerProxyAdmin),
577
- // abi.encodeWithSelector(StrategyBase.initialize.selector, underlyingToken, eigenLayerPauserReg)
578
- // )
579
- // )
580
- // );
581
-
582
- // // REMAINDER OF CODE ADAPTED FROM `_testDepositToStrategy`
583
- // // _testDepositToStrategy(sender, amountToDeposit, underlyingToken, oneWeiFeeOnTransferTokenStrategy);
584
-
585
- // // whitelist the strategy for deposit, in case it wasn't before
586
- // {
587
- // cheats.startPrank(strategyManager.strategyWhitelister());
588
- // IStrategy[] memory _strategy = new IStrategy[](1);
589
- // _strategy[0] = oneWeiFeeOnTransferTokenStrategy;
590
- // strategyManager.addStrategiesToDepositWhitelist(_strategy);
591
- // cheats.stopPrank();
592
- // }
593
- // uint256 operatorSharesBefore = strategyManager.stakerDepositShares(sender, oneWeiFeeOnTransferTokenStrategy);
594
- // // check the expected output
595
- // uint256 expectedSharesOut = oneWeiFeeOnTransferTokenStrategy.underlyingToShares(amountToDeposit);
596
-
597
- // underlyingToken.transfer(sender, amountToDeposit);
598
- // cheats.startPrank(sender);
599
- // underlyingToken.approve(address(strategyManager), type(uint256).max);
600
- // strategyManager.depositIntoStrategy(oneWeiFeeOnTransferTokenStrategy, underlyingToken, amountToDeposit);
601
-
602
- // //check if depositor has never used this strat, that it is added correctly to stakerStrategyList array.
603
- // if (operatorSharesBefore == 0) {
604
- // // check that strategy is appropriately added to dynamic array of all of sender's strategies
605
- // assertTrue(
606
- // strategyManager.stakerStrategyList(sender, strategyManager.stakerStrategyListLength(sender) - 1)
607
- // == oneWeiFeeOnTransferTokenStrategy,
608
- // "_testDepositToStrategy: stakerStrategyList array updated incorrectly"
609
- // );
610
- // }
611
- // // check that the shares out match the expected amount out
612
- // // the actual transfer in will be lower by 1 wei than expected due to stETH's internal rounding
613
- // // to account for this we check approximate rather than strict equivalence here
614
- // {
615
- // uint256 actualSharesOut = strategyManager.stakerDepositShares(sender, oneWeiFeeOnTransferTokenStrategy) - operatorSharesBefore;
616
- // require((actualSharesOut * 1000) / expectedSharesOut > 998, "too few shares");
617
- // require((actualSharesOut * 1000) / expectedSharesOut < 1002, "too many shares");
618
-
619
- // // additional sanity check for deposit not increasing in value
620
- // require(oneWeiFeeOnTransferTokenStrategy.sharesToUnderlying(actualSharesOut) <= amountToDeposit, "value cannot have increased");
621
- // }
622
- // cheats.stopPrank();
623
- // }
624
-
625
311
function test_Revert_WhenDepositsPaused () public {
626
312
uint amount = 1e18 ;
627
313
0 commit comments