function undeploy(uint256 amount) external nonReentrant onlyOwner returns (uint256 undeployedAmount) {
    if (amount == 0) revert ZeroAmount();

    // Get Balance
    uint256 balance = getBalance();
    if (amount > balance) revert InsufficientBalance();

    // Transfer assets back to caller
    uint256 withdrawalValue = _undeploy(amount);

    // Check withdrawal value matches the initial amount
    // Transfer assets to user
    ERC20(_asset).safeTransfer(msg.sender, withdrawalValue);

    balance -= amount;
    emit StrategyUndeploy(msg.sender, withdrawalValue);
    emit StrategyAmountUpdate(balance);

    return amount;
}
function harvest() external returns (int256 balanceChange) {
    // Get Balance
    uint256 newBalance = getBalance();

@>  balanceChange = int256(newBalance) - int256(_deployedAmount);

    if (balanceChange > 0) {
        emit StrategyProfit(uint256(balanceChange));
    } else if (balanceChange < 0) {
        emit StrategyLoss(uint256(-balanceChange));
    }
    if (balanceChange != 0) {
        emit StrategyAmountUpdate(newBalance);
    }
    _deployedAmount = newBalance;
}
it('PoC - harvest returns loss after undeloy', async () => {
  const { owner, strategySupply, stETH, aave3Pool, otherAccount } = await loadFixture(
    deployStrategySupplyFixture,
  );
  const deployAmount = ethers.parseEther('10');
  await stETH.approve(await strategySupply.getAddress(), deployAmount);
  await strategySupply.deploy(deployAmount);

  //artificial profit
  const profit = ethers.parseEther('1');
  await aave3Pool.mintAtokensArbitrarily(await strategySupply.getAddress(), profit);

  // Undeploy
  const undeployAmount = ethers.parseEther('2');
  await strategySupply.undeploy(undeployAmount);

  await expect(strategySupply.harvest())
    .to.emit(strategySupply, 'StrategyLoss')
    .to.emit(strategySupply, 'StrategyAmountUpdate');
});
