IGlobalSettlement

Git Source

Inherits: IAuthorizable, IDisableable, IModifiable

Functions

params

Getter for the contract parameters struct

function params() external view returns (GlobalSettlementParams memory _globalSettlementParams);

Returns

NameTypeDescription
_globalSettlementParamsGlobalSettlementParamsGlobalSettlement parameters struct

_params

Getter for the unpacked contract parameters struct

function _params() external view returns (uint256 _shutdownCooldown);

Returns

NameTypeDescription
_shutdownCooldownuint256Amount of seconds to wait before calculating redemptions after shutdown

shutdownTime

The timestamp when settlement was triggered

function shutdownTime() external view returns (uint256 _shutdownTime);

outstandingCoinSupply

The outstanding coin supply computed during the settlement process [rad]

function outstandingCoinSupply() external view returns (uint256 _outstandingCoinSupply);

finalCoinPerCollateralPrice

The final coin per collateral price computed during the settlement process

function finalCoinPerCollateralPrice(bytes32 _cType) external view returns (uint256 _finalCoinPerCollateralPrice);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

Returns

NameTypeDescription
_finalCoinPerCollateralPriceuint256The final amount of collateral that a system coin can redeem [rad]

collateralShortfall

The total amount of bad debt for a collateral type computed during the settlement process

function collateralShortfall(bytes32 _cType) external view returns (uint256 _collateralShortfall);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

Returns

NameTypeDescription
_collateralShortfalluint256The total amount of bad debt for a collateral type [wad]

collateralTotalDebt

The total amount of debt for a collateral type computed during the settlement process

function collateralTotalDebt(bytes32 _cType) external view returns (uint256 _collateralTotalDebt);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

Returns

NameTypeDescription
_collateralTotalDebtuint256The total amount of debt for a collateral type [wad]

collateralCashPrice

Final collateral cash price computed during the settlement process, accounting for surplus / shortfall

function collateralCashPrice(bytes32 _cType) external view returns (uint256 _collateralCashPrice);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

Returns

NameTypeDescription
_collateralCashPriceuint256The final collateral cash price [ray]

coinBag

Mapping containing the total amount of coins a user has prepared for redeeming

function coinBag(address _coinHolder) external view returns (uint256 _coinBag);

Parameters

NameTypeDescription
_coinHolderaddressThe address of the user

Returns

NameTypeDescription
_coinBaguint256Amount of coins prepared for redeeming [wad]

coinsUsedToRedeem

Mapping containing the total amount of coins a user has used to redeem collateral

function coinsUsedToRedeem(bytes32 _cType, address _coinHolder) external view returns (uint256 _coinsUsedToRedeem);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_coinHolderaddressThe address of the user

Returns

NameTypeDescription
_coinsUsedToRedeemuint256Amount of coins already used to redeem collateral [wad]

safeEngine

Address of the SAFEEngine contract

function safeEngine() external view returns (ISAFEEngine _safeEngine);

liquidationEngine

Address of the LiquidationEngine contract

function liquidationEngine() external view returns (ILiquidationEngine _liquidationEngine);

oracleRelayer

Address of the OracleRelayer contract

function oracleRelayer() external view returns (IOracleRelayer _oracleRelayer);

accountingEngine

Address of the AccountingEngine contract

function accountingEngine() external view returns (IDisableable _accountingEngine);

stabilityFeeTreasury

Address of the StabilityFeeTreasury contract

function stabilityFeeTreasury() external view returns (IDisableable _stabilityFeeTreasury);

coinJoin

Address of the CoinJoin contract

function coinJoin() external view returns (IDisableable _coinJoin);

collateralJoinFactory

Address of the CollateralJoinFactory contract

function collateralJoinFactory() external view returns (IDisableable _collateralJoinFactory);

collateralAuctionHouseFactory

Address of the CollateralAuctionHouseFactory contract

function collateralAuctionHouseFactory() external view returns (IDisableable _collateralAuctionHouseFactory);

shutdownSystem

Freeze the system and start the cooldown period

This function switches the whenEnabled/whenDisabled modifiers across the system contracts

function shutdownSystem() external;

freezeCollateralType

Calculate a collateral type's final price according to the latest system coin redemption price

function freezeCollateralType(bytes32 _cType) external;

Parameters

NameTypeDescription
_cTypebytes32The collateral type to calculate the price for

fastTrackAuction

Fast track an ongoing collateral auction

function fastTrackAuction(bytes32 _cType, uint256 _auctionId) external;

Parameters

NameTypeDescription
_cTypebytes32The collateral type associated with the auction contract
_auctionIduint256The ID of the auction to be fast tracked

processSAFE

Cancel a SAFE's debt and leave any extra collateral in it

function processSAFE(bytes32 _cType, address _safe) external;

Parameters

NameTypeDescription
_cTypebytes32The collateral type associated with the SAFE
_safeaddressThe SAFE to be processed

freeCollateral

Remove collateral from the caller's SAFE (requires SAFE to have no debt)

function freeCollateral(bytes32 _cType) external;

Parameters

NameTypeDescription
_cTypebytes32The collateral type to free

setOutstandingCoinSupply

Set the final outstanding supply of system coins

There must be no remaining surplus in the accounting engine

