# LendingPool

INIT lending pool contract.

## View Functions

### core

InitCore contract address.

```solidity
function core() external view returns (address initCore);
```

### underlyingToken

Underlying token of the lending pool.

```solidity
function underlyingToken() external view returns (address underlyingToken);
```

### cash

Current liquidity available for borrow.

```solidity
function cash() external view returns (uint256 amt);
```

### totalDebt

Last stored total borrowed amount of underlying token amount, including borrow interest.

```solidity
function totalDebt() external view returns (uint256 totalDebt);
```

### totalDebtShares

Last stored total debt shares.

```solidity
function totalDebtShares() external view returns (uint256 totalDebtShares);
```

### irm

Interest rate model contract address of lending pool.

```solidity
function irm() external view returns (address interestRateModel);
```

### lastAccruedTime

Last stored timestamp that accrue borrow interest.

```solidity
function lastAccruedTime() external view returns (uint256 lastAccruedTimestamp);
```

### reserveFactor\_e18

Reserve factor in `10^18` precision.

```solidity
function reserveFactor_e18() external view returns (uint256 factor);
```

### treasury

INIT treasury contract address.

```solidity
function treasury() external view returns (address treasury);
```

### decimals

inToken decimal (currently equals to`8 + underlyingToken.decimals()`).

```solidity
function decimals() external view returns (uint256 decimal);
```

### debtAmtToShareStored

Convert debt amount to debt shares (rounded up) without interest accrual. For interest accrual, use [debtAmtToShareCurrent](#debtamttosharecurrent).

```solidity
function debtAmtToShareStored(uint _amt) external view returns (uint shares);
```

### debtShareToAmtStored

Convert debt amount to debt shares (rounded up) without interest accrual. For interest accrual, use [debtShareToAmtCurrent](#debtsharetoamtcurrent).

```solidity
function debtShareToAmtStored(uint _shares) external view returns (uint amt);
```

### toShares

Convert the underlying token amount to inToken amount (rounded down) without interest accrual. For interest accrual, use [toShareCurrent](#tosharecurrent).

```solidity
function toShares(uint _amt) external view returns (uint shares);
```

### toAmt

Convert inToken amount to underlying token amount (rounded down) without interest accrual. For interest accrual, use [toAmtCurrent](#toamtcurrent).

```solidity
function toAmt(uint _shares) external view returns (uint amt);
```

### getBorrowRate\_e18

Get current borrow interest in `10^18` precision.

```solidity
function getBorrowRate_e18() external view returns (uint borrowRate_e18);
```

### getSupplyRate\_e18

Get current supply interest in `10^18` precision.

```solidity
function getSupplyRate_e18() external view returns (uint supplyRate_e18);
```

### totalAsset

Get the total underlying token amount lent into the lending pool, including borrow interest since last accrued timestamp.

```solidity
function totalAssets() external view returns (uint totalAsset);
```

## External Functions

### accrueInterest

Accrue borrow interest and update last accrued timestamp.

```solidity
function accrueInterest() external;
```

### debtAmtToShareCurrent

Accrue interest and convert debt amount to debt shares (rounded up).

```solidity
function debtAmtToShareCurrent(uint256 _amt) external returns (shares);
```

Parameters:

| Name   | Type      | Description                           |
| ------ | --------- | ------------------------------------- |
| `_amt` | `uint256` | debt amount to convert to debt shares |

Returns:

| Name     | Type      | Description                                     |
| -------- | --------- | ----------------------------------------------- |
| `shares` | `uint256` | corresponding debt shares after accrue interest |

### debtShareToAmtCurrent

Accrue interest and convert debt shares to debt amount (rounded up).

```solidity
function debtShareToAmtCurrent(uint _shares) external returns (uint amt);
```

Parameters:

| Name      | Type      | Description                           |
| --------- | --------- | ------------------------------------- |
| `_shares` | `uint256` | debt shares to convert to debt amount |

Returns:

| Name  | Type      | Description                                     |
| ----- | --------- | ----------------------------------------------- |
| `amt` | `uint256` | corresponding debt amount after accrue interest |

### toSharesCurrent

Accrue borrow interest and convert the underlying token amount to inToken amount (rounded down).

{% hint style="warning" %}
This is not a view function.
{% endhint %}

```solidity
function toSharesCurrent(uint _amt) external returns (uint shares);
```

Parameters:

| Name   | Type      | Description                        |
| ------ | --------- | ---------------------------------- |
| `_amt` | `uint256` | underlying token amount to convert |

Returns:

| Name     | Type      | Description                                        |
| -------- | --------- | -------------------------------------------------- |
| `shares` | `uint256` | corresponding inToken amount after accrue interest |

### toAmtCurrent

Accrue borrow interest and convert the inToken amount to the underlying token amount (rounded down).

{% hint style="warning" %}
This is not a view function.
{% endhint %}

```solidity
function toAmtCurrent(uint _shares) external returns (uint amt);
```

Parameters:

| Name      | Type      | Description               |
| --------- | --------- | ------------------------- |
| `_shares` | `uint256` | inToken amount to convert |

Returns:

| Name  | Type      | Description                                                 |
| ----- | --------- | ----------------------------------------------------------- |
| `amt` | `uint256` | corresponding underlying token amount after accrue interest |


---

# 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://dev.init.capital/contract-references/lendingpool.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.
