GhoVariableDebtToken
Implements a variable debt token to track the borrowing positions of users at variable rate mode for GHO.
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.
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;
}
Name | Type | Description |
---|---|---|
accumulatedDebtInterest | uint128 | The accumulated debt interest of the user |
discountPercent | uint16 | The 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:
Name | Type | Description |
---|---|---|
initializingPool | IPool | The pool contract that is initializing this contract |
underlyingAsset | address | The address of the underlying asset of this aToken |
incentivesController | IAaveIncentivesController | The smart contract managing potential incentives distribution |
debtTokenDecimals | uint8 | The decimals of the debtToken, same as the underlying asset’s |
debtTokenName | string | The name of the token |
debtTokenSymbol | string | The symbol of the token |
params | bytes | A 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:
Name | Type | Description |
---|---|---|
user | address | The address performing the mint. The address receives the borrowed underlying, being the delegatee in case of credit delegation, or same as onBehalfOf otherwise |
onBehalfOf | address | The address of the user that will receive the scaled debt tokens tokens |
amount | uint256 | The amount of debt tokens being minted |
index | uint256 | The next variable debt liquidity index of the reserve |
Return Values:
Type | Description |
---|---|
bool | true if the the previous balance of the user is 0, false otherwise |
uint256 | The 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:
Name | Type | Description |
---|---|---|
from | address | The address from which the debt will be burned |
amount | uint256 | The amount being burned |
index | uint256 | The variable debt index of the reserve |
Return Values:
Type | Description |
---|---|
uint256 | The 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:
Name | Type | Description |
---|---|---|
ghoAToken | address | The 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:
Name | Type | Description |
---|---|---|
newDiscountRateStrategy | address | The 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:
Name | Type | Description |
---|---|---|
newDiscountToken | address | The 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:
Name | Type | Description |
---|---|---|
sender | address | The address of the sender |
recipient | address | The address of the recipient |
senderDiscountTokenBalance | uint256 | The sender discount token balance |
recipientDiscountTokenBalance | uint256 | The recipient discount token balance |
amount | uint256 | The 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:
Name | Type | Description |
---|---|---|
user | address | The address of the user |
amount | uint256 | The 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:
Name | Type | Description |
---|---|---|
user | address | The 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:
Name | Type | Description |
---|---|---|
user | address | The address of the user |
Return Values:
Type | Description |
---|---|
uint256 | The 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:
Type | Description |
---|---|
uint256 | The 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:
Type | Description |
---|---|
address | The address of the underlying asset |
getAToken
function getAToken() external view override returns (address)
Returns the address of the GhoAToken
contract.
Return Values:
Type | Description |
---|---|
address | The address of the GhoAToken contract |
getDiscountRateStrategy
function getDiscountRateStrategy() external view override returns (address)
Returns the address of the Discount Rate Strategy.
Return Values:
Type | Description |
---|---|
address | The address of the DiscountRateStrategy contract |
getDiscountToken
function getDiscountToken() external view override returns (address)
Returns the address of the Discount Token.
Return Values:
Type | Description |
---|---|
address | The 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:
Name | Type | Description |
---|---|---|
user | address | The address of the user |
Return Values:
Type | Description |
---|---|
uint256 | The 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:
Name | Type | Description |
---|---|---|
user | address | The address of the user |
Return Values:
Type | Description |
---|---|
uint256 | The 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)
allowance
function allowance(address, address) external view virtual override returns (uint256)
approve
function approve(address, uint256) external virtual override returns (bool)
transferFrom
function transferFrom(address, address, uint256) external virtual override returns (bool)
increaseAllowance
function increaseAllowance(address, uint256) external virtual override returns (bool)
decreaseAllowance
function decreaseAllowance(address, uint256) external virtual override returns (bool)