# The calculation time methods of `calculateNextDueDate` and `_canLiquidateLoan` are inconsistent

Teller's calculateNextDueDate and _canLiquidateLoan use inconsistent time math, so borrowers repaying on the quoted due date can still be liquidated.

- Payout: Contest reward
- Severity: medium
- Program: Teller
- Credited: J4de
- Disclosed: 2023-03-20
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-03-teller-judging/issues/78
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-03-teller%3AM-2
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:liquidation

**Target:** TellerV2 lending contract (Solidity)
**Root cause:** calculateNextDueDate derives due dates via BPBDTL.diffMonths from acceptedTimestamp while _canLiquidateLoan uses block.timestamp - liquidationDelay - lastRepaidTimestamp > defaultDuration, so the liquidation threshold can fall before the quoted repayment due date.
**Steps:**
1. Read `calculateNextDueDate` (L854): computes next due date from `diffMonths(acceptedTimestamp, ...)` per payment cycle.
2. Read `_canLiquidateLoan` (L953): returns `block.timestamp - _liquidationDelay - lastRepaidTimestamp > bidDefaultDuration`.
3. Observe the two use different reference points (acceptedTimestamp vs lastRepaidTimestamp) and different arithmetic (month diff vs raw seconds).
4. Construct a loan where the liquidation timestamp computed by `_canLiquidateLoan` precedes the due date returned by `calculateNextDueDate`.
5. Borrower repays at the quoted due date but is already liquidatable.
**How found:** Code-reading comparison of the two time-calculation functions; noticed the borrower-facing due date and the internal liquidation check use different reference timestamps and arithmetic.
**Insight:** When a protocol exposes a user-facing deadline function and a separate internal enforcement function, diff their reference timestamps and arithmetic — mismatches let users be penalized before their quoted deadline.
