Skip to content

Latest commit

 

History

History
328 lines (261 loc) · 8.51 KB

LiquityBase.md

File metadata and controls

328 lines (261 loc) · 8.51 KB

LiquityBase.sol

View Source: contracts/Dependencies/LiquityBase.sol

↗ Extends: BaseMath, ILiquityBase ↘ Derived Contracts: BorrowerOperations, HintHelpers, StabilityPool, TroveManagerBase, TroveManagerBase1MinuteBootstrap

LiquityBase

Contract Members

Constants & Variables

uint256 public constant _100pct;
uint256 public constant ZUSD_GAS_COMPENSATION;
uint256 public constant MIN_NET_DEBT;
contract IActivePool public activePool;
contract IDefaultPool public defaultPool;
contract IPriceFeed public priceFeed;
contract ILiquityBaseParams public liquityBaseParams;

Functions


_getCompositeDebt

function _getCompositeDebt(uint256 _debt) internal pure
returns(uint256)

Arguments

Name Type Description
_debt uint256
Source Code
function _getCompositeDebt(uint256 _debt) internal pure returns (uint256) {
        return _debt.add(ZUSD_GAS_COMPENSATION);
    }

_getNetDebt

function _getNetDebt(uint256 _debt) internal pure
returns(uint256)

Arguments

Name Type Description
_debt uint256
Source Code
function _getNetDebt(uint256 _debt) internal pure returns (uint256) {
        return _debt.sub(ZUSD_GAS_COMPENSATION);
    }

_getCollGasCompensation

function _getCollGasCompensation(uint256 _entireColl) internal view
returns(uint256)

Arguments

Name Type Description
_entireColl uint256
Source Code
function _getCollGasCompensation(uint256 _entireColl) internal view returns (uint256) {
        return _entireColl / liquityBaseParams.PERCENT_DIVISOR();
    }

getEntireSystemColl

function getEntireSystemColl() public view
returns(entireSystemColl uint256)
Source Code
function getEntireSystemColl() public view returns (uint256 entireSystemColl) {
        uint256 activeColl = activePool.getETH();
        uint256 liquidatedColl = defaultPool.getETH();

        return activeColl.add(liquidatedColl);
    }

getEntireSystemDebt

function getEntireSystemDebt() public view
returns(entireSystemDebt uint256)
Source Code
function getEntireSystemDebt() public view returns (uint256 entireSystemDebt) {
        uint256 activeDebt = activePool.getZUSDDebt();
        uint256 closedDebt = defaultPool.getZUSDDebt();

        return activeDebt.add(closedDebt);
    }

_getTCR

function _getTCR(uint256 _price) internal view
returns(TCR uint256)

Arguments

Name Type Description
_price uint256
Source Code
function _getTCR(uint256 _price) internal view returns (uint256 TCR) {
        uint256 entireSystemColl = getEntireSystemColl();
        uint256 entireSystemDebt = getEntireSystemDebt();

        TCR = LiquityMath._computeCR(entireSystemColl, entireSystemDebt, _price);

        return TCR;
    }

_checkRecoveryMode

function _checkRecoveryMode(uint256 _price) internal view
returns(bool)

Arguments

Name Type Description
_price uint256
Source Code
function _checkRecoveryMode(uint256 _price) internal view returns (bool) {
        uint256 TCR = _getTCR(_price);

        return TCR < liquityBaseParams.CCR();
    }

_requireUserAcceptsFee

function _requireUserAcceptsFee(uint256 _fee, uint256 _amount, uint256 _maxFeePercentage) internal pure

Arguments

Name Type Description
_fee uint256
_amount uint256
_maxFeePercentage uint256
Source Code
function _requireUserAcceptsFee(
        uint256 _fee,
        uint256 _amount,
        uint256 _maxFeePercentage
    ) internal pure {
        uint256 feePercentage = _fee.mul(DECIMAL_PRECISION).div(_amount);
        require(feePercentage <= _maxFeePercentage, "Fee exceeded provided maximum");
    }

Contracts