# Deprecation Guide

## Ion Protocol — Deprecation Guide

Ion Protocol is being deprecated. This document explains how to fully exit each type of position without using the frontend application. All transactions can be executed directly through a block explorer such as [Basescan](https://basescan.org).

***

### Contract Addresses

All deployed contract addresses can be found in [deployed-contracts](https://docs.ionprotocol.io/devs/deployed-contracts "mention")

The examples in this guide use the weETH/WETH market on Base.

| Contract             | Address                                                                                                                 |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| IonPool (weETH/WETH) | [`0x00000000000fA8e0FD26b4554d067CF1856De7F5`](https://basescan.org/address/0x00000000000fA8e0FD26b4554d067CF1856De7F5) |
| Handler              | [`0x2A010d84933c9fe7c1d336Fa991FE23743e38EC9`](https://basescan.org/address/0x2A010d84933c9fe7c1d336Fa991FE23743e38EC9) |
| GemJoin              | [`0xe21ae2d45dEDF8dEE2D854774a904d33b8700E78`](https://basescan.org/address/0xe21ae2d45dEDF8dEE2D854774a904d33b8700E78) |
| Ion LRT Vault        | [`0x0000000000895f1D9e978788C6367d47127dd218`](https://basescan.org/address/0x0000000000895f1D9e978788C6367d47127dd218) |
| Liquidation          | [`0x00000000009229776762B5e6b865a06afeB4444c`](https://basescan.org/address/0x00000000009229776762B5e6b865a06afeB4444c) |

***

### 1. How to Exit a Borrow Position

A borrow position consists of:

* **Collateral** deposited into IonPool (weETH in this market)
* **Debt** denominated in the pool's base asset (WETH in this market)

> **Important**: The dust minimum debt value is set to zero. This means you must repay the **entire loan in one transaction** — partial repayments are not supported. The recommended path is to use the `repayFullAndWithdraw` function on the Handler contract, which handles the accruing interest rate calculation for you automatically.

#### Step 1 — Look up your current position

Go to Basescan and open the **IonPool** contract at [`0x00000000000fA8e0FD26b4554d067CF1856De7F5`](https://basescan.org/address/0x00000000000fA8e0FD26b4554d067CF1856De7F5). Navigate to the **Read Contract** tab and call:

* `collateral(ilkIndex, yourAddress)` — returns your locked collateral amount in WAD (18 decimals).
  * `ilkIndex` should be `0`.
* `normalizedDebt(ilkIndex, yourAddress)` — returns your normalized (principal-only) debt in WAD.
  * `ilkIndex` should be `0`.

#### Step 2 — Identify the base asset you need to repay

The base asset is the token you originally borrowed. To look it up on-chain:

1. Go to the **IonPool** contract on Basescan and navigate to the **Read Contract** tab.
2. Call `underlying()` — this returns the ERC-20 address of the base asset (WETH on Base at `0x4200000000000000000000000000000000000006`).
3. Open that token contract on Basescan to confirm the symbol (e.g. "WETH"). This is the token you must hold in your wallet in order to repay.

#### Step 3 — Approve the Handler to spend your base asset

The Handler will pull the repayment amount from your wallet. You must first grant it an allowance.

1. Open the WETH token contract at [`0x4200000000000000000000000000000000000006`](https://basescan.org/address/0x4200000000000000000000000000000000000006) on Basescan.
2. Go to the token's **Write Contract** tab.
3. Call `approve(spender, amount)`:
   * `spender`: `0x2A010d84933c9fe7c1d336Fa991FE23743e38EC9` (Handler address)
   * `amount`: Use `115792089237316195423570985008687907853269984665640564039457584007913129639935` (max uint256) to avoid needing to calculate the exact amount with interest.

#### Step 4 — Call `repayFullAndWithdraw` on the Handler

1. Go to Basescan and open the **Handler** contract at [`0x2A010d84933c9fe7c1d336Fa991FE23743e38EC9`](https://basescan.org/address/0x2A010d84933c9fe7c1d336Fa991FE23743e38EC9).
2. Navigate to the **Write Contract** tab.
3. Call `repayFullAndWithdraw(collateralToWithdraw)`:
   * `collateralToWithdraw`: The collateral amount you noted in Step 1. This must be in WAD (18 decimal units). For example, 1 weETH = `1000000000000000000`.

What this function does atomically:

1. Fetches your current `normalizedDebt` and the live `rate` from IonPool.
2. Calculates the exact repayment amount (rounding up to avoid dust).
3. Pulls the WETH repayment from your wallet and repays all debt on IonPool.
4. Withdraws the specified collateral from IonPool's internal accounting.
5. Calls `GemJoin.exit` to transfer the weETH collateral tokens back to your wallet.

After this transaction confirms, your vault in IonPool will have zero debt and zero collateral.

***

### 2. How to Exit a Lender Position

A lender position consists of interest-bearing tokens held in your wallet, minted when you called `supply` on IonPool. Your balance automatically grows every block as borrowers pay interest.

#### Step 1 — Identify the base asset you will receive

When you withdraw, you receive the pool's base asset back in your wallet. To confirm what that token is:

1. Go to the **IonPool** contract at [`0x00000000000fA8e0FD26b4554d067CF1856De7F5`](https://basescan.org/address/0x00000000000fA8e0FD26b4554d067CF1856De7F5) on Basescan and navigate to the **Read Contract** tab.
2. Call `underlying()` — this returns the ERC-20 address of the base asset (WETH on Base at `0x4200000000000000000000000000000000000006`).

#### Step 2 — Check your current balance

On the same **IonPool** Read Contract tab, call:

* `balanceOf(yourAddress)` — returns the current underlying asset value of your position in WAD. This is the amount of WETH you can withdraw right now, including all accrued interest.

#### Step 3 — Call `withdraw` on IonPool

1. Stay on the **IonPool** contract page.
2. Navigate to the **Write Contract** tab.
3. Call `withdraw(receiverOfUnderlying, amount)`:
   * `receiverOfUnderlying`: The address that should receive the WETH (typically your own address).
   * `amount`: The amount of WETH to withdraw in WAD. Use the value from `balanceOf` in Step 2 to fully exit. You may want to use a slightly smaller value to account for any rounding in the final block before your transaction lands.

After this transaction confirms, your interest-bearing token balance on IonPool will be zero and you will have received WETH in your wallet.

***

### 3. How to Exit a Vault Position

The Ion LRT Vault is an ERC-4626 vault that holds WETH and supplies it across multiple underlying Ion Protocol lending markets on Base. Your position is represented as vault shares in your wallet.

#### Step 1 — Check your shares and underlying value

Go to Basescan and open the **Ion LRT Vault** contract at [`0x0000000000895f1D9e978788C6367d47127dd218`](https://basescan.org/address/0x0000000000895f1D9e978788C6367d47127dd218). On the **Read Contract** tab, call:

* `balanceOf(yourAddress)` — returns your vault share balance.
* `convertToAssets(shares)` — returns the WETH value of your shares at the current exchange rate.
* `maxRedeem(yourAddress)` — returns the maximum shares you can currently redeem given available liquidity.

#### Step 2 — Call `redeem` on the Vault

1. Navigate to the **Write Contract** tab on the Ion LRT Vault.
2. Call `redeem(shares, receiver, owner)`:
   * `shares`: The number of vault shares you want to burn (use your full `balanceOf` to fully exit).
   * `receiver`: The address that should receive the WETH (typically your own address).
   * `owner`: Your own address (the address holding the shares).

Alternatively, if you want to specify an exact WETH amount rather than a share amount, use `withdraw(assets, receiver, owner)` instead.

#### Step 3 — If the transaction reverts with `NotEnoughLiquidityToWithdraw`

The vault iterates through a `withdrawQueue` of underlying Ion lending markets. If the underlying liquidity in those markets has been fully borrowed out, there may not be enough free liquidity to fulfill your withdrawal.

In this situation:

* **Wait**: As borrowers repay their loans or are liquidated, liquidity returns to the markets and becomes available for withdrawal.
* **Check available liquidity**: On the **IonPool** contract(s) supported by the vault, call `liquidity()` on the **Read Contract** tab to see how much WETH is currently available. When liquidity is sufficient to cover your withdrawal amount, retry the transaction.
* You can also call `maxWithdraw(yourAddress)` on the Vault to see the maximum amount currently withdrawable given available liquidity.

> The protocol liquidation contract is at [`0x00000000009229776762B5e6b865a06afeB4444c`](https://basescan.org/address/0x00000000009229776762B5e6b865a06afeB4444c). Liquidations will free up collateral and return liquidity to the lending pools over time.
