Skip to main content

GhoVariableDebtToken

Implements a variable debt token to track the borrowing positions of users at variable rate mode for GHO.

info

It is important to note, although it is based on the VariableDebtToken implementation of the Aave Protocol, the interest rate mode is not variable as it is fixed by the Aave Governance.

caution

A number of operations, such as transfer and approve, are disabled since it is a non-transferable token.

The GhoVariableDebtToken contract inherits the DebtTokenBase, ScaledBalanceTokenBase contracts, and the IGhoVariableDebtToken interface.

This page shows the public constant state variables, structs, external write methods, and the 'not supported methods' within the GhoVariableDebtToken contract. The source code is available on GitHub.

Constant State Variables

DEBT_TOKEN_REVISION

uint256 public constant DEBT_TOKEN_REVISION = 0x1

The revision number of the contract.

Structs

GhoUserState

struct GhoUserState {
uint128 accumulatedDebtInterest;
uint16 discountPercent;
}
NameTypeDescription
accumulatedDebtInterestuint128The accumulated debt interest of the user
discountPercentuint16The discount percent of the user (expressed in bps)

Write Methods

initialize

function initialize(
IPool initializingPool,
address underlyingAsset,
IAaveIncentivesController incentivesController,
uint8 debtTokenDecimals,
string memory debtTokenName,
string memory debtTokenSymbol,
bytes calldata params
) external override initializer

Initializes the debt token.

Emits the Initialized event.

Input Parameters:

NameTypeDescription
initializingPoolIPoolThe pool contract that is initializing this contract
underlyingAssetaddressThe address of the underlying asset of this aToken
incentivesControllerIAaveIncentivesControllerThe smart contract managing potential incentives distribution
debtTokenDecimalsuint8The decimals of the debtToken, same as the underlying asset’s
debtTokenNamestringThe name of the token
debtTokenSymbolstringThe symbol of the token
paramsbytesA set of encoded parameters for additional initialization

mint

function mint(
address user,
address onBehalfOf,
uint256 amount,
uint256 index
) external virtual override onlyPool returns (bool, uint256)
  • Mints the debt token to the onBehalfOf address. Implements the basic logic to mint a scaled balance token.
  • The user’s interest is accumulated here.
  • The discount percent of the user is applied to the accumulated interest.
  • DiscountPercent is rebalanced and “locked for the next period of time”

Input Parameters:

NameTypeDescription
useraddressThe address performing the mint. The address receives the borrowed underlying, being the delegatee in case of credit delegation, or same as onBehalfOf otherwise
onBehalfOfaddressThe address of the user that will receive the scaled debt tokens tokens
amountuint256The amount of debt tokens being minted
indexuint256The next variable debt liquidity index of the reserve

Return Values:

TypeDescription
booltrue if the the previous balance of the user is 0, false otherwise
uint256The scaled total debt of the reserve

burn

function burn(
address from,
uint256 amount,
uint256 index
) external override onlyPool returns (uint256)

Burns the user variable debt token. Implements the basic logic to burn a scaled balance token.

Input Parameters:

NameTypeDescription
fromaddressThe address from which the debt will be burned
amountuint256The amount being burned
indexuint256The variable debt index of the reserve

Return Values:

TypeDescription
uint256The scaled total debt of the reserve

setAToken

function setAToken(address ghoAToken) external override onlyPoolAdmin

Sets a reference to the GhoAToken contract. Checks the AToken has not already been set.

This function can only be called by the Pool Admin.

Emits the ATokenSet event.

Input Parameters:

NameTypeDescription
ghoATokenaddressThe address of the GhoAToken contract

updateDiscountRateStrategy

function updateDiscountRateStrategy(
address newDiscountRateStrategy
) external override onlyPoolAdmin

Updates the Discount Rate Strategy.

This function can only be called by the Pool Admin.

Emits the DiscountRateStrategyUpdated event.

Input Parameters:

NameTypeDescription
newDiscountRateStrategyaddressThe address of the DiscountRateStrategy contract

updateDiscountToken

function updateDiscountToken(address newDiscountToken) external override onlyPoolAdmin

Updates the Discount Token.

This function can only be called by the Pool Admin.

Emits the DiscountTokenUpdated event.

Input Parameters:

