# IonLens

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

**Inherits:** IIonLens

### [State Variables](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#state-variables" id="state-variables"></a>

#### [IonPoolStorageLocation](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#ionpoolstoragelocation" id="ionpoolstoragelocation"></a>

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

#### [EXTSLOAD\_SELECTOR](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#extsload_selector" id="extsload_selector"></a>

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

### [Functions](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#functions" id="functions"></a>

#### [constructor](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#constructor" id="constructor"></a>

```
constructor();
```

#### [\_getIonPoolStorage](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#getionpoolstorage" id="getionpoolstorage"></a>

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

#### [\_toUint256PointerMapping](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#touint256pointermapping" id="touint256pointermapping"></a>

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

#### [queryPoolSlot](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#querypoolslot" id="querypoolslot"></a>

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

#### [ilkCount](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#debtunaccrued" id="debtunaccrued"></a>

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

#### [debt](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#supplycap" id="supplycap"></a>

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

**Returns**

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

#### [totalUnbackedDebt](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#whitelist" id="whitelist"></a>

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

### [Errors](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#errors" id="errors"></a>

#### [SloadFailed](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#sloadfailed" id="sloadfailed"></a>

```
error SloadFailed();
```

#### [InvalidFieldSlot](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#invalidfieldslot" id="invalidfieldslot"></a>

```
error InvalidFieldSlot();
```

### [Structs](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#structs" id="structs"></a>

#### [Ilk](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#ilk" id="ilk"></a>

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

#### [Vault](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <a href="#vault" id="vault"></a>

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

#### [IonPoolStorage](https://docs.ionprotocol.io/devs/smart-contract-architecture/periphery/broken-reference) <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;
}
```
