# What is Isle Finance?

The DeFi protocol that connects the real world supply chain

**Isle Finance** is the decentralized protocol for globally accessible supply chain finance, with a mission to bring the world's supply chain activity on-chain while *expanding capital access* and *increasing supply chain resilience*.

## Financing the global supply chain with DeFi

If the supply chain is the basis of the global economy, then supply chain finance is the *lifeblood* of the global economy. Supply chain finance is the very tool that can help businesses improve their cash flow and reduce costs. Despite its obvious benefits, [its potential continues to be limited for the following reasons](https://www.mckinsey.com/~/media/mckinsey/industries/financial%20services/our%20insights/accelerating%20winds%20of%20change%20in%20global%20payments/chapter-3-supply-chain-finance-a-case-of-convergent-evolution.pdf):

* High Fragmentation
  * e.g. process flows, data sharing, multiple parties, asset types
* Geopolitical turmoil
* Inefficient paper-based procedure
* Limited credit and expertise

The aforementioned issues are particularly severe for small and medium-sized enterprises (SMEs) since they lack the necessary scale to overcome the associated friction and time-consuming processes. Consequently, we believe that decentralized finance (DeFi) technology represents the most effective approach for resolving these challenges.

* **Highly Integrated Tech Stack**: The DeFi technology stack is intentionally designed to be highly interconnected and compatible. It is not uncommon to observe various protocols depending on one another as building blocks for a more comprehensive whole. This approach enables the decentralized nature of the process to be retained while minimizing friction. As a result, DeFi technology is an excellent means of achieving this objective.
* **Global by Default**: DeFi is, by default, a global technology, making it an ideal solution for serving the supply chain in the age of globalization and navigating the geopolitical turmoil and varying regulatory landscape.
* **Digital-native Technology**: Despite considerable efforts over the past two decades, digital adoption in supply chain management has been lagging due to the lack of proper digital infrastructure. DeFi is able to serve as a trusted and reliable digital alternative that has the potential to replace most, if not all, of the inefficient paper-based procedures.
* **Transparent and Trustless**: We believe that *credit* is going to become more easily verifiable using decentralized technology with the help of increasing DeFi adoption and better oracles. Moreover, as zero-knowledge technology matures, on-chain activities could be both trustless and privacy-enabled. The [Proof of Income landscape](https://blog.spectral.finance/the-state-of-on-chain-proof-of-income/) is especially getting a lot of attention, signaling the ecosystem's optimism in this space.

Therefore, Isle Finance is here to **bring all real-world supply chain economic activity on chain and foster global economic prosperity with DeFi technology.**

## Providing real-world investment opportunities for DeFi

Besides the benefits of using DeFi technology for the supply chain, **Isle Finance** is also able to contribute immense value to the entire crypto ecosystem.

The protocol makes crypto loans without requiring crypto collateral. Instead, it relies on real-world supply chain activity, which finally unlocks access to crypto capital for companies around the world. By collaborating and integrating with the vibrant crypto ecosystem (digital identity solutions, decentralized credit oracles, etc.), **Isle** is the solution for crypto capital to finance the global supply chain.

Over the past decade, the crypto space has been notorious for speculative activities, rug pulls, hacks, and more. It has been associated with high risks due to the prevalence of information asymmetry created in complex crypto-money games. We believe that without real-world economic activities, the need for complex financial derivatives will be limited, and adoption will only go so far. **Isle** is here to be the foundational building block to bring the supply chain onto DeFi. By doing so, **Isle** can significantly expand the use case of DeFi.


# What is Supply Chain Finance?

The engine that powers the global economy

## Overview

Supply chain finance is an age-old financial need to **finance the working capital necessary to run any business**. When successfully delivered, it enables corporate buyers to secure inventory by extending payment terms and improves certainty on forward orders for suppliers.

The overall supply chain finance landscape can be roughly differentiated into three segments.

* **Documentary business**: includes traditional off-balance-sheet trade finance instruments such as letters of credit, international guarantees, and banks' payment obligations. These instruments are used to protect the two corporate parties involved in a transaction against potential risks, such as an exporter protecting against country-related risks in its importer's domestic market.
* **Seller-side finance**: includes factoring and invoice financing, which provide financing to corporate sellers by anticipating liquidity related to commercial transactions.
* **Buyer-side finance**: aims at large buyers and their suppliers. It covers the financing needs of suppliers originated by large buyers, such as **reverse factoring** and **dynamic discounting**. This segment has traditionally been a smaller and more fragmented market, but it is now growing at double-digits due to increasing interest and new offerings by players.

## A Buyer-centric approach - Reverse Factoring

**Isle Finance** is a novel funding solution to cover the needs of suppliers, originated by large buyers, where suppliers can get financed with crypto through buyer-approved invoices on the blockchain.

The following presents a sample business use case where Nike could utilize Isle Finance to finance its suppliers.

<figure><img src="https://2281051322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF35WafurLZ7ildJqRiyv%2Fuploads%2Fgit-blob-10f6bc5322547b3f1de215f3d9735cc6515d7af0%2FFlow.png?alt=media" alt=""><figcaption><p>Sample Business Flow</p></figcaption></figure>


# Glossary of Key Terms

## Participants

* **Pool Admins:** Fintech industry experts who are responsible for managing buyer pools on behalf of the protocol
* **Buyers:** Companies that approve their receivables and extend financing to their corresponding supplier with the pool
* **Suppliers:** Companies that can get paid early for every buyer-approved receivable
* **Liquidity Providers (LPs):** Liquidity providers who supply stablecoin capital to different liquidity pools
* **Governance Council**: A group of representatives of the community DAO that configures the protocol on behalf of decentralized governance

### Concepts

* **Pool:** A place where LPs can deposit funds to fund the suppliers of a particular buyer
* **Unrealized Losses**: The total value of all loans that have been marked as impaired
* **Receivables**: The rights a supplier has to receive payment in the future for providing products or services to the buyer (typically collected within 30, 60, 90 days)
* **Loans**: When a pool admin funds a receivable approved by the buyer, a loan between the buyer and the pool is created to represent the repayment obligation.


# Pool Admins

The key to the successful operation of pools

## Overview

Pool Admins are asset specialists and credit experts who manage pools to attract global capital to provide funding for the supply chain. (If you'd like to explore becoming a Pool Admin, please connect with the **Isle Team**)

Each pool will be managed by a Pool Admin, who is responsible for the following

1. Creating a Pool
2. Providing First-Loss Cover
3. Onboarding Buyers
4. Negotiating and Funding Loans
5. Impairing Loans
6. Triggering Defaults

## Creating a Pool

A pool is an [**ERC4626**](https://erc4626.info/) smart contract through which liquidity providers deposit and withdraw capital. Once approved by governance, a Pool Admin can create and configure pools via the `PoolConfigurator`.

The Pool Admin is responsible for setting and updating these parameters after the pool is created.

* **Base Rate**: The base annual interest rate assumed in this pool (e.g. 5%)
* **Pool Admin Fee**: The fee as a percentage of total interest repaid that will be distributed to the Pool Admin (e.g. 10%)
* **Is Open to Public**:
  * Permissioned: only lenders added to the whitelist can deposit liquidity
  * Permissionless: anyone can deposit liquidity

{% hint style="info" %}
Note that when the parameters are updated, it will only affect new loans that are created afterwards but not the loans that have already been created.
{% endhint %}

## Providing Pool Cover

Pool Admins are required to provide a certain amount of first-loss **Pool Cover** in order to align incentives with the Lenders.

When loans default, the **Pool Cover** will be liquidated with a maximum liquidation of `MAX_COVER_LIQUIDATION` per default.

## Onboarding Participants

Pool Admins are responsible for maintaining the whitelists of valid buyer and sellers of the pool. Only the buyer and its associated sellers who have passed the due diligence of Pool Admins are permitted to interact with the pool.

They are also advised to sign a Master Loan Agreement with the buyer or add insurance to ensure a smoother legal recollection process. Even though this is not mandatory, it could strengthen the Pool Admins credibility and the lender's confidence to invest.

## Negotiating and Funding Loans

After buyers approve their receivables along with the set of specified terms, **Pool Admins** can fund the approved receivables through `LoanManager`. Then, the suppliers can withdraw the released funds from `LoanManager`.

## Impairing Loans

We give **Pool Admins** the ability to impair loans in the event of a potential non-payment or insufficient payment scenario. The impairment can be put in place to better distribute losses to all current lenders.

This prevents a situation where a loan is known to be compromised, and some lenders withdraw their capital prior to the loss, leading to the remaining lenders bearing more of the lost capital.

Loan impairments should be used when **Pool Admins** believes they will be able to quickly recover part of or all of the loan's value from the buyer.

When a loan is impaired, all *deposits* will be made using the **original exchange rate**, while *withdrawals* will be made using an **impaired exchange rate**.

{% hint style="info" %}
**Unrealized Losses** represent the total value of all loans that have been marked as impaired.
{% endhint %}

$$
ExchangeRate = \frac{TotalAssets}{Shares}
$$

$$
ImpairedExchangeRate = \frac{TotalAssets - UnrealizedLosses}{Shares}
$$

If a liquidity provider decides to withdraw when the loan is impaired, they will suffer a permanent impairment loss. Any future recoveries from the pool will be distributed pro rata to those lenders that remained in the pool. That is, during loan impairments, liquidity providers are advised against withdrawing existing shares or depositing new capital before the situation of the default becomes more clear.

## Triggering Defaults

When it is clear that the borrower has not made a payment (including non-payment or insufficient payment of principal or interest) past the grace period on a loan, the Pool Admin can trigger a default. The default will

1. Reduce the pool's value by the amount of losses
2. Slash **Pool Admin**'s Pool Cover
3. Kick off the legal recollection process


# Buyers

Pay the suppliers early and repay later

## Overview

Buyers are companies that seek financing for their suppliers. They can approve receivables, which enable their suppliers to receive direct financing through the pool. Before the expiration of the receivables, the corresponding buyers will then make repayments back to the pool. Since they are the ones making the repayment, the **credibility of the buyers** are the most important metric for investors.

## Buyer Onboarding

After a pool is created, the **Pool Admin** should conduct due diligence on the buyer and assign the buyer to the pool.

## Approving Receivables

{% hint style="info" %}
We expect buyers and the Pool Admin to negotiate terms offline so as to minimize unneeded expenditure.
{% endhint %}

After buyers negotiate the terms with the **Pool Admin,** they should approve the receivables for funding with the following terms.

* **Collateral ID:** The token ID of the receivable NFT to approve
* **PrincipalRequested**: The amount of funds for the seller to withdraw

$$
Principal = FaceAmount \times (1 - DiscountRate)
$$

* **Interest Rate**: The interest rate applied on the principal (must be larger than the **Base Rate** of the pool)
* **Late Interest Rate Premium**: The extra interest rate that will be applied if the buyer is late on repayment
* **Grace Period**: The length of time after the due date during which payment may be made with an additional late interest rate premium
* **Repayment Date:** The repayment date of the receivable
* **Recipient**: The supplier who is able to withdraw the funds

{% hint style="info" %}
**Discount Rate** will be determined in the negotiation process and should typically be in the range of 0% \~ 50% depending on the industry of the buyer and seller.
{% endhint %}

The **Discount Rate** will differ for each receivable and the principal provided for each invoice will follow the following table.

<table><thead><tr><th width="122">Invoice</th><th>Discount Rate</th><th>Face Amount</th><th>Principal</th></tr></thead><tbody><tr><td>Inv-1</td><td>15%</td><td>$100,000</td><td>$85,000</td></tr><tr><td>Inv-2</td><td>30%</td><td>$200,000</td><td>$140,000</td></tr></tbody></table>

If the negotiation goes successfully, the **Pool Admin** can then fund the receivables, which marks the start of the loan.

However, the **Pool Admin** may reject a buyer's request to initiate a loan due to the following reasons.

1. The **Pool Admin** needs more information on the validity of the invoices
2. The pool does not have sufficient liquidity to be lent out

## Repaying Loans

Before the loan expires, the buyer will have to repay the loan before the repayment date. The interest will be calculated as **simple interest** on the principal amount. After the buyer repays the loan fully, the loan will be closed.

<details>

<summary>Example Calculation</summary>

Let's say that a buyer has a loan with the following terms

* Principal: $140,000
* Interest Rate: 10%
* Late Interest Rate Premium: 5%
* Start Date: 2023/8/1
* Repayment Date: 2023/9/1

*Payment before expiration:*

If the buyer repays on 2023/8/25, the interest applied will be$$$140,000 \times 10% \times 24/365 = $ 920.55$$

*Late Payment:*

If the buyer repays on 2023/9/5, the interest applied will be $$ $140,000 \times (10% \times 31/365 + 15% \times 4/365) = $1419.18 $$

Here, we calculate using days instead of seconds in order to simplify the calculation. In practice, it is calculated in seconds.

</details>

## Impairments and Defaults

If the buyer is deemed unlikely to repay the loan, the loan can be impaired by the **Pool Admin**.

Furthermore, if the buyer misses the repayment date of the loan, the loan will be marked as default by the **Pool Admin.**

## Buyer Repayment Incentives

{% hint style="info" %}
The key question is why buyers would pay back what they borrowed.
{% endhint %}

### First Incentive: Positive on-chain credit history

Since buyers would need to publicize their wallet addresses when approving invoices, their on-chain history becomes public to future creditors. As more financial activity moves on chain, companies will be more incentivized to maintain a good long-term credit history on chain.

### Second Incentive: The ability to continue to use Isle Finance

As soon as a buyer defaults, it would be immediately banned from approving more receivables for their suppliers, which could cause more working capital problems in the supply chain.

Moreover, buyers would be repaying either the protocol or the supplier no matter what. Therefore, Isle imposes no extra cost on the buyer and would allow its supplier to get early capital financing, which is a win-win scenario for both sides.


# Sellers

Get paid early and invest it in working capital

## Overview

Sellers are companies that will benefit from getting paid early to finance their operations with working capital.

## Minting Receivable NFTs

Any seller or buyer is allowed to mint receivable NFTs, which represent the rights and obligations between buyers and sellers. It should contain the following information:

* **Owner:** The owner of the receivable, which should be the seller when it is first minted
* **Buyer:** The company who received the goods and has the obligation to pay
* **Seller:** The company who sold the goods and has the right to be paid
* **Face Amount**: The amount due for payment at the expiration date
* **Repayment Date**: The expected date of repayment for the receivable

## Supplier Onboarding

In order to become a valid supplier for reverse factoring, the supplier will have to send an application to the corresponding **Pool Admin** to get whitelisted. Note that a seller must be whitelisted before they can redeem funds.

## Withdraw Funds

After invoices are approved for their suppliers, the suppliers will be able to withdraw the principal of the loans at any time by transferring the receivables NFT to the `LoanManager`.


# Liquidity Providers

Smart investors who earn yield by providing funds

{% hint style="info" %}
Liquidity providers are investors who hope to earn yields by investing in the liquidity pool.
{% endhint %}

## Supplying Capital

Each pool will follow the [ERC4626 vault standard](https://erc4626.info/). This standard specifies how the LP tokens accrue value from the buyer's repayment of loans. Before depositing, you should go through the following steps:

1. (*Only for Permissioned Pools*) Pass KYC conducted by the Pool Admin.
2. Review the pool's track record and understand the **Pool Admin** and the **Buyer** of the pool.
3. Review the terms for withdrawal so you know when you can withdraw and how much.

## Withdrawing Capital

All withdrawal requests are grouped into **Withdrawal Cycles** (1–2 weeks), which are cyclically occurring periods of time. By grouping users into cycles, **Pool Admins** ensure that users get a prorated distribution of cash in the event of partial liquidity in the system.

At the start of each cycle (such as the first two days of each two-week cycle), there will be a window of time where part of the liquidity is locked for withdrawal requests that were submitted in the previous cycle. This window is called the **Withdrawal Window**.

During each **Withdrawal Window**, the amount of liquidity required to satisfy all withdrawals will be locked and not at the disposal of **Pool Admins**.

Withdrawing from the protocol can be simplified to the following 3 steps

1. Submit a withdrawal request during the current **Withdrawal Cycle**. (users can modify or cancel their withdrawal request during this time)
2. Wait for the following cycle to complete until they can execute their withdrawal request during their eligible withdrawal window
3. Execute their withdrawal request during their eligible **Withdrawal Window**

### Request Not Executed

If the user fails to execute their request during their allotted withdrawal window, they will have to resubmit their withdrawal request.

### Insufficient Liquidity

If there is not enough liquidity to fulfill all withdrawals during the window, those eligible for withdrawal will receive their share of the proceeds pro-rata and have the remaining funds **requested moved to the very next withdrawal window**.


# Governance

Manages protocol-wide configurations

The community DAO is in charge of managing governance. It has the ability to perform maintenance functions and parameter adjustments to the protocol via decentralized voting, including:

* Deploying and upgrading pools
* Changing protocol configurations and parameters
* Pausing protocol activity in the event of an emergency

Anyone can participate in governance by making proposals, discussing them, and participating in Snapshot votes.

## Participation

### Governance Forum

This is a place where community members can make and discuss proposals.

### Governance Council

The governance council of Isle has been set up to execute on-chain transactions on behalf of the results of community votes. The Isle Council is a 3-of-5 multisig with 5 members representing all stakeholders participating in the protocol.

Members of the governance council will be released after the protocol launches officially.

## Governance Parameters

These are the list of parameters that will be managed and set by the governor

### Pool Configuration

* `maxCoverLiquidation`: the maximum liquidation of the pool admin's cover in the event of a default (e.g. 10% means the protocol liquidate at most 10% of the pool cover at the event of a default)
* `minCover`: the minimum pool cover size required for the pool
* `poolLimit`: The maximum size of the pool

### Global Configuration

* `isReceivableAsset`: a whitelist of valid receivable assets
* `isPoolAsset`: a whitelist of valid pool assets
* `isPoolAdmin`: a whitelist of valid pool admins
* `isleVault`: address of the **Isle vault**
* `protocolFee`: the global fee as a percentage of interest earned
* Emergency pausing
  * `contractPaused`: whether the contract is paused
  * `isFunctionPaused`: whether the function of a contract is paused


# Fees

Fees are charged as **a portion of gross interest** repaid by Buyers when payments are made. Currently, two of the following fees are applied.

* **Pool Admin Fees:** Set by the Pool Admin\
  `Fee paid for Admin: interest * adminFee`
* **Protocol Fees**: Set by Governance\
  `Fee paid for Protocol: interest * protocolFee`


# Smart Contract Overview

### IsleGlobals

This singleton contract is in charge of the Isle protocol configuration, handling values such as protocol fees, the list of valid Pool admin, Receivable assets, Pool assets, and more. It can only be owned and administered by the Governor.

### PoolAddressesProvider

Serves as the address registry of the pool and can update implementations of contracts within the pool. This contract is immutable, and its address will never change. By default, it should be owned by the governor.

### PoolConfigurator

It has a one-to-one relationship with the pool. It handles most of the administrative functions for the pool, as well as the interface between the pool and other contracts. The only actors that are allowed to interact with the PoolConfigurator is the Pool Admin, Governor, and other contracts.

### Pool

The pool implements the vault standard (ERC4626) ,and it's intentionally kept as simple as possible, containing mostly token and deposit / withdrawal functionality. It's the only contract that LPs need to interact with. Due to its immutability, some logic is delegated to the PoolConfigurator, which is the only external contract that the Pool interacts with.

### WithdrawalManager

Due to the nature of lending protocols, the majority of assets will not be available for withdrawal for LPs. To ensure fairness, this contract implements the logic that controls when and how much each LP can withdraw at the time.

### LoanManager

Handles everything related to the issuance, repayment, accounting, default and impairments of all loans in a pool. The accounting is done on a separate contract instead of the pool to allow future flexibility. Currently, there will only be one loan manager within a pool, though we may allow for multiple in the future.


# Diagrams

## Contract Architecture

Architecture of all smart contracts

<figure><img src="https://2281051322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF35WafurLZ7ildJqRiyv%2Fuploads%2Fgit-blob-843625ccd770dc6c42835e842b3aeb94c0149458%2Fimage%20(2).png?alt=media" alt=""><figcaption></figcaption></figure>

## Scenarios

A collection of scenarios to help you understand how Isle Finance works from end to end

### Borrowing

#### Seller mints receivables NFT

{% @mermaid/diagram content="flowchart LR;
S((Seller))
R\[Receivables]
S -- "mintReceivable" --> R
R -- "transferReceivable" --> S" %}

#### Buyer requests for a loan to be created for the receivable

{% @mermaid/diagram content="flowchart LR;
B((Buyer))
LM\[LoanManager]
B -- "requestLoan" --> LM" %}

#### Pool Admin funds loan

{% @mermaid/diagram content="flowchart LR;
PM((PoolAdmin))
PC\[PoolConfigurator]
LM\[LoanManager]
P\[Pool]
PM -- "fundLoan" --> LM
LM -- "requestFunds" --> PC
PC -- "transferFrom" --> P
P -- "transferFunds" --> LM" %}

#### Seller withdraws funds by submitting the invoice

{% @mermaid/diagram content="flowchart LR
S((Seller))
LM((LoanManager))
S -- "withdrawFunds" --> LM
S -- "transferReceivables" --> LM
LM -- "transferFunds" --> S
" %}

#### Buyer repays loan

{% @mermaid/diagram content="flowchart LR
B((Buyer))
LM\[LoanManager]
TV\[Treasury Vault]
PA((Pool Admin))
P\[Pool]
B -- "repayLoan" --> LM
B -- "transferFunds" --> LM
LM -- "transferFunds" --> PA
LM -- "transferFunds" --> P
LM -- "transferFunds" --> TV" %}

### Lending

#### Lender deposits funds

{% @mermaid/diagram content="flowchart LR
LP((Lender))
P\[Pool]
LP -- "deposit" --> P
LP -- "transferFunds" --> P
P -- "transferShares" --> LP" %}

#### Lender requests redemption

{% @mermaid/diagram content="flowchart LR
LP((Lender))
P\[Pool]
PC\[PoolConfigurator]
WM\[WithdrawalManager]
LP -- "requestRedeem" --> P
P -- "requestRedeem" --> PC
PC -- "addShares" --> WM
LP -- "transferShares" --> WM" %}

#### Lender redeems funds

{% @mermaid/diagram content="flowchart LR
LP((Lender))
P\[Pool]
PC\[PoolConfigurator]
WM\[WithdrawalManager]
LP -- "redeem" --> P
P -- "processRedeem" --> PC
PC -- "processExit" --> WM
P -- "transferFunds" --> LP" %}

#### Lender remove redemption request

{% @mermaid/diagram content="flowchart LR
LP((Lender))
P\[Pool]
PC\[PoolConfigurator]
WM\[WithdrawalManager]
LP -- "removeShares" --> P
P -- "removeShares" --> PC
PC -- "removeShares" --> WM
WM -- "transferShares" --> LP" %}

### Pool Configuration

{% hint style="info" %}
There could be multiple sellers, but only a single buyer for a pool.
{% endhint %}

{% @mermaid/diagram content="flowchart LR;
PA((Pool Admin))
PC\[Pool Configurator]
PA -- "setBuyer" --> PC
PA -- "setValidSeller" --> PC
PA -- "setValidLender" --> PC
PA -- "setOpenToPublic" --> PC
PA -- "setAdminFee" --> PC
" %}

{% @mermaid/diagram content="flowchart LR
GV((Governor))
PC\[Pool Configurator]
GV -- "setPoolLimit" --> PC
GV -- "setMaxCoverLiquidation" --> PC
GV -- "setMinCover" --> PC" %}


# Loan Accounting

## Overview

The total assets under management (AUM) of a loan manager is represented as the sum of **outstanding principal** and **outstanding interest**. In the following section, we will explain how the accounting works to reflect the fair value of the loans.

## Outstanding Principal

Outstanding principal is simply the sum of principal balance of all outstanding loans $$i$$.

$$
principalOutstanding = \sum{principal\_i}
$$

## Outstanding Interest

{% hint style="info" %}
Since the measure below is used to estimate the aggregate value of current outstanding interests, late interest penalties will not be accounted as those repayments are not guaranteed.
{% endhint %}

Outstanding interest has to represent the current aggregate value of the outstanding interest in all loans in the most accurate and efficient way possible. Interest is represented as fixed amounts owed at a **given date**. For example, a $1 million loan with 12% APR interest due in 30 days will be shown as:

$$
interest = 1e6 \times 0.12 \times \frac{30}{365} = 9863.01
$$

The buyer will have to repay $9863.01 in interest when the loan gets repaid on time.

### Naive Approach

The current value of an interest at any given time can be recognized linearly on the total interest that will be due on due date, which could be represented by the following equation

$$
interest(t) = interestDue \times \frac{t - startDate}{dueDate - startDate}
$$

Expanding on this concept, the naive calculation of the outstanding interest of all loans will be

$$
interest(t) = \sum{interestDue\_i \times \frac{t - startDate\_i}{dueDate\_i-startDate\_i}}
$$

### Optimized Approach (Aggregated Issuance)

In a protocol managing many loans at once, calculating the outstanding interest by summing the values naively will be extremely gas expensive. Since the rate of interest accrual for a single loan will be linear within its time frame, we can formulate a **piecewise linear function** that only has kinks when either a new loan is added or repaid. The function consists of four parameters

<figure><img src="https://2281051322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF35WafurLZ7ildJqRiyv%2Fuploads%2Fgit-blob-231f7449d15f9a552f273c63fd42c4e22ed6c1af%2Fimage%20(3).png?alt=media" alt=""><figcaption><p>Rates here are represented as per day while in practice, it is per second</p></figcaption></figure>

1. $$issuanceRate$$: Units of funds earned per second as interest for all outstanding loans
2. $$accountedInterest$$: "Snapshotted value" of outstanding interest updated at each point the function parameters are updated
3. $$domainStart$$: The timestamp marking the start of the issuing domain. Set to `block.timestamp` after each update.
4. $$domainEnd$$: The timestamp marking the end of the issuing domain.

$$
outstandingInterest(t) = accountedInterest + issuanceRate \times (t - domainStart)
$$

where $$domainStart \leq t \leq domainEnd$$

### In Practice: Advance Payment Accounting

Whenever any interaction is made with the LoanManager, the function `_advanceGlobalPaymentAccounting` is called to account all Loan's **outstanding interest** and to represent the current state at the current timestamp.


# Withdrawal Management

## Overview

The process of withdrawals is managed by the `WithdrawalManager`. The `withdrawalManager` holds custody of users' LP tokens and allows them to withdraw at specified time intervals - **Withdrawal Window** after waiting a minimum of a full **Withdrawal Cycle**. Users' withdrawal requests are grouped into cycles so that pro-rata distributions of available cash can be performed.

<figure><img src="https://2281051322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF35WafurLZ7ildJqRiyv%2Fuploads%2Fgit-blob-46bfb64deadffcad8b8bf6eda88115e24f9b1ff6%2Fimage%20(14).png?alt=media" alt=""><figcaption><p>Normal withdrawal process</p></figcaption></figure>

## Request Updates

If a user misses their withdrawal window or wishes to modify their withdrawal request, they have several options to update it.

### Modify Action

**Purpose:** For users looking to adjust the amount of shares in their withdrawal request, the modify action provides the means to either increase or decrease the desired amount.

**How to Perform:**

* To increase the number of shares, call `requestRedeem(n)` with `n` specifying the new total amount of shares desired.
* To decrease the number of shares, call `removeShares(n)`, where `n` reflects the number of shares to be removed from the request.

### Cancel Action

**Purpose:** Users who wish to cancel their withdrawal request entirely can use this action to remove all associated shares, effectively nullifying the request.

**How to Perform:** Execute `removeShares(n)` to cancel the request, where `n` is the total amount of shares initially requested for withdrawal.

In all cases, the withdrawal request will be treated as a **normal withdrawal request** and will have to wait for a **minimum of a full withdrawal cycle** before the funds can be withdrawn.

## Exchange Rate Calculation

{% hint style="info" %}
Users withdrawing in the same withdrawal window may experience different exchange rates if they exchange at different time points.
{% endhint %}

When the actual withdrawal is performed, the amount of funds withdrawn is calculated by converting the shares requested for withdrawal into funds using the **current exchange rate**.

## Liquidity Locking

During each withdrawal window, the total amount of funds required to satisfy all withdrawals will be continuously locked using the current exchange rate. These locked liquidity can not be used by the Pool Admin for funding.

<details>

<summary>Example</summary>

If the current shares available for withdrawal is as follows

* User 1: 100 shares
* User 2: 200 shares

At time point 1 (exchange rate: 1.5)

* Total locked liquidity would be 450

At time point 2 (exchange rate: 1.75)

* Total locked liquidity would be 525

</details>

## Pro-rata Distribution

When there is insufficient liquidity to satisfy all withdrawals, the available amount of liquidity will be proportionally distributed between users based on the size of their withdrawals. For example, if there is only enough assets to satisfy 50% of all withdrawals, each user can only withdraw 50% of their requested amount. Also, withdrawals requests that can not be fulfilled due to **insufficient liquidity** will be automatically forwarded to the next withdrawal window without any additional delays.

The formula related to the distribution can be written as follows

$$
redeemableShares(user) = min(lockedShares(user), lockedShares(user) \times \frac{availableLiquidity}{totalLockedLiquidity})
$$

where

$$
totalLockedLiquidity = totalCycleShares(cycle) \times exchangeRate
$$

## Configuration Management

The **Pool Admin** can update update the duration of each Withdrawal Cycle and/or Withdrawal Window. This change will only take effect after the current and two following Withdrawal Cycles.


# Upgradability

## Overview

The governor is responsible for upgrading contracts when required.

## Contracts

* Immutable
  * `Pool.sol`
  * `PoolAddressesProvider.sol`
* UUPS upgradable
  * `Receivables.sol`
  * `IsleGlobals.sol`
* Transparent Upgradable
  * `PoolConfigurator.sol`
  * `WithdrawalManager.sol`
  * `LoanManager.sol`


# IsleGlobals

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/IsleGlobals.sol)

**Inherits:** [IIsleGlobals](/contract-documentation/interfaces/iisleglobals), [VersionedInitializable](/contract-documentation/libraries/upgradability/versionedinitializable), [Governable](/contract-documentation/abstracts/governable), UUPSUpgradeable

## State Variables

### ISLE\_GLOBALS\_REVISION

```solidity
uint256 private constant ISLE_GLOBALS_REVISION = 0x1;
```

### protocolFee

```solidity
uint24 public override protocolFee;
```

### isleVault

```solidity
address public override isleVault;
```

### protocolPaused

```solidity
bool public override protocolPaused;
```

### isContractPaused

```solidity
mapping(address => bool) public override isContractPaused;
```

### isFunctionUnpaused

```solidity
mapping(address => mapping(bytes4 => bool)) public override isFunctionUnpaused;
```

### isPoolAdmin

```solidity
mapping(address => bool) public override isPoolAdmin;
```

### isReceivableAsset

```solidity
mapping(address => bool) public override isReceivableAsset;
```

### isPoolAsset

```solidity
mapping(address => bool) public override isPoolAsset;
```

## Functions

### getRevision

Returns the revision number of the contract

*Needs to be defined in the inherited class as a constant.*

```solidity
function getRevision() public pure virtual override returns (uint256 revision_);
```

**Returns**

| Name        | Type      | Description         |
| ----------- | --------- | ------------------- |
| `revision_` | `uint256` | The revision number |

### \_authorizeUpgrade

```solidity
function _authorizeUpgrade(address newImplementation_) internal override onlyGovernor;
```

### initialize

Initializes the contract.

```solidity
function initialize(address governor_) external override initializer;
```

**Parameters**

| Name        | Type      | Description                  |
| ----------- | --------- | ---------------------------- |
| `governor_` | `address` | The address of the governor. |

### setIsleVault

Sets the address of the Isle vault.

```solidity
function setIsleVault(address vault_) external override onlyGovernor;
```

**Parameters**

| Name     | Type      | Description                    |
| -------- | --------- | ------------------------------ |
| `vault_` | `address` | The address of the Isle vault. |

### setProtocolPaused

Pause or unpause the protocol.

```solidity
function setProtocolPaused(bool protocolPaused_) external override onlyGovernor;
```

**Parameters**

| Name              | Type   | Description                                            |
| ----------------- | ------ | ------------------------------------------------------ |
| `protocolPaused_` | `bool` | A boolean indicating the status of the protocol pause. |

### setContractPaused

Pause or unpause a specific contract.

```solidity
function setContractPaused(address contract_, bool contractPaused_) external override onlyGovernor;
```

**Parameters**

| Name              | Type      | Description                                              |
| ----------------- | --------- | -------------------------------------------------------- |
| `contract_`       | `address` | The address of the contract to set the pause status for. |
| `contractPaused_` | `bool`    | A boolean indicating the pause status of the contract.   |

### setFunctionUnpaused

Unpause or ununpause a specific function in a contract.

```solidity
function setFunctionUnpaused(address contract_, bytes4 sig_, bool functionUnpaused_) external override onlyGovernor;
```

**Parameters**

| Name                | Type      | Description                                            |
| ------------------- | --------- | ------------------------------------------------------ |
| `contract_`         | `address` | The address of the contract.                           |
| `sig_`              | `bytes4`  | The function signature.                                |
| `functionUnpaused_` | `bool`    | A boolean indicating whether the function is unpaused. |

### setProtocolFee

Sets the protocol fee.

```solidity
function setProtocolFee(uint24 protocolFee_) external override onlyGovernor;
```

**Parameters**

| Name           | Type     | Description                                                                   |
| -------------- | -------- | ----------------------------------------------------------------------------- |
| `protocolFee_` | `uint24` | A uint24 indicating the protocol fee (100.0000% = 1e6 (6 decimal precision)). |

### setValidReceivableAsset

Sets the validity of a receivable asset (should match ERC-721).

```solidity
function setValidReceivableAsset(address receivableAsset_, bool isValid_) external override onlyGovernor;
```

**Parameters**

| Name               | Type      | Description                                                  |
| ------------------ | --------- | ------------------------------------------------------------ |
| `receivableAsset_` | `address` | The address of the receivable asset to set the validity for. |
| `isValid_`         | `bool`    | A boolean indicating the validity of the receivable asset.   |

### setValidPoolAsset

Sets the validity of the pool asset (should match ERC-20).

```solidity
function setValidPoolAsset(address poolAsset_, bool isValid_) external override onlyGovernor;
```

**Parameters**

| Name         | Type      | Description                                            |
| ------------ | --------- | ------------------------------------------------------ |
| `poolAsset_` | `address` | The address of the pool asset to set the validity for. |
| `isValid_`   | `bool`    | A boolean indicating the validity of the pool asset.   |

### setValidPoolAdmin

Sets the validity of a pool admin.

```solidity
function setValidPoolAdmin(address poolAdmin_, bool isValid_) external override onlyGovernor;
```

**Parameters**

| Name         | Type      | Description                                            |
| ------------ | --------- | ------------------------------------------------------ |
| `poolAdmin_` | `address` | The address of the pool admin to set the validity for. |
| `isValid_`   | `bool`    | A boolean indicating the validity of the pool admin.   |

### isFunctionPaused

Returns the pause status of a specific function in a contract.

```solidity
function isFunctionPaused(address contract_, bytes4 sig_) public view override returns (bool functionIsPaused_);
```

**Parameters**

| Name        | Type      | Description                  |
| ----------- | --------- | ---------------------------- |
| `contract_` | `address` | The address of the contract. |
| `sig_`      | `bytes4`  | The function signature.      |

**Returns**

| Name                | Type   | Description                                                               |
| ------------------- | ------ | ------------------------------------------------------------------------- |
| `functionIsPaused_` | `bool` | isFunctionPaused\_ A boolean indicating the pause status of the function. |

### isFunctionPaused

Returns the pause status of a specific function in a contract.

```solidity
function isFunctionPaused(bytes4 sig_) external view override returns (bool functionIsPaused_);
```

**Parameters**

| Name   | Type     | Description             |
| ------ | -------- | ----------------------- |
| `sig_` | `bytes4` | The function signature. |

**Returns**

| Name                | Type   | Description                                                               |
| ------------------- | ------ | ------------------------------------------------------------------------- |
| `functionIsPaused_` | `bool` | isFunctionPaused\_ A boolean indicating the pause status of the function. |


# LoanManager

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/LoanManager.sol)

**Inherits:** [ILoanManager](/contract-documentation/interfaces/iloanmanager), IERC721Receiver, [LoanManagerStorage](/contract-documentation/loanmanagerstorage), [VersionedInitializable](/contract-documentation/libraries/upgradability/versionedinitializable), [ReentrancyGuardUpgradeable](/contract-documentation/libraries/reentrancyguardupgradeable)

## State Variables

### LOAN\_MANAGER\_REVISION

```solidity
uint256 public constant LOAN_MANAGER_REVISION = 0x1;
```

### HUNDRED\_PERCENT

```solidity
uint256 public constant HUNDRED_PERCENT = 1e6;
```

### SCALED\_ONE

```solidity
uint256 private constant SCALED_ONE = 1e18;
```

### PRECISION

```solidity
uint256 public constant PRECISION = 1e27;
```

### ADDRESSES\_PROVIDER

```solidity
IPoolAddressesProvider public immutable ADDRESSES_PROVIDER;
```

## Functions

### constructor

```solidity
constructor(IPoolAddressesProvider provider_);
```

### initialize

```solidity
function initialize(address asset_) external override initializer;
```

### whenNotPaused

*Can only be called when the function is not paused*

```solidity
modifier whenNotPaused();
```

### onlyPoolAdminOrGovernor

*Can only be called by the Pool Admin or the Governor*

```solidity
modifier onlyPoolAdminOrGovernor();
```

### onlyPoolAdmin

*Can only be called by the Pool Admin*

```solidity
modifier onlyPoolAdmin();
```

### onlyPoolConfigurator

*Can only be called by the PoolConfigurator*

```solidity
modifier onlyPoolConfigurator();
```

### getRevision

Returns the revision number of the contract

*Needs to be defined in the inherited class as a constant.*

```solidity
function getRevision() public pure virtual override returns (uint256 revision_);
```

**Returns**

| Name        | Type      | Description         |
| ----------- | --------- | ------------------- |
| `revision_` | `uint256` | The revision number |

### onERC721Received

*Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} by `operator` from `from`, this function is called. It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.*

```solidity
function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4);
```

### getLoanInfo

Gets the loan info.

```solidity
function getLoanInfo(uint16 loanId_) external view returns (Loan.Info memory loan_);
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |

**Returns**

| Name    | Type        | Description                                |
| ------- | ----------- | ------------------------------------------ |
| `loan_` | `Loan.Info` | Struct that contains the info of the loan. |

### accruedInterest

Gets the amount of interest up until this point in time.

```solidity
function accruedInterest() public view override returns (uint256 accruedInterest_);
```

**Returns**

| Name               | Type      | Description                                                 |
| ------------------ | --------- | ----------------------------------------------------------- |
| `accruedInterest_` | `uint256` | The amount of accrued interest up until this point in time. |

### assetsUnderManagement

Gets the total assets under management.

```solidity
function assetsUnderManagement() public view override returns (uint256 assetsUnderManagement_);
```

**Returns**

| Name                     | Type      | Description                                 |
| ------------------------ | --------- | ------------------------------------------- |
| `assetsUnderManagement_` | `uint256` | The total value of assets under management. |

### getLoanPaymentDetailedBreakdown

Gets the detailed payment breakdown of a loan up until this point in time.

```solidity
function getLoanPaymentDetailedBreakdown(
    uint16 loanId_
)
    public
    view
    override
    returns (uint256 principal_, uint256[2] memory interest_);
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |

**Returns**

| Name         | Type         | Description                                                                                                     |
| ------------ | ------------ | --------------------------------------------------------------------------------------------------------------- |
| `principal_` | `uint256`    | The principal due for the loan.                                                                                 |
| `interest_`  | `uint256[2]` | <p>Interest Parameter:<br>\[0]: The interest due for the loan.<br>\[1]: The late interest due for the loan.</p> |

### getLoanPaymentBreakdown

Gets the payment breakdown of a loan up until this point in time.

```solidity
function getLoanPaymentBreakdown(uint16 loanId_) public view override returns (uint256 principal_, uint256 interest_);
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |

**Returns**

| Name         | Type      | Description                          |
| ------------ | --------- | ------------------------------------ |
| `principal_` | `uint256` | The principal due for the loan.      |
| `interest_`  | `uint256` | The total interest due for the loan. |

### updateAccounting

Manually updates the accounting state of the pool.

```solidity
function updateAccounting() external whenNotPaused onlyPoolAdminOrGovernor;
```

### requestLoan

Used by buyer to request a loan from the pool with the following terms.

```solidity
function requestLoan(
    address receivableAsset_,
    uint256 receivablesTokenId_,
    uint256 gracePeriod_,
    uint256 principalRequested_,
    uint256[2] memory rates_
)
    external
    override
    whenNotPaused
    returns (uint16 loanId_);
```

**Parameters**

| Name                  | Type         | Description                                                                       |
| --------------------- | ------------ | --------------------------------------------------------------------------------- |
| `receivableAsset_`    | `address`    |                                                                                   |
| `receivablesTokenId_` | `uint256`    | Token ID of the receivable that would be used as collateral.                      |
| `gracePeriod_`        | `uint256`    | Grace period of the loan.                                                         |
| `principalRequested_` | `uint256`    | Amount of principal requested by the buyer.                                       |
| `rates_`              | `uint256[2]` | <p>Rates parameters:<br>\[0]: interestRate.<br>\[1]: lateInterestPremiumRate.</p> |

**Returns**

| Name      | Type     | Description                     |
| --------- | -------- | ------------------------------- |
| `loanId_` | `uint16` | Id of the loan that is created. |

### fundLoan

Used by the pool admin to fund the loan requested by the buyer.

```solidity
function fundLoan(uint16 loanId_) external override nonReentrant whenNotPaused onlyPoolAdmin;
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |

### repayLoan

Repays the loan (note that the loan can be repaid early but not partially).

```solidity
function repayLoan(uint16 loanId_) external override whenNotPaused returns (uint256 principal_, uint256 interest_);
```

**Parameters**

| Name      | Type     | Description              |
| --------- | -------- | ------------------------ |
| `loanId_` | `uint16` | Id of the loan to repay. |

**Returns**

| Name         | Type      | Description              |
| ------------ | --------- | ------------------------ |
| `principal_` | `uint256` | Principal amount repaid. |
| `interest_`  | `uint256` | Interest amount repaid.  |

### withdrawFunds

Used by sellers to withdraw funds from a loan.

```solidity
function withdrawFunds(uint16 loanId_, address destination_) external override whenNotPaused;
```

**Parameters**

| Name           | Type      | Description                            |
| -------------- | --------- | -------------------------------------- |
| `loanId_`      | `uint16`  | Id of the loan to withdraw funds from. |
| `destination_` | `address` | The destination address for the funds. |

### impairLoan

Impairs the loan.

```solidity
function impairLoan(uint16 loanId_) external override whenNotPaused onlyPoolAdminOrGovernor;
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |

### removeLoanImpairment

Removes the impairment on the loan.

```solidity
function removeLoanImpairment(uint16 loanId_) external override nonReentrant whenNotPaused onlyPoolAdminOrGovernor;
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |

### triggerDefault

Triggers the default of a loan.

```solidity
function triggerDefault(
    uint16 loanId_
)
    external
    override
    whenNotPaused
    onlyPoolConfigurator
    returns (uint256 remainingLosses_, uint256 protocolFees_);
```

**Parameters**

| Name      | Type     | Description                           |
| --------- | -------- | ------------------------------------- |
| `loanId_` | `uint16` | The id of the loan that is triggered. |

**Returns**

| Name               | Type      | Description                     |
| ------------------ | --------- | ------------------------------- |
| `remainingLosses_` | `uint256` | The amount of remaining losses. |
| `protocolFees_`    | `uint256` | The amount of protocol fees.    |

### \_getIssuance

```solidity
function _getIssuance(uint256 issuanceRate_, uint256 interval_) internal pure returns (uint256 issuance_);
```

### \_getInterestBreakdown

```solidity
function _getInterestBreakdown(
    uint256 currentTime_,
    uint256 startDate_,
    uint256 dueDate_,
    uint256 principal_,
    uint256 interestRate_,
    uint256 lateInterestPremiumRate_
)
    internal
    pure
    returns (uint256[2] memory interest_);
```

### \_getInterest

```solidity
function _getInterest(
    uint256 principal_,
    uint256 interestRate_,
    uint256 interval_
)
    internal
    pure
    returns (uint256 interest_);
```

### \_getLateInterest

```solidity
function _getLateInterest(
    uint256 currentTime_,
    uint256 principal_,
    uint256 interestRate_,
    uint256 dueDate_,
    uint256 lateInterestPremiumRate_
)
    internal
    pure
    returns (uint256 lateInterest_);
```

### \_getPeriodicInterestRate

```solidity
function _getPeriodicInterestRate(
    uint256 interestRate_,
    uint256 interval_
)
    internal
    pure
    returns (uint256 periodicInterestRate_);
```

### \_poolConfigurator

```solidity
function _poolConfigurator() internal view returns (address poolConfigurator_);
```

### \_globals

```solidity
function _globals() internal view returns (address globals_);
```

### \_governor

```solidity
function _governor() internal view returns (address governor_);
```

### \_poolAdmin

```solidity
function _poolAdmin() internal view returns (address poolAdmin_);
```

### \_pool

```solidity
function _pool() internal view returns (address pool_);
```

### \_vault

```solidity
function _vault() internal view returns (address vault_);
```

### \_advanceGlobalPaymentAccounting

```solidity
function _advanceGlobalPaymentAccounting() internal;
```

### \_updateIssuanceParams

```solidity
function _updateIssuanceParams(uint256 issuanceRate_, uint112 accountedInterest_) internal;
```

### \_compareAndSubtractAccountedInterest

```solidity
function _compareAndSubtractAccountedInterest(uint256 amount_) internal;
```

### \_getAccruedAmount

```solidity
function _getAccruedAmount(
    uint256 totalAccruingAmount_,
    uint256 startTime_,
    uint256 endTime_,
    uint256 currentTime_
)
    internal
    pure
    returns (uint256 accruedAmount_);
```

### \_getDefaultInterestAndFees

```solidity
function _getDefaultInterestAndFees(
    uint16 loanId_,
    Loan.PaymentInfo memory paymentInfo_
)
    internal
    view
    returns (uint256 netInterest_, uint256 netLateInterest_, uint256 protocolFees_);
```

### \_getInterestAndFeesFromLiquidationInfo

```solidity
function _getInterestAndFeesFromLiquidationInfo(
    uint16 loanId_
)
    internal
    view
    returns (uint256 netInterest_, uint256 netLateInterest_, uint256 protocolFees_);
```

### \_getNetInterest

```solidity
function _getNetInterest(uint256 interest_, uint256 feeRate_) internal pure returns (uint256 netInterest_);
```

### \_getPaymentAccruedInterest

```solidity
function _getPaymentAccruedInterest(
    uint256 startTime_,
    uint256 endTime_,
    uint256 paymentIssuanceRate_
)
    internal
    pure
    returns (uint256 accruedInterest_);
```

### \_accountToEndOfPayment

```solidity
function _accountToEndOfPayment(
    uint256 paymentId_,
    uint256 issuanceRate_,
    uint256 intervalStart_,
    uint256 intervalEnd_
)
    internal
    returns (uint256 accountedInterestIncrease_, uint256 issuanceRateReduction_);
```

### \_deletePayment

```solidity
function _deletePayment(uint16 loanId_) internal;
```

### \_handlePaymentAccounting

```solidity
function _handlePaymentAccounting(uint16 loanId_) internal returns (uint256 issuanceRate_);
```

### \_queuePayment

```solidity
function _queuePayment(uint16 loanId_, uint256 startDate_, uint256 dueDate_) internal returns (uint256 newRate_);
```

### \_reverseLoanImpairment

```solidity
function _reverseLoanImpairment(Loan.LiquidationInfo memory liquidationInfo_) internal;
```

### \_addPaymentToList

```solidity
function _addPaymentToList(uint48 paymentDueDate_) internal returns (uint24 paymentId_);
```

### \_removePaymentFromList

```solidity
function _removePaymentFromList(uint256 paymentId_) internal;
```

### \_distributeClaimedFunds

```solidity
function _distributeClaimedFunds(uint16 loanId_, uint256 principal_, uint256 interest_) internal;
```

### \_handleDefault

```solidity
function _handleDefault(
    uint16 loanId_,
    uint256 netInterest_,
    uint256 netLateInterest_
)
    internal
    returns (uint256 remainingLosses_);
```

### \_revertIfPaused

```solidity
function _revertIfPaused() internal view;
```

### \_revertIfNotPoolAdminOrGovernor

```solidity
function _revertIfNotPoolAdminOrGovernor() internal view;
```

### \_revertIfNotPoolAdmin

```solidity
function _revertIfNotPoolAdmin() internal view;
```

### \_revertIfNotPoolConfigurator

```solidity
function _revertIfNotPoolConfigurator() internal view;
```

### \_revertIfCallerNotReceivableBuyer

```solidity
function _revertIfCallerNotReceivableBuyer(address buyer_) internal view;
```

### \_revertIfInvalidReceivable

```solidity
function _revertIfInvalidReceivable(
    uint256 receivablesTokenId_,
    address buyer_,
    address seller_,
    uint256 repaymentTimestamp_
)
    internal
    view;
```

### \_min

```solidity
function _min(uint256 a_, uint256 b_) internal pure returns (uint256 minimum_);
```


# LoanManagerStorage

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/LoanManagerStorage.sol)

**Inherits:** [ILoanManagerStorage](/contract-documentation/interfaces/iloanmanagerstorage)

## State Variables

### loanCounter

```solidity
uint16 public override loanCounter;
```

### paymentCounter

```solidity
uint24 public override paymentCounter;
```

### paymentWithEarliestDueDate

```solidity
uint24 public override paymentWithEarliestDueDate;
```

### domainStart

```solidity
uint48 public override domainStart;
```

### domainEnd

```solidity
uint48 public override domainEnd;
```

### accountedInterest

```solidity
uint112 public override accountedInterest;
```

### principalOut

```solidity
uint128 public override principalOut;
```

### unrealizedLosses

```solidity
uint128 public override unrealizedLosses;
```

### issuanceRate

```solidity
uint256 public override issuanceRate;
```

### asset

```solidity
address public override asset;
```

### paymentIdOf

```solidity
mapping(uint16 => uint24) public override paymentIdOf;
```

### impairmentFor

```solidity
mapping(uint16 => Loan.Impairment) public impairmentFor;
```

### payments

```solidity
mapping(uint256 => Loan.PaymentInfo) public payments;
```

### sortedPayments

```solidity
mapping(uint256 => Loan.SortedPayment) public sortedPayments;
```

### liquidationInfoFor

```solidity
mapping(uint16 => Loan.LiquidationInfo) public liquidationInfoFor;
```

### \_loans

```solidity
mapping(uint16 => Loan.Info) internal _loans;
```


# Pool

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/Pool.sol)

**Inherits:** [IPool](/contract-documentation/interfaces/ipool), ERC20Permit

See the documentation in {IPool}.

## State Variables

### configurator

```solidity
address public configurator;
```

### \_asset

```solidity
ERC20Permit private immutable _asset;
```

### \_underlyingDecimals

```solidity
uint8 private immutable _underlyingDecimals;
```

## Functions

### constructor

```solidity
constructor(
    address configurator_,
    address asset_,
    string memory name_,
    string memory symbol_
)
    ERC20Permit(name_)
    ERC20(name_, symbol_);
```

### depositWithPermit

Deposits assets into the pool with the permit signature.

```solidity
function depositWithPermit(
    uint256 assets_,
    address receiver_,
    uint256 deadline_,
    uint8 v_,
    bytes32 r_,
    bytes32 s_
)
    external
    returns (uint256 shares_);
```

**Parameters**

| Name        | Type      | Description                           |
| ----------- | --------- | ------------------------------------- |
| `assets_`   | `uint256` | The amount of assets to deposit.      |
| `receiver_` | `address` | The address of the receiver.          |
| `deadline_` | `uint256` | The deadline of the permit signature. |
| `v_`        | `uint8`   | The v of the permit signature.        |
| `r_`        | `bytes32` | The r of the permit signature.        |
| `s_`        | `bytes32` | The s of the permit signature.        |

**Returns**

| Name      | Type      | Description                                |
| --------- | --------- | ------------------------------------------ |
| `shares_` | `uint256` | The corresponding amount of shares minted. |

### mintWithPermit

Mints shares from the pool with the permit signature.

```solidity
function mintWithPermit(
    uint256 shares_,
    address receiver_,
    uint256 maxAssets_,
    uint256 deadline_,
    uint8 v_,
    bytes32 r_,
    bytes32 s_
)
    external
    returns (uint256 assets_);
```

**Parameters**

| Name         | Type      | Description                              |
| ------------ | --------- | ---------------------------------------- |
| `shares_`    | `uint256` | The amount of shares to mint.            |
| `receiver_`  | `address` | The address of the receiver.             |
| `maxAssets_` | `uint256` | The maximum amount of assets to deposit. |
| `deadline_`  | `uint256` | The deadline of the permit signature.    |
| `v_`         | `uint8`   | The v of the permit signature.           |
| `r_`         | `bytes32` | The r of the permit signature.           |
| `s_`         | `bytes32` | The s of the permit signature.           |

**Returns**

| Name      | Type      | Description                                   |
| --------- | --------- | --------------------------------------------- |
| `assets_` | `uint256` | The corresponding amount of assets deposited. |

### removeShares

Remove shares from the pool.

```solidity
function removeShares(uint256 shares_, address owner_) external override returns (uint256 sharesReturned_);
```

**Parameters**

| Name      | Type      | Description                     |
| --------- | --------- | ------------------------------- |
| `shares_` | `uint256` | The amount of shares to remove. |
| `owner_`  | `address` | The owner of the shares.        |

**Returns**

| Name              | Type      | Description                    |
| ----------------- | --------- | ------------------------------ |
| `sharesReturned_` | `uint256` | The amount of shares returned. |

### requestRedeem

Request the redemption of shares from the pool.

```solidity
function requestRedeem(uint256 shares_, address owner_) external override;
```

**Parameters**

| Name      | Type      | Description                     |
| --------- | --------- | ------------------------------- |
| `shares_` | `uint256` | The amount of shares to redeem. |
| `owner_`  | `address` | The owner of the shares.        |

### balanceOfAssets

Returns of the balance of the account.

```solidity
function balanceOfAssets(address account_) public view override returns (uint256 balanceOfAssets_);
```

**Parameters**

| Name       | Type      | Description                 |
| ---------- | --------- | --------------------------- |
| `account_` | `address` | The address of the account. |

**Returns**

| Name               | Type      | Description                    |
| ------------------ | --------- | ------------------------------ |
| `balanceOfAssets_` | `uint256` | assets\_ The amount of assets. |

### convertToExitAssets

Returns the amount of assets that can be withdrawn for the amount of shares.

```solidity
function convertToExitAssets(uint256 shares_) public view override returns (uint256 assets_);
```

**Parameters**

| Name      | Type      | Description           |
| --------- | --------- | --------------------- |
| `shares_` | `uint256` | The amount of shares. |

**Returns**

| Name      | Type      | Description           |
| --------- | --------- | --------------------- |
| `assets_` | `uint256` | The amount of assets. |

### convertToExitShares

Returns the amount of shares that will be burned to withdraw the amount of assets.

```solidity
function convertToExitShares(uint256 assets_) public view override returns (uint256 shares_);
```

**Parameters**

| Name      | Type      | Description                       |
| --------- | --------- | --------------------------------- |
| `assets_` | `uint256` | The amount of assets to withdraw. |

**Returns**

| Name      | Type      | Description           |
| --------- | --------- | --------------------- |
| `shares_` | `uint256` | The amount of shares. |

### unrealizedLosses

Returns the unrealized losses of the pool.

```solidity
function unrealizedLosses() public view override returns (uint256 unrealizedLosses_);
```

**Returns**

| Name                | Type      | Description            |
| ------------------- | --------- | ---------------------- |
| `unrealizedLosses_` | `uint256` | The unrealized losses. |

### deposit

Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.

* MUST emit the Deposit event.
* MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the deposit execution, and are accounted for during deposit.
* MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc).

NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.

```solidity
function deposit(uint256 assets, address receiver) public override returns (uint256 shares);
```

### mint

As opposed to [deposit](https://github.com/isle-labs/isle-docs/blob/main/contracts/Pool.sol/contract.Pool.md#deposit), minting is allowed even if the vault is in a state where the price of a share is zero. In this case, the shares will be minted without requiring any assets to be deposited.

* MUST emit the Deposit event.
* MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint execution, and are accounted for during mint.
* MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc).

NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.

```solidity
function mint(uint256 shares, address receiver) public override returns (uint256 assets);
```

### withdraw

Withdraw functions not implemented

* MUST emit the Withdraw event.
* MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the withdraw execution, and are accounted for during withdraw.
* MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.

```solidity
function withdraw(uint256 assets_, address receiver_, address owner_) public pure override returns (uint256 shares_);
```

### redeem

Burns exactly shares from owner and sends assets of underlying tokens to receiver.

* MUST emit the Withdraw event.
* MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the redeem execution, and are accounted for during redeem.
* MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc).

NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.

```solidity
function redeem(uint256 shares_, address receiver_, address owner_) public override returns (uint256 assets_);
```

### maxDeposit

Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, through a deposit call.

* MUST return a limited value if receiver is subject to some deposit limit.
* MUST return 2 \*\* 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
* MUST NOT revert.

```solidity
function maxDeposit(address receiver_) public view override returns (uint256 maxAssets_);
```

### maxMint

Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.

* MUST return a limited value if receiver is subject to some mint limit.
* MUST return 2 \*\* 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
* MUST NOT revert.

```solidity
function maxMint(address receiver_) public view override returns (uint256 maxShares_);
```

### maxWithdraw

Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a withdraw call.

* MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* MUST NOT revert.

```solidity
function maxWithdraw(address owner_) public pure override returns (uint256 maxAssets_);
```

### maxRedeem

Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, through a redeem call.

* MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
* MUST NOT revert.

```solidity
function maxRedeem(address owner_) public view override returns (uint256 maxShares_);
```

### previewWithdraw

Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, given current on-chain conditions.

* MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if called in the same transaction.
* MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though the withdrawal would be accepted, regardless if the user has enough shares, etc.
* MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* MUST NOT revert.

NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.

```solidity
function previewWithdraw(uint256 assets_) public pure override returns (uint256 shares_);
```

### previewRedeem

Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, given current on-chain conditions.

* MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the same transaction.
* MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the redemption would be accepted, regardless if the user has enough shares, etc.
* MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* MUST NOT revert.

NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by redeeming.

```solidity
function previewRedeem(uint256 shares_) public view override returns (uint256 assets_);
```

### convertToShares

Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal scenario where all the conditions are met.

* MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* MUST NOT show any variations depending on the caller.
* MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* MUST NOT revert.

NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.

```solidity
function convertToShares(uint256 assets_) public view override returns (uint256 shares_);
```

### convertToAssets

Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal scenario where all the conditions are met.

* MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* MUST NOT show any variations depending on the caller.
* MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* MUST NOT revert. NOTE: This calculation MAY

NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.

```solidity
function convertToAssets(uint256 shares_) public view override returns (uint256 assets_);
```

### previewDeposit

Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current on-chain conditions.

* MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called in the same transaction.
* MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the deposit would be accepted, regardless if the user has enough tokens approved, etc.
* MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* MUST NOT revert.

NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.

```solidity
function previewDeposit(uint256 assets_) public view override returns (uint256 shares_);
```

### previewMint

Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given current on-chain conditions.

* MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the same transaction.
* MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint would be accepted, regardless if the user has enough tokens approved, etc.
* MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* MUST NOT revert.

NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by minting.

```solidity
function previewMint(uint256 shares_) public view override returns (uint256 assets_);
```

### decimals

*Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This "original" value is cached during construction of the vault contract. If this read operation fails (e.g., the asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals.*

```solidity
function decimals() public view override(IERC20Metadata, ERC20) returns (uint8);
```

### asset

Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.

* MUST be an ERC-20 token contract.
* MUST NOT revert.

```solidity
function asset() public view override returns (address);
```

### totalAssets

Returns the total amount of the underlying asset that is “managed” by Vault.

* SHOULD include any compounding that occurs from yield.
* MUST be inclusive of any fees that are charged against assets in the Vault.
* MUST NOT revert.

```solidity
function totalAssets() public view override returns (uint256);
```

### \_deposit

*Deposit/mint common workflow.*

```solidity
function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal;
```

### \_withdraw

*Withdraw/redeem common workflow.*

```solidity
function _withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares) internal;
```

### \_decimalsOffset

```solidity
function _decimalsOffset() internal pure returns (uint8);
```

### \_convertToShares

```solidity
function _convertToShares(uint256 assets_, Math.Rounding rounding_) internal view virtual returns (uint256 shares_);
```

### \_convertToExitShares

```solidity
function _convertToExitShares(
    uint256 assets_,
    Math.Rounding rounding_
)
    internal
    view
    virtual
    returns (uint256 shares_);
```

### \_convertToAssets

```solidity
function _convertToAssets(uint256 shares_, Math.Rounding rounding_) internal view virtual returns (uint256 assets_);
```

### \_convertToExitAssets

```solidity
function _convertToExitAssets(
    uint256 shares_,
    Math.Rounding rounding_
)
    internal
    view
    virtual
    returns (uint256 assets_);
```


# PoolAddressesProvider

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/PoolAddressesProvider.sol)

**Inherits:** [IPoolAddressesProvider](/contract-documentation/interfaces/ipooladdressesprovider)

## State Variables

### \_marketId

```solidity
string private _marketId;
```

### \_addresses

```solidity
mapping(bytes32 => address) private _addresses;
```

### POOL\_CONFIGURATOR

```solidity
bytes32 private constant POOL_CONFIGURATOR = "POOL_CONFIGURATOR";
```

### ISLE\_GLOBALS

```solidity
bytes32 private constant ISLE_GLOBALS = "ISLE_GLOBALS";
```

### LOAN\_MANAGER

```solidity
bytes32 private constant LOAN_MANAGER = "LOAN_MANAGER";
```

### WITHDRAWAL\_MANAGER

```solidity
bytes32 private constant WITHDRAWAL_MANAGER = "WITHDRAWAL_MANAGER";
```

## Functions

### onlyGovernor

```solidity
modifier onlyGovernor();
```

### constructor

```solidity
constructor(string memory marketId_, IIsleGlobals globals_);
```

### getMarketId

```solidity
function getMarketId() external view override returns (string memory marketId_);
```

### setMarketId

```solidity
function setMarketId(string memory newMarketId_) external override onlyGovernor;
```

### getPoolConfigurator

Retrieves the address of the PoolConfigurator proxy.

```solidity
function getPoolConfigurator() external view override returns (address);
```

**Returns**

| Name     | Type      | Description                                |
| -------- | --------- | ------------------------------------------ |
| `<none>` | `address` | The address of the PoolConfigurator proxy. |

### setPoolConfiguratorImpl

Sets or initializes the PoolConfigurator proxy with a new implementation.

```solidity
function setPoolConfiguratorImpl(
    address newPoolConfiguratorImpl,
    bytes calldata params
)
    external
    override
    onlyGovernor;
```

**Parameters**

| Name                      | Type      | Description                                             |
| ------------------------- | --------- | ------------------------------------------------------- |
| `newPoolConfiguratorImpl` | `address` | The address of the new PoolConfigurator implementation. |
| `params`                  | `bytes`   | The initialization parameters for the PoolConfigurator. |

### getLoanManager

Retrieves the address of the LoanManager proxy.

```solidity
function getLoanManager() external view override returns (address);
```

**Returns**

| Name     | Type      | Description                           |
| -------- | --------- | ------------------------------------- |
| `<none>` | `address` | The address of the LoanManager proxy. |

### setLoanManagerImpl

Sets or initializes the LoanManager proxy with a new implementation.

```solidity
function setLoanManagerImpl(address newLoanManagerImpl, bytes calldata params) external override onlyGovernor;
```

**Parameters**

| Name                 | Type      | Description                                        |
| -------------------- | --------- | -------------------------------------------------- |
| `newLoanManagerImpl` | `address` | The address of the new LoanManager implementation. |
| `params`             | `bytes`   | The initialization parameters for the LoanManager. |

### getWithdrawalManager

Retrieves the address of the WithdrawalManager proxy.

```solidity
function getWithdrawalManager() external view override returns (address);
```

**Returns**

| Name     | Type      | Description                                 |
| -------- | --------- | ------------------------------------------- |
| `<none>` | `address` | The address of the WithdrawalManager proxy. |

### setWithdrawalManagerImpl

Sets or initializes the WithdrawalManager proxy with a new implementation.

```solidity
function setWithdrawalManagerImpl(
    address newWithdrawalManagerImpl,
    bytes calldata params
)
    external
    override
    onlyGovernor;
```

**Parameters**

| Name                       | Type      | Description                                              |
| -------------------------- | --------- | -------------------------------------------------------- |
| `newWithdrawalManagerImpl` | `address` | The address of the new WithdrawalManager implementation. |
| `params`                   | `bytes`   | The initialization parameters for the WithdrawalManager. |

### setAddressAsProxy

Updates or initializes a proxy for a given identifier with a new implementation address.

*Use with caution for identifiers without dedicated setter functions to prevent unintended effects.*

```solidity
function setAddressAsProxy(
    bytes32 id,
    address newImplementationAddress,
    bytes calldata params
)
    external
    override
    onlyGovernor;
```

**Parameters**

| Name                       | Type      | Description                                           |
| -------------------------- | --------- | ----------------------------------------------------- |
| `id`                       | `bytes32` | The identifier of the contract to update.             |
| `newImplementationAddress` | `address` | The address of the new implementation.                |
| `params`                   | `bytes`   | The initialization parameters for the proxy contract. |

### getIsleGlobals

Retrieves the address of IsleGlobals.

```solidity
function getIsleGlobals() external view override returns (address);
```

**Returns**

| Name     | Type      | Description                 |
| -------- | --------- | --------------------------- |
| `<none>` | `address` | The address of IsleGlobals. |

### setIsleGlobals

Sets a new address for IsleGlobals, replacing the current address in the registry.

```solidity
function setIsleGlobals(address newIsleGlobals) external override onlyGovernor;
```

**Parameters**

| Name             | Type      | Description                      |
| ---------------- | --------- | -------------------------------- |
| `newIsleGlobals` | `address` | The new address for IsleGlobals. |

### getAddress

Fetches an address associated with a given identifier.

*Can return either a direct contract address or a proxy address.*

```solidity
function getAddress(bytes32 id) public view override returns (address);
```

**Parameters**

| Name | Type      | Description                                 |
| ---- | --------- | ------------------------------------------- |
| `id` | `bytes32` | The identifier of the contract to retrieve. |

**Returns**

| Name     | Type      | Description                                           |
| -------- | --------- | ----------------------------------------------------- |
| `<none>` | `address` | The address associated with the specified identifier. |

### setAddress

Directly sets a new address for a given identifier, replacing the current address.

*Use with caution as this will overwrite the existing address without any checks.*

```solidity
function setAddress(bytes32 id, address newAddress) external override onlyGovernor;
```

**Parameters**

| Name         | Type      | Description                                       |
| ------------ | --------- | ------------------------------------------------- |
| `id`         | `bytes32` | The identifier for which to set the address.      |
| `newAddress` | `address` | The new address to associate with the identifier. |

### \_updateImpl

Internal function to update the implementation of a specific proxied component of the protocol.

*If there is no proxy registered with the given identifier, it creates the proxy setting `newAddress` as implementation and calls the initialize() function on the proxy*

*If there is already a proxy registered, it just updates the implementation to `newAddress` and calls the initialize() function via upgradeToAndCall() in the proxy*

```solidity
function _updateImpl(bytes32 id, address newAddress) internal;
```

**Parameters**

| Name         | Type      | Description                           |
| ------------ | --------- | ------------------------------------- |
| `id`         | `bytes32` | The id of the proxy to be updated     |
| `newAddress` | `address` | The address of the new implementation |

### \_updateImpl

```solidity
function _updateImpl(bytes32 id, address newAddress, bytes memory params) internal;
```

### \_setMarketId

Updates the identifier of the Isle market.

```solidity
function _setMarketId(string memory newMarketId) internal;
```

**Parameters**

| Name          | Type     | Description              |
| ------------- | -------- | ------------------------ |
| `newMarketId` | `string` | The new id of the market |

### \_getProxyImplementation

Returns the the implementation contract of the proxy contract by its identifier.

*It returns ZERO if there is no registered address with the given id*

*It reverts if the registered address with the given id is not `InitializableImmutableAdminUpgradeabilityProxy`*

```solidity
function _getProxyImplementation(bytes32 id) internal view returns (address);
```

**Parameters**

| Name | Type      | Description |
| ---- | --------- | ----------- |
| `id` | `bytes32` | The id      |

**Returns**

| Name     | Type      | Description                                |
| -------- | --------- | ------------------------------------------ |
| `<none>` | `address` | The address of the implementation contract |


# PoolConfigurator

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/PoolConfigurator.sol)

**Inherits:** [VersionedInitializable](/contract-documentation/libraries/upgradability/versionedinitializable), [IPoolConfigurator](/contract-documentation/interfaces/ipoolconfigurator), [PoolConfiguratorStorage](/contract-documentation/poolconfiguratorstorage)

See the documentation in {IPoolConfigurator}.

## State Variables

### HUNDRED\_PERCENT

```solidity
uint256 public constant HUNDRED_PERCENT = 1_000_000;
```

### POOL\_CONFIGURATOR\_REVISION

```solidity
uint256 public constant POOL_CONFIGURATOR_REVISION = 0x1;
```

### ADDRESSES\_PROVIDER

```solidity
IPoolAddressesProvider public immutable ADDRESSES_PROVIDER;
```

## Functions

### whenNotPaused

```solidity
modifier whenNotPaused();
```

### onlyAdminOrGovernor

```solidity
modifier onlyAdminOrGovernor();
```

### onlyGovernor

```solidity
modifier onlyGovernor();
```

### onlyAdmin

```solidity
modifier onlyAdmin();
```

### onlyPool

```solidity
modifier onlyPool();
```

### constructor

```solidity
constructor(IPoolAddressesProvider provider_);
```

### getRevision

Returns the revision number of the contract

*Needs to be defined in the inherited class as a constant.*

```solidity
function getRevision() public pure virtual override returns (uint256 revision_);
```

**Returns**

| Name        | Type      | Description         |
| ----------- | --------- | ------------------- |
| `revision_` | `uint256` | The revision number |

### initialize

The initializer function for the pool configurator (must be called directly after deployment).

```solidity
function initialize(
    IPoolAddressesProvider provider_,
    address poolAdmin_,
    address asset_,
    string calldata name_,
    string calldata symbol_
)
    external
    override
    initializer;
```

**Parameters**

| Name         | Type                     | Description                                 |
| ------------ | ------------------------ | ------------------------------------------- |
| `provider_`  | `IPoolAddressesProvider` | The address of the pool addresses provider. |
| `poolAdmin_` | `address`                | The address of the pool admin.              |
| `asset_`     | `address`                | The ERC20 asset used in the lending pool.   |
| `name_`      | `string`                 | The name of the pool token.                 |
| `symbol_`    | `string`                 | The symbol of the pool token.               |

### transferAdmin

Transfers to a new admin.

```solidity
function transferAdmin(address newAdmin_) external virtual override onlyGovernor;
```

**Parameters**

| Name        | Type      | Description                   |
| ----------- | --------- | ----------------------------- |
| `newAdmin_` | `address` | The address of the new admin. |

### setBuyer

Assigns a buyer to the pool.

```solidity
function setBuyer(address buyer_) external override whenNotPaused onlyAdmin;
```

**Parameters**

| Name     | Type      | Description                             |
| -------- | --------- | --------------------------------------- |
| `buyer_` | `address` | The address of the buyer for this pool. |

### setValidSeller

Sets the status of a seller.

```solidity
function setValidSeller(address seller_, bool isValid_) external override whenNotPaused onlyAdmin;
```

**Parameters**

| Name       | Type      | Description                  |
| ---------- | --------- | ---------------------------- |
| `seller_`  | `address` | The address of the seller.   |
| `isValid_` | `bool`    | Whether the seller is valid. |

### setValidLender

Sets the status of a lender (liquidity providers).

```solidity
function setValidLender(address lender_, bool isValid_) external override whenNotPaused onlyAdmin;
```

**Parameters**

| Name       | Type      | Description                  |
| ---------- | --------- | ---------------------------- |
| `lender_`  | `address` | The address of the lender.   |
| `isValid_` | `bool`    | Whether the lender is valid. |

### setAdminFee

Sets the admin fee rate that would be applied to the pool.

```solidity
function setAdminFee(uint24 adminFee_) external override whenNotPaused onlyAdmin;
```

**Parameters**

| Name        | Type     | Description        |
| ----------- | -------- | ------------------ |
| `adminFee_` | `uint24` | The new admin fee. |

### setOpenToPublic

Sets whether the pool is open to the public (permissioned or permissionless).

```solidity
function setOpenToPublic(bool isOpenToPublic_) external override whenNotPaused onlyAdmin;
```

**Parameters**

| Name              | Type   | Description                             |
| ----------------- | ------ | --------------------------------------- |
| `isOpenToPublic_` | `bool` | Whether the pool is open to the public. |

### setMaxCoverLiquidation

Sets the max cover liquidation for the pool configurator.

```solidity
function setMaxCoverLiquidation(uint24 maxCoverLiquidation_) external override whenNotPaused onlyGovernor;
```

**Parameters**

| Name                   | Type     | Description                                                   |
| ---------------------- | -------- | ------------------------------------------------------------- |
| `maxCoverLiquidation_` | `uint24` | The max cover liquidation as a percentage for the pool admin. |

### setMinCover

Sets the min cover required for the pool configurator.

```solidity
function setMinCover(uint104 minCover_) external override whenNotPaused onlyGovernor;
```

**Parameters**

| Name        | Type      | Description                                |
| ----------- | --------- | ------------------------------------------ |
| `minCover_` | `uint104` | The min cover required for the pool admin. |

### setPoolLimit

Sets the pool limit for the pool configurator.

```solidity
function setPoolLimit(uint104 poolLimit_) external override whenNotPaused onlyGovernor;
```

**Parameters**

| Name         | Type      | Description                 |
| ------------ | --------- | --------------------------- |
| `poolLimit_` | `uint104` | The size limit of the pool. |

### requestFunds

Request funds from the pool and fund the loan manager.

```solidity
function requestFunds(uint256 principal_) external override whenNotPaused;
```

**Parameters**

| Name         | Type      | Description                         |
| ------------ | --------- | ----------------------------------- |
| `principal_` | `uint256` | The amount of principal to request. |

### triggerDefault

Triggers the defaults of a specific loan in the loan manager.

```solidity
function triggerDefault(uint16 loanId_) external override whenNotPaused onlyAdminOrGovernor;
```

**Parameters**

| Name      | Type     | Description                   |
| --------- | -------- | ----------------------------- |
| `loanId_` | `uint16` | The ID of the defaulted loan. |

### requestRedeem

Requests to redeem shares.

```solidity
function requestRedeem(uint256 shares_, address owner_) external override whenNotPaused onlyPool;
```

**Parameters**

| Name      | Type      | Description                     |
| --------- | --------- | ------------------------------- |
| `shares_` | `uint256` | The amount of shares to redeem. |
| `owner_`  | `address` | The owner of the shares.        |

### processRedeem

Processes the redemption of shares for a specific owner.

```solidity
function processRedeem(
    uint256 shares_,
    address owner_,
    address sender_
)
    external
    override
    whenNotPaused
    onlyPool
    returns (uint256 redeemableShares_, uint256 resultingAssets_);
```

**Parameters**

| Name      | Type      | Description                        |
| --------- | --------- | ---------------------------------- |
| `shares_` | `uint256` | The amount of shares to redeem.    |
| `owner_`  | `address` | The owner of the shares.           |
| `sender_` | `address` | The sender of the process request. |

**Returns**

| Name                | Type      | Description                                                    |
| ------------------- | --------- | -------------------------------------------------------------- |
| `redeemableShares_` | `uint256` | The amount of redeemable shares.                               |
| `resultingAssets_`  | `uint256` | The corresponding amount of assets with the redeemable shares. |

### removeShares

Removes shares from its withdrawal request.

```solidity
function removeShares(
    uint256 shares_,
    address owner_
)
    external
    override
    whenNotPaused
    onlyPool
    returns (uint256 sharesReturned_);
```

**Parameters**

| Name      | Type      | Description                                     |
| --------- | --------- | ----------------------------------------------- |
| `shares_` | `uint256` | The amount of shares to remove from withdrawal. |
| `owner_`  | `address` | The owner of the shares.                        |

**Returns**

| Name              | Type      | Description                    |
| ----------------- | --------- | ------------------------------ |
| `sharesReturned_` | `uint256` | The amount of shares returned. |

### depositCover

Pool admin deposits pool cover.

```solidity
function depositCover(uint256 amount_) external override whenNotPaused;
```

**Parameters**

| Name      | Type      | Description                                          |
| --------- | --------- | ---------------------------------------------------- |
| `amount_` | `uint256` | The amount of assets to deposit as first-loss cover. |

### withdrawCover

Pool admin withdraws from pool cover.

```solidity
function withdrawCover(uint256 amount_, address recipient_) external override whenNotPaused onlyAdmin;
```

**Parameters**

| Name         | Type      | Description                                             |
| ------------ | --------- | ------------------------------------------------------- |
| `amount_`    | `uint256` | The amount of assets to withdraw from first-loss cover. |
| `recipient_` | `address` | The address of the recipient.                           |

### openToPublic

Returns whether the pool is open to public.

```solidity
function openToPublic() external view override returns (bool openToPublic_);
```

**Returns**

| Name            | Type   | Description                         |
| --------------- | ------ | ----------------------------------- |
| `openToPublic_` | `bool` | Whether the pool is open to public. |

### adminFee

Returns the admin fee of the pool.

```solidity
function adminFee() external view override returns (uint24 adminFee_);
```

**Returns**

| Name        | Type     | Description                |
| ----------- | -------- | -------------------------- |
| `adminFee_` | `uint24` | The admin fee of the pool. |

### maxCoverLiquidation

Returns the max cover liquidation of the pool.

```solidity
function maxCoverLiquidation() external view returns (uint24 maxCoverLiquidation_);
```

**Returns**

| Name                   | Type     | Description                            |
| ---------------------- | -------- | -------------------------------------- |
| `maxCoverLiquidation_` | `uint24` | The max cover liquidation of the pool. |

### minCover

Returns the min cover required for the pool configurator.

```solidity
function minCover() external view returns (uint104 minCover_);
```

**Returns**

| Name        | Type      | Description                                |
| ----------- | --------- | ------------------------------------------ |
| `minCover_` | `uint104` | The min cover required for the pool admin. |

### poolLimit

Returns the pool limit of the pool configurator.

```solidity
function poolLimit() external view returns (uint104 poolLimit_);
```

**Returns**

| Name         | Type      | Description                 |
| ------------ | --------- | --------------------------- |
| `poolLimit_` | `uint104` | The size limit of the pool. |

### maxDeposit

Returns the max deposit amount of a receiver.

```solidity
function maxDeposit(address receiver_) external view virtual override returns (uint256 maxAssets_);
```

**Parameters**

| Name        | Type      | Description                  |
| ----------- | --------- | ---------------------------- |
| `receiver_` | `address` | The address of the receiver. |

**Returns**

| Name         | Type      | Description                                     |
| ------------ | --------- | ----------------------------------------------- |
| `maxAssets_` | `uint256` | The max amount of assets that can be deposited. |

### maxMint

Returns the max mint amount of a receiver.

```solidity
function maxMint(address receiver_) external view virtual override returns (uint256 maxShares_);
```

**Parameters**

| Name        | Type      | Description                  |
| ----------- | --------- | ---------------------------- |
| `receiver_` | `address` | The address of the receiver. |

**Returns**

| Name         | Type      | Description                                  |
| ------------ | --------- | -------------------------------------------- |
| `maxShares_` | `uint256` | The max amount of shares that can be minted. |

### maxRedeem

Returns the max redeem amount of an owner.

```solidity
function maxRedeem(address owner_) external view virtual override returns (uint256 maxShares_);
```

**Parameters**

| Name     | Type      | Description               |
| -------- | --------- | ------------------------- |
| `owner_` | `address` | The address of the owner. |

**Returns**

| Name         | Type      | Description                                    |
| ------------ | --------- | ---------------------------------------------- |
| `maxShares_` | `uint256` | The max amount of shares that can be redeemed. |

### previewRedeem

Previews the amount of assets that can be redeemed for the amount of shares specified.

```solidity
function previewRedeem(address owner_, uint256 shares_) external view virtual override returns (uint256 assets_);
```

**Parameters**

| Name      | Type      | Description                     |
| --------- | --------- | ------------------------------- |
| `owner_`  | `address` | The address of the owner.       |
| `shares_` | `uint256` | The amount of shares to redeem. |

**Returns**

| Name      | Type      | Description                                  |
| --------- | --------- | -------------------------------------------- |
| `assets_` | `uint256` | The amount of assets that would be received. |

### totalAssets

Returns the total amount of assets in the pool.

```solidity
function totalAssets() external view override returns (uint256 totalAssets_);
```

**Returns**

| Name           | Type      | Description                             |
| -------------- | --------- | --------------------------------------- |
| `totalAssets_` | `uint256` | The total amount of assets in the pool. |

### hasSufficientCover

Returns whether the pool currently has sufficient cover.

```solidity
function hasSufficientCover() external view override returns (bool hasSufficientCover_);
```

**Returns**

| Name                  | Type   | Description                                      |
| --------------------- | ------ | ------------------------------------------------ |
| `hasSufficientCover_` | `bool` | Whether the pool currently has sufficient cover. |

### unrealizedLosses

Returns the current amount of unrealized losses of the pool.

```solidity
function unrealizedLosses() external view override returns (uint256 unrealizedLosses_);
```

**Returns**

| Name                | Type      | Description                                          |
| ------------------- | --------- | ---------------------------------------------------- |
| `unrealizedLosses_` | `uint256` | The current amount of unrealized losses of the pool. |

### \_totalAssets

```solidity
function _totalAssets() internal view returns (uint256 totalAssets_);
```

### \_revertIfPaused

```solidity
function _revertIfPaused() internal view;
```

### \_revertIfNotAdmin

```solidity
function _revertIfNotAdmin() internal view;
```

### \_revertIfNotAdminOrGovernor

```solidity
function _revertIfNotAdminOrGovernor() internal view;
```

### \_revertIfNotGovernor

```solidity
function _revertIfNotGovernor() internal view;
```

### \_revertIfNotPool

```solidity
function _revertIfNotPool() internal view;
```

### \_hasSufficientCover

```solidity
function _hasSufficientCover() internal view returns (bool hasSufficientCover_);
```

### \_handleCover

```solidity
function _handleCover(uint256 losses_) internal;
```

### \_min

```solidity
function _min(uint256 a_, uint256 b_) internal pure returns (uint256 min_);
```

### \_getMaxAssets

```solidity
function _getMaxAssets(address receiver_, uint256 totalAssets_) internal view returns (uint256 maxAssets_);
```

### \_globals

```solidity
function _globals() internal view returns (IIsleGlobals globals_);
```

### \_loanManager

```solidity
function _loanManager() internal view returns (ILoanManager loanManager_);
```

### \_withdrawalManager

```solidity
function _withdrawalManager() internal view returns (IWithdrawalManager withdrawalManager_);
```


# PoolConfiguratorStorage

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/PoolConfiguratorStorage.sol)

**Inherits:** [IPoolConfiguratorStorage](https://github.com/isle-labs/isle-docs/blob/main/docs/contracts/interfaces/IPoolConfiguratorStorage.md)

## State Variables

### \_config

```solidity
PoolConfigurator.Config internal _config;
```

### admin

```solidity
address public override admin;
```

### asset

```solidity
address public override asset;
```

### pool

```solidity
address public override pool;
```

### buyer

```solidity
address public override buyer;
```

### poolCover

```solidity
uint256 public override poolCover;
```

### isSeller

```solidity
mapping(address => bool) public override isSeller;
```

### isLender

```solidity
mapping(address => bool) public override isLender;
```


# Receivable

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/Receivable.sol)

**Inherits:** [ReceivableStorage](/contract-documentation/receivablestorage), Initializable, ERC721Upgradeable, ERC721EnumerableUpgradeable, ERC721BurnableUpgradeable, UUPSUpgradeable, [IReceivable](/contract-documentation/interfaces/ireceivable)

## Functions

### \_authorizeUpgrade

```solidity
function _authorizeUpgrade(address newImplementation) internal override onlyGovernor;
```

### initialize

*Initializes the Receivable.*

```solidity
function initialize(address isleGlobal_) external override initializer;
```

**Parameters**

| Name          | Type      | Description                    |
| ------------- | --------- | ------------------------------ |
| `isleGlobal_` | `address` | The address of the isleGlobal. |

### createReceivable

Mint a new receivable.

*The event faceAmount is converted to decimal with 6 decimals.*

```solidity
function createReceivable(RCV.Create calldata params_) external override returns (uint256 tokenId_);
```

**Parameters**

| Name      | Type         | Description                                                            |
| --------- | ------------ | ---------------------------------------------------------------------- |
| `params_` | `RCV.Create` | The struct containing the information of the receivable to be created. |

**Returns**

| Name       | Type      | Description                             |
| ---------- | --------- | --------------------------------------- |
| `tokenId_` | `uint256` | The id of the newly created receivable. |

### getReceivableInfoById

*Get the information of a receivable.*

```solidity
function getReceivableInfoById(uint256 tokenId_) external view override returns (RCV.Info memory info_);
```

**Parameters**

| Name       | Type      | Description               |
| ---------- | --------- | ------------------------- |
| `tokenId_` | `uint256` | The id of the receivable. |

**Returns**

| Name    | Type       | Description                                              |
| ------- | ---------- | -------------------------------------------------------- |
| `info_` | `RCV.Info` | The struct containing the information of the receivable. |

### burnReceivable

*Burn a receivable.*

```solidity
function burnReceivable(uint256 tokenId_) external;
```

**Parameters**

| Name       | Type      | Description               |
| ---------- | --------- | ------------------------- |
| `tokenId_` | `uint256` | The id of the receivable. |

### governor

*Get governor from IsleGlobals.*

```solidity
function governor() public view returns (address governor_);
```

**Returns**

| Name        | Type      | Description                  |
| ----------- | --------- | ---------------------------- |
| `governor_` | `address` | The address of the governor. |

### \_beforeTokenTransfer

not support batch transfer

*Hook that is called before any token transfer.*

```solidity
function _beforeTokenTransfer(
    address from_,
    address to_,
    uint256 tokenId_,
    uint256 batchSize_
)
    internal
    override(ERC721Upgradeable, ERC721EnumerableUpgradeable);
```

### supportsInterface

*See {IERC165-supportsInterface}.*

```solidity
function supportsInterface(
    bytes4 interfaceId_
)
    public
    view
    override(ERC721Upgradeable, ERC721EnumerableUpgradeable)
    returns (bool);
```


# ReceivableStorage

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/ReceivableStorage.sol)

## State Variables

### isleGlobal

```solidity
address public isleGlobal;
```

### \_tokenIdCounter

```solidity
uint256 internal _tokenIdCounter;
```

### idToReceivableInfo

```solidity
mapping(uint256 => Receivable.Info) public idToReceivableInfo;
```

### \_\_gap

*This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain. See <https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage\\_gaps>*

```solidity
uint256[100] private __gap;
```


# WithdrawalManager

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/WithdrawalManager.sol)

**Inherits:** [WithdrawalManagerStorage](/contract-documentation/withdrawalmanagerstorage), [IWithdrawalManager](/contract-documentation/interfaces/iwithdrawalmanager), [VersionedInitializable](/contract-documentation/libraries/upgradability/versionedinitializable)

## State Variables

### WITHDRAWAL\_MANAGER\_REVISION

```solidity
uint256 public constant WITHDRAWAL_MANAGER_REVISION = 0x1;
```

### ADDRESSES\_PROVIDER

```solidity
IPoolAddressesProvider public immutable ADDRESSES_PROVIDER;
```

## Functions

### onlyPoolAdmin

```solidity
modifier onlyPoolAdmin();
```

### onlyPoolConfigurator

```solidity
modifier onlyPoolConfigurator();
```

### whenProtocolNotPaused

```solidity
modifier whenProtocolNotPaused();
```

### getRevision

Returns the revision number of the contract

*Needs to be defined in the inherited class as a constant.*

```solidity
function getRevision() public pure virtual override returns (uint256 revision_);
```

**Returns**

| Name        | Type      | Description         |
| ----------- | --------- | ------------------- |
| `revision_` | `uint256` | The revision number |

### constructor

```solidity
constructor(IPoolAddressesProvider provider_);
```

### initialize

Initializes the Withdrawal Manager.

*Function is invoked by the proxy contract when the Withdrawal Manager Contract is added to the PoolAddressesProvider of the market.*

```solidity
function initialize(
    IPoolAddressesProvider provider_,
    uint256 cycleDuration_,
    uint256 windowDuration_
)
    external
    override
    initializer;
```

**Parameters**

| Name              | Type                     | Description                               |
| ----------------- | ------------------------ | ----------------------------------------- |
| `provider_`       | `IPoolAddressesProvider` | The address of the PoolAddressesProvider. |
| `cycleDuration_`  | `uint256`                | The total duration of a withdrawal cycle. |
| `windowDuration_` | `uint256`                | The duration of the withdrawal window.    |

### setExitConfig

Pool admin sets a new configuration for the withdrawal manager.

```solidity
function setExitConfig(uint256 cycleDuration_, uint256 windowDuration_) external override whenProtocolNotPaused;
```

**Parameters**

| Name              | Type      | Description                                |
| ----------------- | --------- | ------------------------------------------ |
| `cycleDuration_`  | `uint256` | The total duration of a withdrawal cycle.  |
| `windowDuration_` | `uint256` | The total duration of a withdrawal window. |

### addShares

Add more shares for withdrawal.

```solidity
function addShares(uint256 shares_, address owner_) external override onlyPoolConfigurator;
```

**Parameters**

| Name      | Type      | Description                  |
| --------- | --------- | ---------------------------- |
| `shares_` | `uint256` | The amount of shares to add. |
| `owner_`  | `address` | The owner of the shares.     |

### removeShares

Remove shares from withdrawal.

```solidity
function removeShares(
    uint256 shares_,
    address owner_
)
    external
    override
    onlyPoolConfigurator
    returns (uint256 sharesReturned_);
```

**Parameters**

| Name      | Type      | Description                                     |
| --------- | --------- | ----------------------------------------------- |
| `shares_` | `uint256` | The amount of shares to remove from withdrawal. |
| `owner_`  | `address` | The owner of the shares.                        |

### processExit

Process the exit of requested shares of a owner.

```solidity
function processExit(
    uint256 requestedShares_,
    address owner_
)
    external
    override
    onlyPoolConfigurator
    returns (uint256 redeemableShares_, uint256 resultingAssets_);
```

**Parameters**

| Name               | Type      | Description                     |
| ------------------ | --------- | ------------------------------- |
| `requestedShares_` | `uint256` | The amount of shares to redeem. |
| `owner_`           | `address` | The owner of the shares.        |

**Returns**

| Name                | Type      | Description                                                    |
| ------------------- | --------- | -------------------------------------------------------------- |
| `redeemableShares_` | `uint256` | The amount of redeemable shares.                               |
| `resultingAssets_`  | `uint256` | The corresponding amount of assets with the redeemable shares. |

### isInExitWindow

Checks if the owner has a withdrawal request in the exit window.

```solidity
function isInExitWindow(address owner_) external view override returns (bool isInExitWindow_);
```

**Parameters**

| Name     | Type      | Description                 |
| -------- | --------- | --------------------------- |
| `owner_` | `address` | The owner address to check. |

**Returns**

| Name              | Type   | Description                                                    |
| ----------------- | ------ | -------------------------------------------------------------- |
| `isInExitWindow_` | `bool` | True if the owner has a withdrawal request in the exit window. |

### lockedLiquidity

Gets the total amount of liquidity locked in the current cycle.

```solidity
function lockedLiquidity() external view override returns (uint256 lockedLiquidity_);
```

**Returns**

| Name               | Type      | Description                                                |
| ------------------ | --------- | ---------------------------------------------------------- |
| `lockedLiquidity_` | `uint256` | The total amount of liquidity locked in the current cycle. |

### previewRedeem

Previews the amount of shares and assets that can be redeemed.

```solidity
function previewRedeem(
    address owner_,
    uint256 shares_
)
    external
    view
    override
    returns (uint256 redeemableShares_, uint256 resultingAssets_);
```

**Parameters**

| Name      | Type      | Description                     |
| --------- | --------- | ------------------------------- |
| `owner_`  | `address` | The owner of the shares.        |
| `shares_` | `uint256` | The amount of shares to redeem. |

**Returns**

| Name                | Type      | Description                                                    |
| ------------------- | --------- | -------------------------------------------------------------- |
| `redeemableShares_` | `uint256` | The amount of redeemable shares.                               |
| `resultingAssets_`  | `uint256` | The corresponding amount of assets with the redeemable shares. |

### getCycleConfig

Gets the configuration of a config id.

```solidity
function getCycleConfig(uint256 configId_) public view override returns (WM.CycleConfig memory config_);
```

**Parameters**

| Name        | Type      | Description           |
| ----------- | --------- | --------------------- |
| `configId_` | `uint256` | The id of the config. |

**Returns**

| Name      | Type             | Description |
| --------- | ---------------- | ----------- |
| `config_` | `WM.CycleConfig` | The config. |

### getConfigAtId

Gets the configuration of a given cycle id.

```solidity
function getConfigAtId(uint256 cycleId_) public view override returns (WM.CycleConfig memory config_);
```

**Parameters**

| Name       | Type      | Description   |
| ---------- | --------- | ------------- |
| `cycleId_` | `uint256` | The cycle id. |

**Returns**

| Name      | Type             | Description                             |
| --------- | ---------------- | --------------------------------------- |
| `config_` | `WM.CycleConfig` | The configuration used at the cycle id. |

### getCurrentConfig

Gets the configuration of the current cycle id.

```solidity
function getCurrentConfig() public view override returns (WM.CycleConfig memory config_);
```

**Returns**

| Name      | Type             | Description                                     |
| --------- | ---------------- | ----------------------------------------------- |
| `config_` | `WM.CycleConfig` | The configuration used at the current cycle id. |

### getCurrentCycleId

Gets the current cycle id.

```solidity
function getCurrentCycleId() public view override returns (uint256 cycleId_);
```

**Returns**

| Name       | Type      | Description                  |
| ---------- | --------- | ---------------------------- |
| `cycleId_` | `uint256` | The id of the current cycle. |

### getWindowStart

Gets the starting time of a window for a given cycle id.

```solidity
function getWindowStart(uint256 cycleId_) public view override returns (uint64 windowStart_);
```

**Parameters**

| Name       | Type      | Description          |
| ---------- | --------- | -------------------- |
| `cycleId_` | `uint256` | The id of the cycle. |

**Returns**

| Name           | Type     | Description                      |
| -------------- | -------- | -------------------------------- |
| `windowStart_` | `uint64` | The starting time of the window. |

### getWindowAtId

Gets the start and end time of a window for a given cycle id.

```solidity
function getWindowAtId(uint256 cycleId_) public view override returns (uint64 windowStart_, uint64 windowEnd_);
```

**Parameters**

| Name       | Type      | Description          |
| ---------- | --------- | -------------------- |
| `cycleId_` | `uint256` | The id of the cycle. |

**Returns**

| Name           | Type     | Description                      |
| -------------- | -------- | -------------------------------- |
| `windowStart_` | `uint64` | The starting time of the window. |
| `windowEnd_`   | `uint64` | The ending time of the window.   |

### getRedeemableAmounts

```solidity
function getRedeemableAmounts(
    uint256 lockedShares_,
    address owner_
)
    public
    view
    override
    returns (uint256 redeemableShares_, uint256 resultingAssets_);
```

### \_poolConfigurator

```solidity
function _poolConfigurator() internal view returns (address poolConfigurator_);
```

### \_poolAdmin

```solidity
function _poolAdmin() internal view returns (address poolAdmin_);
```

### \_globals

```solidity
function _globals() internal view returns (address globals_);
```

### \_asset

```solidity
function _asset() internal view returns (address asset_);
```

### \_pool

```solidity
function _pool() internal view returns (address pool_);
```

### \_emitUpdate

```solidity
function _emitUpdate(address account_, uint256 lockedShares_, uint256 exitCycleId_) internal;
```

### \_emitProcess

```solidity
function _emitProcess(address account_, uint256 sharesToRedeem_, uint256 assetsToWithdraw_) internal;
```

### \_revertIfNotPoolAdmin

```solidity
function _revertIfNotPoolAdmin() internal view;
```

### \_revertIfNotPoolConfigurator

```solidity
function _revertIfNotPoolConfigurator() internal view;
```


# WithdrawalManagerStorage

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/WithdrawalManagerStorage.sol)

**Inherits:** [IWithdrawalManagerStorage](/contract-documentation/interfaces/iwithdrawalmanagerstorage)

## State Variables

### latestConfigId

```solidity
uint256 public override latestConfigId;
```

### cycleConfigs

```solidity
mapping(uint256 => WithdrawalManager.CycleConfig) internal cycleConfigs;
```

### exitCycleId

```solidity
mapping(address => uint256) public override exitCycleId;
```

### lockedShares

```solidity
mapping(address => uint256) public override lockedShares;
```

### totalCycleShares

```solidity
mapping(uint256 => uint256) public override totalCycleShares;
```


# abstracts


# Governable

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/abstracts/Governable.sol)

**Inherits:** [IGovernable](/contract-documentation/interfaces/igovernable)

See the documentation in {IGovernable}.

## State Variables

### governor

The address of the governor account or contract.

```solidity
address public override governor;
```

### pendingGovernor

The address of the pending governor account or contract.

```solidity
address public override pendingGovernor;
```

### \_\_\_\_\_\_gap

```solidity
uint256[50] private ______gap;
```

## Functions

### onlyGovernor

Reverts if called by any account other than the governor.

```solidity
modifier onlyGovernor() virtual;
```

### nominateGovernor

Configure the pendingGovernor to newGovnernor parameter.

```solidity
function nominateGovernor(address newGovernor_) external virtual override onlyGovernor;
```

**Parameters**

| Name           | Type      | Description       |
| -------------- | --------- | ----------------- |
| `newGovernor_` | `address` | The new governor. |

### acceptGovernor

The pending governor should accept and become the governor.

*Only the pendingGovernor can trigger this function.*

```solidity
function acceptGovernor() external virtual override;
```

### cancelPendingGovenor

Cancel the nominated pending governor.

*Only the governor can trigger this function*

```solidity
function cancelPendingGovenor() external virtual override onlyGovernor;
```


# interfaces


# IGovernable

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/interfaces/IGovernable.sol)

Contract module that provides a basic access control mechanism, with a governor that can be granted exclusive access to specific functions. The inheriting contract must set the initial governor in the constructor.

## Functions

### governor

The address of the governor account or contract.

```solidity
function governor() external view returns (address governor_);
```

### pendingGovernor

The address of the pending governor account or contract.

```solidity
function pendingGovernor() external view returns (address pendingGovernor_);
```

### nominateGovernor

Configure the pendingGovernor to newGovnernor parameter.

*Does not revert if the pendingGovernor is the same, or there is already a pendingGovernor address.*

```solidity
function nominateGovernor(address newGovernor) external;
```

**Parameters**

| Name          | Type      | Description                                                 |
| ------------- | --------- | ----------------------------------------------------------- |
| `newGovernor` | `address` | The nominated governor, it will become the pendingGovernor. |

### acceptGovernor

The pending governor should accept and become the governor.

*Only the pendingGovernor can trigger this function.*

```solidity
function acceptGovernor() external;
```

### cancelPendingGovenor

Cancel the nominated pending governor.

*Only the governor can trigger this function*

```solidity
function cancelPendingGovenor() external;
```

## Events

### AcceptGovernor

Emitted when the pendingGovernor is accepted.

```solidity
event AcceptGovernor(address indexed oldGovernor, address indexed newGovernor);
```

**Parameters**

| Name          | Type      | Description                      |
| ------------- | --------- | -------------------------------- |
| `oldGovernor` | `address` | The address of the old governor. |
| `newGovernor` | `address` | The address of the new governor. |

### NominateGovernor

Emitted when the pendingGovernor is nominated.

*Configure the pending governor value, not revert if the pending governor is not zero address*

```solidity
event NominateGovernor(address indexed governor, address indexed pendingGovernor);
```

**Parameters**

| Name              | Type      | Description                            |
| ----------------- | --------- | -------------------------------------- |
| `governor`        | `address` | The address of original governor       |
| `pendingGovernor` | `address` | The address of the new pendingGovernor |

### CancelPendingGovernor

Emitted when the pendingGovernor is reset to zero address

*Reset the pending governor to zero address*

```solidity
event CancelPendingGovernor(address indexed oldPendingGovernor);
```

**Parameters**

| Name                 | Type      | Description                              |
| -------------------- | --------- | ---------------------------------------- |
| `oldPendingGovernor` | `address` | The original configured pending governor |


# IIsleGlobals

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/interfaces/IIsleGlobals.sol)

**Inherits:** [IIsleGlobalsEvents](/contract-documentation/interfaces/iisleglobalsevents), [IGovernable](/contract-documentation/interfaces/igovernable)

Interface for the IsleGlobals contract.

This interface provides functions to manage the global configurations of the Isle Protocol.

## Functions

### initialize

Initializes the contract.

```solidity
function initialize(address governor_) external;
```

**Parameters**

| Name        | Type      | Description                  |
| ----------- | --------- | ---------------------------- |
| `governor_` | `address` | The address of the governor. |

### setIsleVault

Sets the address of the Isle vault.

```solidity
function setIsleVault(address isleVault_) external;
```

**Parameters**

| Name         | Type      | Description                    |
| ------------ | --------- | ------------------------------ |
| `isleVault_` | `address` | The address of the Isle vault. |

### setProtocolPaused

Pause or unpause the protocol.

```solidity
function setProtocolPaused(bool protocolPaused_) external;
```

**Parameters**

| Name              | Type   | Description                                            |
| ----------------- | ------ | ------------------------------------------------------ |
| `protocolPaused_` | `bool` | A boolean indicating the status of the protocol pause. |

### setContractPaused

Pause or unpause a specific contract.

```solidity
function setContractPaused(address contract_, bool contractPaused_) external;
```

**Parameters**

| Name              | Type      | Description                                              |
| ----------------- | --------- | -------------------------------------------------------- |
| `contract_`       | `address` | The address of the contract to set the pause status for. |
| `contractPaused_` | `bool`    | A boolean indicating the pause status of the contract.   |

### setFunctionUnpaused

Unpause or ununpause a specific function in a contract.

Normally used to unpause specific functions when a contract is paused.

```solidity
function setFunctionUnpaused(address contract_, bytes4 sig_, bool functionUnpaused_) external;
```

**Parameters**

| Name                | Type      | Description                                            |
| ------------------- | --------- | ------------------------------------------------------ |
| `contract_`         | `address` | The address of the contract.                           |
| `sig_`              | `bytes4`  | The function signature.                                |
| `functionUnpaused_` | `bool`    | A boolean indicating whether the function is unpaused. |

### setProtocolFee

Sets the protocol fee.

```solidity
function setProtocolFee(uint24 protocolFee_) external;
```

**Parameters**

| Name           | Type     | Description                                                                   |
| -------------- | -------- | ----------------------------------------------------------------------------- |
| `protocolFee_` | `uint24` | A uint24 indicating the protocol fee (100.0000% = 1e6 (6 decimal precision)). |

### setValidReceivableAsset

Sets the validity of a receivable asset (should match ERC-721).

```solidity
function setValidReceivableAsset(address receivableAsset_, bool isValid_) external;
```

**Parameters**

| Name               | Type      | Description                                                  |
| ------------------ | --------- | ------------------------------------------------------------ |
| `receivableAsset_` | `address` | The address of the receivable asset to set the validity for. |
| `isValid_`         | `bool`    | A boolean indicating the validity of the receivable asset.   |

### setValidPoolAsset

Sets the validity of the pool asset (should match ERC-20).

```solidity
function setValidPoolAsset(address poolAsset_, bool isValid_) external;
```

**Parameters**

| Name         | Type      | Description                                            |
| ------------ | --------- | ------------------------------------------------------ |
| `poolAsset_` | `address` | The address of the pool asset to set the validity for. |
| `isValid_`   | `bool`    | A boolean indicating the validity of the pool asset.   |

### setValidPoolAdmin

Sets the validity of a pool admin.

```solidity
function setValidPoolAdmin(address poolAdmin_, bool isValid_) external;
```

**Parameters**

| Name         | Type      | Description                                            |
| ------------ | --------- | ------------------------------------------------------ |
| `poolAdmin_` | `address` | The address of the pool admin to set the validity for. |
| `isValid_`   | `bool`    | A boolean indicating the validity of the pool admin.   |

### protocolFee

Returns the protocol fee.

```solidity
function protocolFee() external view returns (uint24 protocolFee_);
```

**Returns**

| Name           | Type     | Description                           |
| -------------- | -------- | ------------------------------------- |
| `protocolFee_` | `uint24` | A uint24 indicating the protocol fee. |

### isleVault

Gets isle vault address.

```solidity
function isleVault() external view returns (address isleVault_);
```

**Returns**

| Name         | Type      | Description                    |
| ------------ | --------- | ------------------------------ |
| `isleVault_` | `address` | The address of the isle vault. |

### protocolPaused

Gets the status of the protocol pause.

```solidity
function protocolPaused() external view returns (bool protocolPaused_);
```

**Returns**

| Name              | Type   | Description                                          |
| ----------------- | ------ | ---------------------------------------------------- |
| `protocolPaused_` | `bool` | A boolean indicating whether the protocol is paused. |

### isContractPaused

Returns the pause status of a specific contract.

```solidity
function isContractPaused(address contract_) external view returns (bool contractPaused_);
```

**Parameters**

| Name        | Type      | Description                           |
| ----------- | --------- | ------------------------------------- |
| `contract_` | `address` | The address of the contract to check. |

**Returns**

| Name              | Type   | Description                                        |
| ----------------- | ------ | -------------------------------------------------- |
| `contractPaused_` | `bool` | A boolean indicating whether a contract is paused. |

### isFunctionUnpaused

Returns the unpause status of a specific function in a contract.

```solidity
function isFunctionUnpaused(address contract_, bytes4 sig_) external view returns (bool functionUnpaused_);
```

**Parameters**

| Name        | Type      | Description                  |
| ----------- | --------- | ---------------------------- |
| `contract_` | `address` | The address of the contract. |
| `sig_`      | `bytes4`  | The function signature.      |

**Returns**

| Name                | Type   | Description                                            |
| ------------------- | ------ | ------------------------------------------------------ |
| `functionUnpaused_` | `bool` | A boolean indicating whether the function is unpaused. |

### isPoolAdmin

Returns if the account is a valid poolAdmin.

```solidity
function isPoolAdmin(address account_) external view returns (bool isPoolAdmin_);
```

**Parameters**

| Name       | Type      | Description                          |
| ---------- | --------- | ------------------------------------ |
| `account_` | `address` | The address of the account to check. |

**Returns**

| Name           | Type   | Description                               |
| -------------- | ------ | ----------------------------------------- |
| `isPoolAdmin_` | `bool` | Whether the account is a valid poolAdmin. |

### isReceivableAsset

Gets the validity of a receivable asset.

```solidity
function isReceivableAsset(address receivableAsset_) external view returns (bool isReceivableAsset_);
```

**Parameters**

| Name               | Type      | Description                                  |
| ------------------ | --------- | -------------------------------------------- |
| `receivableAsset_` | `address` | The address of the receivableAsset to query. |

**Returns**

| Name                 | Type   | Description                                                |
| -------------------- | ------ | ---------------------------------------------------------- |
| `isReceivableAsset_` | `bool` | A boolean indicating the validity of the receivable asset. |

### isPoolAsset

Gets the validity of a pool asset.

```solidity
function isPoolAsset(address poolAsset_) external view returns (bool isPoolAsset_);
```

**Parameters**

| Name         | Type      | Description                            |
| ------------ | --------- | -------------------------------------- |
| `poolAsset_` | `address` | The address of the poolAsset to query. |

**Returns**

| Name           | Type   | Description                                          |
| -------------- | ------ | ---------------------------------------------------- |
| `isPoolAsset_` | `bool` | A boolean indicating the validity of the pool asset. |

### isFunctionPaused

Returns the pause status of a specific function in a contract.

```solidity
function isFunctionPaused(address contract_, bytes4 sig_) external view returns (bool isFunctionPaused_);
```

**Parameters**

| Name        | Type      | Description                  |
| ----------- | --------- | ---------------------------- |
| `contract_` | `address` | The address of the contract. |
| `sig_`      | `bytes4`  | The function signature.      |

**Returns**

| Name                | Type   | Description                                            |
| ------------------- | ------ | ------------------------------------------------------ |
| `isFunctionPaused_` | `bool` | A boolean indicating the pause status of the function. |

### isFunctionPaused

Returns the pause status of a specific function in the caller contract.

```solidity
function isFunctionPaused(bytes4 sig_) external view returns (bool isFunctionPaused_);
```

**Parameters**

| Name   | Type     | Description             |
| ------ | -------- | ----------------------- |
| `sig_` | `bytes4` | The function signature. |

**Returns**

| Name                | Type   | Description                                            |
| ------------------- | ------ | ------------------------------------------------------ |
| `isFunctionPaused_` | `bool` | A boolean indicating the pause status of the function. |


# IIsleGlobalsEvents

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/interfaces/IIsleGlobalsEvents.sol)

