Module 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::token_base

@title Token Base Module @author Aave @notice Base module for token implementations in the Aave protocol @dev Provides core functionality for aTokens and debt tokens with scaled balances

use 0x1::event;
use 0x1::fungible_asset;
use 0x1::object;
use 0x1::option;
use 0x1::primary_fungible_store;
use 0x1::signer;
use 0x1::smart_table;
use 0x1::string;
use 0x24e01fa503119e76bf9eea69eec59884fc3da82f5ea23bf5f20f8ce358a4606::acl_manage;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::error_config;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::rewards_controller;
use 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::wad_ray_math;

Struct Transfer

@notice Emitted when tokens are moved from one account to another @dev Note that value may be zero @param from The address sending the tokens @param to The address receiving the tokens @param value The amount of tokens transferred @param token The address of the token

#[event]
struct Transfer has drop, store

Struct Mint

@notice Emitted after a mint action @param caller The address performing the mint @param on_behalf_of The address of the user that will receive the minted tokens @param value The scaled-up amount being minted (based on user entered amount and balance increase from interest) @param balance_increase The increase in scaled-up balance since the last action of 'on_behalf_of' @param index The next liquidity index of the reserve @param token The a/v token address

#[event]
struct Mint has drop, store

Struct Burn

@notice Emitted after a burn action @dev If the burn function does not involve a transfer of the underlying asset, the target defaults to zero address @param from The address from which the tokens will be burned @param target The address that will receive the underlying, if any @param value The scaled-up amount being burned (user entered amount - balance increase from interest) @param balance_increase The increase in scaled-up balance since the last action of 'from' @param index The next liquidity index of the reserve @param token The a/v token address

#[event]
struct Burn has drop, store

Struct UserState

@notice Stores user-specific token data @param balance The scaled balance of the user @param additional_data The liquidity index at the time of last balance update

struct UserState has copy, drop, store

Resource ManagedFungibleAsset

@notice Hold refs to control the minting, transfer and burning of fungible assets @param mint_ref Reference for minting tokens @param transfer_ref Reference for transferring tokens @param burn_ref Reference for burning tokens

#[resource_group_member(#[group = 0x1::object::ObjectGroup])]
struct ManagedFungibleAsset has drop, key

Resource TokenBaseState

@notice Hold stateful information about tokens based on ScaledBalanceTokenBase @param scaled_total_supply The total supply of the token in scaled units @param user_state Mapping of user addresses to their state @param incentives_controller Address of the incentives controller, if set

#[resource_group_member(#[group = 0x1::object::ObjectGroup])]
struct TokenBaseState has key

Function get_previous_index

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

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

Function get_incentives_controller

@notice Returns the incentives controller address @param metadata_address The address of the token @return The address of the incentives controller, if set

#[view]
public fun get_incentives_controller(metadata_address: address): option::Option<address>

Function scaled_balance_of

@notice Returns the scaled balance of a user @dev The scaled balance is the balance divided by the reserve's liquidity index at the time of the update @param owner The address of the user @param metadata_address The address of the token @return The scaled balance of the user

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

Function scaled_total_supply

@notice Returns the total supply in scaled units @param metadata_address The address of the token @return The total supply in scaled units

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

Function get_scaled_user_balance_and_supply

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

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

Function name

@notice Returns the name of the token @param metadata_address The address of the token @return The name of the token

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

Function symbol

@notice Returns the symbol of the token @param metadata_address The address of the token @return The symbol of the token

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

Function decimals

@notice Returns the number of decimals of the token @param metadata_address The address of the token @return The number of decimals

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

Function only_pool_admin

@notice Checks if the caller is a pool admin @param account The account to check @dev Aborts if the account is not a pool admin

public fun only_pool_admin(account: &signer)

Function only_token_admin

@notice Checks if the caller is a token admin @param account The account to check @dev Aborts if the account is not a token admin

public fun only_token_admin(account: &signer)

Function set_incentives_controller

@notice Sets the incentives controller for the token @dev Only callable by friend modules @param admin The signer of the admin account @param metadata_address The address of the 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 create_token

@notice Creates a new token @dev Only callable by the a_token_factory and variable_debt_token_factory module @param constructor_ref The constructor reference of the token @param name The name of the token @param symbol The symbol of the token @param decimals The decimals of the token @param icon_uri The icon URI of the token @param project_uri The project URI of the token @param incentives_controller The incentive controller address, if any

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

Function mint_scaled

@notice Mints tokens to a recipient @dev Only callable by the a_token_factory and variable_debt_token_factory module @param caller The address performing the mint @param on_behalf_of The address of the user that will receive the minted tokens @param amount The amount of tokens to mint @param index The next liquidity index of the reserve @param metadata_address The address of the token @return Whether this is the first time tokens are minted to the recipient

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

Function burn_scaled

@notice Burns tokens from a user @dev Only callable by the a_token_factory and variable_debt_token_factory module @dev In some instances, the mint event could be emitted from a burn transaction if the amount to burn is less than the interest that the user accrued @param user The address from which the tokens will be burned @param target The address that will receive the underlying @param amount The amount being burned @param index The next liquidity index of the reserve @param metadata_address The address of the token

public(friend) fun burn_scaled(user: address, target: address, amount: u256, index: u256, metadata_address: address)

Function transfer

@notice Transfers tokens between accounts @dev Only callable by the a_token_factory and pool_token_logic module @param sender The address from which the tokens will be transferred @param recipient The address that will receive the tokens @param amount The amount being transferred @param index The next liquidity index of the reserve @param metadata_address The address of the token

public(friend) fun transfer(sender: address, recipient: address, amount: u256, index: u256, metadata_address: address)

Function drop_token

@notice Drops the token data from the token map @dev Only callable by the a_token_factory and variable_debt_token_factory module @param metadata_address The address of the token

public(friend) fun drop_token(metadata_address: address)