Inflated `ercDebt` via manipulated `ercDebtRate` disrupts liquidation, causing congestion. Skewed liquidation efforts as liquidators target artificially inflated ShortRecords.
Audit: 2024-03-dittoeth-findings
Severity: MEDIUM

# Lines of code

https://github.com/code-423n4/2024-03-dittoeth/blob/91faf46078bb6fe8ce9f55bcb717e5d2d302d22e/contracts/libraries/LibSRUtil.sol#L151-L163
https://github.com/code-423n4/2024-03-dittoeth/blob/91faf46078bb6fe8ce9f55bcb717e5d2d302d22e/contracts/libraries/LibSRUtil.sol#L156-L161


# Vulnerability details

   - `updateErcDebt` function in the `LibSRUtil` library is responsible for updating the `ercDebt` of a ShortRecord based on the current `ercDebtRate`.
   - The function calculates the debt adjustment by multiplying the ShortRecord's `ercDebt` with the difference between the current `ercDebtRate` and the ShortRecord's stored `ercDebtRate`.
   - If the debt adjustment is positive, it is added to the ShortRecord's `ercDebt`, and the ShortRecord's `ercDebtRate` is updated to the current `ercDebtRate`.
   - https://github.com/code-423n4/2024-03-dittoeth/blob/91faf46078bb6fe8ce9f55bcb717e5d2d302d22e/contracts/libraries/LibSRUtil.sol#L151-L163

     ```solidity
     function updateErcDebt(STypes.ShortRecord storage short, address asset) internal {
         AppStorage storage s = appStorage();

         // Distribute ercDebt
         uint64 ercDebtRate = s.asset[asset].ercDebtRate;
         uint88 ercDebt = short.ercDebt.mulU88(ercDebtRate - short.ercDebtRate);

         if (ercDebt > 0) {
             short.ercDebt += ercDebt;
             short.ercDebtRate = ercDebtRate;
         }
     }
     ```

From the potential manipulation of the `ercDebtRate` parameter, which is stored in the `Asset` struct and can be updated by the protocol.
   - If an attacker can manipulate the `ercDebtRate` to a significantly higher value, it can inflate the `ercDebt` of ShortRecords when the `updateErcDebt` function is called.
   - https://github.com/code-423n4/2024-03-dittoeth/blob/91faf46078bb6fe8ce9f55bcb717e5d2d302d22e/contracts/libraries/LibSRUtil.sol#L156-L161

     ```solidity
     uint88 ercDebt = short.ercDebt.mulU88(ercDebtRate - short.ercDebtRate);

     if (ercDebt > 0) {
         short.ercDebt += ercDebt;
         short.ercDebtRate = ercDebtRate;
     }
     ```

     If the `ercDebtRate` is manipulated to a much higher value, the `ercDebt` calculation can result in a significant increase in the ShortRecord's `ercDebt`.

   - When the `updateErcDebt` function is called with the manipulated `ercDebtRate`, it calculates an inflated `ercDebt` adjustment for the ShortRecord.
   - The inflated `ercDebt` is added to the ShortRecord's existing `ercDebt`, resulting in a sudden and significant increase in the ShortRecord's debt.
   - This manipulation can cause ShortRecords that originally had low `ercDebt` to suddenly meet the `minShortErc` requirement, making them eligible for liquidation.

## Impact
   - The sudden inflation of `ercDebt` across multiple ShortRecords can overwhelm the liquidation process, causing congestion and potential instability in the system.
   - The manipulation of `ercDebtRate` can also alter the incentives for liquidators, as Sh