## Events

### Initialized

*The IsleGlobals contract has been initialized.*

```solidity
event Initialized(address governor_);
```

**Parameters**

| Name        | Type      | Description                  |
| ----------- | --------- | ---------------------------- |
| `governor_` | `address` | The address of the governor. |

### IsleVaultSet

*The address for the Isle vault has been set.*

```solidity
event IsleVaultSet(address indexed previousVault_, address indexed newVault_);
```

**Parameters**

| Name             | Type      | Description         |
| ---------------- | --------- | ------------------- |
| `previousVault_` | `address` | The previous vault. |
| `newVault_`      | `address` | The new vault.      |

### ProtocolPausedSet

*The protocol pause was set to a new state.*

```solidity
event ProtocolPausedSet(address indexed caller_, bool protocolPaused_);
```

**Parameters**

| Name              | Type      | Description                                                              |
| ----------------- | --------- | ------------------------------------------------------------------------ |
| `caller_`         | `address` | The address of the security admin or governor that performed the action. |
| `protocolPaused_` | `bool`    | The protocol paused state.                                               |

### ContractPausedSet

*Emitted when a contract is paused or unpaused.*

```solidity
event ContractPausedSet(address indexed caller_, address indexed contract_, bool contractPaused_);
```

**Parameters**

| Name              | Type      | Description                                           |
| ----------------- | --------- | ----------------------------------------------------- |
| `caller_`         | `address` | The address that performed the action.                |
| `contract_`       | `address` | The address of the contract being paused or unpaused. |
| `contractPaused_` | `bool`    | The new paused state of the contract.                 |

