# Deposit Lifecycle

At a high level, users receive Illuminate Principal Tokens that represent their lending position, and upon maturity, may redeem Illuminate Principal Tokens for underlying at a 1:1 ratio.

## Lend

The first step in the deposit lifecycle is calling `lend` on the Lender contract. In doing so, the user sends their underlying to the Lender contract, and in exchange receives Illuminate Principal Tokens. The Lender contract custodies the protocol principal tokens the user elected to use to execute the loan.

As an example, let's say a user calls `lend` on Lender.sol, lending 100 USDC on Notional in the December 2022 market. At the end of the `lend` call, and can receive a return of 5% over the term of the loan:

* Lender: holds 105 Notional (External) PTs
* User: holds 105 Illuminate PTs

## Mint

As an alternative to directly lending through Illuminate, users can also purchase external principal tokens and then wrap them at a 1:1 ratio into Illuminate Principal Tokens.

As an example, let's say a user lends 100 USDC directly on Notional in the December 2022 market at a rate of 5% for one year. This leaves the user with 105 Notional PTs.\
\
By then calling `mint` on Lender.sol, this user can then wrap their 105 Notional PTs into 105 Illuminate PTs (likely in order to perform arbitrage).

* Lender: holds 105 Notional (External) PTs
* User: holds 105 Illuminate PTs

## Redeem (External PT)

Once the lending market has matured, anyone can call protocol `redeem` to retrieve each protocol's principal tokens and convert them to the underlying asset for the matured market. Calling a protocol redeem results in the Lender transferring its principal token holdings to the Redeemer contract. From there, the Redeemer calls the protocol's redeem method to get the underlying asset. In addition, the Redeemer updates a `holdings` mapping which indicates how much of the underlying was redeemed for a particular market.

Following our example, at the end of a `redeem` call for Notional:

* Lender: no longer holds any of Notional's PTs
* Redeemer: now holds 105 USDC (redeemed via Notional)
* User: still holds the original 105 Illuminate PTs

## Redeem (Illuminate PT)

Finally, a user can call `redeem` to redeem their ERC5095 Illuminate principal tokens for the underlying. In calling Illuminates `redeem`, the user transfers their PTs to the Redeemer contract. In turn, the Redeemer burns the tokens and transfers the underlying to the user. At this point, the `holdings` mapping is used to determine the ratio of principal tokens owed to the user. In addition, the `holdings` mapping is updated to reflect that the redemption of the Illuminate PTs has occurred.

Again, from our example, following the Illuminate `redeem` call:

* Lender: no longer holds any PTs for the market
* Redeemer: no longer holds the redeemed underlying asset
* User: now holds the 105 USDC from their loan


---

# 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.illuminate.finance/smart-contracts/deposit-lifecycle.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.
