-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTroveManagerStorage.sol
More file actions
102 lines (74 loc) · 3.01 KB
/
TroveManagerStorage.sol
File metadata and controls
102 lines (74 loc) · 3.01 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
// SPDX-License-Identifier: MIT
pragma solidity 0.6.11;
import "./Interfaces/IStabilityPool.sol";
import "./Interfaces/ICollSurplusPool.sol";
import "./Interfaces/IZUSDToken.sol";
import "./Interfaces/ISortedTroves.sol";
import "./Interfaces/IZEROToken.sol";
import "./Interfaces/IZEROStaking.sol";
import "./Interfaces/IFeeDistributor.sol";
import "./Dependencies/Ownable.sol";
import "./Dependencies/BaseMath.sol";
import "./Dependencies/console.sol";
contract TroveManagerStorage is Ownable, BaseMath {
string public constant NAME = "TroveManager";
// --- Connected contract declarations ---
address public troveManagerRedeemOps;
address public borrowerOperationsAddress;
IStabilityPool public _stabilityPool;
address gasPoolAddress;
ICollSurplusPool collSurplusPool;
IZUSDToken public _zusdToken;
IZEROToken public _zeroToken;
IZEROStaking public _zeroStaking;
IFeeDistributor public feeDistributor;
// A doubly linked list of Troves, sorted by their sorted by their collateral ratios
ISortedTroves public sortedTroves;
// --- Data structures ---
uint256 public baseRate;
// The timestamp of the latest fee operation (redemption or new ZUSD issuance)
uint256 public lastFeeOperationTime;
enum Status {
nonExistent,
active,
closedByOwner,
closedByLiquidation,
closedByRedemption
}
// Store the necessary data for a trove
struct Trove {
uint256 debt;
uint256 coll;
uint256 stake;
Status status;
uint128 arrayIndex;
}
mapping(address => Trove) public Troves;
uint256 public totalStakes;
// Snapshot of the value of totalStakes, taken immediately after the latest liquidation
uint256 public totalStakesSnapshot;
// Snapshot of the total collateral across the ActivePool and DefaultPool, immediately after the latest liquidation.
uint256 public totalCollateralSnapshot;
/*
* L_ETH and L_ZUSDDebt track the sums of accumulated liquidation rewards per unit staked. During its lifetime, each stake earns:
*
* An ETH gain of ( stake * [L_ETH - L_ETH(0)] )
* A ZUSDDebt increase of ( stake * [L_ZUSDDebt - L_ZUSDDebt(0)] )
*
* Where L_ETH(0) and L_ZUSDDebt(0) are snapshots of L_ETH and L_ZUSDDebt for the active Trove taken at the instant the stake was made
*/
uint256 public L_ETH;
uint256 public L_ZUSDDebt;
// Map addresses with active troves to their RewardSnapshot
mapping(address => RewardSnapshot) public rewardSnapshots;
// Object containing the ETH and ZUSD snapshots for a given active trove
struct RewardSnapshot {
uint256 ETH;
uint256 ZUSDDebt;
}
// Array of all active trove addresses - used to to compute an approximate hint off-chain, for the sorted list insertion
address[] public TroveOwners;
// Error trackers for the trove redistribution calculation
uint256 public lastETHError_Redistribution;
uint256 public lastZUSDDebtError_Redistribution;
}