### FunctionUnpausedSet

*Emitted when a function is unpaused or paused.*

```solidity
event FunctionUnpausedSet(
    address indexed caller_, address indexed contract_, bytes4 indexed sig_, bool functionUnpaused_
);
```

**Parameters**

| Name                | Type      | Description                             |
| ------------------- | --------- | --------------------------------------- |
| `caller_`           | `address` | The address that performed the action.  |
| `contract_`         | `address` | The address of the contract.            |
| `sig_`              | `bytes4`  | The function signature.                 |
| `functionUnpaused_` | `bool`    | The new unpaused state of the function. |

### ProtocolFeeSet

*Emitted when the protocol fee has been set.*

```solidity
event ProtocolFeeSet(uint24 protocolFee_);
```

**Parameters**

| Name           | Type     | Description                 |
| -------------- | -------- | --------------------------- |
| `protocolFee_` | `uint24` | The new protocol fee value. |

### ValidReceivableAssetSet

*A valid asset was set.*

```solidity
event ValidReceivableAssetSet(address indexed receivableAsset_, bool isValid_);
```

**Parameters**

| Name               | Type      | Description                           |
| ------------------ | --------- | ------------------------------------- |
| `receivableAsset_` | `address` | The address of the receivable asset.  |
| `isValid_`         | `bool`    | The validity of the receivable asset. |

