Module 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::supply_logic

@title Supply Logic Module @author Aave @notice Implements the logic for supply and withdraw operations

use 0x1::event;
use 0x1::fungible_asset;
use 0x1::object;
use 0x1::signer;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::error_config;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::reserve_config;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::user_config;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::a_token_factory;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::coin_migrator;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::emode_logic;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::events;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::fungible_asset_manager;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool_fee_manager;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::pool_logic;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::validation_logic;
use 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::math_utils;
use 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::wad_ray_math;

Struct Supply

@dev Emitted on supply() @param reserve The address of the underlying asset of the reserve @param user The address initiating the supply @param on_behalf_of The beneficiary of the supply, receiving the aTokens @param amount The amount supplied @param referral_code The referral code used

#[event]
struct Supply has drop, store

Struct Withdraw

@dev Emitted on withdraw() @param reserve The address of the underlying asset being withdrawn @param user The address initiating the withdrawal, owner of aTokens @param to The address that will receive the underlying @param amount The amount to be withdrawn

#[event]
struct Withdraw has drop, store

Function supply

@notice Supplies an amount of underlying fungible asset into the reserve, receiving in return overlying aTokens. - E.g. User supplies 100 USDC and gets in return 100 aUSDC @param account The account signer that will supply the asset @param asset The address of the underlying fungible asset to supply @param amount The amount to be supplied @param on_behalf_of The address that will receive the aTokens, same as account address if the user wants to receive them on his own wallet, or a different address if the beneficiary of aTokens is a different wallet @param referral_code Code used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-man

public entry fun supply(account: &signer, asset: address, amount: u256, on_behalf_of: address, referral_code: u16)

Function supply_coin

@notice Supplies an amount of underlying asset of type Coin into the reserve, receiving in return overlying aTokens. - E.g. User supplies 100 APT and gets in return 100 aAPT @param account The account signer that will supply the asset @param asset The address of the underlying asset of type coin to supply @param amount The amount to be supplied @param on_behalf_of The address that will receive the aTokens, same as account address if the user wants to receive them on his own wallet, or a different address if the beneficiary of aTokens is a different wallet @param referral_code Code used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-man

public entry fun supply_coin<CoinType>(account: &signer, amount: u256, on_behalf_of: address, referral_code: u16)

Function withdraw

@notice Withdraws an amount of underlying asset from the reserve, burning the equivalent aTokens owned E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC @param account The account signer that will withdraw the asset @param asset The address of the underlying asset to withdraw @param amount The underlying amount to be withdrawn - Send the value math_utils::u256_max() in order to withdraw the whole aToken balance @param to The address that will receive the underlying, same as account address if the user wants to receive it on his own wallet, or a different address if the beneficiary is a different wallet

public entry fun withdraw(account: &signer, asset: address, amount: u256, to: address)

Function set_user_use_reserve_as_collateral

@notice Allows suppliers to enable/disable a specific supplied asset as collateral @dev Emits the ReserveUsedAsCollateralEnabled() event if the asset can be activated as collateral. @dev In case the asset is being deactivated as collateral, ReserveUsedAsCollateralDisabled() is emitted. @param account The account signer that will enable/disable the usage of the asset as collateral @param asset The address of the underlying asset supplied @param use_as_collateral True if the user wants to use the supply as collateral, false otherwise

public entry fun set_user_use_reserve_as_collateral(account: &signer, asset: address, use_as_collateral: bool)