# IonLens

[Git Source](https://github.com/Ion-Protocol/ion-protocol/blob/88cc595825f1dc2eb738fb93e172a3e8ab7a5c43/src/periphery/IonLens.sol)

**Inherits:** IIonLens

### [State Variables](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#state-variables" id="state-variables"></a>

#### [IonPoolStorageLocation](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#ionpoolstoragelocation" id="ionpoolstoragelocation"></a>

```
bytes32 private constant IonPoolStorageLocation = 0xceba3d526b4d5afd91d1b752bf1fd37917c20a6daf576bcb41dd1c57c1f67e00;
```

#### [EXTSLOAD\_SELECTOR](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#extsload_selector" id="extsload_selector"></a>

```
bytes4 private constant EXTSLOAD_SELECTOR = 0x1e2eaeaf;
```

### [Functions](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#functions" id="functions"></a>

#### [constructor](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#constructor" id="constructor"></a>

```
constructor();
```

#### [\_getIonPoolStorage](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#getionpoolstorage" id="getionpoolstorage"></a>

```
function _getIonPoolStorage() internal pure returns (IonPoolStorage storage $);
```

#### [\_toUint256PointerMapping](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#touint256pointermapping" id="touint256pointermapping"></a>

```
function _toUint256PointerMapping(mapping(bytes32 => uint256) storage inPtr)
    private
    pure
    returns (mapping(address => StorageSlot.Uint256Slot) storage outPtr);
```

#### [queryPoolSlot](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#querypoolslot" id="querypoolslot"></a>

```
function queryPoolSlot(IIonPool pool, uint256 slot) public view returns (uint256 value);
```

#### [ilkCount](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#ilkcount" id="ilkcount"></a>

```
function ilkCount(IIonPool pool) external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                 |
| -------- | --------- | ------------------------------------------- |
| `<none>` | `uint256` | The total amount of collateral in the pool. |

#### [getIlkIndex](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#getilkindex" id="getilkindex"></a>

```
function getIlkIndex(IIonPool pool, address ilkAddress) external view returns (uint8);
```

**Returns**

| Name     | Type    | Description                                    |
| -------- | ------- | ---------------------------------------------- |
| `<none>` | `uint8` | The index of the collateral with `ilkAddress`. |

#### [totalNormalizedDebt](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#totalnormalizeddebt" id="totalnormalizeddebt"></a>

```
function totalNormalizedDebt(IIonPool pool, uint8 ilkIndex) external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                                               |
| -------- | --------- | ------------------------------------------------------------------------- |
| `<none>` | `uint256` | The total amount of normalized debt for collateral with index `ilkIndex`. |

#### [rateUnaccrued](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#rateunaccrued" id="rateunaccrued"></a>

```
function rateUnaccrued(IIonPool pool, uint8 ilkIndex) external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                    |
| -------- | --------- | ---------------------------------------------- |
| `<none>` | `uint256` | The `rate` that has been persisted to storage. |

#### [lastRateUpdate](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#lastrateupdate" id="lastrateupdate"></a>

```
function lastRateUpdate(IIonPool pool, uint8 ilkIndex) external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                                                 |
| -------- | --------- | --------------------------------------------------------------------------- |
| `<none>` | `uint256` | The timestamp of the last rate update for collateral with index `ilkIndex`. |

#### [spot](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#spot" id="spot"></a>

```
function spot(IIonPool pool, uint8 ilkIndex) external view returns (address);
```

**Returns**

| Name     | Type      | Description                                           |
| -------- | --------- | ----------------------------------------------------- |
| `<none>` | `address` | The spot oracle for collateral with index `ilkIndex`. |

#### [debtCeiling](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#debtceiling" id="debtceiling"></a>

```
function debtCeiling(IIonPool pool, uint8 ilkIndex) external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                            |
| -------- | --------- | ------------------------------------------------------ |
| `<none>` | `uint256` | The debt ceiling for collateral with index `ilkIndex`. |

#### [dust](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#dust" id="dust"></a>

```
function dust(IIonPool pool, uint8 ilkIndex) external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                          |
| -------- | --------- | ---------------------------------------------------- |
| `<none>` | `uint256` | The dust value for collateral with index `ilkIndex`. |

#### [gem](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#gem" id="gem"></a>

```
function gem(IIonPool pool, uint8 ilkIndex, address user) external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                                           |
| -------- | --------- | --------------------------------------------------------------------- |
| `<none>` | `uint256` | Amount of `gem` that `user` has for collateral with index `ilkIndex`. |

#### [unbackedDebt](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#unbackeddebt" id="unbackeddebt"></a>

```
function unbackedDebt(IIonPool pool, address unbackedDebtor) external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                             |
| -------- | --------- | --------------------------------------- |
| `<none>` | `uint256` | The amount of unbacked debt `user` has. |

#### [isOperator](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#isoperator" id="isoperator"></a>

```
function isOperator(IIonPool pool, address user, address operator) external view returns (bool);
```

**Returns**

| Name     | Type   | Description                                                       |
| -------- | ------ | ----------------------------------------------------------------- |
| `<none>` | `bool` | Whether or not `operator` is an `operator` on `user`'s positions. |

#### [debtUnaccrued](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#debtunaccrued" id="debtunaccrued"></a>

```
function debtUnaccrued(IIonPool pool) public view returns (uint256);
```

#### [debt](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#debt" id="debt"></a>

*This includes unbacked debt.*

```
function debt(IIonPool pool) external view returns (uint256);
```

**Returns**

| Name     | Type      | Description               |
| -------- | --------- | ------------------------- |
| `<none>` | `uint256` | The total amount of debt. |

#### [liquidity](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#liquidity" id="liquidity"></a>

```
function liquidity(IIonPool pool) external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                                    |
| -------- | --------- | ---------------------------------------------- |
| `<none>` | `uint256` | The total amount of ETH liquidity in the pool. |

#### [supplyCap](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#supplycap" id="supplycap"></a>

```
function supplyCap(IIonPool pool) external view returns (uint256);
```

**Returns**

| Name     | Type      | Description    |
| -------- | --------- | -------------- |
| `<none>` | `uint256` | The supply cap |

#### [totalUnbackedDebt](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#totalunbackeddebt" id="totalunbackeddebt"></a>

```
function totalUnbackedDebt(IIonPool pool) external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                        |
| -------- | --------- | ---------------------------------- |
| `<none>` | `uint256` | The total amount of unbacked debt. |

#### [interestRateModule](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#interestratemodule" id="interestratemodule"></a>

```
function interestRateModule(IIonPool pool) external view returns (address);
```

**Returns**

| Name     | Type      | Description                              |
| -------- | --------- | ---------------------------------------- |
| `<none>` | `address` | The address of the interest rate module. |

#### [whitelist](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#whitelist" id="whitelist"></a>

```
function whitelist(IIonPool pool) external view returns (address);
```

### [Errors](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#errors" id="errors"></a>

#### [SloadFailed](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#sloadfailed" id="sloadfailed"></a>

```
error SloadFailed();
```

#### [InvalidFieldSlot](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#invalidfieldslot" id="invalidfieldslot"></a>

```
error InvalidFieldSlot();
```

### [Structs](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#structs" id="structs"></a>

#### [Ilk](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#ilk" id="ilk"></a>

```
struct Ilk {
    IlkSlot0 slot0;
    StorageSlot.AddressSlot spot;
    StorageSlot.Uint256Slot debtCeiling;
    StorageSlot.Uint256Slot dust;
}
```

#### [Vault](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#vault" id="vault"></a>

```
struct Vault {
    StorageSlot.Uint256Slot collateral;
    StorageSlot.Uint256Slot normalizedDebt;
}
```

#### [IonPoolStorage](broken://pages/SNZHVNQKjOjU66krm17Y) <a href="#ionpoolstorage" id="ionpoolstorage"></a>

```
struct IonPoolStorage {
    Ilk[] ilks;
    EnumerableSet.AddressSet ilkAddresses;
    mapping(uint256 ilkIndex => mapping(address user => Vault)) vaults;
    mapping(uint256 ilkIndex => mapping(address user => StorageSlot.Uint256Slot)) gem;
    mapping(address unbackedDebtor => StorageSlot.Uint256Slot) unbackedDebt;
    mapping(address user => mapping(address operator => StorageSlot.Uint256Slot)) isOperator;
    StorageSlot.Uint256Slot debt;
    StorageSlot.Uint256Slot liquidity;
    StorageSlot.Uint256Slot supplyCap;
    StorageSlot.Uint256Slot totalUnbackedDebt;
    StorageSlot.AddressSlot interestRateModule;
    StorageSlot.AddressSlot whitelist;
}
```


---

# 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://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/ionlens.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.