### ValidPoolAssetSet

*A valid asset was set.*

```solidity
event ValidPoolAssetSet(address indexed poolAsset_, bool isValid_);
```

**Parameters**

| Name         | Type      | Description                |
| ------------ | --------- | -------------------------- |
| `poolAsset_` | `address` | The address of the asset.  |
| `isValid_`   | `bool`    | The validity of the asset. |

### ValidPoolAdminSet

*Emitted when a valid pool admin is set.*

```solidity
event ValidPoolAdminSet(address indexed poolAdmin_, bool isValid_);
```

**Parameters**

| Name         | Type      | Description                     |
| ------------ | --------- | ------------------------------- |
| `poolAdmin_` | `address` | The address of the pool admin.  |
| `isValid_`   | `bool`    | The validity of the pool admin. |


# ILoanManager

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/interfaces/ILoanManager.sol)

**Inherits:** [ILoanManagerEvents](/contract-documentation/interfaces/iloanmanagerevents), [ILoanManagerStorage](/contract-documentation/interfaces/iloanmanagerstorage)

Creates and manages loans.

## Functions

### initialize

Initializes the loan manager.

```solidity
function initialize(address asset_) external;
```

**Parameters**

| Name     | Type      | Description                                 |
| -------- | --------- | ------------------------------------------- |
| `asset_` | `address` | The address of the asset used for the pool. |

