{
    "Function": "_redeemCollateralFromTrove",
    "File": "contracts/src/TroveManager.sol",
    "Parent Contracts": [
        "contracts/src/Interfaces/ITroveEvents.sol",
        "contracts/src/Interfaces/ITroveManager.sol",
        "contracts/src/Dependencies/LiquityBase.sol",
        "contracts/src/Interfaces/ILiquityBase.sol"
    ],
    "High-Level Calls": [
        "ISortedTroves",
        "LiquityMath",
        "ISortedTroves"
    ],
    "Internal Calls": [
        "_applySingleRedemption",
        "_getLatestTroveData"
    ],
    "Library Calls": [
        "_min"
    ],
    "Low-Level Calls": [],
    "Code": "function _redeemCollateralFromTrove(\n        IDefaultPool _defaultPool,\n        SingleRedemptionValues memory _singleRedemption,\n        uint256 _maxBoldamount,\n        uint256 _price,\n        uint256 _redemptionRate\n    ) internal {\n        _getLatestTroveData(_singleRedemption.troveId, _singleRedemption.trove);\n\n        // Determine the remaining amount (lot) to be redeemed, capped by the entire debt of the Trove\n        _singleRedemption.boldLot = LiquityMath._min(_maxBoldamount, _singleRedemption.trove.entireDebt);\n\n        // Get the amount of Coll equal in USD value to the boldLot redeemed\n        uint256 correspondingColl = (_singleRedemption.boldLot * DECIMAL_PRECISION) / _price;\n        // Calculate the collFee separately (for events)\n        _singleRedemption.collFee = (correspondingColl * _redemptionRate) / DECIMAL_PRECISION;\n        // Get the final collLot to send to redeemer, leaving the fee in the Trove\n        _singleRedemption.collLot = correspondingColl - _singleRedemption.collFee;\n\n        bool isTroveInBatch = _singleRedemption.batchAddress != address(0);\n        uint256 newDebt = _applySingleRedemption(_defaultPool, _singleRedemption, isTroveInBatch);\n\n        // Make Trove zombie if it's tiny (and it wasn\u2019t already), in order to prevent griefing future (normal, sequential) redemptions\n        if (newDebt < MIN_DEBT) {\n            if (!_singleRedemption.isZombieTrove) {\n                Troves[_singleRedemption.troveId].status = Status.zombie;\n                if (isTroveInBatch) {\n                    sortedTroves.removeFromBatch(_singleRedemption.troveId);\n                } else {\n                    sortedTroves.remove(_singleRedemption.troveId);\n                }\n                // If it\u2019s a partial redemption, let\u2019s store a pointer to it so it\u2019s used first in the next one\n                if (newDebt > 0) {\n                    lastZombieTroveId = _singleRedemption.troveId;\n                }\n            } else if (newDebt == 0) {\n                // Reset last zombie trove pointer if the previous one was fully redeemed now\n                lastZombieTroveId = 0;\n            }\n        }\n        // Note: technically, it could happen that the Trove pointed to by `lastZombieTroveId` ends up with\n        // newDebt >= MIN_DEBT thanks to BOLD debt redistribution, which means it _could_ be made active again,\n        // however we don't do that here, as it would require hints for re-insertion into `SortedTroves`.\n    }"
}