> For the complete documentation index, see [llms.txt](https://dev.init.capital/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.init.capital/guides/advanced-interaction/flashloan.md).

# Flashloan

INIT offers a 0% fee flashloan for users to atomically use the available liquidity from lending pools to use elsewhere. The caller of `flash` function must be a contract that implements `flashCallback` function.&#x20;

During the flashloan, the caller receives flashloan from lending pools and can execute arbitrary logic from bytes `data` through `flashCallback` which is called to the caller by InitCore. At the end of the flashloan, the caller must return the loan to the borrowed lending pools.

{% hint style="info" %}
It is recommended to check that the sender is the InitCore in the `flashCallback` function to prevent unauthorized calls.
{% endhint %}

```solidity
// Example Flashloan contract
contract FlashloanContract {
    function flashCallback(address[] calldata lendingPools, uint256[] calldata amounts, bytes calldata data) external {
        // check that the caller is InitCore
        require(msg.sender == INIT_CORE, 'unauthorized'); 
        
        // do some logic 
        
        // transfer back amounts to corresponding lending pools
    }
    
    function flash(address[] calldata lendingPools, uint256[] calldata amounts, bytes calldata data) external {
        // initiate flash loan
        IInitCore(INIT_CORE).flash(lendingPools, amounts, data);
    }
}


```
