Yield in trove is lost when closing a strategy vault
The funds in the trove contract are not claimed during the emergency close flow and can not be claimed in a normal way during this situation, because of a status change. Therefore, all the acquired yield will be lost.\\nWhen users deposit, or withdraw tokens, all acquired yield from GMX is sent to the trove contract:\\n```\\nfunction deposit(\\n  GMXTypes.Store storage self,\\n  GMXTypes.DepositParams memory dp,\\n  bool isNative\\n) external {\\n  // Sweep any tokenA/B in vault to the temporary trove for future compouding and to prevent\\n  // it from being considered as part of depositor's assets\\n  if (self.tokenA.balanceOf(address(this)) > 0) {\\n    self.tokenA.safeTransfer(self.trove, self.tokenA.balanceOf(address(this)));\\n  }\\n  if (self.tokenB.balanceOf(address(this)) > 0) {\\n    self.tokenB.safeTransfer(self.trove, self.tokenB.balanceOf(address(this)));\\n  }\\n // rest of code\\n}\\n```\\n\\n```\\nfunction withdraw(\\n  GMXTypes.Store storage self,\\n  GMXTypes.WithdrawParams memory wp\\n) external {\\n  // Sweep any tokenA/B in vault to the temporary trove for future compouding and to prevent\\n  // it from being considered as part of withdrawers assets\\n  if (self.tokenA.balanceOf(address(this)) > 0) {\\n    self.tokenA.safeTransfer(self.trove, self.tokenA.balanceOf(address(this)));\\n  }\\n  if (self.tokenB.balanceOf(address(this)) > 0) {\\n    self.tokenB.safeTransfer(self.trove, self.tokenB.balanceOf(address(this)));\\n  }\\n // rest of code\\n}\\n```\\n\\nThe only way in the system to claim these yield is the compound function, which calls the beforeCompoundChecks function:\\n```\\nfunction compound(\\n  GMXTypes.Store storage self,\\n  GMXTypes.CompoundParams memory cp\\n) external {\\n  // Transfer any tokenA/B from trove to vault\\n  if (self.tokenA.balanceOf(address(self.trove)) > 0) {\\n    self.tokenA.safeTransferFrom(\\n      address(self.trove),\\n      address(this),\\n      self.tokenA.balanceOf(address(self.trove))\\n    );\\n  }\\n  if (self.tokenB.balanceOf(address(self.trove)) > 0) {\\n    self.tokenB.safeTransferFrom(\\n      address(self.trove),\\n      address(this),\\n      self.tokenB.balanceOf(address(self.trove))\\n    );\\n  }\\n // rest of code\\n GMXChecks.beforeCompoundChecks(self);\\n // rest of code\\n}\\n```\\n\\nThis function reverts if the current status of the system is not Open or Compound_Failed:\\n```\\nfunction beforeCompoundChecks(\\n  GMXTypes.Store storage self\\n) external view {\\n  if (\\n    self.status != GMXTypes.Status.Open &&\\n    self.status != GMXTypes.Status.Compound_Failed\\n  ) revert Errors.NotAllowedInCurrentVaultStatus();\\n // rest of code\\n}\\n```\\n\\nAs the emergency close flow updates this status to Paused and later to Closed, calling compound will revert:\\n```\\nfunction emergencyPause(\\n  GMXTypes.Store storage self\\n) external {\\n  self.refundee = payable(msg.sender);\\n\\n  GMXTypes.RemoveLiquidityParams memory _rlp;\\n\\n  // Remove all of the vault's LP tokens\\n  _rlp.lpAmt = self.lpToken.balanceOf(address(this));\\n  _rlp.executionFee = msg.value;\\n\\n  GMXManager.removeLiquidity(\\n    self,\\n    _rlp\\n  );\\n\\n  self.status = GMXTypes.Status.Paused;\\n\\n  emit EmergencyPause();\\n}\\n```\\n\\n```\\nfunction emergencyClose(\\n  GMXTypes.Store storage self,\\n  uint256 deadline\\n) external {\\n  GMXChecks.beforeEmergencyCloseChecks(self);\\n\\n  // Repay all borrowed assets; 1e18 == 100% shareRatio to repay\\n  GMXTypes.RepayParams memory _rp;\\n  (\\n    _rp.repayTokenAAmt,\\n    _rp.repayTokenBAmt\\n  ) = GMXManager.calcRepay(self, 1e18);\\n\\n  (\\n    bool _swapNeeded,\\n    address _tokenFrom,\\n    address _tokenTo,\\n    uint256 _tokenToAmt\\n  ) = GMXManager.calcSwapForRepay(self, _rp);\\n\\n  if (_swapNeeded) {\\n    ISwap.SwapParams memory _sp;\\n\\n    _sp.tokenIn = _tokenFrom;\\n    _sp.tokenOut = _tokenTo;\\n    _sp.amountIn = IERC20(_tokenFrom).balanceOf(address(this));\\n    _sp.amountOut = _tokenToAmt;\\n    _sp.slippage = self.minSlippage;\\n    _sp.deadline = deadline;\\n\\n    GMXManager.swapTokensForExactTokens(self, _sp);\\n  }\\n\\n  GMXManager.repay(\\n    self,\\n    _rp.repayTokenAAmt,\\n    _rp.repayTokenBAmt\\n  );\\n\\n  self.status = GMXTypes.Status.Closed;\\n\\n  emit EmergencyClose(\\n    _rp.repayTokenAAmt,\\n    _rp.repayTokenBAmt\\n  );\\n}\\n```\\n\\nAnd as we can see during these process the funds inside the trove contract are never claimed and as the strategy vault is the only address that can claim the funds of the trove, all funds are gone.\\n```\\ncontract GMXTrove {\\n\\n  /* ==================== STATE VARIABLES ==================== */\\n\\n  // Address of the vault this trove handler is for\\n  IGMXVault public vault;\\n\\n  /* ====================== CONSTRUCTOR ====================== */\\n\\n  /**\\n    * @notice Initialize trove contract with associated vault address\\n    * @param _vault Address of vault\\n  */\\n  constructor (address _vault) {\\n    vault = IGMXVault(_vault);\\n\\n    GMXTypes.Store memory _store = vault.store();\\n\\n    // Set token approvals for this trove's vault contract\\n    _store.tokenA.approve(address(vault), type(uint256).max);\\n    _store.tokenB.approve(address(vault), type(uint256).max);\\n  }\\n}\\n```\\n
Transfer the funds inside the trove into the vault during the emergency close process.
If a strategy vault is closed, all funds in the trove are lost.
```\\nfunction deposit(\\n  GMXTypes.Store storage self,\\n  GMXTypes.DepositParams memory dp,\\n  bool isNative\\n) external {\\n  // Sweep any tokenA/B in vault to the temporary trove for future compouding and to prevent\\n  // it from being considered as part of depositor's assets\\n  if (self.tokenA.balanceOf(address(this)) > 0) {\\n    self.tokenA.safeTransfer(self.trove, self.tokenA.balanceOf(address(this)));\\n  }\\n  if (self.tokenB.balanceOf(address(this)) > 0) {\\n    self.tokenB.safeTransfer(self.trove, self.tokenB.balanceOf(address(this)));\\n  }\\n // rest of code\\n}\\n```\\n