View Source: contracts/MultiTroveGetter.sol
↗ Extends: MultiTroveGetterStorage
MultiTroveGetter
struct CombinedTroveData {
address owner,
uint256 debt,
uint256 coll,
uint256 stake,
uint256 snapshotETH,
uint256 snapshotZUSDDebt
}
- setAddresses(TroveManager _troveManager, ISortedTroves _sortedTroves)
- getMultipleSortedTroves(int256 _startIdx, uint256 _count)
- _getMultipleSortedTrovesFromHead(uint256 _startIdx, uint256 _count)
- _getMultipleSortedTrovesFromTail(uint256 _startIdx, uint256 _count)
function setAddresses(TroveManager _troveManager, ISortedTroves _sortedTroves) public nonpayable onlyOwner
Arguments
Name | Type | Description |
---|---|---|
_troveManager | TroveManager | |
_sortedTroves | ISortedTroves |
Source Code
function setAddresses(TroveManager _troveManager, ISortedTroves _sortedTroves) public onlyOwner {
troveManager = _troveManager;
sortedTroves = _sortedTroves;
}
function getMultipleSortedTroves(int256 _startIdx, uint256 _count) external view
returns(_troves struct MultiTroveGetter.CombinedTroveData[])
Arguments
Name | Type | Description |
---|---|---|
_startIdx | int256 | |
_count | uint256 |
Source Code
function getMultipleSortedTroves(int256 _startIdx, uint256 _count)
external
view
returns (CombinedTroveData[] memory _troves)
{
uint256 startIdx;
bool descend;
if (_startIdx >= 0) {
startIdx = uint256(_startIdx);
descend = true;
} else {
startIdx = uint256(-(_startIdx + 1));
descend = false;
}
uint256 sortedTrovesSize = sortedTroves.getSize();
if (startIdx >= sortedTrovesSize) {
_troves = new CombinedTroveData[](0);
} else {
uint256 maxCount = sortedTrovesSize - startIdx;
if (_count > maxCount) {
_count = maxCount;
}
if (descend) {
_troves = _getMultipleSortedTrovesFromHead(startIdx, _count);
} else {
_troves = _getMultipleSortedTrovesFromTail(startIdx, _count);
}
}
}
function _getMultipleSortedTrovesFromHead(uint256 _startIdx, uint256 _count) internal view
returns(_troves struct MultiTroveGetter.CombinedTroveData[])
Arguments
Name | Type | Description |
---|---|---|
_startIdx | uint256 | |
_count | uint256 |
Source Code
function _getMultipleSortedTrovesFromHead(uint256 _startIdx, uint256 _count)
internal
view
returns (CombinedTroveData[] memory _troves)
{
address currentTroveowner = sortedTroves.getFirst();
for (uint256 idx = 0; idx < _startIdx; ++idx) {
currentTroveowner = sortedTroves.getNext(currentTroveowner);
}
_troves = new CombinedTroveData[](_count);
for (uint256 idx = 0; idx < _count; ++idx) {
_troves[idx].owner = currentTroveowner;
(
_troves[idx].debt,
_troves[idx].coll,
_troves[idx].stake,
/* status */
/* arrayIndex */
,
) = troveManager.Troves(currentTroveowner);
(_troves[idx].snapshotETH, _troves[idx].snapshotZUSDDebt) = troveManager.rewardSnapshots(
currentTroveowner
);
currentTroveowner = sortedTroves.getNext(currentTroveowner);
}
}
function _getMultipleSortedTrovesFromTail(uint256 _startIdx, uint256 _count) internal view
returns(_troves struct MultiTroveGetter.CombinedTroveData[])
Arguments
Name | Type | Description |
---|---|---|
_startIdx | uint256 | |
_count | uint256 |
Source Code
function _getMultipleSortedTrovesFromTail(uint256 _startIdx, uint256 _count)
internal
view
returns (CombinedTroveData[] memory _troves)
{
address currentTroveowner = sortedTroves.getLast();
for (uint256 idx = 0; idx < _startIdx; ++idx) {
currentTroveowner = sortedTroves.getPrev(currentTroveowner);
}
_troves = new CombinedTroveData[](_count);
for (uint256 idx = 0; idx < _count; ++idx) {
_troves[idx].owner = currentTroveowner;
(
_troves[idx].debt,
_troves[idx].coll,
_troves[idx].stake,
/* status */
/* arrayIndex */
,
) = troveManager.Troves(currentTroveowner);
(_troves[idx].snapshotETH, _troves[idx].snapshotZUSDDebt) = troveManager.rewardSnapshots(
currentTroveowner
);
currentTroveowner = sortedTroves.getPrev(currentTroveowner);
}
}
- ActivePool
- ActivePoolStorage
- BaseMath
- BorrowerOperations
- BorrowerOperationsScript
- BorrowerOperationsStorage
- BorrowerWrappersScript
- CheckContract
- CollSurplusPool
- CollSurplusPoolStorage
- console
- Context
- DefaultPool
- DefaultPoolStorage
- DocsCover
- DSAuth
- DSAuthEvents
- DSAuthority
- DSNote
- DSProxy
- DSProxyCache
- DSProxyFactory
- ERC20
- ETHTransferScript
- FeeDistributor
- FeeDistributorStorage
- GasPool
- HintHelpers
- HintHelpersStorage
- IActivePool
- IBalanceRedirectPresale
- IBorrowerOperations
- ICollSurplusPool
- IDefaultPool
- IERC20
- IERC2612
- IExternalPriceFeed
- IFeeDistributor
- IFeeSharingProxy
- ILiquityBase
- ILiquityBaseParams
- IMasset
- IMoCBaseOracle
- Initializable
- IPool
- IPriceFeed
- IRSKOracle
- ISortedTroves
- IStabilityPool
- ITroveManager
- IWrbtc
- IZUSDToken
- LiquityBase
- LiquityBaseParams
- LiquityMath
- LiquitySafeMath128
- MoCMedianizer
- MultiTroveGetter
- MultiTroveGetterStorage
- NueToken
- Ownable
- PriceFeed
- PriceFeedStorage
- ProxiableContract
- ProxiableContract2
- Proxy
- RskOracle
- SafeMath
- SortedTroves
- SortedTrovesStorage
- StabilityPool
- StabilityPoolScript
- StabilityPoolStorage
- Storage
- Storage2
- TokenScript
- TroveManager
- TroveManagerBase
- TroveManagerBase1MinuteBootstrap
- TroveManagerRedeemOps
- TroveManagerScript
- TroveManagerStorage
- UpgradableProxy
- ZUSDToken
- ZUSDTokenStorage