> ## Documentation Index
> Fetch the complete documentation index at: https://rootsfi.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Trove Manager

Step into the heart of individual collateralized debt positions with the Trove Manager. This contract is the central hub for all operations related to a specific collateral type, managing its Troves, associated fees, rates, and overall system health for that asset. Explore its comprehensive suite of functions for opening Troves, managing debt and collateral, processing redemptions, and handling liquidations, along with events that track every critical state change.

## Functions

### `BOOTSTRAP_PERIOD()`

Returns the duration of the bootstrap period. (View)

```solidity theme={null}
function BOOTSTRAP_PERIOD() -> uint256 [view]
```

### `CCR()`

Returns the Collateralization Ratio of this Trove Manager. (View)

```solidity theme={null}
function CCR() -> uint256 [view]
```

### `DEBT_GAS_COMPENSATION()`

Returns the gas compensation for debt operations. (View)

```solidity theme={null}
function DEBT_GAS_COMPENSATION() -> uint256 [view]
```

### `DECIMAL_PRECISION()`

Returns the decimal precision used. (View)

```solidity theme={null}
function DECIMAL_PRECISION() -> uint256 [view]
```

### `L_collateral()`

Returns the L\_collateral term for reward calculations. (View)

```solidity theme={null}
function L_collateral() -> uint256 [view]
```

### `L_debt()`

Returns the L\_debt term for reward calculations. (View)

```solidity theme={null}
function L_debt() -> uint256 [view]
```

### `MAX_INTEREST_RATE_IN_BPS()`

Returns the maximum interest rate in basis points. (View)

```solidity theme={null}
function MAX_INTEREST_RATE_IN_BPS() -> uint256 [view]
```

### `MCR()`

Returns the Minimum Collateralization Ratio for Troves in this manager. (View)

```solidity theme={null}
function MCR() -> uint256 [view]
```

### `PERCENT_DIVISOR()`

Returns the divisor for percentage calculations. (View)

```solidity theme={null}
function PERCENT_DIVISOR() -> uint256 [view]
```

### `ROOTS_CORE()`

Returns the address of the `IRootsCore` contract. (View)

```solidity theme={null}
function ROOTS_CORE() -> address (contract IRootsCore) [view]
```

### `SUNSETTING_INTEREST_RATE()`

Returns the interest rate applied during the sunsetting period. (View)

```solidity theme={null}
function SUNSETTING_INTEREST_RATE() -> uint256 [view]
```

### `Troves`

Returns details of a specific Trove. (View)

```solidity theme={null}
function Troves(_account: address) -> (uint256, uint256, uint256, uint8 (enum ITroveManager.Status), uint128, uint256) [view]
```

### `activeInterestIndex()`

Returns the current active interest index. (View)

```solidity theme={null}
function activeInterestIndex() -> uint256 [view]
```

### `addCollateralSurplus`

Adds collateral surplus to a borrower's account (typically after liquidation).

```solidity theme={null}
function addCollateralSurplus(borrower: address, collSurplus: uint256) [nonpayable]
```

### `applyPendingRewards`

Applies pending rewards to a borrower's Trove.

```solidity theme={null}
function applyPendingRewards(_borrower: address) -> (uint256, uint256) [nonpayable]
```

### `baseRate()`

Returns the current base rate for borrowing fees. (View)

```solidity theme={null}
function baseRate() -> uint256 [view]
```

### `borrowerOperationsAddress()`

Returns the address of the Borrower Operations contract. (View)

```solidity theme={null}
function borrowerOperationsAddress() -> address [view]
```

### `borrowingFeeFloor()`

Returns the floor for borrowing fees. (View)

```solidity theme={null}
function borrowingFeeFloor() -> uint256 [view]
```

### `claimCollateral`

Allows a user to claim their collateral surplus.

```solidity theme={null}
function claimCollateral(_receiver: address) [nonpayable]
```

### `claimReward` (Version 1)

Claims rewards for a specified 'from' address to a 'receiver'.

```solidity theme={null}
function claimReward(_from: address, _receiver: address) -> uint256 [nonpayable]
```

### `claimReward` (Version 2)

Claims rewards for the message sender.

