> ## 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.

# Borrower Operations

Unlock the power of your collateral with the Borrower Operations contract. This crucial component of the Roots protocol empowers users to manage their financial positions (Troves) with precision. Explore functions for opening new Troves, adjusting existing collateral and debt levels, claiming rewards, and more. Key events will keep you informed of every significant operation.

## Functions

### `CCR()`

Returns the Collateralization Ratio of the system. (View)

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

### `DEBT_GAS_COMPENSATION()`

Returns the gas compensation amount for debt-related operations. (View)

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

### `DECIMAL_PRECISION()`

Returns the decimal precision used in calculations. (View)

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

### `PERCENT_DIVISOR()`

Returns the divisor used 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]
```

### `addColl`

Adds collateral to a user's Trove.

```solidity theme={null}
function addColl(troveManager: address (contract ITroveManager), account: address, _collateralAmount: uint256, _upperHint: address, _lowerHint: address) [nonpayable]
```

### `adjustTrove`

Adjusts a user's Trove by depositing/withdrawing collateral and/or increasing/decreasing debt.

```solidity theme={null}
function adjustTrove(troveManager: address (contract ITroveManager), account: address, _maxFeePercentage: uint256, _collDeposit: uint256, _collWithdrawal: uint256, _debtChange: uint256, _isDebtIncrease: bool, _upperHint: address, _lowerHint: address) [nonpayable]
```

### `checkRecoveryMode`

Checks if the system is in recovery mode based on the provided Total Collateralization Ratio (TCR). (Pure)

```solidity theme={null}
function checkRecoveryMode(TCR: uint256) -> bool [pure]
```

### `claimRewards`

Claims rewards for a user from specified Trove Managers.

```solidity theme={null}
function claimRewards(_to: address, _troveManagerIndexes: uint256[]) [nonpayable]
```

### `closeTrove`

Closes a user's Trove.

```solidity theme={null}
function closeTrove(troveManager: address (contract ITroveManager), account: address) [nonpayable]
```

### `configureCollateral`

Configures a collateral token for a specific Trove Manager.

```solidity theme={null}
function configureCollateral(troveManager: address (contract ITroveManager), collateralToken: address (contract IERC20)) [nonpayable]
```

### `debtToken()`

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

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

### `factory()`

Returns the factory address. (View)

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

### `fetchBalances()`

Fetches system balances. (Nonpayable)

```solidity theme={null}
function fetchBalances() -> tuple (struct IBorrowerOperations.SystemBalances) [nonpayable]
```

### `getCompositeDebt`

Calculates the composite debt including fees. (View)

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

### `getGlobalSystemBalances()`

Gets the global system balances. (Nonpayable)

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

### `getTCR()`

Gets the Total Collateralization Ratio of the system. (Nonpayable)

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

### `guardian()`

Returns the guardian address. (View)

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

### `initialize`

Initializes the BorrowerOperations contract.

```solidity theme={null}
function initialize(_debtTokenAddress: address, _factory: address) [nonpayable]
```

### `isApprovedDelegate`

Checks if a caller is an approved delegate for an owner. (View)

```solidity theme={null}
function isApprovedDelegate(owner: address, caller: address) -> bool [view]
```

### `minNetDebt()`

Returns the minimum net debt required for a Trove. (View)

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

### `openTrove`

Opens a new Trove for a user with specified collateral and debt amounts.

```solidity theme={null}
function openTrove(troveManager: address (contract ITroveManager), account: address, _maxFeePercentage: uint256, _collateralAmount: uint256, _debtAmount: uint256, _upperHint: address, _lowerHint: address) [nonpayable]
```

### `owner()`

Returns the owner address of the contract. (View)

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

### `removeTroveManager`

Removes a Trove Manager from the system.

```solidity theme={null}
function removeTroveManager(troveManager: address (contract ITroveManager)) [nonpayable]
```

### `repayDebt`

Repays a specified amount of debt for a user's Trove.

```solidity theme={null}
function repayDebt(troveManager: address (contract ITroveManager), account: address, _debtAmount: uint256, _upperHint: address, _lowerHint: address) [nonpayable]
```

### `setDelegateApproval`

Sets or revokes delegate approval for an address.

```solidity theme={null}
function setDelegateApproval(_delegate: address, _isApproved: bool) [nonpayable]
```

### `setMinNetDebt`

Sets the minimum net debt for Troves.

```solidity theme={null}
function setMinNetDebt(_minNetDebt: uint256) [nonpayable]
```

### `troveManagersData`

Returns data for a specific Trove Manager, including its collateral token and other parameters. (View)

```solidity theme={null}
function troveManagersData(troveManager: address (contract ITroveManager)) -> (address (contract IERC20), uint16) [view]
```

### `withdrawColl`

Withdraws collateral from a user's Trove.

```solidity theme={null}
function withdrawColl(troveManager: address (contract ITroveManager), account: address, _collWithdrawal: uint256, _upperHint: address, _lowerHint: address) [nonpayable]
```

### `withdrawDebt`

Withdraws (borrows) a specified amount of debt from a user's Trove.

```solidity theme={null}
function withdrawDebt(troveManager: address (contract ITroveManager), account: address, _maxFeePercentage: uint256, _debtAmount: uint256, _upperHint: address, _lowerHint: address) [nonpayable]
```

## Events

### `BorrowingFeePaid` (Version 1)

Emitted when a borrowing fee is paid, specifying the collateral token.

```solidity theme={null}
event BorrowingFeePaid(borrower: address, collateralToken: address (contract IERC20), amount: uint256)
```

### `BorrowingFeePaid` (Version 2)

Emitted when a borrowing fee is paid.

```solidity theme={null}
event BorrowingFeePaid(borrower: address, amount: uint256)
```

### `CollateralConfigured`

Emitted when a collateral token is configured for a Trove Manager.

```solidity theme={null}
event CollateralConfigured(troveManager: address (contract ITroveManager), collateralToken: address (contract IERC20))
```

### `DelegateApprovalSet`

Emitted when delegate approval status is changed for a caller.

```solidity theme={null}
event DelegateApprovalSet(caller: address, delegate: address, isApproved: bool)
```

### `TroveCreated`

Emitted when a new Trove is created.

```solidity theme={null}
event TroveCreated(_borrower: address, arrayIndex: uint256)
```

### `TroveManagerRemoved`

Emitted when a Trove Manager is removed.

```solidity theme={null}
event TroveManagerRemoved(troveManager: address (contract ITroveManager))
```

### `TroveUpdated`

Emitted when a Trove is updated.

```solidity theme={null}
event TroveUpdated(_borrower: address, _debt: uint256, _coll: uint256, stake: uint256, operation: uint8)
```
