GlobalSettlement
is meant to shut down the system and reimburse SAFE users as well as system coin holders with all the collateral that's locked inside.authorizedAccounts[usr: address]
, addAuthorization
/removeAuthorization
/isAuthorized
- auth mechanismssafeEngine
- address of the SAFEEngine
liquidationEngine
- address of the LiquidationEngine
accountingEngine
- address of the AccountingEngine
oracleRelayer
- address of the OracleRelayer
coinSavingsAccount
- address of the CoinSavingsAccount
stabilityFeeTreasury
- address of the StabilityFeeTreasury
contractEnabled
- whether settlement has been triggered or notshutdownTime
- unix timestamp of the moment when settlement was triggeredshutdownCooldown
- cooldown post shutdown during which no on-chain processing can be doneoutstandingCoinSupply
- outstanding system coin supply after all deficit / surplus has been taken into accountfinalCoinPerCollateralPrice[collateralType: bytes32]
- price per collateral type at time of settlementcollateralShortfall[collateralType: bytes32]
- shortfall per collateral type (taking into account under-collateralised SAFEs)collateralTotalDebt[collateralType: bytes32]
- outstanding debt per collateral typecollateralCashPrice[collateralType: bytes32]
- amount of system coins to be paid for one unit of a specific collateral typecoinBag[usr: address]
- system coins ready to be swapped for collateral. Coins cannot be transferred out of a bagcoinsUsedToRedeem[usr: address]
- the amount of already swapped system coins for a specific addressisAuthorized
- checks whether an address is part of authorizedAddresses
(and thus can call authed functions).modifyParameters()
- update parameters such as the safeEngine
, shutdownCooldown
etcshutdownSystem()
- start the settlement process. Usually called by ESM
freezeCollateralType(collateralType: bytes32)
- sets the final price of a collateral typefastTrackAuction(collateralType: bytes32, auctionId: uint256)
- cancel / terminate a live auctionprocessSAFE(collateralType: bytes32, safe: address)
- cancel a SAFE's owed debt freeCollateral(collateralType: bytes32)
- remove remaining collateral from a SAFE (can occur only after there's no debt in the SAFE)setOutstandingCoinSupply()
- fix the outstanding supply of system coinscalculateCashPrice(collateralType: bytes32)
- calculates a price for each collateral type (system coins per unit of collateral type) taking into account system surplus / deficitprepareCoinsForRedeeming(coinAmount: uint256)
- add system coins in a coinBag
and prepare them to redemmCollateral
redeemCollateral(collateralType: bytes32, coinsAmount: uint)
- swap coins from a bag with a specific collateral typeliquidationCRatio
(collateralization ratio under which a SAFE gets liquidated) should be allowed to retrieve surplus collateral.shutdownSystem()
:freezeCollateralType(collateralType)
:collateralType
, reading off the price feed. We must process some system state before it is possible to calculate the final systemCoin / collateral price. In particular, we need to determine:collateralShortfall
(considers under-collateralised SAFEs)outstandingCoinSupply
(after including system system surplus / deficit)processSAFE
.processSAFE(collateralType, safe)
outstandingCoinSupply
by processing ongoing coin generating processes, i.e. auctions. We need to ensure that auctions will not generate any further coin income. In the two-way auction model this occurs when all auctions are in the reverse (decreaseSoldAmount
) phase. There are two ways of ensuring this: waiting until shutdownCooldown
seconds have passed since the initial settlement trigger or use fastTrackAuction
.shutdownCooldown
or fastTrackAuction
shutdownCooldown
: set the cooldown period to be at least as long as the longest auction duration (which needs to be determined by the shutdown administrator). This takes a fairly predictable time to occur but with altered auction dynamics due to the now varying price of the system coin. fastTrackAuction
: cancel all ongoing auctions and seize the collateral. This allows for faster processing at the expense of more calls. This option allows coin holders to retrieve their collateral faster. Concretely, fastTrackAuction(collateralType, auctionId)
:terminateAuctionPrematurely
)GlobalSettlement
and (in case the system uses EnglishCollateralHouse
s) returns coins (the bid) to the highest bidderEnglishCollateralHouse
, reduceAuctionedAmount
(reverse) phase auctions can continue normally.fastTrackAuction
being enabled on a per-auction basis.freeCollateral(collateralType)
:setOutstandingCoinSupply()
AccountingEngine
has no more surplus left. AccountingEngine.transferPostSettlementSurplus
can be called in order to drain any remaining surplus and allow setOutstandingCoinSupply
to be executed.setOutstandingCoinSupply
fixes the total outstanding supply of coins.calculateCashPrice(collateralType)
collateralCashPrice
(amount of system coins per one unit of collateral). It adjusts the cash price in the case of system deficit / surplus.prepareCoinsForRedeeming
into coinBag
s. Once prepared, coins cannot be transferred out of the bag. More coins can be added to a bag later.prepareCoinsForRedeeming(coinAmount)
coinBag
in order to redeemCollateral
. The bigger the bag, the more collateral the user can claim.redeemCollateral(collateralType, collateralAmount)
collateralType