58689 sc critical incorrect deduction logic in alchemistv3 redeem may lead to insufficient contract collateral
Description
Brief/Intro
Vulnerability Details
// AlchemistV3::redeem()
function redeem(uint256 amount) external onlyTransmuter {
_earmark();
// SNIP...
// move only the net collateral + fee
@> uint256 collRedeemed = convertDebtTokensToYield(amount);
@> uint256 feeCollateral = collRedeemed * protocolFee / BPS;
@> uint256 totalOut = collRedeemed + feeCollateral;
// update locked collateral + collateral weight
uint256 old = _totalLocked;
@> _totalLocked = totalOut > old ? 0 : old - totalOut;
@>1 _collateralWeight += PositionDecay.WeightIncrement(totalOut > old ? old : totalOut, old);
@> TokenUtils.safeTransfer(myt, transmuter, collRedeemed);
@> TokenUtils.safeTransfer(myt, protocolFeeReceiver, feeCollateral);
@>1 _mytSharesDeposited -= collRedeemed + feeCollateral;
emit Redemption(redeemedDebtTotal);
}Impact Details
References
Proof of Concept
Proof of Concept
Previous56893 sc low pending admin cannot accept ownership in alchemistcuratorNext56801 sc insight function burn could be gas optimized
Was this helpful?