```solidity theme={null}
function claimReward() -> uint256 [nonpayable]
```

### `claimReward` (Version 3)

Claims rewards for the message sender to a specified 'receiver'.

```solidity theme={null}
function claimReward(_receiver: address) -> uint256 [nonpayable]
```

### `claimableReward`

Returns the amount of reward a borrower can claim.

```solidity theme={null}
function claimableReward(_borrower: address) -> uint256 [nonpayable]
```

### `closeTrove`

Closes a borrower's Trove.

```solidity theme={null}
function closeTrove(_borrower: address, _receiver: address, collAmount: uint256, debtAmount: uint256) [nonpayable]
```

### `closeTroveByLiquidation`

Closes a Trove due to liquidation.

```solidity theme={null}
function closeTroveByLiquidation(_borrower: address) [nonpayable]
```

### `collateralToken()`

Returns the address of the collateral token for this Trove Manager. (View)

```solidity theme={null}
function collateralToken() -> address (contract IERC20) [view]
```

### `collectInterests`

Collects accrued interest, updating relevant system parameters.

```solidity theme={null}
function collectInterests() [nonpayable]
```

### `debtToken()`

Returns the address of the `IDebtToken` contract. (View)

```solidity theme={null}
function debtToken() -> address (contract IDebtToken) [view]
```

### `decayBaseRateAndGetBorrowingFee`

Decays the base rate and returns the current borrowing fee for a given debt amount.

```solidity theme={null}
function decayBaseRateAndGetBorrowingFee(_debt: uint256) -> uint256 [nonpayable]
```

### `decreaseDebtAndSendCollateral`

Decreases debt and sends collateral, typically during redemptions.

```solidity theme={null}
function decreaseDebtAndSendCollateral(account: address, debt: uint256, coll: uint256) [nonpayable]
```

### `defaultedCollateral()`

Returns the amount of collateral defaulted in this Trove Manager. (View)

```solidity theme={null}
function defaultedCollateral() -> uint256 [view]
```

### `defaultedDebt()`

Returns the amount of debt defaulted in this Trove Manager. (View)

```solidity theme={null}
function defaultedDebt() -> uint256 [view]
```

### `emissionId()`

Returns emission IDs related to this Trove Manager. (View)

```solidity theme={null}
function emissionId() -> (uint16, uint16) [view]
```

### `fetchPrice()`

Fetches the current price of the collateral token from the price feed.

```solidity theme={null}
function fetchPrice() -> uint256 [nonpayable]
```

### `finalizeLiquidation`

Finalizes a liquidation process, distributing collateral and gas compensation.

```solidity theme={null}
function finalizeLiquidation(_liquidator: address, _debt: uint256, _coll: uint256, _collSurplus: uint256, _debtGasComp: uint256, _collGasComp: uint256) [nonpayable]
```

### `getBorrowingFee`

Calculates the current borrowing fee for a given debt amount without decaying the base rate. (View)

```solidity theme={null}
function getBorrowingFee(_debt: uint256) -> uint256 [view]
```

### `getBorrowingFeeWithDecay`

Calculates the current borrowing fee for a given debt amount after decaying the base rate. (View)

```solidity theme={null}
function getBorrowingFeeWithDecay(_debt: uint256) -> uint256 [view]
```

### `getBorrowingRate()`

Returns the current borrowing rate without decaying. (View)

```solidity theme={null}
function getBorrowingRate() -> uint256 [view]
```

### `getBorrowingRateWithDecay()`

Returns the current borrowing rate after decaying. (View)

```solidity theme={null}
function getBorrowingRateWithDecay() -> uint256 [view]
```

### `getCurrentICR`

Calculates the Individual Collateralization Ratio (ICR) of a borrower's Trove at a given price. (View)

```solidity theme={null}
function getCurrentICR(_borrower: address, _price: uint256) -> uint256 [view]
```

### `getEntireDebtAndColl`

Returns the entire debt and collateral details for a borrower. (View)

```solidity theme={null}
function getEntireDebtAndColl(_borrower: address) -> (uint256, uint256, uint256, uint256) [view]
```

### `getEntireSystemBalances()`

