Fathom Protocol
  • Introduction
  • FXD Stablecoin
    • FXD Smart Contract Architecture
    • Minting and Burning Mechanisms with LTV Ratio
    • Soft-Pegging to the US Dollar
    • Opening and closing position flows
    • BookKeeping mechanism
      • Stablecoin Accounting
      • Collateral Accounting
    • Liquidation
      • Fixed Spread Liquidation Strategy
      • Liquidation process walk through
    • Emergency Shutdown
    • Maths for position safety
    • Fee structure
    • Risk Management
    • Interfaces
      • ProxyWalletRegistry
      • ProxyWallet
        • FathomStablecoinProxyActions
      • CollateralPoolConfig
      • BookKeeper
      • FXD
      • LiquidationEngine
      • FlashMintModule
      • PriceFeed
      • ShowStopper
      • StabilityFeeCollector
      • SystemDebtEngine
      • AdminControls
    • Deployments
      • XDC Network
    • User Guides
      • Open FXD position
      • Top Up FXD Position
      • Repay and close FXD position
    • Fathom Stablecoin Smart Contracts
    • Fathom Stablecoin Subgraph
  • Vaults
    • Key Features
    • Definitions
    • Architecture
    • Fees
    • Workflows
    • Vault Management
    • Strategy Creation
    • Interfaces
      • Factory
      • Vault
      • BaseStrategy
      • TokenizedStrategy
    • Deployments
      • XDC Network
    • User Guides
      • Deposit and Withdraw in Vault
    • Fathom Vaults Smart Contracts
    • Fathom Vaults Subgraph
  • Lending
    • Core Concepts
    • Protocol Mechanics
    • Architecture
    • Interfaces
      • FmToken
      • VariableDebtToken
      • StableDebtToken
      • L2Pool
      • PoolAddressesProvider
    • User Guides
      • Supply, Borrow, Repay and Withdraw Asset
    • Deployments
      • XDC Network
    • Fathom Lending Smart Contracts
    • Fathom Lending Subgraph
  • DEX
    • Core Concepts
    • Architecture
    • Interfaces
      • Factory
      • Pair
      • Router
    • User Guides
      • Providing Liquidity
      • Swapping Assets
    • Deployments
      • XDC Network
    • Fathom DEX Smart Contracts
    • Fathom DEX Subgraph
  • DAO
    • DAO Structure
    • Governance Process
    • Staking Process
    • Treasury Management
    • Risk Management and Security Measures
    • Contributing to Fathom DAO
    • Interfaces
      • FTHM
      • Staking
        • Vault
        • RewardsCalculator
        • vFTHM
      • Governance
        • TimelockController
    • Deployments
      • XDC Network
    • User Guides
      • Staking
      • Proposing
      • Voting
    • Fathom DAO Smart Contracts
    • Fathom DAO Subgraph
  • Whitepaper
    • Version 1.0
  • Resources
  • FXD Deployments
  • FTHM Deployments
  • Privacy Policy
  • Terms of Service
Powered by GitBook

Copyright© Fathom App 2024.

On this page

Was this helpful?

Export as PDF
  1. FXD Stablecoin

Emergency Shutdown

PreviousLiquidation process walk throughNextMaths for position safety

Last updated 11 months ago

Was this helpful?

The emergency shutdown process for Fathom's FXD is a comprehensive mechanism designed to safeguard both the protocol and its users in a significant crisis. This process is crucial for maintaining stability in decentralized finance (DeFi) systems. The emergency shutdown facilitates the return of excess collateral from safe positions. It allows for the return of collateral to those who give back FXD to the protocol, using a specific FXD to Collateral conversion ratio determined during the emergency shutdown. Here's a detailed explanation of the Fathom protocol's emergency shutdown procedure:

1. Initiating Emergency Shutdown

function cage(uint256 _cageCoolDown) external;
function cagePool(bytes32 _collateralPoolId) external;
function accumulateBadDebt(bytes32 _collateralPoolId, address _positionAddress) external;
function redeemLockedCollateral(
    bytes32 _collateralPoolId,
    address _positionAddress,
    address _collateralReceiver,
    bytes calldata /* _data */
) external;

3. Returning FXD and Retrieving Collateral

function finalizeDebt() external;
function stablecoinAdapterDeposit(
    address _adapter,
    address _positionAddress,
    uint256 _stablecoinAmount, // [wad]
    bytes calldata _data
) public;
function execute(bytes memory _data) public payable returns (bytes memory _response);
function accumulateStablecoin(uint256 _amount) external;
function redeemStablecoin(bytes32 _collateralPoolId, uint256 _amount) external;

4. Final Withdrawal of Collateral

  • Emergency Withdrawal: Finally, users can call the emergency withdrawal function to withdraw their collateral.

function emergencyWithdraw(address _to) external;

