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

Last updated

Copyright© Fathom App 2024.