Discover the sophisticated data structure that keeps Troves organized: Sorted Troves. This contract maintains a doubly-linked list of all Troves, sorted by their Individual Collateralization Ratio (ICR), enabling efficient liquidation and redemption processes. Explore its functions for navigating and managing this crucial list.

Functions

contains

Checks if a Trove ID is present in the sorted list. (View)

function contains(_id: address) -> bool [view]

data

Returns internal data of the sorted list. (View)

function data() -> (address, address, uint256) [view]

findInsertPosition

Finds the correct position (previous and next Trove IDs) to insert a new Trove based on its NICR. (View)

function findInsertPosition(_NICR: uint256, _prevId: address, _nextId: address) -> (address, address) [view]

getFirst

Returns the ID of the first Trove in the sorted list (lowest ICR). (View)

function getFirst() -> address [view]

getLast

Returns the ID of the last Trove in the sorted list (highest ICR). (View)

function getLast() -> address [view]

getNext

Returns the ID of the next Trove in the list relative to a given Trove ID. (View)

function getNext(_id: address) -> address [view]

getPrev

Returns the ID of the previous Trove in the list relative to a given Trove ID. (View)

function getPrev(_id: address) -> address [view]

getSize

Returns the total number of Troves in the sorted list. (View)

function getSize() -> uint256 [view]

insert

Inserts a new Trove ID into the sorted list at the correct position based on its NICR.

function insert(_id: address, _NICR: uint256, _prevId: address, _nextId: address) [nonpayable]

isEmpty

Checks if the sorted list of Troves is empty. (View)

function isEmpty() -> bool [view]

reInsert

Re-inserts a Trove ID into the sorted list when its NICR changes, finding its new correct position.

function reInsert(_id: address, _newNICR: uint256, _prevId: address, _nextId: address) [nonpayable]

remove

Removes a Trove ID from the sorted list.

function remove(_id: address) [nonpayable]

setAddresses

Sets the address of the Trove Manager contract.

function setAddresses(_troveManagerAddress: address) [nonpayable]

troveManager

Returns the address of the associated ITroveManager contract. (View)

function troveManager() -> address (contract ITroveManager) [view]

validInsertPosition

Validates if a given insert position (based on NICR, previous ID, and next ID) is correct. (View)

function validInsertPosition(_NICR: uint256, _prevId: address, _nextId: address) -> bool [view]

Events

NodeAdded

Emitted when a new Trove (node) is added to the sorted list.

event NodeAdded(_id: address, _NICR: uint256)

NodeRemoved

Emitted when a Trove (node) is removed from the sorted list.

event NodeRemoved(_id: address)