Module 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::flashloan_logic
@title Flashloan Logic Module @author Aave @notice Implements the logic for the flash loans
- Struct
FlashLoan
- Struct
FlashLoanLocalVars
- Struct
SimpleFlashLoansReceipt
- Struct
ComplexFlashLoansReceipt
- Struct
FlashLoanRepaymentParams
- Function
flash_loan
- Function
flash_loan_simple
- Function
pay_flash_loan_complex
- Function
pay_flash_loan_simple
- Function
get_simple_flashloan_receipt_sender
- Function
get_simple_flashloan_receipt_receiver
- Function
get_simple_flashloan_receipt_index
- Function
get_simple_flashloan_current_asset
- Function
get_simple_flashloan_current_amount
- Function
get_simple_flashloan_total_premium
- Function
get_simple_flashloan_premium_total
- Function
get_simple_flashloan_premium_to_protocol
- Function
get_simple_flashloan_referral_code
- Function
get_simple_flashloan_on_behalf_of
- Function
get_complex_flashloan_receipt_sender
- Function
get_complex_flashloan_receipt_receiver
- Function
get_complex_flashloan_receipt_index
- Function
get_complex_flashloan_current_asset
- Function
get_complex_flashloan_current_amount
- Function
get_complex_flashloan_total_premium
- Function
get_complex_flashloan_premium_total
- Function
get_complex_flashloan_premium_to_protocol
- Function
get_complex_flashloan_referral_code
- Function
get_complex_flashloan_interest_rate_mode
- Function
get_complex_flashloan_on_behalf_of
use 0x1::event;
use 0x1::object;
use 0x1::signer;
use 0x1::vector;
use 0x24e01fa503119e76bf9eea69eec59884fc3da82f5ea23bf5f20f8ce358a4606::acl_manage;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::error_config;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::user_config;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::a_token_factory;
use 0xd5044d9f4b80910ef7b8910a68d2ac257d14319fb9315ddce1ca5190878bc8ea::borrow_logic;
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 FlashLoan
@dev Emitted on pay_flash_loan_complex() and handle_flash_loan_repayment() @param target The address of the flash loan receiver contract @param initiator The address initiating the flash loan @param asset The address of the asset being flash borrowed @param amount The amount flash borrowed @param interest_rate_mode The flashloan mode: 0 for regular flashloan, 2 for Variable debt @param premium The fee flash borrowed @param referral_code The referral code used
#[event]
struct FlashLoan has drop, store
Struct FlashLoanLocalVars
@notice Helper struct for internal variables used in the execute_flash_loan_complex
and execute_flash_loan_simple
function
@dev Holds temporary data during flash loan execution
struct FlashLoanLocalVars has copy, drop
Struct SimpleFlashLoansReceipt
@notice Receipt for simple flash loans containing all information about the flash loan @dev Used to track and validate flash loan repayments
struct SimpleFlashLoansReceipt
Struct ComplexFlashLoansReceipt
@notice Receipt for complex flash loans containing all information about the flash loan @dev Used to track and validate complex flash loan repayments with different interest rate modes
struct ComplexFlashLoansReceipt
Struct FlashLoanRepaymentParams
@notice Parameters for flash loan repayment @dev Used to pass flash loan repayment details to the handle_flash_loan_repayment function
struct FlashLoanRepaymentParams has drop
Function flash_loan
@notice Allows smartcontracts to access the liquidity of the pool within one transaction,
as long as the amount taken plus a fee is returned.
@dev IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept
into consideration. For further details please visit https://docs.aave.com/developers/
@param initiator The signer account of the flash loan initiator
@param receiver_address The address of the contract receiving the funds
@param assets The addresses of the assets being flash-borrowed
@param amounts The amounts of the assets being flash-borrowed
@param interest_rate_modes Types of the debt to open if the flash loan is not returned:
0 -> Don't open any debt, just revert if funds can't be transferred from the receiver
2 -> Open debt at variable rate for the value of the amount flash-borrowed to the on_behalf_of
address
@param on_behalf_of The address that will receive the debt in the case of using on interest_rate_modes
2, on_behalf_of Should be the account address
@param referral_code The code used to register the integrator originating the operation, for potential rewards.
@return the receipt for the complex flashloan
public fun flash_loan(initiator: &signer, receiver_address: address, assets: vector<address>, amounts: vector<u256>, interest_rate_modes: vector<u8>, on_behalf_of: address, referral_code: u16): vector<flashloan_logic::ComplexFlashLoansReceipt>
Function flash_loan_simple
@notice Allows smartcontracts to access the liquidity of the pool within one transaction, as long as the amount taken plus a fee is returned. @dev IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration. For further details please visit https://docs.aave.com/developers/ @param initiator The signer account of the flash loan initiator @param receiver_address The address of the contract receiving the funds @param asset The address of the asset being flash-borrowed @param amount The amount of the asset being flash-borrowed @param referral_code The code used to register the integrator originating the operation, for potential rewards. @return the receipt for the simple flashloan
public fun flash_loan_simple(initiator: &signer, receiver_address: address, asset: address, amount: u256, referral_code: u16): flashloan_logic::SimpleFlashLoansReceipt
Function pay_flash_loan_complex
@notice Repays flashloaned assets + premium @dev Will pull the amount + premium from the receiver @param flash_loan_receiver The signer account of the flash loan receiver @param flashloan_receipts The receipts of the flashloaned assets
public fun pay_flash_loan_complex(flash_loan_receiver: &signer, flashloan_receipts: vector<flashloan_logic::ComplexFlashLoansReceipt>)
Function pay_flash_loan_simple
@notice Repays flashloaned assets + premium @dev Will pull the amount + premium from the receiver @param flash_loan_receiver The signer account of flash loan receiver @param flashloan_receipt The receipt of the flashloaned asset
public fun pay_flash_loan_simple(flash_loan_receiver: &signer, flashloan_receipt: flashloan_logic::SimpleFlashLoansReceipt)
Function get_simple_flashloan_receipt_sender
@notice Returns the simple flashloan receipt sender @param receipt The simple flashloan receipt received @return the address of the sender inside the simple flashloan receipt
public fun get_simple_flashloan_receipt_sender(receipt: &flashloan_logic::SimpleFlashLoansReceipt): address
Function get_simple_flashloan_receipt_receiver
@notice Returns the simple flashloan receipt receiver @param receipt The simple flashloan receipt received @return the address of the receiver inside the simple flashloan receipt
public fun get_simple_flashloan_receipt_receiver(receipt: &flashloan_logic::SimpleFlashLoansReceipt): address
Function get_simple_flashloan_receipt_index
@notice Returns the simple flashloan receipt index @param receipt The simple flashloan receipt received @return the simple flashloan receipt index
public fun get_simple_flashloan_receipt_index(receipt: &flashloan_logic::SimpleFlashLoansReceipt): u256
Function get_simple_flashloan_current_asset
@notice Returns the simple flashloan receipt current asset @param receipt The simple flashloan receipt received @return the simple flashloan receipt asset
public fun get_simple_flashloan_current_asset(receipt: &flashloan_logic::SimpleFlashLoansReceipt): address
Function get_simple_flashloan_current_amount
@notice Returns the simple flashloan receipt current amount @param receipt The simple flashloan receipt received @return the simple flashloan receipt amount
public fun get_simple_flashloan_current_amount(receipt: &flashloan_logic::SimpleFlashLoansReceipt): u256
Function get_simple_flashloan_total_premium
@notice Returns the simple flashloan receipt total premium @param receipt The simple flashloan receipt received @return the simple flashloan receipt total premium
public fun get_simple_flashloan_total_premium(receipt: &flashloan_logic::SimpleFlashLoansReceipt): u256
Function get_simple_flashloan_premium_total
@notice Returns the simple flashloan receipt premium total @param receipt The simple flashloan receipt received @return the simple flashloan receipt premium total
public fun get_simple_flashloan_premium_total(receipt: &flashloan_logic::SimpleFlashLoansReceipt): u256
Function get_simple_flashloan_premium_to_protocol
@notice Returns the simple flashloan receipt premium to protocol @param receipt The simple flashloan receipt received @return the simple flashloan receipt premium to protocol
public fun get_simple_flashloan_premium_to_protocol(receipt: &flashloan_logic::SimpleFlashLoansReceipt): u256
Function get_simple_flashloan_referral_code
@notice Returns the simple flashloan receipt referral code @param receipt The simple flashloan receipt received @return the simple flashloan receipt referral code
public fun get_simple_flashloan_referral_code(receipt: &flashloan_logic::SimpleFlashLoansReceipt): u16
Function get_simple_flashloan_on_behalf_of
@notice Returns the simple flashloan receipt on behalf of @param receipt The simple flashloan receipt received @return the simple flashloan receipt on behalf of
public fun get_simple_flashloan_on_behalf_of(receipt: &flashloan_logic::SimpleFlashLoansReceipt): address
Function get_complex_flashloan_receipt_sender
@notice Returns the complex flashloan receipt sender @param receipt The complex flashloan receipt received @return the complex flashloan receipt sender
public fun get_complex_flashloan_receipt_sender(receipt: &flashloan_logic::ComplexFlashLoansReceipt): address
Function get_complex_flashloan_receipt_receiver
@notice Returns the complex flashloan receipt receiver @param receipt The complex flashloan receipt received @return the complex flashloan receipt receiver
public fun get_complex_flashloan_receipt_receiver(receipt: &flashloan_logic::ComplexFlashLoansReceipt): address
Function get_complex_flashloan_receipt_index
@notice Returns the complex flashloan receipt index @param receipt The complex flashloan receipt received @return the complex flashloan receipt index
public fun get_complex_flashloan_receipt_index(receipt: &flashloan_logic::ComplexFlashLoansReceipt): u256
Function get_complex_flashloan_current_asset
@notice Returns the complex flashloan receipt current asset @param receipt The complex flashloan receipt received @return the complex flashloan receipt asset
public fun get_complex_flashloan_current_asset(receipt: &flashloan_logic::ComplexFlashLoansReceipt): address
Function get_complex_flashloan_current_amount
@notice Returns the complex flashloan receipt current amount @param receipt The complex flashloan receipt received @return the complex flashloan receipt amount
public fun get_complex_flashloan_current_amount(receipt: &flashloan_logic::ComplexFlashLoansReceipt): u256
Function get_complex_flashloan_total_premium
@notice Returns the complex flashloan receipt total premium @param receipt The complex flashloan receipt received @return the complex flashloan receipt total premium
public fun get_complex_flashloan_total_premium(receipt: &flashloan_logic::ComplexFlashLoansReceipt): u256
Function get_complex_flashloan_premium_total
@notice Returns the complex flashloan receipt premium total @param receipt The complex flashloan receipt received @return the complex flashloan receipt total premium
public fun get_complex_flashloan_premium_total(receipt: &flashloan_logic::ComplexFlashLoansReceipt): u256
Function get_complex_flashloan_premium_to_protocol
@notice Returns the complex flashloan receipt premium to protocol @param receipt The complex flashloan receipt received @return the complex flashloan receipt premium to protocol
public fun get_complex_flashloan_premium_to_protocol(receipt: &flashloan_logic::ComplexFlashLoansReceipt): u256
Function get_complex_flashloan_referral_code
@notice Returns the complex flashloan receipt referral code @param receipt The complex flashloan receipt received @return the complex flashloan receipt referral code
public fun get_complex_flashloan_referral_code(receipt: &flashloan_logic::ComplexFlashLoansReceipt): u16
Function get_complex_flashloan_interest_rate_mode
@notice Returns the complex flashloan receipt interest rate mode @param receipt The complex flashloan receipt received @return the complex flashloan receipt interest rate mode
public fun get_complex_flashloan_interest_rate_mode(receipt: &flashloan_logic::ComplexFlashLoansReceipt): u8
Function get_complex_flashloan_on_behalf_of
@notice Returns the complex flashloan receipt on behalf of @param receipt The complex flashloan receipt received @return the complex flashloan receipt on behalf of
public fun get_complex_flashloan_on_behalf_of(receipt: &flashloan_logic::ComplexFlashLoansReceipt): address