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. Lending
  2. Interfaces

StableDebtToken

https://github.com/Into-the-Fathom/fathom-lending-platform-smart-contracts/blob/master/contracts/protocol/tokenization/StableDebtToken.sol

The StableDebtToken is a specialized token in the Fathom protocol used to track borrowing positions at a stable interest rate. This token does not inherit from IERC20 to save on code size and avoids standard ERC20 functionalities such as transfers and approvals, given its non-transferable nature.

Events

  • Initialized: Emitted when the token is initialized.

    • underlyingAsset: Address of the underlying asset.

    • pool: Address of the associated pool.

    • incentivesController: Address of the incentives controller.

    • debtTokenDecimals: Decimals of the debt token.

    • debtTokenName: Name of the debt token.

    • debtTokenSymbol: Symbol of the debt token.

    • params: Encoded parameters for additional initialization.

  • Mint: Emitted when new stable debt is minted.

    • user: Address of the user who triggered the minting.

    • onBehalfOf: Address receiving the stable debt tokens.

    • amount: Amount minted (user-entered amount + balance increase from interest).

    • currentBalance: Balance of the user based on the previous balance and balance increase from interest.

    • balanceIncrease: Increase in balance since the last action of the user onBehalfOf.

    • newRate: Rate of the debt after the minting.

    • avgStableRate: Next average stable rate after the minting.

    • newTotalSupply: Next total supply of the stable debt token after the action.

  • Burn: Emitted when stable debt is burned.

    • from: Address from which the debt will be burned.

    • amount: Amount being burned (user-entered amount - balance increase from interest).

    • currentBalance: Balance of the user based on the previous balance and balance increase from interest.

    • balanceIncrease: Increase in balance since the last action of from.

    • avgStableRate: Next average stable rate after the burning.

    • newTotalSupply: Next total supply of the stable debt token after the action.

Functions

initialize

Initializes the debt token.

  • Parameters:

    • pool: The pool contract that is initializing this contract.

    • underlyingAsset: The address of the underlying asset of this debt token.

    • incentivesController: The smart contract managing potential incentives distribution.

    • debtTokenDecimals: The decimals of the debt token, same as the underlying asset's.

    • debtTokenName: The name of the token.

    • debtTokenSymbol: The symbol of the token.

    • params: Encoded parameters for additional initialization.

getAverageStableRate

Returns the average rate of all the stable rate loans.

  • Returns:

    • The average stable rate.

getUserLastUpdated

Returns the timestamp of the last update of the user.

  • Parameters:

    • user: The address of the user.

  • Returns:

    • The timestamp.

getUserStableRate

Returns the stable rate of the user's debt.

  • Parameters:

    • user: The address of the user.

  • Returns:

    • The stable rate of the user.

balanceOf

Returns the balance of a user.

  • Parameters:

    • account: The address of the user.

  • Returns:

    • The balance of the user.

mint

Mints debt tokens to the onBehalfOf address.

  • Parameters:

    • user: The address receiving the borrowed underlying.

    • onBehalfOf: The address receiving the debt tokens.

    • amount: The amount of debt tokens to mint.

    • rate: The rate of the debt being minted.

  • Returns:

    • bool: True if it is the first borrow, false otherwise.

    • uint256: The total stable debt.

    • uint256: The average stable borrow rate.

burn

Burns debt of user.

  • Parameters:

    • from: The address from which the debt will be burned.

    • amount: The amount of debt tokens getting burned.

  • Returns:

    • uint256: The total stable debt.

    • uint256: The average stable borrow rate.

getSupplyData

Returns the principal, the total supply, the average stable rate, and the timestamp for the last update.

  • Returns:

    • uint256: The principal.

    • uint256: The total supply.

    • uint256: The average stable rate.

    • uint40: The timestamp of the last update.

getTotalSupplyAndAvgRate

Returns the total supply and the average stable rate.

  • Returns:

    • uint256: The total supply.

    • uint256: The average rate.

totalSupply

Returns the total supply of the stable debt tokens.

  • Returns:

    • The total supply.

getTotalSupplyLastUpdated

Returns the timestamp of the last update of the total supply.

  • Returns:

    • The timestamp.

principalBalanceOf

Returns the principal debt balance of the user.

  • Parameters:

    • user: The address of the user.

  • Returns:

    • The debt balance of the user since the last burn/mint action.

UNDERLYING_ASSET_ADDRESS

Returns the address of the underlying asset of this stable debt token.

  • Returns:

    • The address of the underlying asset.

Non-Implemented ERC20 Functions

The following ERC20 functions are not implemented because StableDebtToken is non-transferable:

  • transfer

  • allowance

  • approve

  • transferFrom

  • increaseAllowance

  • decreaseAllowance

PreviousVariableDebtTokenNextL2Pool

Last updated 11 months ago

Was this helpful?