### getLoanInfo

Gets the loan info.

```solidity
function getLoanInfo(uint16 loanId_) external view returns (Loan.Info memory loan_);
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |

**Returns**

| Name    | Type        | Description                                |
| ------- | ----------- | ------------------------------------------ |
| `loan_` | `Loan.Info` | Struct that contains the info of the loan. |

### accruedInterest

Gets the amount of interest up until this point in time.

```solidity
function accruedInterest() external view returns (uint256 accruedInterest_);
```

**Returns**

| Name               | Type      | Description                                                 |
| ------------------ | --------- | ----------------------------------------------------------- |
| `accruedInterest_` | `uint256` | The amount of accrued interest up until this point in time. |

### assetsUnderManagement

Gets the total assets under management.

```solidity
function assetsUnderManagement() external view returns (uint256 assetsUnderManagement_);
```

**Returns**

| Name                     | Type      | Description                                 |
| ------------------------ | --------- | ------------------------------------------- |
| `assetsUnderManagement_` | `uint256` | The total value of assets under management. |

### getLoanPaymentDetailedBreakdown

Gets the detailed payment breakdown of a loan up until this point in time.

```solidity
function getLoanPaymentDetailedBreakdown(
    uint16 loanId_
)
    external
    view
    returns (uint256 principal_, uint256[2] memory interest_);
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |

**Returns**

| Name         | Type         | Description                                                                                                     |
| ------------ | ------------ | --------------------------------------------------------------------------------------------------------------- |
| `principal_` | `uint256`    | The principal due for the loan.                                                                                 |
| `interest_`  | `uint256[2]` | <p>Interest Parameter:<br>\[0]: The interest due for the loan.<br>\[1]: The late interest due for the loan.</p> |

### getLoanPaymentBreakdown

Gets the payment breakdown of a loan up until this point in time.

```solidity
function getLoanPaymentBreakdown(uint16 loanId_) external view returns (uint256 principal_, uint256 interest_);
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |

**Returns**

| Name         | Type      | Description                          |
| ------------ | --------- | ------------------------------------ |
| `principal_` | `uint256` | The principal due for the loan.      |
| `interest_`  | `uint256` | The total interest due for the loan. |

### updateAccounting

Manually updates the accounting state of the pool.

```solidity
function updateAccounting() external;
```

### fundLoan

Used by the pool admin to fund the loan requested by the buyer.

```solidity
function fundLoan(uint16 loanId_) external;
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |

