Skip to content

Commit 214e53d

Browse files
Fix Accounting (#262)
1 parent f63b3d3 commit 214e53d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/MevEth.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -748,23 +748,23 @@ contract MevEth is Auth, ERC20, IERC4626, ITinyMevEth {
748748
if (creamAmount == 0) revert MevEthErrors.ZeroValue();
749749

750750
// Calculate the equivalent mevETH to be redeemed based on the ratio
751-
uint256 mevEthAmount = creamAmount * uint256(CREAM_TO_MEV_ETH_PERCENT) / 1000;
751+
uint256 assets = creamAmount * uint256(CREAM_TO_MEV_ETH_PERCENT) / 1000;
752+
if (assets < MIN_DEPOSIT) revert MevEthErrors.DepositTooSmall();
752753

753754
// Convert the shares to assets and update the fraction elastic and base
754-
uint256 assets = convertToAssets(mevEthAmount);
755-
if (assets < MIN_DEPOSIT) revert MevEthErrors.DepositTooSmall();
755+
uint256 shares = convertToShares(assets);
756756

757757
fraction.elastic += uint128(assets);
758-
fraction.base += uint128(mevEthAmount);
758+
fraction.base += uint128(shares);
759759

760760
// Burn CreamEth2 tokens
761761
IERC20Burnable(creamToken).burnFrom(msg.sender, creamAmount);
762762

763763
// Mint the equivalent mevETH
764-
_mint(msg.sender, mevEthAmount);
764+
_mint(msg.sender, shares);
765765

766766
// Emit event
767-
emit CreamRedeemed(msg.sender, creamAmount, mevEthAmount);
767+
emit CreamRedeemed(msg.sender, creamAmount, shares);
768768
}
769769

770770
// Event emitted when Cream tokens are redeemed for mevETH

0 commit comments

Comments
 (0)