Skip to content

Commit 1abc86d

Browse files
authored
fix: remedy rounding issue in _deposit4626() by adding remainder to _deposit() call (#657)
1 parent 60dd29e commit 1abc86d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/router-plus/SuperformRouterPlus.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ contract SuperformRouterPlus is ISuperformRouterPlus, BaseSuperformRouterPlus {
627627
/// @notice deposits ERC4626 vault shares into superform
628628
/// @param vault_ The ERC4626 vault to redeem from
629629
/// @param args Rest of the arguments to deposit 4626
630+
/// @param arrayLength The length of the array of deposit4626 calls
630631
function _deposit4626(address vault_, Deposit4626Args calldata args, uint256 arrayLength) internal {
631632
_transferERC20In(IERC20(vault_), args.receiverAddressSP, args.amount);
632633
IERC4626 vault = IERC4626(vault_);
@@ -639,10 +640,15 @@ contract SuperformRouterPlus is ISuperformRouterPlus, BaseSuperformRouterPlus {
639640

640641
uint256 amountIn = _validateAndGetAmountIn(args.depositCallData, amountRedeemed);
641642

642-
uint256 msgValue = msg.value / arrayLength;
643643
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+
}
644650

645-
_deposit(router, asset, amountIn, msgValue, args.depositCallData);
651+
_deposit(router, asset, amountIn, valueToDeposit, args.depositCallData);
646652

647653
_tokenRefunds(router, assetAdr, args.receiverAddressSP, balanceBefore);
648654

0 commit comments

Comments
 (0)