ShowStopper

https://github.com/Into-the-Fathom/fathom-stablecoin-smart-contracts/blob/master/contracts/main/stablecoin-core/ShowStopper.sol

The ShowStopper contract manages the emergency shutdown of a system. It allows authorized users to trigger a shutdown to stop all essential financial operations, calculate and settle debts, and enable the redemption of collateral by users. The shutdown process ensures that the system can be gracefully wound down while protecting user assets.

Storage Variables

  • bookKeeper: Reference to the IBookKeeper contract which handles all accounting-related operations.

  • liquidationEngine: Reference to the ILiquidationEngine contract, responsible for handling the liquidation process during normal operations.

  • systemDebtEngine: Reference to the ISystemDebtEngine, which manages the system's debts and surpluses.

  • priceOracle: Reference to the IPriceOracle contract, providing updated asset prices.

  • live: Boolean flag indicating if the system is active (1) or in shutdown mode (0).

  • cagedTimestamp: Timestamp when the emergency shutdown was triggered.

  • cageCoolDown: Cool-down period post-shutdown during which operations remain paused.

  • debt: Total system debt recorded post-shutdown.

  • cagePrice: Mapping of collateral types to their fixed prices set at the time of shutdown.

  • badDebtAccumulator: Mapping tracking accumulated bad debts per collateral type.

  • totalDebtShare: Mapping of total debt per collateral type.

  • finalCashPrice: Final settled cash price per collateral type for redeeming stablecoins.

  • stablecoinAccumulator: Tracks the total stablecoins deposited by users post-shutdown for later collateral redemption.

  • redeemedStablecoinAmount: Mapping of redeemed stablecoin amounts per user per collateral type.

Functions

  • cage(uint256 _cageCoolDown): Triggers the emergency shutdown and sets the cool-down period.

  • cagePool(bytes32 _collateralPoolId): Locks the price of a specific collateral type at the time of shutdown.

  • accumulateBadDebt(bytes32 _collateralPoolId, address _positionAddress): Calculates and accumulates bad debt for a given collateral type and position.

  • finalizeDebt(): Finalizes the total system debt after processing all positions.

  • finalizeCashPrice(bytes32 _collateralPoolId): Finalizes the cash price for a collateral type, determining the redemption value for stablecoins.

  • accumulateStablecoin(uint256 _amount): Accumulates stablecoins deposited by a user for later redemption.

  • redeemStablecoin(bytes32 _collateralPoolId, uint256 _amount): Allows users to redeem stablecoins for collateral based on the final cash price.

  • redeemLockedCollateral(bytes32 _collateralPoolId, address _positionAddress, address _collateralReceiver): Redeems the locked collateral for a position, transferring it to the specified receiver.

Events

  • LogCage(uint256 _cageCoolDown): Emitted when the emergency shutdown is triggered.

  • LogCageCollateralPool(bytes32 indexed collateralPoolId): Emitted when a collateral pool is locked at its cage price.

  • LogAccumulateBadDebt(bytes32 indexed collateralPoolId, address indexed positionAddress, uint256 amount, uint256 debtShare): Emitted when bad debt is accumulated for a position.

  • LogRedeemLockedCollateral(bytes32 indexed collateralPoolId, address indexed positionAddress, uint256 lockedCollateral): Emitted when locked collateral is redeemed post-shutdown.

  • LogFinalizeDebt(): Emitted when the final system debt is calculated.

  • LogFinalizeCashPrice(bytes32 indexed collateralPoolId): Emitted when the final cash price for a collateral type is set.

  • LogAccumulateStablecoin(address indexed ownerAddress, uint256 amount): Emitted when a user's stablecoins are accumulated for redemption.

  • LogRedeemStablecoin(bytes32 indexed collateralPoolId, address indexed ownerAddress, uint256 amount): Emitted when stablecoins are redeemed for collateral.

Last updated

Copyright© Fathom App 2024.