Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a flash loan in blockchain?
A flash loan is a type of uncollateralized loan that must be borrowed and repaid within a single blockchain transaction.
Click to reveal answer
beginner
Why do flash loans not require collateral?
Because the loan is repaid within the same transaction, the blockchain ensures the lender either gets the money back or the whole transaction fails, so no collateral is needed.
Click to reveal answer
beginner
What happens if a flash loan is not repaid in the same transaction?
The entire transaction is reverted, meaning all actions are undone and the loan is never given out.
Click to reveal answer
intermediate
Give a simple example use case of a flash loan.
A trader can borrow funds to quickly buy an asset, sell it at a higher price, repay the loan, and keep the profit, all within one transaction.
Click to reveal answer
intermediate
What is a key risk associated with flash loans?
Flash loans can be used for attacks like price manipulation or exploiting vulnerabilities in smart contracts.
Click to reveal answer
What ensures a flash loan is safe for the lender?
AThe borrower provides collateral
BThe loan must be repaid within the same transaction
CThe loan is insured by a third party
DThe loan is given only to trusted users
✗ Incorrect
Flash loans require repayment within the same transaction, or the transaction fails, protecting the lender.
Which of these is NOT a characteristic of a flash loan?
ALoan duration can be several days
BNo collateral required
CRepaid within one transaction
DUsed for arbitrage or quick trades
✗ Incorrect
Flash loans must be repaid within the same transaction, so they cannot last several days.
What happens if a flash loan is not repaid on time?
AThe transaction is reverted
BThe lender loses money
CThe borrower is blacklisted
DThe loan is converted to a regular loan
✗ Incorrect
If the flash loan is not repaid in the same transaction, the entire transaction is reverted.
Flash loans are mostly used for:
ALong-term investments
BBuying real estate
CQuick arbitrage opportunities
DPaying salaries
✗ Incorrect
Flash loans are used for quick trades like arbitrage within one transaction.
Which is a potential risk of flash loans?
AThey require high collateral
BThey are only available to banks
CThey have long repayment periods
DThey can be used to exploit smart contract bugs
✗ Incorrect
Flash loans can be used maliciously to exploit vulnerabilities in smart contracts.
Explain how a flash loan works in a blockchain transaction.
Think about what happens if the loan is not paid back immediately.
You got /3 concepts.
Describe one practical use case and one risk of flash loans.
Consider both benefits and dangers of instant loans.
You got /2 concepts.
Practice
(1/5)
1. What is the main feature of a flash loan in blockchain?
easy
A. You can borrow funds without collateral but must repay within the same transaction
B. You borrow funds with collateral and repay anytime
C. You borrow funds and repay after 30 days
D. You borrow funds only for staking purposes
Solution
Step 1: Understand flash loan basics
Flash loans allow borrowing without collateral but require repayment in the same transaction.
Step 2: Compare options
Only You can borrow funds without collateral but must repay within the same transaction correctly states no collateral and instant repayment.
Final Answer:
You can borrow funds without collateral but must repay within the same transaction -> Option A
Quick Check:
Flash loan = no collateral + instant repayment [OK]
C. Using transferFrom instead of approve for repayment
D. Not calling the lending pool to borrow funds
Solution
Step 1: Analyze repayment method
The code tries to pull repayment using transferFrom from msg.sender, which is incorrect.
Step 2: Correct repayment approach
Flash loans require approving the lending pool to pull funds, not transferring from msg.sender.
Final Answer:
Using transferFrom instead of approve for repayment -> Option C
Quick Check:
Repayment needs approve(), not transferFrom() [OK]
Hint: Repay by approve(), not transferFrom() [OK]
Common Mistakes:
Confusing transferFrom with approve
Forgetting to approve lending pool
Misunderstanding msg.sender role
5. You want to use a flash loan to perform arbitrage between two decentralized exchanges (DEXs). Which sequence correctly describes the steps inside executeOperation to profit and repay the loan?
hard
A. Borrow funds -> Buy low on DEX1 -> Sell high on DEX2 -> Approve repayment -> Return true
B. Borrow funds -> Approve repayment -> Buy low on DEX1 -> Sell high on DEX2 -> Return true
C. Approve repayment -> Borrow funds -> Buy low on DEX1 -> Sell high on DEX2 -> Return true
D. Buy low on DEX1 -> Borrow funds -> Sell high on DEX2 -> Approve repayment -> Return true
Solution
Step 1: Understand flash loan flow
You first borrow funds, then use them to buy low on one DEX and sell high on another to gain profit.
Step 2: Approve repayment and finish
After trading, approve the lending pool to pull the loan plus fee, then return true to complete.
Final Answer:
Borrow funds -> Buy low on DEX1 -> Sell high on DEX2 -> Approve repayment -> Return true -> Option A