Lending pool state transition will be broken when pool is expired in late state
Lending pool state transition will be broken when pool is expired in late state\\n```\\n  function _getLendingPoolStatus(address _lendingPoolAddress)\\n    internal\\n    view\\n    returns (LendingPoolStatus)\\n  {\\n    if (!_isReferenceLendingPoolAdded(_lendingPoolAddress)) {\\n      return LendingPoolStatus.NotSupported;\\n    }\\n\\n\\n    ILendingProtocolAdapter _adapter = _getLendingProtocolAdapter(\\n      _lendingPoolAddress\\n    );\\n\\n\\n    if (_adapter.isLendingPoolExpired(_lendingPoolAddress)) {\\n      return LendingPoolStatus.Expired;\\n    }\\n\\n\\n    if (\\n      _adapter.isLendingPoolLateWithinGracePeriod(\\n        _lendingPoolAddress,\\n        Constants.LATE_PAYMENT_GRACE_PERIOD_IN_DAYS\\n      )\\n    ) {\\n      return LendingPoolStatus.LateWithinGracePeriod;\\n    }\\n\\n\\n    if (_adapter.isLendingPoolLate(_lendingPoolAddress)) {\\n      return LendingPoolStatus.Late;\\n    }\\n\\n\\n    return LendingPoolStatus.Active;\\n  }\\n```\\n\\nAs you can see, pool is expired if time of credit line has ended or loan is fully paid.\\nState transition for lending pool is done inside `DefaultStateManager._assessState` function. This function is responsible to lock capital, when state is late and unlock it when it's changed from late to active again.\\nBecause the first state that is checked is `expired` there can be few problems.\\nFirst problem. Suppose that lending pool is in late state. So capital is locked. There are 2 options now: payment was done, so pool becomes active and capital unlocked, payment was not done then pool has defaulted. But in case when state is late, and lending pool expired or loan is fully repaid(so it's also becomes expired), then capital will not be unlocked as there is no such transition Late -> Expired. The state will be changed to Expired and no more actions will be done. Also in this case it's not possible to detect if lending pool expired because of time or because no payment was done.\\nSecond problem. Lending pool is in active state. Last payment should be done some time before `_creditLine.termEndTime()`. Payment was not done, which means that state should be changed to Late and capital should be locked, but state was checked when loan has ended, so it became Expired and again there is no such transition that can detect that capital should be locked in this case. The state will be changed to Expired and no more actions will be done.
These are tricky cases, think about transition for lending pool in such cases.
Depending on situation, capital can be locked forever or protection buyers will not be compensated.
```\\n  function _getLendingPoolStatus(address _lendingPoolAddress)\\n    internal\\n    view\\n    returns (LendingPoolStatus)\\n  {\\n    if (!_isReferenceLendingPoolAdded(_lendingPoolAddress)) {\\n      return LendingPoolStatus.NotSupported;\\n    }\\n\\n\\n    ILendingProtocolAdapter _adapter = _getLendingProtocolAdapter(\\n      _lendingPoolAddress\\n    );\\n\\n\\n    if (_adapter.isLendingPoolExpired(_lendingPoolAddress)) {\\n      return LendingPoolStatus.Expired;\\n    }\\n\\n\\n    if (\\n      _adapter.isLendingPoolLateWithinGracePeriod(\\n        _lendingPoolAddress,\\n        Constants.LATE_PAYMENT_GRACE_PERIOD_IN_DAYS\\n      )\\n    ) {\\n      return LendingPoolStatus.LateWithinGracePeriod;\\n    }\\n\\n\\n    if (_adapter.isLendingPoolLate(_lendingPoolAddress)) {\\n      return LendingPoolStatus.Late;\\n    }\\n\\n\\n    return LendingPoolStatus.Active;\\n  }\\n```\\n