Vulnerability: Vaults can avoid liquidations by not letting their vault account be settled
Severity: high

Description:
Vault liquidations will leave un-matured accounts with cash holdings which are then used to offset account debt during vault account settlements. As it stands, any excess cash received via interest accrual will be transferred back to the vault account directly. If a primary or secondary borrow currency is `ETH`, then this excess cash will be transferred natively. Consequently, the recipient may intentionally revert, causing account settlement to fail.\\nThe issue arises in the `VaultAccount.repayAccountPrimeDebtAtSettlement()` function. If there is any excess cash due to interest accrual, then this amount will be refunded to the vault account. Native `ETH` is not wrapped when it should be wrapped, allowing the recipient to take control over the flow of execution.\\n```\\nFile: VaultAccount.sol\\n    function repayAccountPrimeDebtAtSettlement(\\n        PrimeRate memory pr,\\n        VaultStateStorage storage primeVaultState,\\n        uint16 currencyId,\\n        address vault,\\n        address account,\\n        int256 accountPrimeCash,\\n        int256 accountPrimeStorageValue\\n    ) internal returns (int256 finalPrimeDebtStorageValue, bool didTransfer) {\\n        didTransfer = false;\\n        finalPrimeDebtStorageValue = accountPrimeStorageValue;\\n        \\n        if (accountPrimeCash > 0) {\\n            // netPrimeDebtRepaid is a negative number\\n            int256 netPrimeDebtRepaid = pr.convertUnderlyingToDebtStorage(\\n                pr.convertToUnderlying(accountPrimeCash).neg()\\n            );\\n\\n            int256 netPrimeDebtChange;\\n            if (netPrimeDebtRepaid < accountPrimeStorageValue) {\\n                // If the net debt change is greater than the debt held by the account, then only\\n                // decrease the total prime debt by what is held by the account. The residual amount\\n                // will be refunded to the account via a direct transfer.\\n                netPrimeDebtChange = accountPrimeStorageValue;\\n                finalPrimeDebtStorageValue = 0;\\n\\n                int256 primeCashRefund = pr.convertFromUnderlying(\\n                    pr.convertDebtStorageToUnderlying(netPrimeDebtChange.sub(accountPrimeStorageValue))\\n                );\\n                TokenHandler.withdrawPrimeCash(\\n                    account, currencyId, primeCashRefund, pr, false // ETH will be transferred natively\\n                );\\n                didTransfer = true;\\n            } else {\\n                // In this case, part of the account's debt is repaid.\\n                netPrimeDebtChange = netPrimeDebtRepaid;\\n                finalPrimeDebtStorageValue = accountPrimeStorageValue.sub(netPrimeDebtRepaid);\\n            }\\n\\n            // Updates the global prime debt figure and events are emitted via the vault.\\n            pr.updateTotalPrimeDebt(vault, currencyId, netPrimeDebtChange);\\n\\n            // Updates the state on the prime vault storage directly.\\n            int256 totalPrimeDebt = int256(uint256(primeVaultState.totalDebt));\\n            int256 newTotalDebt = totalPrimeDebt.add(netPrimeDebtChange);\\n            // Set the total debt to the storage value\\n            primeVaultState.totalDebt = newTotalDebt.toUint().toUint80();\\n        }\\n    }\\n```\\n\\nAs seen here, a `withdrawWrappedNativeToken` is used to signify when a native `ETH` transfer will be wrapped before sending an amount. In the case of vault settlement, this is always sent to `false`.\\n```\\nFile: TokenHandler.sol\\n    function withdrawPrimeCash(\\n        address account,\\n        uint16 currencyId,\\n        int256 primeCashToWithdraw,\\n        PrimeRate memory primeRate,\\n        bool withdrawWrappedNativeToken\\n    ) internal returns (int256 netTransferExternal) {\\n        if (primeCashToWithdraw == 0) return 0;\\n        require(primeCashToWithdraw < 0);\\n\\n        Token memory underlying = getUnderlyingToken(currencyId);\\n        netTransferExternal = convertToExternal(\\n            underlying, \\n            primeRate.convertToUnderlying(primeCashToWithdraw) \\n        );\\n\\n        // Overflow not possible due to int256\\n        uint256 withdrawAmount = uint256(netTransferExternal.neg());\\n        _redeemMoneyMarketIfRequired(currencyId, underlying, withdrawAmount);\\n\\n        if (underlying.tokenType == TokenType.Ether) {\\n            GenericToken.transferNativeTokenOut(account, withdrawAmount, withdrawWrappedNativeToken);\\n        } else {\\n            GenericToken.safeTransferOut(underlying.tokenAddress, account, withdrawAmount);\\n        }\\n\\n        _postTransferPrimeCashUpdate(account, currencyId, netTransferExternal, underlying, primeRate);\\n    }\\n```\\n\\nIt's likely that the vault account is considered solvent in this case, but due to the inability to trade between currencies, it is not possible to use excess cash in one currency to offset debt in another.

Impact:
Liquidations require vaults to be settled if `block.timestamp` is past the maturity date, hence, it is not possible to deleverage vault accounts, leading to bad debt accrual.

Recommended mitigation:
Consider wrapping `ETH` under all circumstances. This will prevent vault accounts from intentionally reverting and preventing their account from being settled.