BorrowerOperations

Write Methods

function fetchBalances() public returns (SystemBalances memory balances)

Fetches collateral, debt, and price data for all active collaterals.

Return Value
Type
Description

balances

SystemBalances

Struct containing collateral, debt, and price arrays

function openTrove(
        ITroveManager troveManager,
        address account,
        uint256 _maxFeePercentage,
        uint256 _collateralAmount,
        uint256 _debtAmount,
        uint256 _upperHint,
        uint256 _lowerHint,
        address frontEndId,
        address referrerId,
        bool useNative
    ) external payable

Opens a new trove by depositing collateral and borrowing debt tokens.

Parameter
Type
Description

troveManager

ITroveManager

TroveManager for the collateral

account

address

Owner of the new trove

_maxFeePercentage

uint256

Max borrowing fee percentage (e.g., 1e18 = 100%)

_collateralAmount

uint256

Amount of collateral to deposit

_debtAmount

uint256

Amount of debt to borrow

_upperHint

uint256

Hint for trove insertion (gas optimization)

_lowerHint

uint256

Hint for trove insertion (gas optimization)

frontEndId

address

Address of the front-end operator (optional)

referrerId

address

Address of the referrer (optional)

useNative

bool

Whether to use native ETH (if collateral is native)

Adds collateral to an existing trove.

Parameter
Type
Description

troveManager

ITroveManager

TroveManager for the collateral

_troveId

uint256

ID of the trove to modify

account

address

Owner of the trove

_collateralAmount

uint256

Amount of collateral to add

_upperHint

uint256

Hint for trove reinsertion

_lowerHint

uint256

Hint for trove reinsertion

useNative

bool

Whether to use native ETH

Withdraws collateral from an existing trove.

Parameter
Type
Description

troveManager

ITroveManager

TroveManager for the collateral

account

address

Owner of the trove

_collWithdrawal

uint256

Amount of collateral to withdraw

_upperHint

uint256

Hint for trove reinsertion

_lowerHint

uint256

Hint for trove reinsertion

_troveId

uint256

ID of the trove to modify

_useNative

bool

Whether to receive native ETH

Borrows more debt tokens from an existing trove.

Parameter
Type
Description

troveManager

ITroveManager

TroveManager for the collateral

account

address

Owner of the trove

_maxFeePercentage

uint256

Max borrowing fee percentage

_debtAmount

uint256

Amount of debt to borrow

_upperHint

uint256

Hint for trove reinsertion

_lowerHint

uint256

Hint for trove reinsertion

_troveId

uint256

ID of the trove to modify

_useNative

bool

Whether to use native ETH

Repays debt tokens to an existing trove.

Parameter
Type
Description

troveManager

ITroveManager

TroveManager for the collateral

account

address

Owner of the trove

_debtAmount

uint256

Amount of debt to repay

_upperHint

uint256

Hint for trove reinsertion

_lowerHint

uint256

Hint for trove reinsertion

_troveId

uint256

ID of the trove to modify

Adjusts a trove's collateral and/or debt in a single transaction.

Parameter
Type
Description

troveManager

ITroveManager

TroveManager for the collateral

account

address

Owner of the trove

_maxFeePercentage

uint256

Max borrowing fee percentage

_collDeposit

uint256

Amount of collateral to add (if any)

_collWithdrawal

uint256

Amount of collateral to withdraw (if any)

_debtChange

uint256

Amount of debt to add/repay

_isDebtIncrease

bool

true to borrow, false to repay

_upperHint

uint256

Hint for trove reinsertion

_lowerHint

uint256

Hint for trove reinsertion

_troveId

uint256

ID of the trove to modify

_useNative

bool

Whether to use native ETH

Closes an existing trove by repaying all debt and withdrawing all collateral.

Parameter
Type
Description

troveManager

ITroveManager

TroveManager for the collateral

account

address

Owner of the trove

_troveId

uint256

ID of the trove to close

_useNative

bool

Whether to receive native ETH

Returns the total priced collateral and total debt across all collaterals.

Return Value
Type
Description

totalPricedCollateral

uint256

Total value of all collaterals (priced in debt tokens)

totalDebt

uint256

Total system debt

View Methods

Returns the global Total Collateral Ratio (TCR).

Return Value
Type
Description

globalTotalCollateralRatio

uint256

The global Total Collateral Ratio (TCR)

Checks if the system is in Recovery Mode (TCR < CCR).

Parameter
Type
Description

TCR

uint256

Total Collateral Ratio to check

Return Value
Type
Description

bool

bool

true if TCR < CCR (Recovery Mode), else false

Structs and Enums

Events

Last updated