Skip to content

Commit

Permalink
fix: remedy rounding issue in _deposit4626() by adding remainder to…
Browse files Browse the repository at this point in the history
… `_deposit()` call (#657)
  • Loading branch information
TamaraRingas authored Nov 25, 2024
1 parent 60dd29e commit 1abc86d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/router-plus/SuperformRouterPlus.sol
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ contract SuperformRouterPlus is ISuperformRouterPlus, BaseSuperformRouterPlus {
/// @notice deposits ERC4626 vault shares into superform
/// @param vault_ The ERC4626 vault to redeem from
/// @param args Rest of the arguments to deposit 4626
/// @param arrayLength The length of the array of deposit4626 calls
function _deposit4626(address vault_, Deposit4626Args calldata args, uint256 arrayLength) internal {
_transferERC20In(IERC20(vault_), args.receiverAddressSP, args.amount);
IERC4626 vault = IERC4626(vault_);
Expand All @@ -639,10 +640,15 @@ contract SuperformRouterPlus is ISuperformRouterPlus, BaseSuperformRouterPlus {

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

uint256 msgValue = msg.value / arrayLength;
address router = _getAddress(keccak256("SUPERFORM_ROUTER"));
uint256 valueToDeposit;
{
uint256 valuePerItem = (msg.value - (msg.value % arrayLength)) / arrayLength;
uint256 remainingValue = msg.value % arrayLength;
valueToDeposit = valuePerItem + remainingValue;
}

_deposit(router, asset, amountIn, msgValue, args.depositCallData);
_deposit(router, asset, amountIn, valueToDeposit, args.depositCallData);

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

Expand Down

0 comments on commit 1abc86d

Please sign in to comment.