#42158 [SC-High] Users can DoS `Zapper::zapIn` functionality for a token
Description
Brief/Intro
Vulnerability Details
function getMintAmounts(uint256 amount0Max, uint256 amount1Max) external view returns (uint256 amount0, uint256 amount1, uint256 mintAmount) {
uint256 totalSupply = totalSupply();
if (totalSupply > 0) {
(amount0, amount1, mintAmount) = _computeMintAmounts(totalSupply, amount0Max, amount1Max);
} else {
(uint160 sqrtRatioX96,,,,,,) = pool.slot0();
uint128 newLiquidity = LiquidityAmounts.getLiquidityForAmounts(sqrtRatioX96, lowerTick.getSqrtRatioAtTick(), upperTick.getSqrtRatioAtTick(), amount0Max, amount1Max);
mintAmount = uint256(newLiquidity);
(amount0, amount1) = LiquidityAmounts.getAmountsForLiquidity(sqrtRatioX96, lowerTick.getSqrtRatioAtTick(), upperTick.getSqrtRatioAtTick(), newLiquidity);
}
}
function _computeMintAmounts(uint256 totalSupply, uint256 amount0Max, uint256 amount1Max) private view returns (uint256 amount0, uint256 amount1, uint256 mintAmount) {
(uint256 amount0Current, uint256 amount1Current) = getUnderlyingBalances();
if (amount0Current == 0 && amount1Current > 0) {
mintAmount = FullMath.mulDiv(amount1Max, totalSupply, amount1Current);
} else if (amount1Current == 0 && amount0Current > 0) {
mintAmount = FullMath.mulDiv(amount0Max, totalSupply, amount0Current);
} else if (amount0Current == 0 && amount1Current == 0) {
revert("");
} else {
uint256 amount0Mint = FullMath.mulDiv(amount0Max, totalSupply, amount0Current);
uint256 amount1Mint = FullMath.mulDiv(amount1Max, totalSupply, amount1Current);
require(amount0Mint > 0 && amount1Mint > 0, "mint 0");
mintAmount = amount0Mint < amount1Mint ? amount0Mint : amount1Mint;
}
amount0 = FullMath.mulDivRoundingUp(mintAmount, amount0Current, totalSupply);
amount1 = FullMath.mulDivRoundingUp(mintAmount, amount1Current, totalSupply);
}Impact Details
References
Proof of Concept
Proof of Concept
Previous#42152 [SC-Critical] `StakeV2::accumulatedDeptRewardsYeet` fails to account for pending vesting withdrawals which could cause contract insolvencyNext#42166 [SC-Low] Modification of MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR Leads to Unjust Loss of Promised Rewards for Users
Was this helpful?