@@ -373,11 +373,16 @@ contract SuperformRouterPlus is ISuperformRouterPlus, BaseSuperformRouterPlus {
373
373
revert Error.ZERO_INPUT_VALUE ();
374
374
}
375
375
376
+ uint256 valueToPass = msg .value / length;
377
+
376
378
for (uint256 i; i < length; ++ i) {
377
379
if (! whitelistedSelectors[Actions.DEPOSIT][_parseSelectorMem (args[i].depositCallData)]) {
378
380
revert INVALID_DEPOSIT_SELECTOR ();
379
381
}
380
- _deposit4626 (vaults_[i], args[i], length);
382
+ if (i == length - 1 ) {
383
+ valueToPass += msg .value % length;
384
+ }
385
+ _deposit4626 (vaults_[i], args[i], length, valueToPass);
381
386
}
382
387
}
383
388
@@ -628,7 +633,15 @@ contract SuperformRouterPlus is ISuperformRouterPlus, BaseSuperformRouterPlus {
628
633
/// @param vault_ The ERC4626 vault to redeem from
629
634
/// @param args Rest of the arguments to deposit 4626
630
635
/// @param arrayLength The length of the array of deposit4626 calls
631
- function _deposit4626 (address vault_ , Deposit4626Args calldata args , uint256 arrayLength ) internal {
636
+ /// @param valueToPass The value to pass to the deposit function
637
+ function _deposit4626 (
638
+ address vault_ ,
639
+ Deposit4626Args calldata args ,
640
+ uint256 arrayLength ,
641
+ uint256 valueToPass
642
+ )
643
+ internal
644
+ {
632
645
_transferERC20In (IERC20 (vault_), args.receiverAddressSP, args.amount);
633
646
IERC4626 vault = IERC4626 (vault_);
634
647
address assetAdr = vault.asset ();
@@ -641,14 +654,8 @@ contract SuperformRouterPlus is ISuperformRouterPlus, BaseSuperformRouterPlus {
641
654
uint256 amountIn = _validateAndGetAmountIn (args.depositCallData, amountRedeemed);
642
655
643
656
address router = _getAddress (keccak256 ("SUPERFORM_ROUTER " ));
644
- uint256 valueToDeposit;
645
- {
646
- uint256 valuePerItem = (msg .value - (msg .value % arrayLength)) / arrayLength;
647
- uint256 remainingValue = msg .value % arrayLength;
648
- valueToDeposit = valuePerItem + remainingValue;
649
- }
650
657
651
- _deposit (router, asset, amountIn, valueToDeposit , args.depositCallData);
658
+ _deposit (router, asset, amountIn, valueToPass , args.depositCallData);
652
659
653
660
_tokenRefunds (router, assetAdr, args.receiverAddressSP, balanceBefore);
654
661
0 commit comments