# Flash Loan

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

With a flash loan, users can access the pool's liquidity for a single transaction—but only for reserves for which borrowing is permitted—as long as the money borrowed plus the associated fee is returned or, if permitted, a debt position is opened by the end of the transaction.

NAVI Protocol offers two options for flash loans:

* `flashloan`: This type of flash loan allows users to borrow liquidity from pools above, both the money borrowed and debt receipt will be sent to the address who start the transaction.\

* `flashloan_with_AccountCap`: This type of flash loan allows users to borrow liquidity from pools above, but the money borrowed will be sent to the account cap address and debt receipt will be sent to the address who start the transaction. Transaction initializer must destroy the receipt at end of the block to make this transaction happen.

### Flash Loan Config

| Pool    | Fee to LP | Fee to Treasury                                | Max Borrow | Min Borrow |
| ------- | --------- | ---------------------------------------------- | ---------- | ---------- |
| Sui     | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 3,000,000  | 0          |
| vSUI    | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 3,000,000  | 0          |
| haSui   | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 2,000,000  | 0          |
| wUSDC   | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 5,000,000  | 0          |
| nUSDC   | 0%        | ~~0.2%~~ <mark style="color:red;">0</mark>%    | 10,000,000 | 0          |
| USDT    | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 5,000,000  | 0          |
| USDY    | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 1,000,000  | 0          |
| AUSD    | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 1,000,000  | 0          |
| suiETH  | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 1,000      | 0          |
| wETH    | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 500        | 0          |
| NAVX    | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 5,000,000  | 0          |
| CETUS   | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 5,000,000  | 0          |
| FDUSD   | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 2,000,000  | 0          |
| wBTC    | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 10         | 0          |
| NS      | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 5,000,000  | 0          |
| DEEP    | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 5,000,000  | 0          |
| BUCK    | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 5,000,000  | 0          |
| suiUSDT | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 5,000,000  | 0          |
| BLUE    | 0%        | ~~0.2%~~ <mark style="color:red;">0.06</mark>% | 2,000,000  | 0          |

### Key Details&#x20;

Flash loans are currently enabled for **all** pools, with an initial borrowing cap for each pool.

The borrowing fee is distributed between Liquidity Providers (LPs) and the protocol's treasury:

LP Fee: **0%**&#x20;

Treasury Fee: Initially set at 0.2%, temporarily reduced to <mark style="color:red;">0.06%</mark> to attract more developers. Refer to the AssetConfig for current fees. The NAVI Protocol Team regularly assesses risk factors and may adjust maximum borrow limits in the future.



### 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.
6. All of the above happens in 1 ptb transaction (hence in 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
