Module 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::variable_debt_token_factory

@title Variable Debt Token Factory Module @author Aave @notice Factory for creating and managing variable debt tokens in the Aave protocol @dev Manages the creation, minting, burning, and operations of variable debt tokens

use 0x1::event;
use 0x1::fungible_asset;
use 0x1::object;
use 0x1::option;
use 0x1::signer;
use 0x1::smart_table;
use 0x1::string;
use 0x1::table_with_length;
use 0x24e01fa503119e76bf9eea69eec59884fc3da82f5ea23bf5f20f8ce358a4606::acl_manage;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::error_config;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::token_base;
use 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::wad_ray_math;

Struct Initialized

@notice Emitted when a debt token is initialized @param underlying_asset The address of the underlying asset @param incentives_controller The address of the incentives controller @param debt_token_decimals The decimals of the debt token @param debt_token_name The name of the debt token @param debt_token_symbol The symbol of the debt token

#[event]
struct Initialized has drop, store

Resource TokenData

@notice Data structure that stores token-specific information @param underlying_asset The address of the underlying asset

struct TokenData has drop, key

Resource TokenMap

@notice Bi-directional mapping between underlying tokens and variable debt tokens @dev See NOTES of TokenMap in a_token_factory.move for why this design is used @param underlying_to_token Maps underlying token address to variable debt token address @param token_to_underlying Maps variable debt token address to underlying token address

struct TokenMap has key

Function is_variable_debt_token

@notice Checks if the given address represents a variable debt token @param metadata_address The address to check @return True if the address is a variable debt token, false otherwise

#[view]
public fun is_variable_debt_token(metadata_address: address): bool

Function get_underlying_asset_address

@notice Returns the address of the underlying asset of this debt token @param metadata_address The address of the metadata object @return The address of the underlying asset

#[view]
public fun get_underlying_asset_address(metadata_address: address): address

Function get_previous_index

@notice Returns last index interest was accrued to the user's balance @param user The address of the user @param metadata_address The address of the variable debt token @return The last index interest was accrued to the user's balance, expressed in ray

#[view]
public fun get_previous_index(user: address, metadata_address: address): u256

Function scaled_balance_of

@notice Returns the scaled balance of the user @dev The scaled balance is the sum of all the updated stored balance divided by the reserve's liquidity index at the moment of the update @param owner The user whose balance is calculated @param metadata_address The address of the variable debt token @return The scaled balance of the user

#[view]
public fun scaled_balance_of(owner: address, metadata_address: address): u256

Function balance_of

@notice Returns the amount of tokens owned by the account @param owner The address of the token owner @param metadata_address The address of the variable debt token @return The balance of tokens for the owner

#[view]
public fun balance_of(owner: address, metadata_address: address): u256

Function scaled_total_supply

@notice Returns the scaled total supply of the scaled balance token @dev Represents sum(debt/index) @param metadata_address The address of the variable debt token @return The scaled total supply

#[view]
public fun scaled_total_supply(metadata_address: address): u256

Function total_supply

@notice Returns the amount of tokens in existence @param metadata_address The address of the variable debt token @return The total supply of tokens

#[view]
public fun total_supply(metadata_address: address): u256

Function get_scaled_user_balance_and_supply

@notice Returns the scaled balance of the user and the scaled total supply @param owner The address of the user @param metadata_address The address of the variable debt token @return The scaled balance of the user @return The scaled total supply

#[view]
public fun get_scaled_user_balance_and_supply(owner: address, metadata_address: address): (u256, u256)

Function name

@notice Get the name of the fungible asset @param metadata_address The address of the variable debt token @return The name of the fungible asset

#[view]
public fun name(metadata_address: address): string::String

Function symbol

@notice Get the symbol of the fungible asset @param metadata_address The address of the variable debt token @return The symbol of the fungible asset

#[view]
public fun symbol(metadata_address: address): string::String

Function decimals

@notice Get the decimals of the fungible asset @param metadata_address The address of the variable debt token @return The number of decimals

#[view]
public fun decimals(metadata_address: address): u8

Function token_address

@notice Returns the address of a variable debt token by its symbol @param symbol The symbol of the variable debt token to find @return The address of the variable debt token

#[view]
public fun token_address(symbol: string::String): address

Function asset_metadata

@notice Returns the metadata object of a variable debt token by its symbol @param symbol The symbol of the variable debt token to find @return The metadata object of the variable debt token

#[view]
public fun asset_metadata(symbol: string::String): object::Object<fungible_asset::Metadata>

Function create_token

@notice Creates a new variable debt token @dev Callable by the pool_token_logic module @param signer The signer of the caller @param name The name of the variable debt token @param symbol The symbol of the variable debt token @param decimals The decimals of the variable debt token @param icon_uri The icon URI of the variable debt token @param project_uri The project URI of the variable debt token @param incentives_controller The incentive controller address, if any @param underlying_asset The address of the underlying asset @return The address of the variable debt token

public(friend) fun create_token(signer: &signer, name: string::String, symbol: string::String, decimals: u8, icon_uri: string::String, project_uri: string::String, incentives_controller: option::Option<address>, underlying_asset: address): address

Function mint

@notice Mints debt token to the on_behalf_of address @dev Only callable by the borrow_logic module @param caller The address receiving the borrowed underlying, being the delegatee in case of credit delegate, or same as on_behalf_of otherwise @param on_behalf_of The address receiving the debt tokens @param amount The amount of debt being minted @param index The variable debt index of the reserve @param metadata_address The address of the metadata object @return whether this is the first time we mint the VariableDebt token to on_behalf_of

public(friend) fun mint(caller: address, on_behalf_of: address, amount: u256, index: u256, metadata_address: address): bool

Function set_incentives_controller

@notice Sets an incentives controller for the variable debt token @dev Callable by the pool_token_logic module @param admin The address of the admin calling the method @param metadata_address The address of the variable debt token @param incentives_controller The address of the incentives controller

public(friend) fun set_incentives_controller(admin: &signer, metadata_address: address, incentives_controller: option::Option<address>)

Function burn

@notice Burns user variable debt @dev Only callable by the borrow_logic and liquidation_logic module @dev In some instances, a burn transaction will emit a mint event if the amount to burn is less than the interest that the user accrued @param from The address from which the debt will be burned @param amount The amount getting burned @param index The variable debt index of the reserve @param metadata_address The address of the metadata object

public(friend) fun burn(from: address, amount: u256, index: u256, metadata_address: address)

Function drop_token

@notice Drops the variable debt token associated data @dev Callable by the pool_token_logic module @param metadata_address The address of the metadata object

public(friend) fun drop_token(metadata_address: address)