# @naviprotocol/lending

[![npm version](https://badge.fury.io/js/%40naviprotocol%2Flending.svg)](https://badge.fury.io/js/%40naviprotocol%2Flending)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

NAVI Lending SDK is a lending SDK designed specifically for the Sui blockchain, providing complete lending functionality including account management, pool operations, flash loans, liquidation, and reward systems.

## Documentation

For SDK documentation visit http://sdk.naviprotocol.io/lending

## Core Concepts

### Lending Protocol Basics

The NAVI lending protocol allows users to:

- **Deposit**: Deposit assets into pools to earn interest
- **Borrow**: Use deposits as collateral to borrow other assets
- **Repay**: Repay loans and pay interest
- **Withdraw**: Withdraw deposits from pools

### Health Factor

Health factor is an important metric for measuring the safety of a user's lending account:

- **Health Factor > 1**: Account is safe and can continue borrowing
- **Health Factor ≤ 1**: Account is at risk of liquidation

### Flash Loan

Flash loans allow users to borrow assets without collateral, but must be repaid within the same transaction.

## Installation

```npm
npm install @naviprotocol/lending
```

## Code Style and Conventions

### Interface Optional Parameters

The last `options` parameter of the interface is usually an optional object used to customize interface behavior. Common optional parameters include but are not limited to:

- `client`: Sui SDK v2 client instance, such as `SuiJsonRpcClient` from `@mysten/sui/jsonRpc`, used for customizing network requests in multi-network or custom RPC environments.
- `env`: Specify environment (such as `'prod'`、`'dev'`), affecting data sources and on-chain contract addresses, ensuring data isolation and compatibility in different deployment environments.
- `cacheTime`: Custom cache time in milliseconds. By setting cache time, you can reduce duplicate requests and improve performance. For example, `cacheTime: 60000` means cache for 60 seconds.
- `disableCache`: Whether to disable cache
- `accountCap`: In ptb-related operations, use account cap

**Usage Recommendations:**

- If you don't pass `options`, the SDK will automatically use default configuration, suitable for most regular scenarios.
- When you need to customize network, environment, or cache strategy, it's recommended to pass corresponding parameters for more flexible control.


### Interface Naming

- Interfaces with PTB suffix indicate that the current interface is used for constructing transactions.


## Support

- Issues: [GitHub Issues](https://github.com/naviprotocol/naviprotocol-monorepo/issues)
