View Source: contracts/Interfaces/ITroveManager.sol
↗ Extends: ILiquityBase ↘ Derived Contracts: TroveManager
ITroveManager
Events
event FeeDistributorAddressChanged(address _feeDistributorAddress);
event TroveManagerRedeemOpsAddressChanged(address _troveManagerRedeemOps);
event LiquityBaseParamsAddressChanges(address _borrowerOperationsAddress);
event BorrowerOperationsAddressChanged(address _newBorrowerOperationsAddress);
event PriceFeedAddressChanged(address _newPriceFeedAddress);
event ZUSDTokenAddressChanged(address _newZUSDTokenAddress);
event ActivePoolAddressChanged(address _activePoolAddress);
event DefaultPoolAddressChanged(address _defaultPoolAddress);
event StabilityPoolAddressChanged(address _stabilityPoolAddress);
event GasPoolAddressChanged(address _gasPoolAddress);
event CollSurplusPoolAddressChanged(address _collSurplusPoolAddress);
event SortedTrovesAddressChanged(address _sortedTrovesAddress);
event ZEROTokenAddressChanged(address _zeroTokenAddress);
event ZEROStakingAddressChanged(address _zeroStakingAddress);
event Liquidation(uint256 _liquidatedDebt, uint256 _liquidatedColl, uint256 _collGasCompensation, uint256 _ZUSDGasCompensation);
event Redemption(uint256 _attemptedZUSDAmount, uint256 _actualZUSDAmount, uint256 _ETHSent, uint256 _ETHFee);
event TroveUpdated(address indexed _borrower, uint256 _debt, uint256 _coll, uint256 stake, uint8 operation);
event TroveLiquidated(address indexed _borrower, uint256 _debt, uint256 _coll, uint8 operation);
event BaseRateUpdated(uint256 _baseRate);
event LastFeeOpTimeUpdated(uint256 _lastFeeOpTime);
event TotalStakesUpdated(uint256 _newTotalStakes);
event SystemSnapshotsUpdated(uint256 _totalStakesSnapshot, uint256 _totalCollateralSnapshot);
event LTermsUpdated(uint256 _L_ETH, uint256 _L_ZUSDDebt);
event TroveSnapshotsUpdated(uint256 _L_ETH, uint256 _L_ZUSDDebt);
event TroveIndexUpdated(address _borrower, uint256 _newIndex);
- setAddresses(address _feeDistributorAddress, address _troveManagerRedeemOps, address _liquityBaseParamsAddress, address _borrowerOperationsAddress, address _activePoolAddress, address _defaultPoolAddress, address _stabilityPoolAddress, address _gasPoolAddress, address _collSurplusPoolAddress, address _priceFeedAddress, address _zusdTokenAddress, address _sortedTrovesAddress, address _zeroTokenAddress, address _zeroStakingAddress)
- getTroveOwnersCount()
- getTroveFromTroveOwnersArray(uint256 _index)
- getNominalICR(address _borrower)
- getCurrentICR(address _borrower, uint256 _price)
- liquidate(address _borrower)
- liquidateTroves(uint256 _n)
- batchLiquidateTroves(address[] _troveArray)
- redeemCollateral(uint256 _ZUSDAmount, address _firstRedemptionHint, address _upperPartialRedemptionHint, address _lowerPartialRedemptionHint, uint256 _partialRedemptionHintNICR, uint256 _maxIterations, uint256 _maxFee)
- updateStakeAndTotalStakes(address _borrower)
- updateTroveRewardSnapshots(address _borrower)
- addTroveOwnerToArray(address _borrower)
- applyPendingRewards(address _borrower)
- getPendingETHReward(address _borrower)
- getPendingZUSDDebtReward(address _borrower)
- hasPendingRewards(address _borrower)
- getEntireDebtAndColl(address _borrower)
- closeTrove(address _borrower)
- removeStake(address _borrower)
- getRedemptionRate()
- getRedemptionRateWithDecay()
- getRedemptionFeeWithDecay(uint256 _ETHDrawn)
- getBorrowingRate()
- getBorrowingRateWithDecay()
- getBorrowingFee(uint256 ZUSDDebt)
- getBorrowingFeeWithDecay(uint256 _ZUSDDebt)
- decayBaseRateFromBorrowing()
- getTroveStatus(address _borrower)
- getTroveStake(address _borrower)
- getTroveDebt(address _borrower)
- getTroveColl(address _borrower)
- setTroveStatus(address _borrower, uint256 num)
- increaseTroveColl(address _borrower, uint256 _collIncrease)
- decreaseTroveColl(address _borrower, uint256 _collDecrease)
- increaseTroveDebt(address _borrower, uint256 _debtIncrease)
- decreaseTroveDebt(address _borrower, uint256 _debtDecrease)
- getTCR(uint256 _price)
- MCR()
- CCR()
- checkRecoveryMode(uint256 _price)
Called only once on init, to set addresses of other Zero contracts. Callable only by owner
function setAddresses(address _feeDistributorAddress, address _troveManagerRedeemOps, address _liquityBaseParamsAddress, address _borrowerOperationsAddress, address _activePoolAddress, address _defaultPoolAddress, address _stabilityPoolAddress, address _gasPoolAddress, address _collSurplusPoolAddress, address _priceFeedAddress, address _zusdTokenAddress, address _sortedTrovesAddress, address _zeroTokenAddress, address _zeroStakingAddress) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
_feeDistributorAddress | address | feeDistributor contract address |
_troveManagerRedeemOps | address | TroveManagerRedeemOps contract address |
_liquityBaseParamsAddress | address | LiquityBaseParams contract address |
_borrowerOperationsAddress | address | BorrowerOperations contract address |
_activePoolAddress | address | ActivePool contract address |
_defaultPoolAddress | address | DefaultPool contract address |
_stabilityPoolAddress | address | StabilityPool contract address |
_gasPoolAddress | address | GasPool contract address |
_collSurplusPoolAddress | address | CollSurplusPool contract address |
_priceFeedAddress | address | PriceFeed contract address |
_zusdTokenAddress | address | ZUSDToken contract address |
_sortedTrovesAddress | address | SortedTroves contract address |
_zeroTokenAddress | address | ZEROToken contract address |
_zeroStakingAddress | address | ZEROStaking contract address |
Source Code
function setAddresses(
address _feeDistributorAddress,
address _troveManagerRedeemOps,
address _liquityBaseParamsAddress,
address _borrowerOperationsAddress,
address _activePoolAddress,
address _defaultPoolAddress,
address _stabilityPoolAddress,
address _gasPoolAddress,
address _collSurplusPoolAddress,
address _priceFeedAddress,
address _zusdTokenAddress,
address _sortedTrovesAddress,
address _zeroTokenAddress,
address _zeroStakingAddress
) external;
function getTroveOwnersCount() external view
returns(uint256)
Source Code
function getTroveOwnersCount() external view returns (uint256);
function getTroveFromTroveOwnersArray(uint256 _index) external view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
_index | uint256 | Trove owner index |
Returns
Trove from TroveOwners array in given index
Source Code
function getTroveFromTroveOwnersArray(uint256 _index) external view returns (address);
function getNominalICR(address _borrower) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Returns
the nominal collateral ratio (ICR) of a given Trove, without the price. Takes a trove's pending coll and debt rewards from redistributions into account.
Source Code
function getNominalICR(address _borrower) external view returns (uint256);
computes the user’s individual collateralization ratio (ICR) based on their total collateral and total ZUSD debt. Returns 2^256 -1 if they have 0 debt.
function getCurrentICR(address _borrower, uint256 _price) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
_price | uint256 | ETH price |
Returns
the current collateral ratio (ICR) of a given Trove. Takes a trove's pending coll and debt rewards from redistributions into account.
Source Code
nction getCurrentICR(address _borrower, uint256 _price) external view returns (uint256);
Closes the trove if its ICR is lower than the minimum collateral ratio.
function liquidate(address _borrower) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Source Code
nction liquidate(address _borrower) external;
Liquidate a sequence of troves. Closes a maximum number of n under-collateralized Troves, starting from the one with the lowest collateral ratio in the system, and moving upwards
function liquidateTroves(uint256 _n) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
_n | uint256 | max number of under-collateralized Troves to liquidate |
Source Code
nction liquidateTroves(uint256 _n) external;
Attempt to liquidate a custom list of troves provided by the caller.
function batchLiquidateTroves(address[] _troveArray) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
_troveArray | address[] | list of trove addresses |
Source Code
nction batchLiquidateTroves(address[] calldata _troveArray) external;
Send _ZUSDamount ZUSD to the system and redeem the corresponding amount of collateral from as many Troves as are needed to fill the redemption
request. Applies pending rewards to a Trove before reducing its debt and coll.
Note that if _amount is very large, this function can run out of gas, specially if traversed troves are small. This can be easily avoided by
splitting the total _amount in appropriate chunks and calling the function multiple times.
Param _maxIterations
can also be provided, so the loop through Troves is capped (if it’s zero, it will be ignored).This makes it easier to
avoid OOG for the frontend, as only knowing approximately the average cost of an iteration is enough, without needing to know the “topology”
of the trove list. It also avoids the need to set the cap in stone in the contract, nor doing gas calculations, as both gas price and opcode
costs can vary.
All Troves that are redeemed from -- with the likely exception of the last one -- will end up with no debt left, therefore they will be closed.
If the last Trove does have some remaining debt, it has a finite ICR, and the reinsertion could be anywhere in the list, therefore it requires a hint.
A frontend should use getRedemptionHints() to calculate what the ICR of this Trove will be after redemption, and pass a hint for its position
in the sortedTroves list along with the ICR value that the hint was found for.
If another transaction modifies the list between calling getRedemptionHints() and passing the hints to redeemCollateral(), it
is very likely that the last (partially) redeemed Trove would end up with a different ICR than what the hint is for. In this case the
redemption will stop after the last completely redeemed Trove and the sender will keep the remaining ZUSD amount, which they can attempt
to redeem later.
function redeemCollateral(uint256 _ZUSDAmount, address _firstRedemptionHint, address _upperPartialRedemptionHint, address _lowerPartialRedemptionHint, uint256 _partialRedemptionHintNICR, uint256 _maxIterations, uint256 _maxFee) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
_ZUSDAmount | uint256 | ZUSD amount to send to the system |
_firstRedemptionHint | address | calculated ICR hint of first trove after redemption |
_upperPartialRedemptionHint | address | |
_lowerPartialRedemptionHint | address | |
_partialRedemptionHintNICR | uint256 | |
_maxIterations | uint256 | max Troves iterations (can be 0) |
_maxFee | uint256 | max fee percentage to accept |
Source Code
redeemCollateral(
uint256 _ZUSDAmount,
address _firstRedemptionHint,
address _upperPartialRedemptionHint,
address _lowerPartialRedemptionHint,
uint256 _partialRedemptionHintNICR,
uint256 _maxIterations,
uint256 _maxFee
) external;
//
Update borrower's stake based on their latest collateral value
function updateStakeAndTotalStakes(address _borrower) external nonpayable
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Source Code
updateStakeAndTotalStakes(address _borrower) external returns (uint256);
//
Update borrower's snapshots of L_ETH and L_ZUSDDebt to reflect the current values
function updateTroveRewardSnapshots(address _borrower) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Source Code
updateTroveRewardSnapshots(address _borrower) external;
//
Push the owner's address to the Trove owners list, and record the corresponding array index on the Trove struct
function addTroveOwnerToArray(address _borrower) external nonpayable
returns(index uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Returns
index where Trove was inserted
Source Code
addTroveOwnerToArray(address _borrower) external returns (uint256 index);
//
Add the borrowers's coll and debt rewards earned from redistributions, to their Trove
function applyPendingRewards(address _borrower) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Source Code
applyPendingRewards(address _borrower) external;
//
function getPendingETHReward(address _borrower) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Returns
the borrower's pending accumulated ETH reward, earned by their stake
Source Code
getPendingETHReward(address _borrower) external view returns (uint256);
//
function getPendingZUSDDebtReward(address _borrower) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Returns
the borrower's pending accumulated ZUSD reward, earned by their stake
Source Code
getPendingZUSDDebtReward(address _borrower) external view returns (uint256);
/*
function hasPendingRewards(address _borrower) external view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address |
Source Code
hasPendingRewards(address _borrower) external view returns (bool);
//
returns the Troves entire debt and coll, including pending rewards from redistributions.
function getEntireDebtAndColl(address _borrower) external view
returns(debt uint256, coll uint256, pendingZUSDDebtReward uint256, pendingETHReward uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Source Code
getEntireDebtAndColl(address _borrower)
external
view
returns (
uint256 debt,
uint256 coll,
uint256 pendingZUSDDebtReward,
uint256 pendingETHReward
);
//
Close given trove. Called by BorrowerOperations.
function closeTrove(address _borrower) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Source Code
closeTrove(address _borrower) external;
//
Remove borrower's stake from the totalStakes sum, and set their stake to 0
function removeStake(address _borrower) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Source Code
removeStake(address _borrower) external;
//
function getRedemptionRate() external view
returns(uint256)
Source Code
getRedemptionRate() external view returns (uint256);
//
function getRedemptionRateWithDecay() external view
returns(uint256)
Source Code
getRedemptionRateWithDecay() external view returns (uint256);
//
The redemption fee is taken as a cut of the total ETH drawn from the system in a redemption. It is based on the current redemption rate.
function getRedemptionFeeWithDecay(uint256 _ETHDrawn) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_ETHDrawn | uint256 | ETH drawn |
Source Code
getRedemptionFeeWithDecay(uint256 _ETHDrawn) external view returns (uint256);
//
function getBorrowingRate() external view
returns(uint256)
Source Code
getBorrowingRate() external view returns (uint256);
//
function getBorrowingRateWithDecay() external view
returns(uint256)
Source Code
getBorrowingRateWithDecay() external view returns (uint256);
//
function getBorrowingFee(uint256 ZUSDDebt) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
ZUSDDebt | uint256 | ZUSD debt amount to calculate fee |
Returns
borrowing fee using borrowing rate
Source Code
getBorrowingFee(uint256 ZUSDDebt) external view returns (uint256);
//
function getBorrowingFeeWithDecay(uint256 _ZUSDDebt) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_ZUSDDebt | uint256 | ZUSD debt amount to calculate fee |
Returns
borrowing fee using borrowing rate with decay
Source Code
getBorrowingFeeWithDecay(uint256 _ZUSDDebt) external view returns (uint256);
//
Updates the baseRate state variable based on time elapsed since the last redemption or ZUSD borrowing operation.
function decayBaseRateFromBorrowing() external nonpayable
Source Code
decayBaseRateFromBorrowing() external;
//
function getTroveStatus(address _borrower) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Returns
Trove status from given trove
Source Code
getTroveStatus(address _borrower) external view returns (uint256);
//
function getTroveStake(address _borrower) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Returns
Trove stake from given trove
Source Code
getTroveStake(address _borrower) external view returns (uint256);
//
function getTroveDebt(address _borrower) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Returns
Trove debt from given trove
Source Code
getTroveDebt(address _borrower) external view returns (uint256);
//
function getTroveColl(address _borrower) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
Returns
Trove collateral from given trove
Source Code
getTroveColl(address _borrower) external view returns (uint256);
//
function setTroveStatus(address _borrower, uint256 num) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
num | uint256 | status to set |
Source Code
setTroveStatus(address _borrower, uint256 num) external;
//
function increaseTroveColl(address _borrower, uint256 _collIncrease) external nonpayable
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
_collIncrease | uint256 | amount of collateral to increase |
Returns
new trove collateral
Source Code
increaseTroveColl(address _borrower, uint256 _collIncrease) external returns (uint256);
//
function decreaseTroveColl(address _borrower, uint256 _collDecrease) external nonpayable
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
_collDecrease | uint256 | amount of collateral to decrease |
Returns
new trove collateral
Source Code
decreaseTroveColl(address _borrower, uint256 _collDecrease) external returns (uint256);
//
function increaseTroveDebt(address _borrower, uint256 _debtIncrease) external nonpayable
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
_debtIncrease | uint256 | amount of debt to increase |
Returns
new trove debt
Source Code
increaseTroveDebt(address _borrower, uint256 _debtIncrease) external returns (uint256);
//
function decreaseTroveDebt(address _borrower, uint256 _debtDecrease) external nonpayable
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_borrower | address | borrower address |
_debtDecrease | uint256 | amount of debt to decrease |
Returns
new trove debt
Source Code
decreaseTroveDebt(address _borrower, uint256 _debtDecrease) external returns (uint256);
/*
function getTCR(uint256 _price) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_price | uint256 | ETH price |
Returns
the total collateralization ratio (TCR) of the system. The TCR is based on the the entire system debt and collateral (including pending rewards).
Source Code
getTCR(uint256 _price) external view returns (uint256);
fu
function MCR() external view
returns(uint256)
Source Code
MCR() external view returns (uint256);
fu
function CCR() external view
returns(uint256)
Source Code
CCR() external view returns (uint256);
//
reveals whether or not the system is in Recovery Mode (i.e. whether the Total Collateralization Ratio (TCR) is below the Critical Collateralization Ratio (CCR)).
function checkRecoveryMode(uint256 _price) external view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
_price | uint256 |
Source Code
checkRecoveryMode(uint256 _price) external view returns (bool);
}
- 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