# Flash Loan

<figure><img src="https://757519164-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYTRq6w3DGapKHxfqaA3Z%2Fuploads%2F1BvxfPdEMesz5n3oSgGj%2Fimage.png?alt=media&#x26;token=05e432bb-ca25-42e6-9df5-8290c7bc95d7" alt=""><figcaption></figcaption></figure>

NAVI Flash Loans are an innovative financial tool exclusive to the blockchain domain, enabling users to borrow assets without providing upfront collateral. These loans, also known as **One-Block Borrows**, must be initiated and fully settled within the same blockchain block. Their success relies on the execution of predefined conditions within this strict timeframe.

### Overview

Flash loans allow users to access liquidity from a pool for a single transaction, either by:

* Borrowing and repaying the loan plus fees immediately, or
* Opening a debt position if permitted by the pool.

NAVI Protocol offers two options for flash loans:

* `flashloan`:
  * Liquidity is borrowed from the pool.
  * Both the borrowed funds and the debt receipt are sent to the address that initiates the transaction.
* `flashloan_with_AccountCap`:
  * Borrowed funds are sent to a predefined account cap address, while the debt receipt is sent to the transaction initializer.
  * The initializer must destroy the receipt by the end of the block for the transaction to succeed.

### Flash Loan Config

Live fees and pool parameters can be found in [SDK docs](https://sdk.naviprotocol.io/lending/flashloan).

* Availability: Enabled for all pools, with initial borrowing caps per pool.
* Adjustments: NAVI regularly evaluates risk and may update borrowing limits.

### Execution Flow

For SUI developers, a helpful model to consider when developing your solution:

1. Initialize all the parameters required in a [PTB (Programmable Transaction Block)](https://docs.sui.io/guides/developer/sui-101/building-ptb)
2. Your contract calls the `pool::lending::flash_loan_with_ctx`

   &#x20;contract, requesting a Flash Loan of a certain `amount(s)` of `pool(s)`
3. After some sanity checks, the `Lending Contract` transfers the requested `amounts` of the `coins` to your contract, then issue receipt to `receiver` address.
4. Your contract, now holding the flash loaned `amount(s)`, executes any arbitrary operation in the ptb.
5. Call `pool::lending::flash_repay_with_ctx` and send the borrowed money plus fee as an object to the contract.

> All steps occur within a single PTB transaction, i.e., a single SUI block.

### Getting Started

You may refer [NAVI-Developer Doc](https://naviprotocol.gitbook.io/navi-protocol-developer-docs/) or [navi-sdk](https://naviprotocol.gitbook.io/navi-protocol-developer-docs/how-to-interact-with-the-contract/navi-sdk) for efficient development.
