0
0
Blockchain / Solidityprogramming~10 mins

Flash loans in Blockchain / Solidity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a flash loan using the lending pool.

Blockchain / Solidity
lendingPool.[1](asset, amount, params);
Drag options to blanks, or click blank then click option'
Awithdraw
Bdeposit
Cborrow
DflashLoan
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'borrow' instead of 'flashLoan' causes the code to fail because 'borrow' is not the flash loan function.
Using 'deposit' or 'withdraw' does not start a flash loan.
2fill in blank
medium

Complete the code to check if the flash loan was repaid within the same transaction.

Blockchain / Solidity
require(amountOwing <= IERC20(asset).balanceOf([1]), "Flash loan not repaid");
Drag options to blanks, or click blank then click option'
Aaddress(this)
Bbalance
Cmsg.sender
Dtx.origin
Attempts:
3 left
💡 Hint
Common Mistakes
Using msg.sender checks the caller's balance, not the contract's.
Using tx.origin checks the original transaction sender, which is incorrect here.
3fill in blank
hard

Fix the error in the function signature for executing the flash loan logic.

Blockchain / Solidity
function executeOperation(address asset, uint256 amount, uint256 premium, address initiator, bytes calldata [1]) external returns (bool) {
Drag options to blanks, or click blank then click option'
Aparams
Bdata
Cdetails
Dinfo
Attempts:
3 left
💡 Hint
Common Mistakes
Using other names like 'data' or 'info' causes mismatch with the lending pool interface.
Incorrect parameter names cause compilation errors.
4fill in blank
hard

Fill both blanks to calculate the total amount to repay including the premium.

Blockchain / Solidity
uint256 amountOwing = amount [1] premium [2];
Drag options to blanks, or click blank then click option'
A+
B-
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' subtracts the premium, which is incorrect.
Using '*' or '/' causes wrong calculations.
5fill in blank
hard

Fill all three blanks to approve the lending pool to withdraw the owed amount.

Blockchain / Solidity
IERC20(asset).[1](address([2]), [3]);
Drag options to blanks, or click blank then click option'
Aapprove
BlendingPool
CamountOwing
Dtransfer
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'transfer' instead of 'approve' causes errors.
Approving the wrong address or amount causes the flash loan to fail.