# Flash Loan

<figure><img src="/files/9GN2iK2AFadjjFkVg2ty" 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://naviprotocol.gitbook.io/navi-protocol-docs/protocol-mechanics/flash-loan.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
