-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathISortedTroves.sol
More file actions
137 lines (118 loc) · 4 KB
/
ISortedTroves.sol
File metadata and controls
137 lines (118 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;
// Common interface for the SortedTroves Doubly Linked List.
interface ISortedTroves {
// --- Events ---
event SortedTrovesAddressChanged(address _sortedDoublyLLAddress);
event BorrowerOperationsAddressChanged(address _borrowerOperationsAddress);
event NodeAdded(address _id, uint256 _NICR);
event NodeRemoved(address _id);
// --- Functions ---
/**
* @notice Called only once on init, to set addresses of other Zero contracts and size. Callable only by owner
* @dev initializer function, checks addresses are contracts
* @param _size max size of troves list
* @param _TroveManagerAddress TroveManager contract address
* @param _borrowerOperationsAddress BorrowerOperations contract address
*/
function setParams(
uint256 _size,
address _TroveManagerAddress,
address _borrowerOperationsAddress
) external;
/**
* @dev Add a node to the list
* @param _id Node's id
* @param _ICR Node's NICR
* @param _prevId Id of previous node for the insert position
* @param _nextId Id of next node for the insert position
*/
function insert(
address _id,
uint256 _ICR,
address _prevId,
address _nextId
) external;
/**
* @dev Remove a node from the list
* @param _id Node's id
*/
function remove(address _id) external;
/**
* @dev Re-insert the node at a new position, based on its new NICR
* @param _id Node's id
* @param _newICR Node's new NICR
* @param _prevId Id of previous node for the new insert position
* @param _nextId Id of next node for the new insert position
*/
function reInsert(
address _id,
uint256 _newICR,
address _prevId,
address _nextId
) external;
/**
* @dev Checks if the list contains a node
* @param _id Node's id
* @return true if list contains a node with given id
*/
function contains(address _id) external view returns (bool);
/**
* @dev Checks if the list is full
* @return true if list is full
*/
function isFull() external view returns (bool);
/**
* @dev Checks if the list is empty
* @return true if list is empty
*/
function isEmpty() external view returns (bool);
/**
* @return list current size
*/
function getSize() external view returns (uint256);
/**
* @return list max size
*/
function getMaxSize() external view returns (uint256);
/**
* @return the first node in the list (node with the largest NICR)
*/
function getFirst() external view returns (address);
/**
* @return the last node in the list (node with the smallest NICR)
*/
function getLast() external view returns (address);
/**
* @param _id Node's id
* @return the next node (with a smaller NICR) in the list for a given node
*/
function getNext(address _id) external view returns (address);
/**
* @param _id Node's id
* @return the previous node (with a larger NICR) in the list for a given node
*/
function getPrev(address _id) external view returns (address);
/**
* @notice Check if a pair of nodes is a valid insertion point for a new node with the given NICR
* @param _ICR Node's NICR
* @param _prevId Id of previous node for the insert position
* @param _nextId Id of next node for the insert position
*/
function validInsertPosition(
uint256 _ICR,
address _prevId,
address _nextId
) external view returns (bool);
/**
* @notice Find the insert position for a new node with the given NICR
* @param _ICR Node's NICR
* @param _prevId Id of previous node for the insert position
* @param _nextId Id of next node for the insert position
*/
function findInsertPosition(
uint256 _ICR,
address _prevId,
address _nextId
) external view returns (address, address);
}