NameTypeDescription
newDiscountTokenaddressThe address of DiscountToken contract

updateDiscountDistribution

function updateDiscountDistribution(
address sender,
address recipient,
uint256 senderDiscountTokenBalance,
uint256 recipientDiscountTokenBalance,
uint256 amount
) external override onlyDiscountToken

Updates the discount percents of the users when a discount token transfer occurs.

This function is automatically called when stkAAVE tokens are transferred into the user’s address.

This function can only be called by the discount token.

Emits the Transfer and Mint events.

Input Parameters:

NameTypeDescription
senderaddressThe address of the sender
recipientaddressThe address of the recipient
senderDiscountTokenBalanceuint256The sender discount token balance
recipientDiscountTokenBalanceuint256The recipient discount token balance
amountuint256The amount of discount token being transferred

decreaseBalanceFromInterest

function decreaseBalanceFromInterest(address user, uint256 amount) external override onlyAToken

Decreases the amount of interest accumulated by the user.

This function can only be called by the AToken.

Input Parameters:

NameTypeDescription
useraddressThe address of the user
amountuint256The value to be decreased

rebalanceUserDiscountPercent

function rebalanceUserDiscountPercent(address user) external override

Rebalances the discount percent of a user.

Emits the Transfer and Mint events.

Input Parameters:

NameTypeDescription
useraddressThe address of the user

View Methods

balanceOf

function balanceOf(address user) public view virtual override returns (uint256)

Returns the amount of tokens owned by the user.

Standard ERC20 method.

Input Parameters:

NameTypeDescription
useraddressThe address of the user

Return Values:

TypeDescription
uint256The amount of tokens owned by the user

totalSupply

function totalSupply() public view virtual override returns (uint256)

Returns the amount of tokens in existence.

It does not account for active discounts of the users. The discount is deducted from the user’s debt at repayment / liquidation time, so this function always return a greater or equal value than the actual total supply.

Standard ERC20 method.

Return Values:

TypeDescription
uint256The amount of tokens in existence (without accounting for active discounts on debt)

UNDERLYING_ASSET_ADDRESS

function UNDERLYING_ASSET_ADDRESS() external view override returns (address)

Returns the address of the underlying asset of this debtToken, GHO for variableDebtGHO.

Return Values:

TypeDescription
addressThe address of the underlying asset

getAToken

function getAToken() external view override returns (address)

Returns the address of the GhoAToken contract.

Return Values:

TypeDescription
addressThe address of the GhoAToken contract

getDiscountRateStrategy

function getDiscountRateStrategy() external view override returns (address)

Returns the address of the Discount Rate Strategy.

Return Values:

TypeDescription
addressThe address of the DiscountRateStrategy contract

getDiscountToken

function getDiscountToken() external view override returns (address)

Returns the address of the Discount Token.

Return Values:

TypeDescription
addressThe address of Discount Token

getDiscountPercent

function getDiscountPercent(address user) external view override returns (uint256)

Returns the discount percent that will be applied to the accumulated borrow interest of the user.

Input Parameters:

NameTypeDescription
useraddressThe address of the user

Return Values:

TypeDescription
uint256The discount percent (expressed in bps)

getBalanceFromInterest

function getBalanceFromInterest(address user) external view override returns (uint256)

Returns the amount of interest accumulated by the user.

Input Parameters:

NameTypeDescription
useraddressThe address of the user

Return Values:

TypeDescription
uint256The amount of interest accumulated by the user

NOT SUPPORTED METHODS

The following methods automatically revert with the error code 80. The methods show OPERATION_NOT_SUPPORTED as they are not permitted to be executed.

Being non-transferrable, the debt token does not implement any of the standard ERC20 functions for transfer and allowance.

transfer

function transfer(address, uint256) external virtual override returns (bool)
Not supported by design.

allowance

function allowance(address, address) external view virtual override returns (uint256)
Not supported by design.

approve

function approve(address, uint256) external virtual override returns (bool)
Not supported by design.

transferFrom

function transferFrom(address, address, uint256) external virtual override returns (bool)
Not supported by design.

increaseAllowance

function increaseAllowance(address, uint256) external virtual override returns (bool)
Not supported by design.

decreaseAllowance

function decreaseAllowance(address, uint256) external virtual override returns (bool)
Not supported by design.