function setOutstandingCoinSupply() external;

calculateCashPrice

Calculate a collateral's price taking into consideration system surplus/deficit and the finalCoinPerCollateralPrice

function calculateCashPrice(bytes32 _cType) external;

Parameters

NameTypeDescription
_cTypebytes32The collateral whose cash price will be calculated

prepareCoinsForRedeeming

Add coins into a 'bag' so that you can use them to redeem collateral

function prepareCoinsForRedeeming(uint256 _coinAmount) external;

Parameters

NameTypeDescription
_coinAmountuint256The amount of internal system coins to add into the bag

redeemCollateral

Redeem a specific collateral type using an amount of internal system coins from your bag

function redeemCollateral(bytes32 _cType, uint256 _coinsAmount) external;

Parameters

NameTypeDescription
_cTypebytes32The collateral type to redeem
_coinsAmountuint256The amount of internal coins to use from your bag

Events

ShutdownSystem

Emitted when the system is shutdown and the global settlement process begins

event ShutdownSystem();

FreezeCollateralType

Emitted when a collateral type's final price is calculated

event FreezeCollateralType(bytes32 indexed _cType, uint256 _finalCoinPerCollateralPrice);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_finalCoinPerCollateralPriceuint256The final amount of collateral that a system coin can redeem [rad]

FastTrackAuction

Emitted when a collateral auction is fast tracked

event FastTrackAuction(bytes32 indexed _cType, uint256 indexed _auctionId, uint256 _collateralTotalDebt);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_auctionIduint256The ID of the auction to be fast tracked
_collateralTotalDebtuint256The cumulative amount of debt for the collateral type [wad]

ProcessSAFE

Emitted when a SAFE is processed

event ProcessSAFE(bytes32 indexed _cType, address indexed _safe, uint256 _collateralShortfall);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_safeaddressAddress of the processed SAFE
_collateralShortfalluint256The cumulative amount of bad debt for the collateral type [wad]

FreeCollateral

Emitted when a SAFE's surplus collateral is withdrawn

event FreeCollateral(bytes32 indexed _cType, address indexed _sender, uint256 _collateralAmount);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_senderaddressAddress of the caller (representing the SAFE)
_collateralAmountuint256The amount of collateral withdrawn [wad]

SetOutstandingCoinSupply

Emitted when the final outstanding coin supply is set

event SetOutstandingCoinSupply(uint256 _outstandingCoinSupply);

Parameters

NameTypeDescription
_outstandingCoinSupplyuint256The final outstanding coin supply [rad]

CalculateCashPrice

Emitted when a collateral type's cash price is calculated

event CalculateCashPrice(bytes32 indexed _cType, uint256 _collateralCashPrice);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_collateralCashPriceuint256The final collateral cash price [ray]

PrepareCoinsForRedeeming

Emitted when a user adds coins into a 'bag' so that they can use them to redeem collateral

event PrepareCoinsForRedeeming(address indexed _sender, uint256 _coinBag);

Parameters

NameTypeDescription
_senderaddressAddress of the caller
_coinBaguint256The cumulative of coins prepared for redeeming [wad]

RedeemCollateral

Emitted when a user redeems a specific collateral type using an amount of internal system coins from their bag

event RedeemCollateral(
  bytes32 indexed _cType, address indexed _sender, uint256 _coinsAmount, uint256 _collateralAmount
);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_senderaddressAddress of the caller
_coinsAmountuint256The amount of internal coins used from the bag [wad]
_collateralAmountuint256The amount of collateral redeemed [wad]

Errors

GS_FinalCollateralPriceAlreadyDefined

Throws when trying to freeze a collateral type that has already been frozen

error GS_FinalCollateralPriceAlreadyDefined();

GS_FinalCollateralPriceNotDefined

Throws when trying to fast track an auction while the collateral type is not frozen

error GS_FinalCollateralPriceNotDefined();

GS_SafeDebtNotZero

Throws when trying to free the collateral from an unprocessed SAFE

error GS_SafeDebtNotZero();

GS_OutstandingCoinSupplyNotZero

Throws when trying to set the final outstanding coin supply, when it was already set

error GS_OutstandingCoinSupplyNotZero();

GS_OutstandingCoinSupplyZero

Throws when trying to set the final collateral cash price, when the outstanding coin supply was not set

error GS_OutstandingCoinSupplyZero();

GS_SurplusNotZero

Throws when trying to set the final outstanding coin supply, when there's still surplus in the protocol

error GS_SurplusNotZero();

GS_ShutdownCooldownNotFinished

Throws when trying to set the final outstanding coin supply, when the cooldown period has not passed

error GS_ShutdownCooldownNotFinished();

GS_CollateralCashPriceAlreadyDefined

Throws when trying to set the final collateral cash price, when it was already set

error GS_CollateralCashPriceAlreadyDefined();

GS_CollateralCashPriceNotDefined

Throws when trying to redeem collateral when the final collateral cash price was not set

error GS_CollateralCashPriceNotDefined();

GS_InsufficientBagBalance

Throws when trying to redeem more collateral than the user's bag can afford

error GS_InsufficientBagBalance();

Structs

GlobalSettlementParams

struct GlobalSettlementParams {
  uint256 shutdownCooldown;
}