Returns the entire system balances for this Trove Manager.

```solidity theme={null}
function getEntireSystemBalances() -> (uint256, uint256, uint256) [nonpayable]
```

### `getEntireSystemColl()`

Returns the total collateral in the system for this Trove Manager. (View)

```solidity theme={null}
function getEntireSystemColl() -> uint256 [view]
```

### `getEntireSystemDebt()`

Returns the total debt in the system for this Trove Manager. (View)

```solidity theme={null}
function getEntireSystemDebt() -> uint256 [view]
```

### `getNominalICR`

Calculates the nominal ICR of a borrower's Trove (ICR at a price of 1). (View)

```solidity theme={null}
function getNominalICR(_borrower: address) -> uint256 [view]
```

### `getPendingCollAndDebtRewards`

Returns the pending collateral and debt rewards for a borrower. (View)

```solidity theme={null}
function getPendingCollAndDebtRewards(_borrower: address) -> (uint256, uint256) [view]
```

### `getRedemptionFeeWithDecay`

Calculates the redemption fee for a given amount of collateral drawn, after decaying the base rate. (View)

```solidity theme={null}
function getRedemptionFeeWithDecay(_collateralDrawn: uint256) -> uint256 [view]
```

### `getRedemptionRate()`

Returns the current redemption rate without decaying. (View)

```solidity theme={null}
function getRedemptionRate() -> uint256 [view]
```

### `getRedemptionRateWithDecay()`

Returns the current redemption rate after decaying. (View)

```solidity theme={null}
function getRedemptionRateWithDecay() -> uint256 [view]
```

### `getTotalActiveCollateral()`

Returns the total active collateral in this Trove Manager. (View)

```solidity theme={null}
function getTotalActiveCollateral() -> uint256 [view]
```

### `getTotalActiveDebt()`

Returns the total active debt in this Trove Manager. (View)

```solidity theme={null}
function getTotalActiveDebt() -> uint256 [view]
```

### `getTroveCollAndDebt`

Returns the collateral and debt of a specific Trove. (View)

```solidity theme={null}
function getTroveCollAndDebt(_borrower: address) -> (uint256, uint256) [view]
```

### `getTroveFromTroveOwnersArray`

Returns a Trove owner's address from the array by index. (View)

```solidity theme={null}
function getTroveFromTroveOwnersArray(_index: uint256) -> address [view]
```

### `getTroveOwnersCount()`

Returns the total number of Trove owners. (View)

```solidity theme={null}
function getTroveOwnersCount() -> uint256 [view]
```

### `getTroveStake`

Returns the stake associated with a borrower's Trove. (View)

```solidity theme={null}
function getTroveStake(_borrower: address) -> uint256 [view]
```

### `getTroveStatus`

Returns the status of a borrower's Trove. (View)

```solidity theme={null}
function getTroveStatus(_borrower: address) -> uint256 [view]
```

### `getWeek()`

Returns the current week. (View)

```solidity theme={null}
function getWeek() -> uint256 [view]
```

### `getWeekAndDay()`

Returns the current week and day. (View)

```solidity theme={null}
function getWeekAndDay() -> (uint256, uint256) [view]
```

### `guardian()`

Returns the guardian address. (View)

```solidity theme={null}
function guardian() -> address [view]
```

### `hasPendingRewards`

Checks if a borrower has pending rewards. (View)

```solidity theme={null}
function hasPendingRewards(_borrower: address) -> bool [view]
```

### `interestPayable()`

Returns the amount of interest currently payable. (View)

```solidity theme={null}
function interestPayable() -> uint256 [view]
```

### `interestRate()`

Returns the current interest rate. (View)

```solidity theme={null}
function interestRate() -> uint256 [view]
```

### `lastActiveIndexUpdate()`

Returns the timestamp of the last active index update. (View)

```solidity theme={null}
function lastActiveIndexUpdate() -> uint256 [view]
```

### `lastCollateralError_Redistribution()`

Returns the last collateral error from redistribution. (View)

```solidity theme={null}
function lastCollateralError_Redistribution() -> uint256 [view]
```

### `lastDebtError_Redistribution()`

Returns the last debt error from redistribution. (View)

