Overview
Aave is a decentralized liquidity protocol that lets its users borrow and lend funds in a non-custodial way. One innovative use case of Aave is flash loans, where a borrower can borrow tokens from the pool, do something with the tokens, and repay the loan with minimal interest, all in one transaction.
Learn more about flash loans in this guide: How to Make a flash loan using Aave.
A flash loan transaction is a complex transaction, but with QuickAlerts we can easily track whenever such transactions occur.
Aave Flash Loan Executed
Whenever a flash loan is executed the following event is emitted by the AAVE v3 pool smart contract:
FlashLoan (index_topic_1 address target, address initiator, index_topic_2 address asset, uint256 amount, uint8 interestRateMode, uint256 premium, index_topic_3 uint16 referralCode)
To create our expression, we will need to target two values:
- The Aave v3 pool contract address - We'll use the address of the AAVE v3 pool smart contract. This value gets set as the
tx_logs_address
, as we will be looking for any transactions from this address (the contract). - The event the contract emits when the action we're interested in occurs - In the case of the Aave v3 pool contract is the
FlashLoan
event. On EVM blockchains, the event is encoded and can be found intx_logs_topic0
. To get the encoded value, you will need to take the event definition (event name and parameters' types), run it through the Keccak-256 hash function, and prefix it with0x
.
FlashLoan(address,address,address,uint256,uint8,uint256,uint16)
⬇
efefaba5e921573100900a3ad9cf29f222d995fb3b6045797eaea7521bd8d6f0
⬇
0xefefaba5e921573100900a3ad9cf29f222d995fb3b6045797eaea7521bd8d6f0
1tx_logs_address == '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2'2&&3tx_logs_topic0 == '0xefefaba5e921573100900a3ad9cf29f222d995fb3b6045797eaea7521bd8d6f0'