Complete the code to start a flash loan using the lending pool.
lendingPool.[1](asset, amount, params);The flashLoan function initiates a flash loan in most DeFi lending pools.
Complete the code to check if the flash loan was repaid within the same transaction.
require(amountOwing <= IERC20(asset).balanceOf([1]), "Flash loan not repaid");
msg.sender checks the caller's balance, not the contract's.tx.origin checks the original transaction sender, which is incorrect here.The contract's token balance is checked using IERC20(asset).balanceOf(address(this)) to ensure repayment.
Fix the error in the function signature for executing the flash loan logic.
function executeOperation(address asset, uint256 amount, uint256 premium, address initiator, bytes calldata [1]) external returns (bool) {The parameter is conventionally named params to hold extra data passed to the function.
Fill both blanks to calculate the total amount to repay including the premium.
uint256 amountOwing = amount [1] premium [2];
The total amount owed is the sum of the borrowed amount and the premium, so both blanks use '+'.
Fill all three blanks to approve the lending pool to withdraw the owed amount.
IERC20(asset).[1](address([2]), [3]);
The contract must approve the lending pool to withdraw the owed amount using approve.