```solidity theme={null}
function lastDebtError_Redistribution() -> uint256 [view]
```

### `lastFeeOperationTime()`

Returns the timestamp of the last fee operation. (View)

```solidity theme={null}
function lastFeeOperationTime() -> uint256 [view]
```

### `liquidationManager()`

Returns the address of the Liquidation Manager contract. (View)

```solidity theme={null}
function liquidationManager() -> address [view]
```

### `maxBorrowingFee()`

Returns the maximum borrowing fee. (View)

```solidity theme={null}
function maxBorrowingFee() -> uint256 [view]
```

### `maxRedemptionFee()`

Returns the maximum redemption fee. (View)

```solidity theme={null}
function maxRedemptionFee() -> uint256 [view]
```

### `maxSystemDebt()`

Returns the maximum system debt allowed for this Trove Manager. (View)

```solidity theme={null}
function maxSystemDebt() -> uint256 [view]
```

### `minuteDecayFactor()`

Returns the minute decay factor for fee calculations. (View)

```solidity theme={null}
function minuteDecayFactor() -> uint256 [view]
```

### `movePendingTroveRewardsToActiveBalances`

Moves pending Trove rewards to active balances for a given debt and collateral amount.

```solidity theme={null}
function movePendingTroveRewardsToActiveBalances(_debt: uint256, _collateral: uint256) [nonpayable]
```

### `openTrove`

Opens a new Trove for a borrower.

```solidity theme={null}
function openTrove(_borrower: address, _collateralAmount: uint256, _compositeDebt: uint256, NICR: uint256, _upperHint: address, _lowerHint: address) -> (uint256, uint256) [nonpayable]
```

### `owner()`

Returns the owner address of the contract. (View)

```solidity theme={null}
function owner() -> address [view]
```

### `paused()`

Returns true if the contract is paused, false otherwise. (View)

```solidity theme={null}
function paused() -> bool [view]
```

### `priceFeed()`

Returns the address of the `IPriceFeed` contract. (View)

```solidity theme={null}
function priceFeed() -> address (contract IPriceFeed) [view]
```

### `redeemCollateral`

Processes a collateral redemption request.

```solidity theme={null}
function redeemCollateral(_debtAmount: uint256, _firstRedemptionHint: address, _upperPartialRedemptionHint: address, _lowerPartialRedemptionHint: address, _partialRedemptionHintNICR: uint256, _maxIterations: uint256, _maxFeePercentage: uint256) [nonpayable]
```

### `redemptionFeeFloor()`

Returns the floor for redemption fees. (View)

```solidity theme={null}
function redemptionFeeFloor() -> uint256 [view]
```

### `rewardSnapshots`

Returns reward snapshot data for a given account. (View)

```solidity theme={null}
function rewardSnapshots(_account: address) -> (uint256, uint256) [view]
```

### `setAddresses`

Sets essential contract addresses. *Note: This function signature seems to be duplicated from a general parameter configuration context and might be specific to this TroveManager's setup if it only sets limited addresses.*

```solidity theme={null}
function setAddresses(_priceFeedAddress: address, _sortedTrovesAddress: address, _collateralToken: address) [nonpayable]
```

### `setParameters`

Configures various system parameters for this Trove Manager.

```solidity theme={null}
function setParameters(_minuteDecayFactor: uint256, _redemptionFeeFloor: uint256, _maxRedemptionFee: uint256, _borrowingFeeFloor: uint256, _maxBorrowingFee: uint256, _interestRateInBPS: uint256, _maxSystemDebt: uint256, _MCR: uint256) [nonpayable]
```

### `setPaused`

Pauses or unpauses the contract.

```solidity theme={null}
function setPaused(_paused: bool) [nonpayable]
```

### `setPriceFeed`

Sets the price feed address for this Trove Manager.

```solidity theme={null}
function setPriceFeed(_priceFeedAddress: address) [nonpayable]
```

### `setStaker`

Sets the Staker contract address.

```solidity theme={null}
function setStaker(_staker: address) [nonpayable]
```

### `sortedTroves()`

Returns the address of the `ISortedTroves` contract. (View)

