# Liquity TroveManager TCR miscalculation in batchLiquidateTroves

Source: https://junglewise.ai/threats/liquity-trovemanager-tcr-miscalculation-in-batchliquidatetroves-afec4433  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2021-08-05. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

Severity: low · CVSS 3.1 · Published 2021-08-05

Liquity is a decentralized borrowing protocol that allows users to take loans backed by cryptocurrency collateral. A calculation bug in the batch liquidation function temporarily miscalculates the Total Collateral Ratio (TCR) during Recovery Mode, potentially causing the system to exit Recovery Mode prematurely and liquidate troves that should not be liquidated. This could expose stability providers to losses that should otherwise be borne by borrowers, though the impact occurs only in narrow, specific circumstances with particular market and transaction ordering conditions.

Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is This vulnerability exploited in the wild?** No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.

**How severe is This vulnerability?** Low severity, with a CVSS score of 3.1, published 5 August 2021.

**Which products and versions are affected?** @liquity/contracts (npm) SEMVER:introduced=0,last_affected=1.0.0.

**Is there a fix for This vulnerability?** No fixed version is recorded yet. Check the vendor's advisory in the references below. If you run it, Junglewise drafts a mitigation that fits your setup and applies it once you approve, with senior security engineers behind it.

**How is This vulnerability attacked?** It is attacked over the network.

**Am I affected?** Check whether you run @liquity/contracts (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## Technical details

The vulnerability is an incorrect arithmetic calculation in the batchLiquidateTroves() function within TroveManager.sol. When computing the system's entire collateral during batch liquidation in Recovery Mode, the function fails to exclude the liquidated trove's surplus collateral, which should be removed from the calculation since liquidation makes that surplus claimable by the trove owner. This temporary miscalculation causes the TCR check to be inaccurate for the duration of the transaction. The bug requires a specific set of preconditions: the system must be in Recovery Mode with TCR near the 150% boundary (within 0.53% margin for a 1% collateral trove), and liquidations must be ordered in a particular sequence to trigger the distortion. No authentication is required; the attack vector is network-based. Once the transaction completes, the TCR is recalculated correctly. No mainnet patch has been deployed due to the protocol's immutability and the low severity of the issue.

## Affected products

- Liquity contracts 1.0.0 and earlier

## Timeline

- 2021-07-09: disclosed
- 2021-08-05: advisory

## References

- [https://github.com/liquity/dev/security/advisories/GHSA-xh2p-7p87-fhgh](https://github.com/liquity/dev/security/advisories/GHSA-xh2p-7p87-fhgh)
- [https://github.com/liquity/dev/commit/c69d0bae30b5457e89724d880851a03ba7477905](https://github.com/liquity/dev/commit/c69d0bae30b5457e89724d880851a03ba7477905)
