Inconsistency handling of DAI as collateral in the BuyUSSDSellCollateral function
DAI is the base asset of the `USSD.sol` contract, when a rebalacing needs to occur during a peg-down recovery, collateral is sold for DAI, which then is used to buy USSD in the DAI / USSD uniswap pool. Hence, when DAI is the collateral, this is not sold because there no existe a path to sell DAI for DAI.\\nThe above behavior is handled when collateral is about to be sold for DAI, see the comment `no need to swap DAI` (link to the code):\\n```\\nif (collateralval > amountToBuyLeftUSD) {\\n   // sell a portion of collateral and exit\\n   if (collateral[i].pathsell.length > 0) {\\n       uint256 amountBefore = IERC20Upgradeable(baseAsset).balanceOf(USSD);\\n       uint256 amountToSellUnits = IERC20Upgradeable(collateral[i].token).balanceOf(USSD) * ((amountToBuyLeftUSD * 1e18 / collateralval) / 1e18) / 1e18;\\n       IUSSD(USSD).UniV3SwapInput(collateral[i].pathsell, amountToSellUnits);\\n       amountToBuyLeftUSD -= (IERC20Upgradeable(baseAsset).balanceOf(USSD) - amountBefore);\\n       DAItosell += (IERC20Upgradeable(baseAsset).balanceOf(USSD) - amountBefore);\\n   } \\n   else {\\n       // no need to swap DAI\\n       DAItosell = IERC20Upgradeable(collateral[i].token).balanceOf(USSD) * amountToBuyLeftUSD / collateralval;\\n   }\\n}\\n\\nelse {\\n   // @audit-issue Not handling the case where this is DAI as is done above.\\n   // sell all or skip (if collateral is too little, 5% treshold)\\n   if (collateralval >= amountToBuyLeftUSD / 20) {\\n      uint256 amountBefore = IERC20Upgradeable(baseAsset).balanceOf(USSD);\\n      // sell all collateral and move to next one\\n      IUSSD(USSD).UniV3SwapInput(collateral[i].pathsell, IERC20Upgradeable(collateral[i].token).balanceOf(USSD));\\n      amountToBuyLeftUSD -= (IERC20Upgradeable(baseAsset).balanceOf(USSD) - amountBefore);\\n      DAItosell += (IERC20Upgradeable(baseAsset).balanceOf(USSD) - amountBefore);\\n   }\\n}\\n```\\n\\nThe problem is in the `else branch` of the first if statement `collateralval > amountToBuyLeftUSD`, which lacks the check `if (collateral[i].pathsell.length > 0)`
Handle the case as is the done on the if branch of collateralval > amountToBuyLeftUSD:\\n```\\nif (collateral[i].pathsell.length > 0) {\\n  // Sell collateral for DAI\\n}\\nelse {\\n // No need to swap DAI\\n}\\n```\\n
A re-balancing on a peg-down recovery will fail if the `collateralval` of DAI is less than `amountToBuyLeftUSD` but greater than `amountToBuyLeftUSD / 20` since the DAI collateral does not have a sell path.
```\\nif (collateralval > amountToBuyLeftUSD) {\\n   // sell a portion of collateral and exit\\n   if (collateral[i].pathsell.length > 0) {\\n       uint256 amountBefore = IERC20Upgradeable(baseAsset).balanceOf(USSD);\\n       uint256 amountToSellUnits = IERC20Upgradeable(collateral[i].token).balanceOf(USSD) * ((amountToBuyLeftUSD * 1e18 / collateralval) / 1e18) / 1e18;\\n       IUSSD(USSD).UniV3SwapInput(collateral[i].pathsell, amountToSellUnits);\\n       amountToBuyLeftUSD -= (IERC20Upgradeable(baseAsset).balanceOf(USSD) - amountBefore);\\n       DAItosell += (IERC20Upgradeable(baseAsset).balanceOf(USSD) - amountBefore);\\n   } \\n   else {\\n       // no need to swap DAI\\n       DAItosell = IERC20Upgradeable(collateral[i].token).balanceOf(USSD) * amountToBuyLeftUSD / collateralval;\\n   }\\n}\\n\\nelse {\\n   // @audit-issue Not handling the case where this is DAI as is done above.\\n   // sell all or skip (if collateral is too little, 5% treshold)\\n   if (collateralval >= amountToBuyLeftUSD / 20) {\\n      uint256 amountBefore = IERC20Upgradeable(baseAsset).balanceOf(USSD);\\n      // sell all collateral and move to next one\\n      IUSSD(USSD).UniV3SwapInput(collateral[i].pathsell, IERC20Upgradeable(collateral[i].token).balanceOf(USSD));\\n      amountToBuyLeftUSD -= (IERC20Upgradeable(baseAsset).balanceOf(USSD) - amountBefore);\\n      DAItosell += (IERC20Upgradeable(baseAsset).balanceOf(USSD) - amountBefore);\\n   }\\n}\\n```\\n