TroveManager

Write Methods

function collectInterests() external

Mints accumulated interest to the fee receiver. Reverts if no interest is payable.

function fetchPrice() public returns (uint256)

Fetches the latest collateral price from the price feed contract.

Return Values:

Value
Type
Description

price

uint256

Current price of collateral from the price feed

function getEntireSystemBalances() external returns (uint256, uint256, uint256)

Returns a snapshot of the system's total collateral, debt, and current price in one call.

Return Values:

Value
Type
Description

totalCollateral

uint256

Sum of active + defaulted collateral

totalDebt

uint256

Sum of active + defaulted debt (with interest)

price

uint256

Current collateral price from oracle

function claimCollateral(uint256 _troveId, address _receiver, bool _useNative) external

Claims remaining collateral from a closed trove. Only callable by trove owner.

Input Parameters:

Parameter
Type
Description

_troveId

uint256

ID of the trove

_receiver

address

Address to receive collateral

_useNative

bool

Whether to send native ETH

Return Values:

Value
Type
Description

None

-

Function does not return a value

Allows front-end operators to collect accrued interest.

Input Parameters:

Parameter
Type
Description

frontEndId

address

Front-end operator address

Return Values:

Value
Type
Description

None

-

Function does not return a value

View Methods

Returns the most recent price without updating it (gas-efficient).

Return Values:

Value
Type
Description

price

uint256

Last recorded price of collateral (cached)

Calculates the current week and day based on the system’s start time.

Return Values:

Value
Type
Description

week

uint256

Current week since system start

day

uint256

Current day within the week (0–6)

Returns the volume of debt minted per day in a specific week.

Input Parameters:

Parameter
Type
Description

week

uint256

Week number to query

Return Values:

Value
Type
Description

mints

uint32[7]

Array of daily mint amounts for the week

Returns the length of the TroveIds array.

Return Values:

Value
Type
Description

count

uint256

Total number of active troves

Returns a trove ID from the active troves array.

Input Parameters:

Parameter
Type
Description

arrayIndex

uint256

Index in the TroveIds array

Return Values:

Value
Type
Description

troveId

uint256

ID of the trove at the given index

Fetches all trove data (collateral, debt, status, etc.) for a given owner.

Input Parameters:

Parameter
Type
Description

account

address

Owner of the troves

Return Values:

Value
Type
Description

troves

Trove[]

Array of all troves owned by account

Returns the complete data structure for a specific trove.

Input Parameters:

Parameter
Type
Description

_troveId

uint256

ID of the trove

Return Values:

Value
Type
Description

trove

Trove

Struct containing: - debt (uint256) - coll (uint256) - stake (uint256) - status (Status enum) - arrayIndex (uint128) - activeInterestIndex (uint256) - frontEndId (address) - referrerId (address)

Returns the status of a trove (e.g., active, closedByLiquidation).

Input Parameters:

Parameter
Type
Description

_troveId

uint256

ID of the trove

Return Values:

Value
Type
Description

status

uint256

Trove status (0–4, matching Status enum)

Returns the stake (collateral-weighted value) of a trove.

Input Parameters:

Parameter
Type
Description

_troveId

uint256

ID of the trove

Return Values:

Value
Type
Description

stake

uint256

Stake amount for the trove

Returns trove collateral and debt (view).

Input Parameters:

Parameter
Type
Description

_troveId

uint256

ID of the trove

Return Values:

Value
Type
Description

coll

uint256

Total collateral in the trove

debt

uint256

Total debt in the trove

Returns the full state of a trove, including pending rewards.

Input Parameters:

Parameter
Type
Description

_troveId

uint256

ID of the trove

Return Values:

Value
Type
Description

debt

uint256

Total debt (including pending rewards)

coll

uint256

Total collateral (including pending rewards)

pendingDebtReward

uint256

Pending debt redistribution reward

pendingCollateralReward

uint256

Pending collateral redistribution reward

Returns the total collateral locked in the system.

Return Values:

Value
Type
Description

totalCollateral

uint256

Sum of active + defaulted collateral

Returns the total debt in the system, including pending interest.

Return Values:

Value
Type
Description

totalDebt

uint256

Sum of active + defaulted debt (with accrued interest)

Returns nominal collateral ratio (view).

Input Parameters:

Parameter
Type
Description

_troveId

uint256

ID of the trove

_price

uint256 (only for getCurrentICR)

Current price of collateral

Return Values:

Value
Type
Description

ICR

uint256

Collateral ratio (nominal or current)

Input Parameters:

Parameter
Type
Description

_troveId

uint256

ID of the trove

_price

uint256 (only for getCurrentICR)

Current price of collateral

Return Values:

Value
Type
Description

ICR

uint256

Collateral ratio (nominal or current)

Sum of collateral in all non-liquidated/non-redeemed troves.

Return Values:

Value
Type
Description

activeCollateral

uint256

Total collateral in active troves (excluding defaulted)

Calculates active debt with compounded interest since last update.

Return Values:

Value
Type
Description

activeDebt

uint256

Total debt in active troves (including accrued interest)

Computes unclaimed rewards from liquidations affecting the trove.

Input Parameters:

Parameter
Type
Description

_troveId

uint256

ID of the trove

Return Values:

Value
Type
Description

pendingCollateral

uint256

Pending collateral from redistributions

pendingDebt

uint256

Pending debt from redistributions

Returns the address of the TroveNFT contract (used for ownership checks).

Return Values:

Value
Type
Description

troveNFT

ITroveNFT

Interface of the TroveNFT contract

Checks if a trove has unclaimed redistribution rewards.

Input Parameters:

Parameter
Type
Description

_troveId

uint256

ID of the trove

Return Values:

Value
Type
Description

hasRewards

bool

true if trove has pending rewards

Returns the borrowing fee rate (e.g., 0.5% as 5000000000000000).

Return Values:

Value
Type
Description

rate

uint256

Current borrowing rate (based on baseRate)

Estimates the borrowing rate if no new fees are charged.

Return Values:

Value
Type
Description

rate

uint256

Borrowing rate after decay (simulated)

Calculates the fee to borrow _debt.

Input Parameters:

Parameter
Type
Description

_debt

uint256

Debt amount to calculate fee for

Return Values:

Value
Type
Description

fee

uint256

Borrowing fee for _debt at current rate

Estimates the borrowing fee after base rate decay.

Input Parameters:

Parameter
Type
Description

_debt

uint256

Debt amount to calculate fee for

Return Values:

Value
Type
Description

fee

uint256

Fee for _debt at decayed rate

Simulates the decay of baseRate over time.

Return Values:

Value
Type
Description

decayedRate

uint256

Base rate after decay

Aggregates pending rewards (debt + minting) for an account.

Input Parameters:

Parameter
Type
Description

receiver

address

Address to receive rewards

Return Values:

Value
Type
Description

amount

uint256

Total rewards claimed

Input Parameters:

Parameter
Type
Description

_debt

uint256

Base debt amount

Return Values:

Value
Type
Description

compositeDebt

uint256

Debt + gas compensation

netDebt

uint256

Debt - gas compensation

Input Parameters:

Parameter
Type
Description

_debt

uint256

Base debt amount

Return Values:

Value
Type
Description

compositeDebt

uint256

Debt + gas compensation

netDebt

uint256

Debt - gas compensation

Input Parameters:

Parameter
Type
Description

_entireColl

uint256

Total collateral in trove

Return Values:

Value
Type
Description

compensation

uint256

Collateral reserved for gas

Structs and Enums

Events

Note: on the Oasis Sapphire blockchain all events are disabled for privacy preservation purposes

Last updated