```solidity theme={null}
function sortedTroves() -> address (contract ISortedTroves) [view]
```

### `staker()`

Returns the address of the `IStaker` contract. (View)

```solidity theme={null}
function staker() -> address (contract IStaker) [view]
```

### `startSunset()`

Initiates the sunset mode for this Trove Manager.

```solidity theme={null}
function startSunset() [nonpayable]
```

### `sunsetting()`

Returns true if this Trove Manager is in sunset mode. (View)

```solidity theme={null}
function sunsetting() -> bool [view]
```

### `surplusBalances`

Returns surplus balance for a given account. (View)

```solidity theme={null}
function surplusBalances(_account: address) -> uint256 [view]
```

### `systemDeploymentTime()`

Returns the system deployment time. (View)

```solidity theme={null}
function systemDeploymentTime() -> uint256 [view]
```

### `totalCollateralSnapshot()`

Returns the total collateral snapshot. (View)

```solidity theme={null}
function totalCollateralSnapshot() -> uint256 [view]
```

### `totalStakes()`

Returns the total stakes. (View)

```solidity theme={null}
function totalStakes() -> uint256 [view]
```

### `totalStakesSnapshot()`

Returns the total stakes snapshot. (View)

```solidity theme={null}
function totalStakesSnapshot() -> uint256 [view]
```

### `updateBalances()`

Updates balances, likely related to rewards or interest.

```solidity theme={null}
function updateBalances() [nonpayable]
```

### `updateTroveFromAdjustment`

Updates a Trove based on an adjustment operation.

```solidity theme={null}
function updateTroveFromAdjustment(_isDebtIncrease: bool, _debtChange: uint256, _netDebtChange: uint256, _isCollIncrease: bool, _collChange: uint256, _upperHint: address, _lowerHint: address, _borrower: address, _receiver: address) -> (uint256, uint256, uint256) [nonpayable]
```

## Events

### `BaseRateUpdated`

Emitted when the base rate for borrowing fees is updated.

```solidity theme={null}
event BaseRateUpdated(_baseRate: uint256)
```

### `CollateralSent`

Emitted when collateral is sent from the Trove Manager.

```solidity theme={null}
event CollateralSent(_to: address, _amount: uint256)
```

### `LTermsUpdated`

Emitted when L\_collateral and L\_debt terms are updated.

```solidity theme={null}
event LTermsUpdated(_L_collateral: uint256, _L_debt: uint256)
```

### `LastFeeOpTimeUpdated`

Emitted when the last fee operation time is updated.

```solidity theme={null}
event LastFeeOpTimeUpdated(_lastFeeOpTime: uint256)
```

### `Redemption`

Emitted upon a redemption operation processed by this Trove Manager.

```solidity theme={null}
event Redemption(_attemptedDebtAmount: uint256, _actualDebtAmount: uint256, _collateralSent: uint256, _collateralFee: uint256)
```

### `RewardClaimed`

Emitted when rewards are claimed.

```solidity theme={null}
event RewardClaimed(account: address, recipient: address, claimed: uint256)
```

### `SystemSnapshotsUpdated`

Emitted when system-wide snapshots are updated.

```solidity theme={null}
event SystemSnapshotsUpdated(_totalStakesSnapshot: uint256, _totalCollateralSnapshot: uint256)
```

### `TotalStakesUpdated`

Emitted when total stakes are updated.

```solidity theme={null}
event TotalStakesUpdated(_newTotalStakes: uint256)
```

### `TroveIndexUpdated`

Emitted when a Trove's index in the sorted list is updated.

```solidity theme={null}
event TroveIndexUpdated(_borrower: address, _newIndex: uint256)
```

### `TroveSnapshotsUpdated`

Emitted when a Trove's reward snapshots are updated.

```solidity theme={null}
event TroveSnapshotsUpdated(_L_collateral: uint256, _L_debt: uint256)
```

### `TroveUpdated`

Emitted when a Trove is updated (creation, adjustment, liquidation).

```solidity theme={null}
event TroveUpdated(_borrower: address, _debt: uint256, _coll: uint256, _stake: uint256, _operation: uint8 (enum ITroveManager.TroveManagerOperation))
```
