Erroneous check for the end of distribution leads to distribution never ending, therefore no future rewards distributions can be performed, leaving transfers, mints and burns locked
Audit: 2024-02-althea-liquid-infrastructure-findings
Severity: HIGH

# Lines of code

https://github.com/code-423n4/2024-02-althea-liquid-infrastructure/blob/bd6ee47162368e1999a0a5b8b17b701347cf9a7d/liquid-infrastructure/contracts/LiquidInfrastructureERC20.sol#L198
https://github.com/code-423n4/2024-02-althea-liquid-infrastructure/blob/bd6ee47162368e1999a0a5b8b17b701347cf9a7d/liquid-infrastructure/contracts/LiquidInfrastructureERC20.sol#L208
https://github.com/code-423n4/2024-02-althea-liquid-infrastructure/blob/bd6ee47162368e1999a0a5b8b17b701347cf9a7d/liquid-infrastructure/contracts/LiquidInfrastructureERC20.sol#L234


# Vulnerability details

The distribution of the rewards is performed in the `distribute` function. There are three main steps in this function. Firstly, the `_beginDistribution` function is called, locking all transfers, mints and burns. Then it emits an event:

```solidity
257:        function _beginDistribution() internal {
```
```solidity
262:        LockedForDistribution = true;
```
```solidity
280:        emit DistributionStarted();
```

The second step in the function is the transferring of the rewards.

The third step is calling the `_endDistribution` function. Its purpose is to unlock the transfers, mints and burns that were locked at the beginning of the function, set the `LastDistribution` to the current block number, and finally, emit an event.

The problem revolves around the if clause on [line 234](https://github.com/code-423n4/2024-02-althea-liquid-infrastructure/blob/bd6ee47162368e1999a0a5b8b17b701347cf9a7d/liquid-infrastructure/contracts/LiquidInfrastructureERC20.sol#L234):
```solidity
234:        if (nextDistributionRecipient == holders.length) {
235:            _endDistribution();
236:        }
```

The function checks if the `nextDistributionRecipient` is equal to `holders.length`. This statement will never return `true`, therefore [line 235](https://github.com/code-423n4/2024-02-althea-liquid-infrastructure/blob/bd6ee47162368e1999a0a5b8b17b701347cf9a7d/liquid-infrastructure/contracts/LiquidInfrastructureERC20.sol#L235) will not get executed and the distribution will never end, leaving the transfer, mint and burns operations locked. The `LastDistribution` will also not get updated.

## Impact
Rewards can no longer be distributed. The `LockedForDistribution` variable stays equal to `true`, preventing main functionalities (transfers, mints, and burns).

```
77:    /**
78:     * @notice When true, locks all transfers, mints, and burns until the current distribution has completed
79:     */
80:    bool public LockedForDistribution;
```

The issue has a high impact and will occur every time that the `distribute` function is called.

## Proof of Concept
On [line 208](https://github.com/code-423n4/2024-02-althea-liquid-infrastructure/blob/bd6ee47162368e1999a0a5b8b17b701347cf9a7d/liquid-infrastructure/contracts/LiquidInfrastructureERC20.sol#L208), the limit variable is being set to either `nextDistributionRecipient + numDistributions` or `holders.length`, depending on which has a lower