β‘Flash Loan
Developer documentation on how to utilize CROSS for flash loan utility
Overview
Flash loan functionality is healthy for any ecosystem as they assist in ensuring efficient market pricing via arbitrage, healthy collateral levels in lending protocols via flash liquidation, and much more.
Flash loans are a feature designed for developers, due to the technical knowledge required to execute one. Flash Loans allow you to borrow any available amount of assets without putting up any collateral, as long as the liquidity is returned to the protocol within one block transaction. To do a Flash Loan, you will need to build a contract that requests a Flash Loan. The contract will then need to execute the instructed steps and pay back the loan + interest and fees all within the same transaction.
Documentation
Some CROSS pools have flash loan functionalities enabled for a small, industry-standard 0.08% fee.
function flashLoan(
address receiver,
IERC20 token,
uint256 amount,
bytes memory params
) external;Caller must provide a valid receiver address that inherits IFlashLoanReceiver interface.
Upon finishing executeOperation, the pool must have the initial liquidity back along with the associated fee. If the requirement is not met, then the transaction will fail.
Contract Template
We provide a basic example of a flash loan borrower contract:
Here, for getting of Flash-Loan and using of it you need to call getFlashLoan method only.
Example of a loan getting in 1000 USDC:
Last updated