### impairLoan

Impairs the loan.

```solidity
function impairLoan(uint16 loanId_) external;
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |

### removeLoanImpairment

Removes the impairment on the loan.

```solidity
function removeLoanImpairment(uint16 loanId_) external;
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |

### triggerDefault

Triggers the default of a loan.

```solidity
function triggerDefault(uint16 loanId_) external returns (uint256 remainingLosses_, uint256 protocolFees_);
```

**Parameters**

| Name      | Type     | Description                           |
| --------- | -------- | ------------------------------------- |
| `loanId_` | `uint16` | The id of the loan that is triggered. |

**Returns**

| Name               | Type      | Description                     |
| ------------------ | --------- | ------------------------------- |
| `remainingLosses_` | `uint256` | The amount of remaining losses. |
| `protocolFees_`    | `uint256` | The amount of protocol fees.    |

### requestLoan

Used by buyer to request a loan from the pool with the following terms.

```solidity
function requestLoan(
    address receivableAsset_,
    uint256 receivablesTokenId_,
    uint256 gracePeriod_,
    uint256 principalRequested_,
    uint256[2] memory rates_
)
    external
    returns (uint16 loanId_);
```

**Parameters**

| Name                  | Type         | Description                                                                       |
| --------------------- | ------------ | --------------------------------------------------------------------------------- |
| `receivableAsset_`    | `address`    | The address of the receivableAsset                                                |
| `receivablesTokenId_` | `uint256`    | Token ID of the receivable that would be used as collateral.                      |
| `gracePeriod_`        | `uint256`    | Grace period of the loan.                                                         |
| `principalRequested_` | `uint256`    | Amount of principal requested by the buyer.                                       |
| `rates_`              | `uint256[2]` | <p>Rates parameters:<br>\[0]: interestRate.<br>\[1]: lateInterestPremiumRate.</p> |

**Returns**

| Name      | Type     | Description                     |
| --------- | -------- | ------------------------------- |
| `loanId_` | `uint16` | Id of the loan that is created. |

### repayLoan

Repays the loan (note that the loan can be repaid early but not partially).

```solidity
function repayLoan(uint16 loanId_) external returns (uint256 principal_, uint256 interest_);
```

**Parameters**

| Name      | Type     | Description              |
| --------- | -------- | ------------------------ |
| `loanId_` | `uint16` | Id of the loan to repay. |

**Returns**

| Name         | Type      | Description              |
| ------------ | --------- | ------------------------ |
| `principal_` | `uint256` | Principal amount repaid. |
| `interest_`  | `uint256` | Interest amount repaid.  |

### withdrawFunds

Used by sellers to withdraw funds from a loan.

```solidity
function withdrawFunds(uint16 loanId_, address destination_) external;
```

**Parameters**

| Name           | Type      | Description                            |
| -------------- | --------- | -------------------------------------- |
| `loanId_`      | `uint16`  | Id of the loan to withdraw funds from. |
| `destination_` | `address` | The destination address for the funds. |


# ILoanManagerEvents

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/interfaces/ILoanManagerEvents.sol)

## Events

### Initialized

Emitted when the loan manager is initialized.

```solidity
event Initialized(address poolAddressesProvider_, address asset_);
```

**Parameters**

| Name                     | Type      | Description                                 |
| ------------------------ | --------- | ------------------------------------------- |
| `poolAddressesProvider_` | `address` | The address of the pool addresses provider. |
| `asset_`                 | `address` | The address of the asset set.               |

### LoanRequested

Emitted when a loan is requested.

```solidity
event LoanRequested(uint16 indexed loanId_);
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |

### LoanRepaid

Emitted when a loan is repaid.

```solidity
event LoanRepaid(uint16 indexed loanId_, uint256 principal_, uint256 interest_);
```

**Parameters**

| Name         | Type      | Description                 |
| ------------ | --------- | --------------------------- |
| `loanId_`    | `uint16`  | The id of the loan.         |
| `principal_` | `uint256` | The total principal repaid. |
| `interest_`  | `uint256` | The total interest repaid.  |

### FundsWithdrawn

Emitted when the funds of a loan are withdrawn.

```solidity
event FundsWithdrawn(uint16 indexed loanId_, uint256 amount_);
```

**Parameters**

| Name      | Type      | Description                        |
| --------- | --------- | ---------------------------------- |
| `loanId_` | `uint16`  | The id of the loan.                |
| `amount_` | `uint256` | The amount of principal withdrawn. |

### UnrealizedLossesUpdated

Emitted when unrealized losses is updated.

```solidity
event UnrealizedLossesUpdated(uint128 unrealizedLosses_);
```

**Parameters**

| Name                | Type      | Description                    |
| ------------------- | --------- | ------------------------------ |
| `unrealizedLosses_` | `uint128` | The updated unrealized losses. |

### PrincipalOutUpdated

Emitted when the principal out is updated.

```solidity
event PrincipalOutUpdated(uint128 principalOut_);
```

**Parameters**

| Name            | Type      | Description                        |
| --------------- | --------- | ---------------------------------- |
| `principalOut_` | `uint128` | The updated principal outstanding. |

### IssuanceParamsUpdated

Emitted when the issuance params are updated.

```solidity
event IssuanceParamsUpdated(uint48 indexed domainEnd_, uint256 issuanceRate_, uint112 accountedInterest_);
```

**Parameters**

| Name                 | Type      | Description                     |
| -------------------- | --------- | ------------------------------- |
| `domainEnd_`         | `uint48`  | The updated domain end.         |
| `issuanceRate_`      | `uint256` | The updated issuance rate.      |
| `accountedInterest_` | `uint112` | The updated accounted interest. |

### PaymentAdded

Emitted when a new payment is added to the payment linked list.

```solidity
event PaymentAdded(
    uint16 indexed loanId_,
    uint256 indexed paymentId_,
    uint256 protocolFee_,
    uint256 adminFee_,
    uint256 startDate_,
    uint256 dueDate_,
    uint256 newRate_
);
```

**Parameters**

| Name           | Type      | Description                                       |
| -------------- | --------- | ------------------------------------------------- |
| `loanId_`      | `uint16`  | The new loan id that the payment id is linked to. |
| `paymentId_`   | `uint256` | The payment id of the payment.                    |
| `protocolFee_` | `uint256` | The protocol fee rate of the payment.             |
| `adminFee_`    | `uint256` | The admin fee rate of the payment.                |
| `startDate_`   | `uint256` | The start date of the payment.                    |
| `dueDate_`     | `uint256` | The due date of the payment.                      |
| `newRate_`     | `uint256` | The new issuance rate of the payment.             |

### PaymentRemoved

Emitted when a payment is removed from the payment list.

```solidity
event PaymentRemoved(uint16 indexed loanId_, uint256 indexed paymentId_);
```

**Parameters**

| Name         | Type      | Description                                             |
| ------------ | --------- | ------------------------------------------------------- |
| `loanId_`    | `uint16`  | The id of the loan that the payment is associated with. |
| `paymentId_` | `uint256` | The payment id of the payment.                          |

### FeesPaid

Emitted when fees are paid to the admin and protocol.

```solidity
event FeesPaid(uint16 indexed loanId_, uint256 adminFee_, uint256 protocolFee_);
```

**Parameters**

| Name           | Type      | Description                      |
| -------------- | --------- | -------------------------------- |
| `loanId_`      | `uint16`  | The id of the loan.              |
| `adminFee_`    | `uint256` | The amount of admin fee paid.    |
| `protocolFee_` | `uint256` | The amount of protocol fee paid. |

### FundsDistributed

Emitted when the funds are distributed back to the pool, pool admin, and protocol vault.

```solidity
event FundsDistributed(uint16 indexed loanId_, uint256 principal_, uint256 netInterest_);
```

**Parameters**

| Name           | Type      | Description                             |
| -------------- | --------- | --------------------------------------- |
| `loanId_`      | `uint16`  | The id of the loan.                     |
| `principal_`   | `uint256` | The amount of principal distributed.    |
| `netInterest_` | `uint256` | The amount of net interest distributed. |

### LoanImpaired

Emitted when the loan is impaired.

```solidity
event LoanImpaired(uint16 indexed loanId_, uint256 newDueDate_);
```

**Parameters**

| Name          | Type      | Description                            |
| ------------- | --------- | -------------------------------------- |
| `loanId_`     | `uint16`  | The id of the loan.                    |
| `newDueDate_` | `uint256` | The new due date of the impaired loan. |

### ImpairmentRemoved

Emitted when the impairment on the loan is removed.

```solidity
event ImpairmentRemoved(uint16 indexed loanId_, uint256 originalPaymentDueDate_);
```

**Parameters**

| Name                      | Type      | Description                                |
| ------------------------- | --------- | ------------------------------------------ |
| `loanId_`                 | `uint16`  | The id of the loan.                        |
| `originalPaymentDueDate_` | `uint256` | The original payment due date of the loan. |

### DefaultTriggered

Emitted when the loan is defaulted.

```solidity
event DefaultTriggered(uint16 indexed loanId_);
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The id of the loan. |


# ILoanManagerStorage

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/interfaces/ILoanManagerStorage.sol)

## Functions

### asset

Gets the asset used for the protocol.

```solidity
function asset() external view returns (address asset_);
```

**Returns**

| Name     | Type      | Description               |
| -------- | --------- | ------------------------- |
| `asset_` | `address` | The address of the asset. |

### unrealizedLosses

Gets the unrealized losses.

```solidity
function unrealizedLosses() external view returns (uint128);
```

**Returns**

| Name     | Type      | Description                               |
| -------- | --------- | ----------------------------------------- |
| `<none>` | `uint128` | unrealizedLosses\_ The unrealized losses. |

### loanCounter

Gets the total number of loans.

```solidity
function loanCounter() external view returns (uint16);
```

**Returns**

| Name     | Type     | Description                              |
| -------- | -------- | ---------------------------------------- |
| `<none>` | `uint16` | loanCounter\_ The total number of loans. |

### paymentCounter

Gets the total number of payments.

```solidity
function paymentCounter() external view returns (uint24);
```

**Returns**

| Name     | Type     | Description                                    |
| -------- | -------- | ---------------------------------------------- |
| `<none>` | `uint24` | paymentCounter\_ The total number of payments. |

### paymentWithEarliestDueDate

Gets the payment ID with the earliest due date.

```solidity
function paymentWithEarliestDueDate() external view returns (uint24);
```

**Returns**

| Name     | Type     | Description                                                             |
| -------- | -------- | ----------------------------------------------------------------------- |
| `<none>` | `uint24` | paymentWithEarliestDueDate\_ The payment ID with the earliest due date. |

### domainStart

Gets the start date of the domain.

```solidity
function domainStart() external view returns (uint48);
```

**Returns**

| Name     | Type     | Description                                 |
| -------- | -------- | ------------------------------------------- |
| `<none>` | `uint48` | domainStart\_ The start date of the domain. |

### domainEnd

Gets the end date of the domain.

```solidity
function domainEnd() external view returns (uint48);
```

**Returns**

| Name     | Type     | Description                             |
| -------- | -------- | --------------------------------------- |
| `<none>` | `uint48` | domainEnd\_ The end date of the domain. |

### accountedInterest

Gets the accounted interest.

```solidity
function accountedInterest() external view returns (uint112);
```

**Returns**

| Name     | Type      | Description                                 |
| -------- | --------- | ------------------------------------------- |
| `<none>` | `uint112` | accountedInterest\_ The accounted interest. |

### principalOut

Gets the total principal amount lent out.

```solidity
function principalOut() external view returns (uint128);
```

**Returns**

| Name     | Type      | Description                                         |
| -------- | --------- | --------------------------------------------------- |
| `<none>` | `uint128` | principalOut\_ The total principal amount lent out. |

### issuanceRate

Gets the issuance rate.

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

**Returns**

| Name     | Type      | Description                       |
| -------- | --------- | --------------------------------- |
| `<none>` | `uint256` | issuanceRate\_ The issuance rate. |

### paymentIdOf

Gets the payment ID of the given loan.

```solidity
function paymentIdOf(uint16 loanId_) external view returns (uint24);
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `loanId_` | `uint16` | The ID of the loan. |

**Returns**

| Name     | Type     | Description                             |
| -------- | -------- | --------------------------------------- |
| `<none>` | `uint24` | paymentId\_ The payment ID of the loan. |


# IPool

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/interfaces/IPool.sol)

**Inherits:** IERC4626

## Functions

### configurator

Returns the address of the pool configurator.

```solidity
function configurator() external view returns (address configurator_);
```

**Returns**

| Name            | Type      | Description                           |
| --------------- | --------- | ------------------------------------- |
| `configurator_` | `address` | The address of the pool configurator. |

### depositWithPermit

Deposits assets into the pool with the permit signature.

```solidity
function depositWithPermit(
    uint256 assets,
    address receiver,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
)
    external
    returns (uint256 shares_);
```

**Parameters**

| Name       | Type      | Description                           |
| ---------- | --------- | ------------------------------------- |
| `assets`   | `uint256` | The amount of assets to deposit.      |
| `receiver` | `address` | The address of the receiver.          |
| `deadline` | `uint256` | The deadline of the permit signature. |
| `v`        | `uint8`   | The v of the permit signature.        |
| `r`        | `bytes32` | The r of the permit signature.        |
| `s`        | `bytes32` | The s of the permit signature.        |

**Returns**

| Name      | Type      | Description                                |
| --------- | --------- | ------------------------------------------ |
| `shares_` | `uint256` | The corresponding amount of shares minted. |

### mintWithPermit

Mints shares from the pool with the permit signature.

```solidity
function mintWithPermit(
    uint256 shares,
    address receiver,
    uint256 maxAssets,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
)
    external
    returns (uint256 assets_);
```

**Parameters**

| Name        | Type      | Description                              |
| ----------- | --------- | ---------------------------------------- |
| `shares`    | `uint256` | The amount of shares to mint.            |
| `receiver`  | `address` | The address of the receiver.             |
| `maxAssets` | `uint256` | The maximum amount of assets to deposit. |
| `deadline`  | `uint256` | The deadline of the permit signature.    |
| `v`         | `uint8`   | The v of the permit signature.           |
| `r`         | `bytes32` | The r of the permit signature.           |
| `s`         | `bytes32` | The s of the permit signature.           |

**Returns**

| Name      | Type      | Description                                   |
| --------- | --------- | --------------------------------------------- |
| `assets_` | `uint256` | The corresponding amount of assets deposited. |

### removeShares

Remove shares from the pool.

```solidity
function removeShares(uint256 shares_, address owner_) external returns (uint256 sharesReturned_);
```

**Parameters**

| Name      | Type      | Description                     |
| --------- | --------- | ------------------------------- |
| `shares_` | `uint256` | The amount of shares to remove. |
| `owner_`  | `address` | The owner of the shares.        |

**Returns**

| Name              | Type      | Description                    |
| ----------------- | --------- | ------------------------------ |
| `sharesReturned_` | `uint256` | The amount of shares returned. |

### requestRedeem

Request the redemption of shares from the pool.

```solidity
function requestRedeem(uint256 shares_, address owner_) external;
```

**Parameters**

| Name      | Type      | Description                     |
| --------- | --------- | ------------------------------- |
| `shares_` | `uint256` | The amount of shares to redeem. |
| `owner_`  | `address` | The owner of the shares.        |

### balanceOfAssets

Returns of the balance of the account.

```solidity
function balanceOfAssets(address account_) external view returns (uint256 assets_);
```

**Parameters**

| Name       | Type      | Description                 |
| ---------- | --------- | --------------------------- |
| `account_` | `address` | The address of the account. |

**Returns**

| Name      | Type      | Description           |
| --------- | --------- | --------------------- |
| `assets_` | `uint256` | The amount of assets. |

### convertToExitAssets

Returns the amount of assets that can be withdrawn for the amount of shares.

```solidity
function convertToExitAssets(uint256 shares_) external view returns (uint256 assets_);
```

**Parameters**

| Name      | Type      | Description           |
| --------- | --------- | --------------------- |
| `shares_` | `uint256` | The amount of shares. |

**Returns**

| Name      | Type      | Description           |
| --------- | --------- | --------------------- |
| `assets_` | `uint256` | The amount of assets. |

### convertToExitShares

Returns the amount of shares that will be burned to withdraw the amount of assets.

```solidity
function convertToExitShares(uint256 assets_) external view returns (uint256 shares_);
```

**Parameters**

| Name      | Type      | Description                       |
| --------- | --------- | --------------------------------- |
| `assets_` | `uint256` | The amount of assets to withdraw. |

**Returns**

| Name      | Type      | Description           |
| --------- | --------- | --------------------- |
| `shares_` | `uint256` | The amount of shares. |

### unrealizedLosses

Returns the unrealized losses of the pool.

```solidity
function unrealizedLosses() external view returns (uint256 unrealizedLosses_);
```

**Returns**

| Name                | Type      | Description            |
| ------------------- | --------- | ---------------------- |
| `unrealizedLosses_` | `uint256` | The unrealized losses. |


# IPoolAddressesProvider

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/interfaces/IPoolAddressesProvider.sol)

Defines the basic interface for a Pool Addresses Provider.

## Functions

### getMarketId

Retrieves the identifier of the Isle market associated with this contract.

```solidity
function getMarketId() external view returns (string memory);
```

**Returns**

| Name     | Type     | Description                   |
| -------- | -------- | ----------------------------- |
| `<none>` | `string` | The identifier of the market. |

### setMarketId

Links a new market identifier to this PoolAddressesProvider.

*Useful for creating a registry of PoolAddressesProviders for multiple Isle markets.*

```solidity
function setMarketId(string calldata newMarketId) external;
```

**Parameters**

| Name          | Type     | Description                |
| ------------- | -------- | -------------------------- |
| `newMarketId` | `string` | The new market identifier. |

### getAddress

Fetches an address associated with a given identifier.

*Can return either a direct contract address or a proxy address.*

*Returns address(0) if no address is registered with the given identifier.*

```solidity
function getAddress(bytes32 id) external view returns (address);
```

**Parameters**

| Name | Type      | Description                                 |
| ---- | --------- | ------------------------------------------- |
| `id` | `bytes32` | The identifier of the contract to retrieve. |

**Returns**

| Name     | Type      | Description                                           |
| -------- | --------- | ----------------------------------------------------- |
| `<none>` | `address` | The address associated with the specified identifier. |

### setAddressAsProxy

Updates or initializes a proxy for a given identifier with a new implementation address.

*Use with caution for identifiers without dedicated setter functions to prevent unintended effects.*

*Only use for identifiers POOL\_CONFIGURATOR, LOAN\_MANAGER, WITHDRAWAL\_MANAGER, or ISLE\_GLOBALS.*

```solidity
function setAddressAsProxy(bytes32 id, address newImplementationAddress, bytes calldata params) external;
```

**Parameters**

| Name                       | Type      | Description                                           |
| -------------------------- | --------- | ----------------------------------------------------- |
| `id`                       | `bytes32` | The identifier of the contract to update.             |
| `newImplementationAddress` | `address` | The address of the new implementation.                |
| `params`                   | `bytes`   | The initialization parameters for the proxy contract. |

### setAddress

Directly sets a new address for a given identifier, replacing the current address.

*Use with caution as this will overwrite the existing address without any checks.*

*Only use for identifiers POOL\_CONFIGURATOR, LOAN\_MANAGER, WITHDRAWAL\_MANAGER, or ISLE\_GLOBALS.*

```solidity
function setAddress(bytes32 id, address newAddress) external;
```

**Parameters**

| Name         | Type      | Description                                       |
| ------------ | --------- | ------------------------------------------------- |
| `id`         | `bytes32` | The identifier for which to set the address.      |
| `newAddress` | `address` | The new address to associate with the identifier. |

### getPoolConfigurator

Retrieves the address of the PoolConfigurator proxy.

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

**Returns**

| Name     | Type      | Description                                |
| -------- | --------- | ------------------------------------------ |
| `<none>` | `address` | The address of the PoolConfigurator proxy. |

### setPoolConfiguratorImpl

Sets or initializes the PoolConfigurator proxy with a new implementation.

```solidity
function setPoolConfiguratorImpl(address newPoolConfiguratorImpl, bytes calldata params) external;
```

**Parameters**

| Name                      | Type      | Description                                             |
| ------------------------- | --------- | ------------------------------------------------------- |
| `newPoolConfiguratorImpl` | `address` | The address of the new PoolConfigurator implementation. |
| `params`                  | `bytes`   | The initialization parameters for the PoolConfigurator. |

### getLoanManager

Retrieves the address of the LoanManager proxy.

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

**Returns**

| Name     | Type      | Description                           |
| -------- | --------- | ------------------------------------- |
| `<none>` | `address` | The address of the LoanManager proxy. |

### setLoanManagerImpl

Sets or initializes the LoanManager proxy with a new implementation.

```solidity
function setLoanManagerImpl(address newLoanManagerImpl, bytes calldata params) external;
```

**Parameters**

| Name                 | Type      | Description                                        |
| -------------------- | --------- | -------------------------------------------------- |
| `newLoanManagerImpl` | `address` | The address of the new LoanManager implementation. |
| `params`             | `bytes`   | The initialization parameters for the LoanManager. |

### getWithdrawalManager

Retrieves the address of the WithdrawalManager proxy.

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

**Returns**

| Name     | Type      | Description                                 |
| -------- | --------- | ------------------------------------------- |
| `<none>` | `address` | The address of the WithdrawalManager proxy. |

### setWithdrawalManagerImpl

Sets or initializes the WithdrawalManager proxy with a new implementation.

```solidity
function setWithdrawalManagerImpl(address newWithdrawalManagerImpl, bytes calldata params) external;
```

**Parameters**

| Name                       | Type      | Description                                              |
| -------------------------- | --------- | -------------------------------------------------------- |
| `newWithdrawalManagerImpl` | `address` | The address of the new WithdrawalManager implementation. |
| `params`                   | `bytes`   | The initialization parameters for the WithdrawalManager. |

### getIsleGlobals

Retrieves the address of IsleGlobals.

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

**Returns**

| Name     | Type      | Description                 |
| -------- | --------- | --------------------------- |
| `<none>` | `address` | The address of IsleGlobals. |

### setIsleGlobals

Sets a new address for IsleGlobals, replacing the current address in the registry.

```solidity
function setIsleGlobals(address newIsleGlobals) external;
```

**Parameters**

| Name             | Type      | Description                      |
| ---------------- | --------- | -------------------------------- |
| `newIsleGlobals` | `address` | The new address for IsleGlobals. |

## Events

### MarketIdSet

*Emitted when the market identifier is changed.*

```solidity
event MarketIdSet(string indexed oldMarketId, string indexed newMarketId);
```

**Parameters**

| Name          | Type     | Description                            |
| ------------- | -------- | -------------------------------------- |
| `oldMarketId` | `string` | The previous identifier of the market. |
| `newMarketId` | `string` | The new identifier of the market.      |

### PoolConfiguratorUpdated

*Emitted when the address of the PoolConfigurator is updated.*

```solidity
event PoolConfiguratorUpdated(address indexed oldAddress, address indexed newAddress);
```

**Parameters**

| Name         | Type      | Description                                  |
| ------------ | --------- | -------------------------------------------- |
| `oldAddress` | `address` | The former address of the PoolConfigurator.  |
| `newAddress` | `address` | The updated address of the PoolConfigurator. |

### LoanManagerUpdated

*Emitted when the address of the LoanManager is updated.*

```solidity
event LoanManagerUpdated(address indexed oldAddress, address indexed newAddress);
```

**Parameters**

| Name         | Type      | Description                             |
| ------------ | --------- | --------------------------------------- |
| `oldAddress` | `address` | The former address of the LoanManager.  |
| `newAddress` | `address` | The updated address of the LoanManager. |

### WithdrawalManagerUpdated

*Emitted when the address of the WithdrawalManager is updated.*

```solidity
event WithdrawalManagerUpdated(address indexed oldAddress, address indexed newAddress);
```

**Parameters**

| Name         | Type      | Description                                   |
| ------------ | --------- | --------------------------------------------- |
| `oldAddress` | `address` | The former address of the WithdrawalManager.  |
| `newAddress` | `address` | The updated address of the WithdrawalManager. |

### IsleGlobalsUpdated

*Emitted when the address of IsleGlobals is updated.*

```solidity
event IsleGlobalsUpdated(address indexed oldAddress, address indexed newAddress);
```

**Parameters**

| Name         | Type      | Description                         |
| ------------ | --------- | ----------------------------------- |
| `oldAddress` | `address` | The former address of IsleGlobals.  |
| `newAddress` | `address` | The updated address of IsleGlobals. |

### ProxyCreated

*Emitted when a new proxy is created for a contract.*

```solidity
event ProxyCreated(bytes32 indexed id, address indexed proxyAddress, address indexed implementationAddress);
```

**Parameters**

| Name                    | Type      | Description                                                     |
| ----------------------- | --------- | --------------------------------------------------------------- |
| `id`                    | `bytes32` | The identifier of the contract.                                 |
| `proxyAddress`          | `address` | The address of the newly created proxy contract.                |
| `implementationAddress` | `address` | The address of the implementation contract linked to the proxy. |

### AddressSet

*Emitted when a new address is registered for a contract without a proxy.*

```solidity
event AddressSet(bytes32 indexed id, address indexed oldAddress, address indexed newAddress);
```

**Parameters**

| Name         | Type      | Description                                   |
| ------------ | --------- | --------------------------------------------- |
| `id`         | `bytes32` | The identifier of the contract.               |
| `oldAddress` | `address` | The former address of the contract.           |
| `newAddress` | `address` | The newly registered address of the contract. |

### AddressSetAsProxy

*Emitted when the implementation of a registered proxy is updated.*

```solidity
event AddressSetAsProxy(
    bytes32 indexed id,
    address indexed proxyAddress,
    address oldImplementationAddress,
    address indexed newImplementationAddress
);
```

**Parameters**

| Name                       | Type      | Description                                         |
| -------------------------- | --------- | --------------------------------------------------- |
| `id`                       | `bytes32` | The identifier of the contract.                     |
| `proxyAddress`             | `address` | The address of the proxy contract.                  |
| `oldImplementationAddress` | `address` | The former address of the implementation contract.  |
| `newImplementationAddress` | `address` | The updated address of the implementation contract. |


# IPoolConfigurator

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/interfaces/IPoolConfigurator.sol)

**Inherits:** [IPoolConfiguratorStorage](https://github.com/isle-labs/isle-docs/blob/main/docs/contracts/interfaces/IPoolConfiguratorStorage.md), [IPoolConfiguratorEvents](https://github.com/isle-labs/isle-docs/blob/main/docs/contracts/interfaces/IPoolConfiguratorEvents.md)

## Functions

### initialize

The initializer function for the pool configurator (must be called directly after deployment).

```solidity
function initialize(
    IPoolAddressesProvider provider_,
    address poolAdmin_,
    address asset_,
    string memory name_,
    string memory symbol_
)
    external;
