From 76c64e79479bd1fd2052244db1bed4ec2de70561 Mon Sep 17 00:00:00 2001 From: kexley <87971154+kexleyBeefy@users.noreply.github.com> Date: Fri, 15 Aug 2025 17:38:54 +0100 Subject: [PATCH] Issue 439 Rearrange burn call to be before the bulk of the gas spend --- contracts/vault/Vault.sol | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/contracts/vault/Vault.sol b/contracts/vault/Vault.sol index 4053f347..7d0580de 100644 --- a/contracts/vault/Vault.sol +++ b/contracts/vault/Vault.sol @@ -61,7 +61,11 @@ abstract contract Vault is { uint256 fee; (amountOut, fee) = getBurnAmount(_asset, _amountIn); + + _burn(msg.sender, _amountIn); + divest(_asset, amountOut + fee); + VaultLogic.burn( getVaultStorage(), MintBurnParams({ @@ -74,7 +78,6 @@ abstract contract Vault is fee: fee }) ); - _burn(msg.sender, _amountIn); } /// @inheritdoc IVault @@ -85,12 +88,15 @@ abstract contract Vault is { uint256[] memory fees; (amountsOut, fees) = getRedeemAmount(_amountIn); + + _burn(msg.sender, _amountIn); + uint256[] memory totalDivestAmounts = new uint256[](amountsOut.length); for (uint256 i; i < amountsOut.length; i++) { totalDivestAmounts[i] = amountsOut[i] + fees[i]; } - divestMany(assets(), totalDivestAmounts); + VaultLogic.redeem( getVaultStorage(), RedeemParams({ @@ -102,7 +108,6 @@ abstract contract Vault is fees: fees }) ); - _burn(msg.sender, _amountIn); } /// @inheritdoc IVault