DnGmxJuniorVaultManager#_rebalanceBorrow logic is flawed and could result in vault liquidation
DnGmxJuniorVaultManager#_rebalanceBorrow fails to rebalance correctly if only one of the two assets needs a rebalance. In the case where one assets increases rapidly in price while the other stays constant, the vault may be liquidated.\\n```\\n    // If both eth and btc swap amounts are not beyond the threshold then no flashloan needs to be executed | case 1\\n    if (btcAssetAmount == 0 && ethAssetAmount == 0) return;\\n\\n    if (repayDebtBtc && repayDebtEth) {\\n        // case where both the token assets are USDC\\n        // only one entry required which is combined asset amount for both tokens\\n        assets = new address[](1);\\n        amounts = new uint256[](1);\\n\\n        assets[0] = address(state.usdc);\\n        amounts[0] = (btcAssetAmount + ethAssetAmount);\\n    } else if (btcAssetAmount == 0 || ethAssetAmount == 0) {\\n        // Exactly one would be true since case-1 excluded (both false) | case-2\\n        // One token amount = 0 and other token amount > 0\\n        // only one entry required for the non-zero amount token\\n        assets = new address[](1);\\n        amounts = new uint256[](1);\\n\\n        if (btcAssetAmount == 0) {\\n            assets[0] = (repayDebtBtc ? address(state.usdc) : address(state.wbtc));\\n            amounts[0] = btcAssetAmount;\\n        } else {\\n            assets[0] = (repayDebtEth ? address(state.usdc) : address(state.weth));\\n            amounts[0] = ethAssetAmount;\\n        }\\n```\\n\\nThe logic above is used to determine what assets to borrow using the flashloan. If the rebalance amount is under a threshold then the assetAmount is set equal to zero. The first check `if (btcAssetAmount == 0 && ethAssetAmount == 0) return;` is a short circuit that returns if neither asset is above the threshold. The third check `else if (btcAssetAmount == 0 || ethAssetAmount == 0)` is the point of interest. Since we short circuit if both are zero then to meet this condition exactly one asset needs to be rebalanced. The logic that follows is where the error is. In the comments it indicates that it needs to enter with the non-zero amount token but the actual logic reflects the opposite. If `btcAssetAmount == 0` it actually tries to enter with wBTC which would be the zero amount asset.\\nThe result of this can be catastrophic for the vault. If one token increases in value rapidly while the other is constant the vault will only ever try to rebalance the one token but because of this logical error it will never actually complete the rebalance. If the token increase in value enough the vault would actually end up becoming liquidated.
Small change to reverse the logic and make it correct:\\n```\\n-       if (btcAssetAmount == 0) {\\n+       if (btcAssetAmount != 0) {\\n            assets[0] = (repayDebtBtc ? address(state.usdc) : address(state.wbtc));\\n            amounts[0] = btcAssetAmount;\\n        } else {\\n            assets[0] = (repayDebtEth ? address(state.usdc) : address(state.weth));\\n            amounts[0] = ethAssetAmount;\\n        }\\n```\\n
Vault is unable to rebalance correctly if only one asset needs to be rebalanced, which can lead to the vault being liquidated
```\\n    // If both eth and btc swap amounts are not beyond the threshold then no flashloan needs to be executed | case 1\\n    if (btcAssetAmount == 0 && ethAssetAmount == 0) return;\\n\\n    if (repayDebtBtc && repayDebtEth) {\\n        // case where both the token assets are USDC\\n        // only one entry required which is combined asset amount for both tokens\\n        assets = new address[](1);\\n        amounts = new uint256[](1);\\n\\n        assets[0] = address(state.usdc);\\n        amounts[0] = (btcAssetAmount + ethAssetAmount);\\n    } else if (btcAssetAmount == 0 || ethAssetAmount == 0) {\\n        // Exactly one would be true since case-1 excluded (both false) | case-2\\n        // One token amount = 0 and other token amount > 0\\n        // only one entry required for the non-zero amount token\\n        assets = new address[](1);\\n        amounts = new uint256[](1);\\n\\n        if (btcAssetAmount == 0) {\\n            assets[0] = (repayDebtBtc ? address(state.usdc) : address(state.wbtc));\\n            amounts[0] = btcAssetAmount;\\n        } else {\\n            assets[0] = (repayDebtEth ? address(state.usdc) : address(state.weth));\\n            amounts[0] = ethAssetAmount;\\n        }\\n```\\n