```

**Parameters**

| Name         | Type                     | Description                                 |
| ------------ | ------------------------ | ------------------------------------------- |
| `provider_`  | `IPoolAddressesProvider` | The address of the pool addresses provider. |
| `poolAdmin_` | `address`                | The address of the pool admin.              |
| `asset_`     | `address`                | The ERC20 asset used in the lending pool.   |
| `name_`      | `string`                 | The name of the pool token.                 |
| `symbol_`    | `string`                 | The symbol of the pool token.               |

### setMaxCoverLiquidation

Sets the max cover liquidation for the pool configurator.

```solidity
function setMaxCoverLiquidation(uint24 maxCoverLiquidation_) external;
```

**Parameters**

| Name                   | Type     | Description                                                   |
| ---------------------- | -------- | ------------------------------------------------------------- |
| `maxCoverLiquidation_` | `uint24` | The max cover liquidation as a percentage for the pool admin. |

### setMinCover

Sets the min cover required for the pool configurator.

```solidity
function setMinCover(uint104 minCover_) external;
```

**Parameters**

| Name        | Type      | Description                                |
| ----------- | --------- | ------------------------------------------ |
| `minCover_` | `uint104` | The min cover required for the pool admin. |

### setPoolLimit

Sets the pool limit for the pool configurator.

```solidity
function setPoolLimit(uint104 poolLimit_) external;
```

**Parameters**

| Name         | Type      | Description                 |
| ------------ | --------- | --------------------------- |
| `poolLimit_` | `uint104` | The size limit of the pool. |

### transferAdmin

Transfers to a new admin.

```solidity
function transferAdmin(address newAdmin_) external;
```

**Parameters**

| Name        | Type      | Description                   |
| ----------- | --------- | ----------------------------- |
| `newAdmin_` | `address` | The address of the new admin. |

### setOpenToPublic

Sets whether the pool is open to the public (permissioned or permissionless).

```solidity
function setOpenToPublic(bool isOpenToPublic_) external;
```

**Parameters**

| Name              | Type   | Description                             |
| ----------------- | ------ | --------------------------------------- |
| `isOpenToPublic_` | `bool` | Whether the pool is open to the public. |

### setAdminFee

Sets the admin fee rate that would be applied to the pool.

```solidity
function setAdminFee(uint24 adminFee_) external;
```

**Parameters**

| Name        | Type     | Description        |
| ----------- | -------- | ------------------ |
| `adminFee_` | `uint24` | The new admin fee. |

### setBuyer

Assigns a buyer to the pool.

```solidity
function setBuyer(address buyer_) external;
```

**Parameters**

| Name     | Type      | Description                             |
| -------- | --------- | --------------------------------------- |
| `buyer_` | `address` | The address of the buyer for this pool. |

### setValidSeller

Sets the status of a seller.

```solidity
function setValidSeller(address seller_, bool isValid_) external;
```

**Parameters**

| Name       | Type      | Description                  |
| ---------- | --------- | ---------------------------- |
| `seller_`  | `address` | The address of the seller.   |
| `isValid_` | `bool`    | Whether the seller is valid. |

### setValidLender

Sets the status of a lender (liquidity providers).

```solidity
function setValidLender(address lender_, bool isValid_) external;
```

**Parameters**

| Name       | Type      | Description                  |
| ---------- | --------- | ---------------------------- |
| `lender_`  | `address` | The address of the lender.   |
| `isValid_` | `bool`    | Whether the lender is valid. |

### requestFunds

Request funds from the pool and fund the loan manager.

```solidity
function requestFunds(uint256 principal_) external;
```

**Parameters**

| Name         | Type      | Description                         |
| ------------ | --------- | ----------------------------------- |
| `principal_` | `uint256` | The amount of principal to request. |

### triggerDefault

Triggers the defaults of a specific loan in the loan manager.

```solidity
function triggerDefault(uint16 loanId_) external;
```

**Parameters**

| Name      | Type     | Description                   |
| --------- | -------- | ----------------------------- |
| `loanId_` | `uint16` | The ID of the defaulted loan. |

### requestRedeem

Requests to redeem shares.

```solidity
function requestRedeem(uint256 shares_, address owner_) external;
```

**Parameters**

| Name      | Type      | Description                     |
| --------- | --------- | ------------------------------- |
| `shares_` | `uint256` | The amount of shares to redeem. |
| `owner_`  | `address` | The owner of the shares.        |

### processRedeem

Processes the redemption of shares for a specific owner.

```solidity
function processRedeem(
    uint256 shares_,
    address owner_,
    address sender_
)
    external
    returns (uint256 redeemableShares_, uint256 resultingAssets_);
```

**Parameters**

| Name      | Type      | Description                        |
| --------- | --------- | ---------------------------------- |
| `shares_` | `uint256` | The amount of shares to redeem.    |
| `owner_`  | `address` | The owner of the shares.           |
| `sender_` | `address` | The sender of the process request. |

**Returns**

| Name                | Type      | Description                                                    |
| ------------------- | --------- | -------------------------------------------------------------- |
| `redeemableShares_` | `uint256` | The amount of redeemable shares.                               |
| `resultingAssets_`  | `uint256` | The corresponding amount of assets with the redeemable shares. |

### removeShares

Removes shares from its withdrawal request.

```solidity
function removeShares(uint256 shares_, address owner_) external returns (uint256 sharesReturned_);
```

**Parameters**

| Name      | Type      | Description                                     |
| --------- | --------- | ----------------------------------------------- |
| `shares_` | `uint256` | The amount of shares to remove from withdrawal. |
| `owner_`  | `address` | The owner of the shares.                        |

**Returns**

| Name              | Type      | Description                    |
| ----------------- | --------- | ------------------------------ |
| `sharesReturned_` | `uint256` | The amount of shares returned. |

### depositCover

Pool admin deposits pool cover.

```solidity
function depositCover(uint256 amount_) external;
```

**Parameters**

| Name      | Type      | Description                                          |
| --------- | --------- | ---------------------------------------------------- |
| `amount_` | `uint256` | The amount of assets to deposit as first-loss cover. |

### withdrawCover

Pool admin withdraws from pool cover.

```solidity
function withdrawCover(uint256 amount_, address recipient_) external;
```

**Parameters**

| Name         | Type      | Description                                             |
| ------------ | --------- | ------------------------------------------------------- |
| `amount_`    | `uint256` | The amount of assets to withdraw from first-loss cover. |
| `recipient_` | `address` | The address of the recipient.                           |

### maxCoverLiquidation

Returns the max cover liquidation of the pool.

```solidity
function maxCoverLiquidation() external view returns (uint24 maxCoverLiquidation_);
```

**Returns**

| Name                   | Type     | Description                            |
| ---------------------- | -------- | -------------------------------------- |
| `maxCoverLiquidation_` | `uint24` | The max cover liquidation of the pool. |

### minCover

Returns the min cover required for the pool configurator.

```solidity
function minCover() external view returns (uint104 minCover_);
```

**Returns**

| Name        | Type      | Description                                |
| ----------- | --------- | ------------------------------------------ |
| `minCover_` | `uint104` | The min cover required for the pool admin. |

### poolLimit

Returns the pool limit of the pool configurator.

```solidity
function poolLimit() external view returns (uint104 poolLimit_);
```

**Returns**

| Name         | Type      | Description                 |
| ------------ | --------- | --------------------------- |
| `poolLimit_` | `uint104` | The size limit of the pool. |

### openToPublic

Returns whether the pool is open to public.

```solidity
function openToPublic() external view returns (bool openToPublic_);
```

**Returns**

| Name            | Type   | Description                         |
| --------------- | ------ | ----------------------------------- |
| `openToPublic_` | `bool` | Whether the pool is open to public. |

### adminFee

Returns the admin fee of the pool.

```solidity
function adminFee() external view returns (uint24 adminFee_);
```

**Returns**

| Name        | Type     | Description                |
| ----------- | -------- | -------------------------- |
| `adminFee_` | `uint24` | The admin fee of the pool. |

### maxDeposit

Returns the max deposit amount of a receiver.

```solidity
function maxDeposit(address receiver_) external view returns (uint256 maxAssets_);
```

**Parameters**

| Name        | Type      | Description                  |
| ----------- | --------- | ---------------------------- |
| `receiver_` | `address` | The address of the receiver. |

**Returns**

| Name         | Type      | Description                                     |
| ------------ | --------- | ----------------------------------------------- |
| `maxAssets_` | `uint256` | The max amount of assets that can be deposited. |

### maxMint

Returns the max mint amount of a receiver.

```solidity
function maxMint(address receiver_) external view returns (uint256 maxShares_);
```

**Parameters**

| Name        | Type      | Description                  |
| ----------- | --------- | ---------------------------- |
| `receiver_` | `address` | The address of the receiver. |

**Returns**

| Name         | Type      | Description                                  |
| ------------ | --------- | -------------------------------------------- |
| `maxShares_` | `uint256` | The max amount of shares that can be minted. |

### maxRedeem

Returns the max redeem amount of an owner.

```solidity
function maxRedeem(address owner_) external view returns (uint256 maxShares_);
```

**Parameters**

| Name     | Type      | Description               |
| -------- | --------- | ------------------------- |
| `owner_` | `address` | The address of the owner. |

**Returns**

| Name         | Type      | Description                                    |
| ------------ | --------- | ---------------------------------------------- |
| `maxShares_` | `uint256` | The max amount of shares that can be redeemed. |

### previewRedeem

Previews the amount of assets that can be redeemed for the amount of shares specified.

```solidity
function previewRedeem(address owner_, uint256 shares_) external view returns (uint256 assets_);
```

**Parameters**

| Name      | Type      | Description                     |
| --------- | --------- | ------------------------------- |
| `owner_`  | `address` | The address of the owner.       |
| `shares_` | `uint256` | The amount of shares to redeem. |

**Returns**

| Name      | Type      | Description                                  |
| --------- | --------- | -------------------------------------------- |
| `assets_` | `uint256` | The amount of assets that would be received. |

### totalAssets

Returns the total amount of assets in the pool.

```solidity
function totalAssets() external view returns (uint256 totalAssets_);
```

**Returns**

| Name           | Type      | Description                             |
| -------------- | --------- | --------------------------------------- |
| `totalAssets_` | `uint256` | The total amount of assets in the pool. |

### hasSufficientCover

Returns whether the pool currently has sufficient cover.

```solidity
function hasSufficientCover() external view returns (bool hasSufficientCover_);
```

**Returns**

| Name                  | Type   | Description                                      |
| --------------------- | ------ | ------------------------------------------------ |
| `hasSufficientCover_` | `bool` | Whether the pool currently has sufficient cover. |

### unrealizedLosses

Returns the current amount of unrealized losses of the pool.

```solidity
function unrealizedLosses() external view returns (uint256 unrealizedLosses_);
```

**Returns**

| Name                | Type      | Description                                          |
| ------------------- | --------- | ---------------------------------------------------- |
| `unrealizedLosses_` | `uint256` | The current amount of unrealized losses of the pool. |


# IPoolConfiguratorEvents


# IPoolConfiguratorStorage


# IReceivable

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/interfaces/IReceivable.sol)

**Inherits:** [IReceivableEvent](/contract-documentation/interfaces/ireceivableevent)

## Functions

### initialize

*Initializes the Receivable.*

```solidity
function initialize(address initialGovernor_) external;
```

**Parameters**

| Name               | Type      | Description                  |
| ------------------ | --------- | ---------------------------- |
| `initialGovernor_` | `address` | The address of the governor. |

### createReceivable

Mint a new receivable.

*The event faceAmount is converted to decimal with 6 decimals.*

```solidity
function createReceivable(Receivable.Create memory create_) external returns (uint256 tokenId_);
```

**Parameters**

| Name      | Type                | Description                                                            |
| --------- | ------------------- | ---------------------------------------------------------------------- |
| `create_` | `Receivable.Create` | The struct containing the information of the receivable to be created. |

**Returns**

| Name       | Type      | Description                             |
| ---------- | --------- | --------------------------------------- |
| `tokenId_` | `uint256` | The id of the newly created receivable. |

### getReceivableInfoById

*Get the information of a receivable.*

```solidity
function getReceivableInfoById(uint256 tokenId_) external view returns (Receivable.Info memory info_);
```

**Parameters**

| Name       | Type      | Description               |
| ---------- | --------- | ------------------------- |
| `tokenId_` | `uint256` | The id of the receivable. |

**Returns**

| Name    | Type              | Description                                              |
| ------- | ----------------- | -------------------------------------------------------- |
| `info_` | `Receivable.Info` | The struct containing the information of the receivable. |

### burnReceivable

*Burn a receivable.*

```solidity
function burnReceivable(uint256 tokenId_) external;
```

**Parameters**

| Name       | Type      | Description               |
| ---------- | --------- | ------------------------- |
| `tokenId_` | `uint256` | The id of the receivable. |

### governor

Returns the addres of the governor.

```solidity
function governor() external view returns (address governor_);
```

**Returns**

| Name        | Type      | Description                  |
| ----------- | --------- | ---------------------------- |
| `governor_` | `address` | The address of the governor. |


# IReceivableEvent

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/interfaces/IReceivableEvent.sol)

## Events

### AssetCreated

Emitted when mint a new receivable.

```solidity
event AssetCreated(
    address indexed buyer_,
    address indexed seller_,
    uint256 indexed tokenId_,
    uint256 faceAmount_,
    uint256 repaymentTimestamp_
);
```

**Parameters**

| Name                  | Type      | Description                                                                       |
| --------------------- | --------- | --------------------------------------------------------------------------------- |
| `buyer_`              | `address` | The address of the buyer that's expected to pay for this receivable.              |
| `seller_`             | `address` | The address of the seller that's expected to receive payment for this receivable. |
| `tokenId_`            | `uint256` | The id of the receivable.                                                         |
| `faceAmount_`         | `uint256` | The amount of the receivable.                                                     |
| `repaymentTimestamp_` | `uint256` | The timestamp when the receivable is expected to be repaid.                       |

### AssetBurned

Emitted when burn a receivable.

```solidity
event AssetBurned(uint256 indexed tokenId_);
```

**Parameters**

| Name       | Type      | Description               |
| ---------- | --------- | ------------------------- |
| `tokenId_` | `uint256` | The id of the receivable. |

### TransferGovernor

Emitted when the governor is transferred.

```solidity
event TransferGovernor(address indexed oldGovernor, address indexed newGovernor);
```

**Parameters**

| Name          | Type      | Description                      |
| ------------- | --------- | -------------------------------- |
| `oldGovernor` | `address` | The address of the old governor. |
| `newGovernor` | `address` | The address of the new governor. |


# IWithdrawalManager

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/interfaces/IWithdrawalManager.sol)

**Inherits:** [IWithdrawalManagerStorage](/contract-documentation/interfaces/iwithdrawalmanagerstorage)

## Functions

### initialize

Initializes the Withdrawal Manager.

*Function is invoked by the proxy contract when the Withdrawal Manager Contract is added to the PoolAddressesProvider of the market.*

```solidity
function initialize(IPoolAddressesProvider provider_, uint256 cycleDuration_, uint256 windowDuration_) external;
```

**Parameters**

| Name              | Type                     | Description                               |
| ----------------- | ------------------------ | ----------------------------------------- |
| `provider_`       | `IPoolAddressesProvider` | The address of the PoolAddressesProvider. |
| `cycleDuration_`  | `uint256`                | The total duration of a withdrawal cycle. |
| `windowDuration_` | `uint256`                | The duration of the withdrawal window.    |

### setExitConfig

Pool admin sets a new configuration for the withdrawal manager.

```solidity
function setExitConfig(uint256 cycleDuration_, uint256 windowDuration_) external;
```

**Parameters**

| Name              | Type      | Description                                |
| ----------------- | --------- | ------------------------------------------ |
| `cycleDuration_`  | `uint256` | The total duration of a withdrawal cycle.  |
| `windowDuration_` | `uint256` | The total duration of a withdrawal window. |

### addShares

Add more shares for withdrawal.

```solidity
function addShares(uint256 shares_, address owner_) external;
```

**Parameters**

| Name      | Type      | Description                  |
| --------- | --------- | ---------------------------- |
| `shares_` | `uint256` | The amount of shares to add. |
| `owner_`  | `address` | The owner of the shares.     |

### removeShares

Remove shares from withdrawal.

```solidity
function removeShares(uint256 shares_, address owner_) external returns (uint256 sharesReturned_);
```

**Parameters**

| Name      | Type      | Description                                     |
| --------- | --------- | ----------------------------------------------- |
| `shares_` | `uint256` | The amount of shares to remove from withdrawal. |
| `owner_`  | `address` | The owner of the shares.                        |

### processExit

Process the exit of requested shares of a owner.

```solidity
function processExit(
    uint256 requestedShares_,
    address owner_
)
    external
    returns (uint256 redeemableShares_, uint256 resultingAssets_);
```

**Parameters**

| Name               | Type      | Description                     |
| ------------------ | --------- | ------------------------------- |
| `requestedShares_` | `uint256` | The amount of shares to redeem. |
| `owner_`           | `address` | The owner of the shares.        |

**Returns**

| Name                | Type      | Description                                                    |
| ------------------- | --------- | -------------------------------------------------------------- |
| `redeemableShares_` | `uint256` | The amount of redeemable shares.                               |
| `resultingAssets_`  | `uint256` | The corresponding amount of assets with the redeemable shares. |

### isInExitWindow

Checks if the owner has a withdrawal request in the exit window.

```solidity
function isInExitWindow(address owner_) external view returns (bool isInExitWindow_);
```

**Parameters**

| Name     | Type      | Description                 |
| -------- | --------- | --------------------------- |
| `owner_` | `address` | The owner address to check. |

**Returns**

| Name              | Type   | Description                                                    |
| ----------------- | ------ | -------------------------------------------------------------- |
| `isInExitWindow_` | `bool` | True if the owner has a withdrawal request in the exit window. |

### lockedLiquidity

Gets the total amount of liquidity locked in the current cycle.

```solidity
function lockedLiquidity() external view returns (uint256 lockedLiquidity_);
```

**Returns**

| Name               | Type      | Description                                                |
| ------------------ | --------- | ---------------------------------------------------------- |
| `lockedLiquidity_` | `uint256` | The total amount of liquidity locked in the current cycle. |

### previewRedeem

Previews the amount of shares and assets that can be redeemed.

```solidity
function previewRedeem(
    address owner_,
    uint256 shares_
)
    external
    view
    returns (uint256 redeemableShares_, uint256 resultingAssets_);