5. Responsibility of Users

  • Adhering to Process: Users are advised to follow the steps specified to reduce confusion and ensure a smooth process.

  • Bearing Consequences of Deviation: If a user deviates from the prescribed process and incurs a loss, they bear the responsibility for their actions.

6. Responsibility of the protocol

  • Providing instruction: In times of emergency, the Fathom protocol team should provide user-friendly interfaces to ensure that users do not have to deal with overly technical tasks, such as encoding a function call and directly calling the smart contracts.

  • Skimming all the positions: The protocol administrator must ensure that all positions are processed using the accumulateBadDebt function before the coolDownPeriod ends to ensure the correct execution of the emergency shutdown process.

  • Settling systemBadDebt and withdrawing systemSurplus: The protocol administrator must ensure that the systemBadDebt is settled using the systemSurplus, and all the surplus (if any is left) is withdrawn before the finalizeDebt function is called.

Summary of the Fathom's FXD Emergency Shutdown

The emergency shutdown of Fathom's FXD is an intricate, irreversible, multi-step process crucial for preserving the stability and security of the decentralized finance (DeFi) system during significant crises. This procedure involves several key stages:

  1. Initiating Emergency Shutdown: The process begins with halting most protocol activities through the cage function in the ShowStopper contract, marking a no-return point. The cooldown period following this action allows for the necessary processing of positions.

  2. Handling Excess Collateral from Positions: The accumulateBadDebt function, essential for managing excess collateral, must be applied to all positions. This responsibility falls to the protocol administrator if not completed by users. Subsequently, position owners can transfer excess collateral using the redeemLockedCollateral function.

  3. Returning FXD and Retrieving Collateral: After handling bad debt, the finalizeDebt function is called to solidify the debt amount, followed by the finalizeCashPrice function for setting the FXD to collateral conversion ratio. FXD owners must deposit their tokens using the stablecoinAdapterDeposit function, which requires precise encoding and execution. They also need to whitelist the ShowStopper contract for FXD/Collateral manipulation, followed by using redeemStablecoin to transfer collateral.

  4. Final Withdrawal of Collateral: The process concludes with caging the CollateralTokenAdapter and the final step of emergencyWithdraw by users to reclaim their collateral.

  5. User and Protocol Responsibilities: Users must adhere to the specified process sequence to minimize confusion and prevent losses. Any deviation leading to losses falls under the user's responsibility. On the protocol's end, providing user-friendly interfaces during emergencies and ensuring all positions are skimmed within the cooldown period is critical for smooth shutdown execution. The protocol administrator is also responsible for settling system bad debt and withdrawing any remaining system surplus before calling finalizeDebt.

Caging the Protocol: The shutdown process starts with the protocol owner calling the function in the contract. This action halts most activities within the protocol and is irreversible. The _cageCooldown period is the time allotted for calling the accumulateBadDebt function before the finalizeDebt function is executed.

Caging Specific Collateral Pools: The function is then called to initiate the shutdown for a particular collateral pool type, marking a point of no return for that pool.

Accumulating Bad Debt: The function, is called for all positions, leaving each with a certain amount of excess collateral. All positions within the protocol must undergo this process. If any positions have not been processed by users using accumulateBadDebt, the protocol administrator must ensure that all remaining positions are appropriately managed.

Redeeming Locked Collateral: Position owners can then use the function to transfer this excess collateral to a specified receiver. The receiver's collateral balance is recorded in the BookKeeper.

Finalizing Debt and Price: After dealing with bad debt by calling function for all the positions, the function is called to fix the debt amount, followed by the function to set a conversion ratio from FXD to collateral. finalizeDebt function will revert if there will be remaining systemSurplus.

Depositing FXD: FXD Owners deposit their FXD into the system using the function in the contract. Since the FathomStablecoinProxyActions contract serves as a library for the contract, calls to the stablecoinAdapterDeposit function need to be well-encoded and executed using the function of the ProxyWallet, owned by the FXD owner. When encoding the function call, the _positionAddress argument must match the address of the FXD Owner depositing FXD into the protocol.

Whitelisting and Accumulating Stablecoin: FXD owners must the ShowStopper contract in the contract to allow FXD/Collateral manipulation. They then call to move the FXD accounting from the BookKeeper to the ShowStopper’s stablecoinAccumulator.

Redeeming Stablecoin for Collateral: FXD owners use to transfer collateral from the ShowStopper to their account (EOA) within the BookKeeper.

Caging the : This action signifies the end of the process for depositing FXD and retrieving collateral. The owner of the protocol does the caging.

cage
ShowStopper
cagePool
accumulateBadDebt
redeemLockedCollateral
accumulateBadDebt
finalizeDebt
finalizeCashPrice
stablecoinAdapterDeposit
FathomStablecoinProxyActions
ProxyWallet
execute
whitelist
BookKeeper
accumulateStablecoin
redeemStablecoin
CollateralTokenAdapter
Emergency Shutdown