User can prevent liquidations by frontrunning the tx and slightly increasing their collateral
User can prevent liquidations by frontrunning the tx and decreasing their debt so that the liquidation transaction reverts.\\nIn the liquidation transaction, the caller has to specify the amount of debt they want to liquidate, `_debtAmount`. The maximum value for that parameter is the total amount of debt the user holds:\\n```\\n    function liquidate(\\n        address _account,\\n        uint256 _debtAmount,\\n        uint256 _minExchangeRate\\n    ) external onlyLiquidator whenNotPaused updateReward(_account) returns (bool) {\\n        if (_debtAmount == 0) revert wrongLiquidationAmount();\\n\\n        UserDetails memory accDetails = userDetails[_account];\\n\\n        // Since Taurus accounts' debt continuously decreases, liquidators may pass in an arbitrarily large number in order to\\n        // request to liquidate the entire account.\\n        if (_debtAmount > accDetails.debt) {\\n            _debtAmount = accDetails.debt;\\n        }\\n\\n        // Get total fee charged to the user for this liquidation. Collateral equal to (liquidated taurus debt value * feeMultiplier) will be deducted from the user's account.\\n        // This call reverts if the account is healthy or if the liquidation amount is too large.\\n        (uint256 collateralToLiquidate, uint256 liquidationSurcharge) = _calcLiquidation(\\n            accDetails.collateral,\\n            accDetails.debt,\\n            _debtAmount\\n        );\\n```\\n\\nIn `_calcLiquidation()`, the contract determines how much collateral to liquidate when `_debtAmount` is paid by the caller. In that function, there's a check that reverts if the caller tries to liquidate more than they are allowed to depending on the position's health.\\n```\\n    function _calcLiquidation(\\n        uint256 _accountCollateral,\\n        uint256 _accountDebt,\\n        uint256 _debtToLiquidate\\n    ) internal view returns (uint256 collateralToLiquidate, uint256 liquidationSurcharge) {\\n        // // rest of code \\n        \\n        // Revert if requested liquidation amount is greater than allowed\\n        if (\\n            _debtToLiquidate >\\n            _getMaxLiquidation(_accountCollateral, _accountDebt, price, decimals, totalLiquidationDiscount)\\n        ) revert wrongLiquidationAmount();\\n```\\n\\nThe goal is to get that if-clause to evaluate to `true` so that the transaction reverts. To modify your position's health you have two possibilities: either you increase your collateral or decrease your debt. So instead of preventing the liquidation by pushing your position to a healthy state, you only modify it slightly so that the caller's liquidation transaction reverts.\\nGiven that Alice has:\\n100 TAU debt\\n100 Collateral (price = $1 so that collateralization rate is 1) Her position can be liquidated. The max value is:\\n```\\n    function _getMaxLiquidation(\\n        uint256 _collateral,\\n        uint256 _debt,\\n        uint256 _price,\\n        uint8 _decimals,\\n        uint256 _liquidationDiscount\\n    ) internal pure returns (uint256 maxRepay) {\\n        // Formula to find the liquidation amount is as follows\\n        // [(collateral * price) - (liqDiscount * liqAmount)] / (debt - liqAmount) = max liq ratio\\n        // Therefore\\n        // liqAmount = [(max liq ratio * debt) - (collateral * price)] / (max liq ratio - liqDiscount)\\n        maxRepay =\\n            ((MAX_LIQ_COLL_RATIO * _debt) - ((_collateral * _price * Constants.PRECISION) / (10 ** _decimals))) /\\n            (MAX_LIQ_COLL_RATIO - _liquidationDiscount);\\n\\n        // Liquidators cannot repay more than the account's debt\\n        if (maxRepay > _debt) {\\n            maxRepay = _debt;\\n        }\\n\\n        return maxRepay;\\n    }\\n```\\n\\n$(1.3e18 * 100e18 - (100e18 * 1e18 * 1e18) / 1e18) / 1.3e18 = 23.07e18$ (leave out liquidation discount for easier math)\\nThe liquidator will probably use the maximum amount they can liquidate and call `liquidate()` with `23.07e18`. Alice frontruns the liquidator's transaction and increases the collateral by `1`. That will change the max liquidation amount to: $(1.3e18 * 100e18 - 101e18 * 1e18) / 1.3e18 = 22.3e18$.\\nThat will cause `_calcLiquidation()` to revert because `23.07e18 > 22.3e18`.\\nThe actual amount of collateral to add or debt to decrease depends on the liquidation transaction. But, generally, you would expect the liquidator to liquidate as much as possible. Thus, you only have to slightly move the position to cause their transaction to revert
In `_calcLiquidation()` the function shouldn't revert if _debtToLiqudiate > `_getMaxLiquidation()`. Instead, just continue with the value `_getMaxLiquidation()` returns.
User can prevent liquidations by slightly modifying their position without putting it at a healthy state.
```\\n    function liquidate(\\n        address _account,\\n        uint256 _debtAmount,\\n        uint256 _minExchangeRate\\n    ) external onlyLiquidator whenNotPaused updateReward(_account) returns (bool) {\\n        if (_debtAmount == 0) revert wrongLiquidationAmount();\\n\\n        UserDetails memory accDetails = userDetails[_account];\\n\\n        // Since Taurus accounts' debt continuously decreases, liquidators may pass in an arbitrarily large number in order to\\n        // request to liquidate the entire account.\\n        if (_debtAmount > accDetails.debt) {\\n            _debtAmount = accDetails.debt;\\n        }\\n\\n        // Get total fee charged to the user for this liquidation. Collateral equal to (liquidated taurus debt value * feeMultiplier) will be deducted from the user's account.\\n        // This call reverts if the account is healthy or if the liquidation amount is too large.\\n        (uint256 collateralToLiquidate, uint256 liquidationSurcharge) = _calcLiquidation(\\n            accDetails.collateral,\\n            accDetails.debt,\\n            _debtAmount\\n        );\\n```\\n