// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import "forge-std/console.sol";
import {MockERC4626} from "./MockERC4626.sol";
import {MathUpgradeable as Math} from "openzeppelin-contracts-upgradeable/utils/math/MathUpgradeable.sol";
import { IERC4626, IERC20 } from "../../../src/interfaces/vault/IERC4626.sol";

contract MockERC4626WithFees is MockERC4626 {
    using Math for uint256;
    constructor(
        IERC20 _asset,
        string memory _name,
        string memory _symbol
    ) MockERC4626(_asset, _name, _symbol) {}


    /// @notice `previewRedeem` that takes withdrawal fees into account
    function previewRedeem(uint256 shares)
        public
        view
        override
        returns (uint256)
    {
        uint256 assets = convertToAssets(shares);
        uint256 withdrawalFee = 10;
        uint256 fee = assets.mulDiv(
            withdrawalFee,
            10_000,
            Math.Rounding.Up
        );
        assets -= fee;

        return assets;
    }

    function beforeWithdraw(uint256 assets, uint256 shares) internal override {
        MockERC4626.beforeWithdraw(assets,shares);
        uint256 assetsWithoutFees = convertToAssets(shares);
        uint256 fee = assetsWithoutFees - assets;
        // in real adapters, withdrawal would cause _underlyingBalance to change 
        // here simulate that by burning asset tokens. same effect. holdings decrease by fee percent
        asset.transfer(address(0xdead), fee); 
    }

}
pragma solidity ^0.8.15;

+import "forge-std/console.sol";
 import { Test } from "forge-std/Test.sol";
 import { MockERC20 } from "../utils/mocks/MockERC20.sol";
 import { MockERC4626 } from "../utils/mocks/MockERC4626.sol";
+import { MockERC4626WithFees } from "../utils/mocks/MockERC4626WithFees.sol";
 import { Vault } from "../../src/vault/Vault.sol";
@@ -824,7 +826,7 @@ contract VaultTest is Test {

   // Change Adapter
   function test__changeAdapter() public {
-    MockERC4626 newAdapter = new MockERC4626(IERC20(address(asset)), "Mock Token Vault", "vwTKN");
+    MockERC4626 newAdapter = new MockERC4626WithFees(IERC20(address(asset)), "Mock Token Vault", "vwTKN");
     uint256 depositAmount = 1 ether;

     // Deposit funds for testing
@@ -858,6 +860,19 @@ contract VaultTest is Test {
     assertEq(asset.allowance(address(vault), address(newAdapter)), type(uint256).max);

     assertEq(vault.highWaterMark(), oldHWM);
+
+    console.log(asset.balanceOf(address(newAdapter)) );
+    console.log(newAdapter.balanceOf(address(vault)) );
+
+    vm.startPrank(alice);
+    uint256 rounds = 10;
+    for (uint256 i = 0;i<rounds;i++){
+      vault.changeAdapter();
+    }
+
+    console.log(asset.balanceOf(address(newAdapter)) );
+    console.log(newAdapter.balanceOf(address(vault)) );
+
   }
Running 1 test for test/vault/Vault.t.sol:VaultTest
[PASS] test__changeAdapter() (gas: 2896175)
Logs:
  2000000000000000000 <---- asset.balanceOf(address(newAdapter)
  2000000000000000000 <---- newAdapter.balanceOf(address(vault)
  1980089760419496416 <---- asset.balanceOf(address(newAdapter)
  1980089760419496416 <---- newAdapter.balanceOf(address(vault)