```

**Parameters**

| Name      | Type      | Description                     |
| --------- | --------- | ------------------------------- |
| `owner_`  | `address` | The owner of the shares.        |
| `shares_` | `uint256` | The amount of shares to redeem. |

**Returns**

| Name                | Type      | Description                                                    |
| ------------------- | --------- | -------------------------------------------------------------- |
| `redeemableShares_` | `uint256` | The amount of redeemable shares.                               |
| `resultingAssets_`  | `uint256` | The corresponding amount of assets with the redeemable shares. |

### getCycleConfig

Gets the configuration of a config id.

```solidity
function getCycleConfig(uint256 configId_) external view returns (WithdrawalManager.CycleConfig memory config_);
```

**Parameters**

| Name        | Type      | Description           |
| ----------- | --------- | --------------------- |
| `configId_` | `uint256` | The id of the config. |

**Returns**

| Name      | Type                            | Description |
| --------- | ------------------------------- | ----------- |
| `config_` | `WithdrawalManager.CycleConfig` | The config. |

### getConfigAtId

Gets the configuration of a given cycle id.

```solidity
function getConfigAtId(uint256 cycleId_) external view returns (WithdrawalManager.CycleConfig memory config_);
```

**Parameters**

| Name       | Type      | Description   |
| ---------- | --------- | ------------- |
| `cycleId_` | `uint256` | The cycle id. |

**Returns**

| Name      | Type                            | Description                             |
| --------- | ------------------------------- | --------------------------------------- |
| `config_` | `WithdrawalManager.CycleConfig` | The configuration used at the cycle id. |

### getCurrentConfig

Gets the configuration of the current cycle id.

```solidity
function getCurrentConfig() external view returns (WithdrawalManager.CycleConfig memory config_);
```

**Returns**

| Name      | Type                            | Description                                     |
| --------- | ------------------------------- | ----------------------------------------------- |
| `config_` | `WithdrawalManager.CycleConfig` | The configuration used at the current cycle id. |

### getCurrentCycleId

Gets the current cycle id.

```solidity
function getCurrentCycleId() external view returns (uint256 cycleId_);
```

**Returns**

| Name       | Type      | Description                  |
| ---------- | --------- | ---------------------------- |
| `cycleId_` | `uint256` | The id of the current cycle. |

### getWindowStart

Gets the starting time of a window for a given cycle id.

```solidity
function getWindowStart(uint256 cycleId_) external view returns (uint64 windowStart_);
```

**Parameters**

| Name       | Type      | Description          |
| ---------- | --------- | -------------------- |
| `cycleId_` | `uint256` | The id of the cycle. |

**Returns**

| Name           | Type     | Description                      |
| -------------- | -------- | -------------------------------- |
| `windowStart_` | `uint64` | The starting time of the window. |

### getWindowAtId

Gets the start and end time of a window for a given cycle id.

```solidity
function getWindowAtId(uint256 cycleId_) external view returns (uint64 windowStart_, uint64 windowEnd_);
```

**Parameters**

| Name       | Type      | Description          |
| ---------- | --------- | -------------------- |
| `cycleId_` | `uint256` | The id of the cycle. |

**Returns**

| Name           | Type     | Description                      |
| -------------- | -------- | -------------------------------- |
| `windowStart_` | `uint64` | The starting time of the window. |
| `windowEnd_`   | `uint64` | The ending time of the window.   |

### getRedeemableAmounts

Gets the redeemable amount of an owner based in the current cycle.

```solidity
function getRedeemableAmounts(
    uint256 lockedShares_,
    address owner_
)
    external
    view
    returns (uint256 redeemableShares_, uint256 resultingAssets_);
```

**Parameters**

| Name            | Type      | Description                                  |
| --------------- | --------- | -------------------------------------------- |
| `lockedShares_` | `uint256` | The amount of locked shares under the owner. |
| `owner_`        | `address` | The address of the owner.                    |

**Returns**

| Name                | Type      | Description                                                    |
| ------------------- | --------- | -------------------------------------------------------------- |
| `redeemableShares_` | `uint256` | The amount of redeemable shares.                               |
| `resultingAssets_`  | `uint256` | The corresponding amount of assets with the redeemable shares. |

## Events

### Initialized

Emitted when a withdrawal manager is initialized.

```solidity
event Initialized(address poolAddressesProvider_, uint256 cycleDuration_, uint256 windowDuration_);
```

**Parameters**

| Name                     | Type      | Description                               |
| ------------------------ | --------- | ----------------------------------------- |
| `poolAddressesProvider_` | `address` | The address of the PoolAddressesProvider. |
| `cycleDuration_`         | `uint256` | The duration of a withdrawal cycle.       |
| `windowDuration_`        | `uint256` | The duration of the withdrawal window.    |

### ConfigurationUpdated

Emitted when the configuration of the withdrawal manager is updated.

```solidity
event ConfigurationUpdated(
    uint256 indexed configId_,
    uint64 initialCycleId_,
    uint64 initialCycleTime_,
    uint64 cycleDuration_,
    uint64 windowDuration_
);
```

**Parameters**

| Name                | Type      | Description                             |
| ------------------- | --------- | --------------------------------------- |
| `configId_`         | `uint256` | The id of the configuration.            |
| `initialCycleId_`   | `uint64`  | The id of the initial cycle.            |
| `initialCycleTime_` | `uint64`  | The starting time of the initial cycle. |
| `cycleDuration_`    | `uint64`  | The duration of a withdrawal cycle.     |
| `windowDuration_`   | `uint64`  | The duration of the withdrawal window.  |

### WithdrawalCancelled

Emitted when a withdrawal is cancelled.

```solidity
event WithdrawalCancelled(address indexed account_);
```

**Parameters**

| Name       | Type      | Description                                |
| ---------- | --------- | ------------------------------------------ |
| `account_` | `address` | The account whose withdrawal is cancelled. |

### WithdrawalProcessed

Emitted when a withdrawal is processed.

```solidity
event WithdrawalProcessed(address indexed account_, uint256 sharesToRedeem_, uint256 assetsToWithdraw_);
```

**Parameters**

| Name                | Type      | Description                                |
| ------------------- | --------- | ------------------------------------------ |
| `account_`          | `address` | The account whose withdrawal is processed. |
| `sharesToRedeem_`   | `uint256` | The amount of shares to redeem.            |
| `assetsToWithdraw_` | `uint256` | The amount of assets to withdraw.          |

### WithdrawalUpdated

Emitted when a withdrawal is updated.

```solidity
event WithdrawalUpdated(address indexed account_, uint256 lockedShares_, uint64 windowStart_, uint64 windowEnd_);
```

**Parameters**

| Name            | Type      | Description                                     |
| --------------- | --------- | ----------------------------------------------- |
| `account_`      | `address` | The account whose withdrawal is updated.        |
| `lockedShares_` | `uint256` | The new amount of locked shares.                |
| `windowStart_`  | `uint64`  | The new starting time of the withdrawal window. |
| `windowEnd_`    | `uint64`  | The new ending time of the withdrawal window.   |


# IWithdrawalManagerStorage

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/interfaces/IWithdrawalManagerStorage.sol)

## Functions

### latestConfigId

Gets the id of the latest config.

```solidity
function latestConfigId() external view returns (uint256 configId_);
```

**Returns**

| Name        | Type      | Description                  |
| ----------- | --------- | ---------------------------- |
| `configId_` | `uint256` | The id of the latest config. |

### exitCycleId

Gets the exit cycle id of an account.

```solidity
function exitCycleId(address account_) external view returns (uint256 cycleId_);
```

**Parameters**

| Name       | Type      | Description                 |
| ---------- | --------- | --------------------------- |
| `account_` | `address` | The address of the account. |

**Returns**

| Name       | Type      | Description               |
| ---------- | --------- | ------------------------- |
| `cycleId_` | `uint256` | The id of the exit cycle. |

### lockedShares

Gets the locked shares of an account.

```solidity
function lockedShares(address account_) external view returns (uint256 lockedShares_);
```

**Parameters**

| Name       | Type      | Description                 |
| ---------- | --------- | --------------------------- |
| `account_` | `address` | The address of the account. |

**Returns**

| Name            | Type      | Description                                    |
| --------------- | --------- | ---------------------------------------------- |
| `lockedShares_` | `uint256` | The amount of locked shares under the account. |

### totalCycleShares

Gets the total locked shares of a cycle.

```solidity
function totalCycleShares(uint256 cycleId_) external view returns (uint256 totalCycleShares_);
```

**Parameters**

| Name       | Type      | Description          |
| ---------- | --------- | -------------------- |
| `cycleId_` | `uint256` | The id of the cycle. |

**Returns**

| Name                | Type      | Description                                        |
| ------------------- | --------- | -------------------------------------------------- |
| `totalCycleShares_` | `uint256` | The total amount of locked shares under the cycle. |


# libraries


# Errors

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/libraries/Errors.sol)

## Errors

### InvalidCaller

Thrown when `msg.sender` is not the expected one.

```solidity
error InvalidCaller(address caller, address expectedCaller);
```

### CallerNotGovernor

Thrown when `msg.sender` is not the governor.

```solidity
error CallerNotGovernor(address governor_, address caller_);
```

### NotPoolAdminOrGovernor

Thrown when `msg.sender` is neither the pool admin nor the governor.

```solidity
error NotPoolAdminOrGovernor(address caller_);
```

### NotPoolAdmin

Thrown when `msg.sender` is not the pool admin.

```solidity
error NotPoolAdmin(address caller_);
```

### NotPoolConfigurator

Thrown when `msg.sender` is not the pool configurator.

```solidity
error NotPoolConfigurator(address caller_);
```

### InvalidAddressesProvider

```solidity
error InvalidAddressesProvider(address provider, address expectedProvider);
```

### FunctionPaused

```solidity
error FunctionPaused(bytes4 sig);
```

### ProtocolPaused

```solidity
error ProtocolPaused();
```

### AddressesProviderZeroAddress

Thrown when pool addresses provider is set to 0.

```solidity
error AddressesProviderZeroAddress();
```

### GovernorZeroAddress

Thrown when the new governor is zero address.

```solidity
error GovernorZeroAddress();
```

### ZeroAddress

Thrown when the address is zero address.

```solidity
error ZeroAddress();
```

### ReentrancyGuardReentrantCall

Thrown when a reentrancy lock is already set.

```solidity
error ReentrancyGuardReentrantCall();
```

### PoolConfigurator\_InvalidPoolAdmin

Thrown when the pool admin set is not on the whitelist.

```solidity
error PoolConfigurator_InvalidPoolAdmin(address poolAdmin_);
```

### PoolConfigurator\_InvalidPoolAsset

Thrown when the asset set is not on the whitelist.

```solidity
error PoolConfigurator_InvalidPoolAsset(address asset_);
```

### PoolConfigurator\_CallerNotLoanManager

Thrown when `msg.sender` is not the loan manager.

```solidity
error PoolConfigurator_CallerNotLoanManager(address expectedCaller_, address caller_);
```

### PoolConfigurator\_CallerNotPoolAdminOrGovernor

Thrown when caller is not pool admin or governor.

```solidity
error PoolConfigurator_CallerNotPoolAdminOrGovernor(address caller_);
```

### PoolConfigurator\_CallerNotPoolAdmin

Thrown when caller is not pool admin.

```solidity
error PoolConfigurator_CallerNotPoolAdmin(address caller_);
```

### PoolConfigurator\_CallerNotGovernor

Thrown when caller is not governor.

```solidity
error PoolConfigurator_CallerNotGovernor(address caller_);
```

### PoolConfigurator\_PoolSupplyZero

Thrown when the total supply of the pool is zero.

```solidity
error PoolConfigurator_PoolSupplyZero();
```

### PoolConfigurator\_InsufficientCover

Thrown when the pool cover is insufficient.

```solidity
error PoolConfigurator_InsufficientCover();
```

### PoolConfigurator\_InsufficientLiquidity

Thrown when the pool has insufficient liquidity to fund new loans.

```solidity
error PoolConfigurator_InsufficientLiquidity();
```

### PoolConfigurator\_NoAllowance

Thrown when the spender has no allowance from the owner.

```solidity
error PoolConfigurator_NoAllowance(address owner_, address spender_);
```

### PoolConfigurator\_PoolApproveWithdrawalManagerFailed

Thrown when the pool fails to approve the withdrawal manager with the amount of shares.

```solidity
error PoolConfigurator_PoolApproveWithdrawalManagerFailed(uint256 amount_);
```

### PoolConfigurator\_Paused

Thrown when the pool configurator is paused.

```solidity
error PoolConfigurator_Paused();
```

### PoolAddressesProvider\_InvalidGlobals

Thrown when IsleGlobals is set to 0.

```solidity
error PoolAddressesProvider_InvalidGlobals(address globals);
```

### Globals\_InvalidVault

Thrown when vault is set to 0.

```solidity
error Globals_InvalidVault(address vault);
```

### Globals\_CallerNotPendingGovernor

Thrown when the caller is not penging governor

```solidity
error Globals_CallerNotPendingGovernor(address pendingGovernor_);
```

### LoanManager\_InvalidReceivable

Thrown when buyer approves an invalid receivable (either buyer or seller is not whitelisted or repayment timestamp is in the past).

```solidity
error LoanManager_InvalidReceivable(uint256 receivablesTokenId_);
```

### LoanManager\_PrincipalRequestedTooHigh

Thrown when the buyer requests for a principal larger than the face amount of the receivable.

```solidity
error LoanManager_PrincipalRequestedTooHigh(uint256 principalRequested_, uint256 maxPrincipal_);
```

### LoanManager\_Overdraw

Thrown when the seller overdraws.

```solidity
error LoanManager_Overdraw(uint16 loanId_, uint256 amount_, uint256 withdrawableAmount_);
```

### LoanManager\_NotLoan

Thrown when the loan id is invalid.

```solidity
error LoanManager_NotLoan(uint16 loanId_);
```

### LoanManager\_LoanImpaired

Thrown when the loan is already impaired.

```solidity
error LoanManager_LoanImpaired(uint16 loanId_);
```

### LoanManager\_LoanNotImpaired

Thrown when the loan is not impaired.

```solidity
error LoanManager_LoanNotImpaired(uint16 loanId_);
```

### LoanManager\_PastDueDate

Thrown when the loan is past due date.

```solidity
error LoanManager_PastDueDate(uint16 loanId_, uint256 dueDate_, uint256 currentTimestamp_);
```

### LoanManager\_ReceivableAssetNotAllowed

Thrown when the receivable asset is not allowed.

```solidity
error LoanManager_ReceivableAssetNotAllowed(address receivableAsset_);
```

### LoanManager\_NotPastDueDatePlusGracePeriod

Thrown when current time is not past due date plus grace period.

```solidity
error LoanManager_NotPastDueDatePlusGracePeriod(uint16 loanId_);
```

### LoanManager\_CallerNotReceivableBuyer

Thrown when `msg.sender` is not the buyer.

```solidity
error LoanManager_CallerNotReceivableBuyer(address expectedBuyer_);
```

### LoanManager\_AssetZeroAddress

Thrown when an asset address is set to 0 for a loan manager.

```solidity
error LoanManager_AssetZeroAddress();
```

### LoanManager\_LoanNotFunded

Thrown when the seller withraw fund before the loan be funded.

```solidity
error LoanManager_LoanNotFunded();
```

### WithdrawalManager\_ZeroWindow

Thrown when the window duration set is 0.

```solidity
error WithdrawalManager_ZeroWindow();
```

### WithdrawalManager\_WindowGreaterThanCycle

Thrown when the window duration set is larger than the cycle duration.

```solidity
error WithdrawalManager_WindowGreaterThanCycle();
```

### WithdrawalManager\_WithdrawalPending

Thrown when the withdrawal is still pending.

```solidity
error WithdrawalManager_WithdrawalPending(address owner_);
```

### WithdrawalManager\_NoOp

Thrown when the action results in no change.

```solidity
error WithdrawalManager_NoOp(address owner_);
```

### WithdrawalManager\_Overremove

Thrown when the owner removes more shares than they have.

```solidity
error WithdrawalManager_Overremove(address owner_, uint256 shares_, uint256 lockedShares_);
```

### WithdrawalManager\_NoRequest

Thrown when the owner has no withdrawal request (that is locked shares is zero).

```solidity
error WithdrawalManager_NoRequest(address owner_);
```

### WithdrawalManager\_InvalidShares

Thrown when the shares a owner requests to withdraw differs from their withdrawal request.

```solidity
error WithdrawalManager_InvalidShares(address owner_, uint256 requestedShares_, uint256 lockedShares_);
```

### WithdrawalManager\_NotInWindow

Thrown when the current time is not in the owner's withdrawal window.

```solidity
error WithdrawalManager_NotInWindow(uint256 currentTimestamp_, uint256 windowStart_, uint256 windowEnd_);
```

### Pool\_ZeroAsset

Thrown when an asset address is 0.

```solidity
error Pool_ZeroAsset();
```

### Pool\_ZeroConfigurator

Thrown when pool configurator address is set to 0.

```solidity
error Pool_ZeroConfigurator();
```

### Pool\_FailedApprove

Thrown when the asset fails to approve the pool configurator with max amount.

```solidity
error Pool_FailedApprove();
```

### Pool\_RecipientZeroAddress

Thrown when the receiver address is 0.

```solidity
error Pool_RecipientZeroAddress();
```

### Pool\_DepositGreaterThanMax

Thrown when the deposit amount is greater than the max deposit.

```solidity
error Pool_DepositGreaterThanMax(uint256 assets, uint256 maxDeposit);
```

### Pool\_MintGreaterThanMax

Thrown when the mint amount is greater than the max mint.

```solidity
error Pool_MintGreaterThanMax(uint256 shares, uint256 maxMint);
```

### Pool\_InsufficientPermit

Thrown when the assets is greater than the max amount to deposit.

```solidity
error Pool_InsufficientPermit(uint256 assets, uint256 permits);
```

### Pool\_RedeemMoreThanMax

Thrown when the redeem shares is greater than the max redeem amount.

```solidity
error Pool_RedeemMoreThanMax(uint256 shares, uint256 maxRedeem);
```

### Pool\_WithdrawalNotImplemented

Thrown when anyone calls the `previewWithdraw` function.

```solidity
error Pool_WithdrawalNotImplemented();
```


# PoolDeployer

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/libraries/PoolDeployer.sol)

Library containing the logic to deploy a pool contract.

## Functions

### createPool

Deploys a new pool contract.

```solidity
function createPool(
    address configurator_,
    address asset_,
    string memory name_,
    string memory symbol_
)
    public
    returns (address pool_);
```


# ReentrancyGuardUpgradeable

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/libraries/ReentrancyGuard.sol)

**Inherits:** [VersionedInitializable](/contract-documentation/libraries/upgradability/versionedinitializable)

## State Variables

### NOT\_ENTERED

```solidity
uint256 private constant NOT_ENTERED = 1;
```

### ENTERED

```solidity
uint256 private constant ENTERED = 2;
```

### ReentrancyGuardStorageLocation

```solidity
bytes32 private constant ReentrancyGuardStorageLocation =
    0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
```

## Functions

### \_getReentrancyGuardStorage

```solidity
function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $);
```

### \_\_ReentrancyGuard\_init

```solidity
function __ReentrancyGuard_init() internal onlyInitializing;
```

### nonReentrant

```solidity
modifier nonReentrant();
```

## Structs

### ReentrancyGuardStorage

```solidity
struct ReentrancyGuardStorage {
    uint256 _status;
}
```


# types


# PoolConfigurator

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/libraries/types/DataTypes.sol)

Namespace for the structs used in [PoolConfigurator](/contract-documentation/libraries/types/poolconfigurator)

## Structs

### Config

```solidity
struct Config {
    bool openToPublic;
    uint24 adminFee;
    uint24 maxCoverLiquidation;
    uint104 minCover;
    uint104 poolLimit;
}
```


# Loan

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/libraries/types/DataTypes.sol)

Namespace for the structs used in {LoanManager}

## Structs

### Info

```solidity
struct Info {
    address buyer;
    address seller;
    address receivableAsset;
    uint256 receivableTokenId;
    uint256 principal;
    uint256 drawableFunds;
    uint256 interestRate;
    uint256 lateInterestPremiumRate;
    uint256 startDate;
    uint256 dueDate;
    uint256 originalDueDate;
    uint256 gracePeriod;
    bool isImpaired;
}
```

### LiquidationInfo

```solidity
struct LiquidationInfo {
    bool triggeredByGovernor;
    uint128 principal;
    uint120 interest;
    uint256 lateInterest;
    uint96 protocolFees;
}
```

### PaymentInfo

```solidity
struct PaymentInfo {
    uint24 protocolFee;
    uint24 adminFee;
    uint48 startDate;
    uint48 dueDate;
    uint128 incomingNetInterest;
    uint256 issuanceRate;
}
```

### SortedPayment

```solidity
struct SortedPayment {
    uint24 previous;
    uint24 next;
    uint48 paymentDueDate;
}
```

### Impairment

```solidity
struct Impairment {
    uint40 impairedDate;
    bool impariedByGovernor;
}
```


# Receivable

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/libraries/types/DataTypes.sol)

Namespace for the structs used in [Receivable](/contract-documentation/libraries/types/receivable)

## Structs

### Create

```solidity
struct Create {
    address buyer;
    address seller;
    uint256 faceAmount;
    uint256 repaymentTimestamp;
    uint16 currencyCode;
}
```

**Properties**

| Name                 | Type      | Description                                                                                     |
| -------------------- | --------- | ----------------------------------------------------------------------------------------------- |
| `buyer`              | `address` | The address of the buyer that's expected to pay for this receivable.                            |
| `seller`             | `address` | The address of the seller that's expected to receive payment for this receivable.               |
| `faceAmount`         | `uint256` | The amount of the receivable.                                                                   |
| `repaymentTimestamp` | `uint256` | The timestamp when the receivable is expected to be repaid.                                     |
| `currencyCode`       | `uint16`  | The currency code specified by ISO 4217 in which the receivable is expressed, e.g. 840 for USD. |

### Info

```solidity
struct Info {
    address buyer;
    address seller;
    uint256 faceAmount;
    uint256 repaymentTimestamp;
    bool isValid;
    uint16 currencyCode;
}
```


# WithdrawalManager

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/libraries/types/DataTypes.sol)

Namespace for the structs used in [WithdrawalManager](/contract-documentation/libraries/types/withdrawalmanager)

## Structs

### CycleConfig

```solidity
struct CycleConfig {
    uint64 initialCycleId;
    uint64 initialCycleTime;
    uint64 cycleDuration;
    uint64 windowDuration;
}
```


# upgradability


# UUPSProxy

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/libraries/upgradability/UUPSProxy.sol)

**Inherits:** ERC1967Proxy

## Functions

### constructor

```solidity
constructor(address _implementation, bytes memory _data) ERC1967Proxy(_implementation, _data);
```


# VersionedInitializable

[Git Source](https://github.com/isle-labs/isle-contract/blob/main/contracts/libraries/upgradability/VersionedInitializable.sol)

**Author:** Aave, inspired by the OpenZeppelin Initializable contract

Helper contract to implement initializer functions. To use it, replace the constructor with a function that has the `initializer` modifier.

*WARNING: Unlike constructors, initializer functions must be manually invoked. This applies both to deploying an Initializable contract, as well as extending an Initializable contract via inheritance. WARNING: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or ensure that all initializers are idempotent, because this is not dealt with automatically as with constructors.*

## State Variables

### INITIALIZABLE\_STORAGE

```solidity
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
```

### **\_\_**&#x67;ap

```solidity
uint256[50] private ______gap;
```

## Functions

### initializer

*Modifier to use in the initializer function of a contract.*

```solidity
modifier initializer();
```

### onlyInitializing

*Modifier to use when a function is restricted to the initialization phase.*

```solidity
modifier onlyInitializing();
```

### getRevision

Returns the revision number of the contract

*Needs to be defined in the inherited class as a constant.*

```solidity
function getRevision() public pure virtual returns (uint256);
```

**Returns**

| Name     | Type      | Description         |
| -------- | --------- | ------------------- |
| `<none>` | `uint256` | The revision number |

### isConstructor

Returns true if and only if the function is running in the constructor

```solidity
function isConstructor() private view returns (bool);
```

**Returns**

| Name     | Type   | Description                                        |
| -------- | ------ | -------------------------------------------------- |
| `<none>` | `bool` | True if the function is running in the constructor |

### \_getInitializableStorage

```solidity
function _getInitializableStorage() private pure returns (VersionedInitializableStorage storage $);
```

### \_getLastInitializedRevision

```solidity
function _getLastInitializedRevision() internal view returns (uint256);
```

### \_getInitializing

```solidity
function _getInitializing() internal view returns (bool);
```

## Structs

### VersionedInitializableStorage

*Indicates that the contract has been initialized.*

```solidity
struct VersionedInitializableStorage {
    uint256 lastInitializedRevision;
    bool initializing;
}
```


