# Overview

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2FgdE6LIP15ksqsyMY7cET%2FMain%20Graphic%20(1).gif?alt=media&amp;token=28193c95-a7cb-460b-8107-884fb5aa494e" alt=""><figcaption></figcaption></figure>

**Untitled Bank** is a permissionless, and modular lending platform designed to provide a seamless and inclusive experience for all users. Our mission is to unlock the potential of underutilized assets by leveraging our unique **Aggregated and Layered Bank architecture**. Untitled Bank simplifies asset management and lending operations, making decentralized finance (DeFi) more accessible to both novice and experienced users.


# Problem Statement

Decentralized finance (DeFi) has transformed traditional financial systems by removing intermediaries and relying on smart contracts for trustless transactions. While DeFi offers numerous advantages over traditional finance, including transparency and accessibility, existing lending platforms often face limitations. which we identified as such:

* **Limited asset diversity and accessibility on existing platforms, creating barriers for regular retail users.**
* **Low capital efficiency due to underutilized assets in a fragmented ecosystem.**
* **Lack of cross-chain interoperability, restricting liquidity and access to assets across different chains.**
* **DAO-centric risk management potentially limiting scalability and efficient decision-making.**

Untitled Bank aims to address these issues with a interoperable modular architecture that leverages a Layered Bank system to offer a more inclusive and flexible approach to decentralized lending.


# Solution: Aggregated Lending

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2FQ0IkilC9j4KePFGFhOxP%2F02.png?alt=media&amp;token=b5fecfe3-d5b4-4e4e-b811-741b1ac01de1" alt=""><figcaption><p>Aggregated Layers: Core Bank and Core Market</p></figcaption></figure>

Untitled Bank introduces **Aggregated Lending**, an innovative solution that unifies permissionless lending markets through aggregation layers - the **Core Market** and **Core Bank**. The Core Market aggregates markets with identical collateral-loan asset pairs, while the Core Bank manages the aggregated liquidity pools. This layered structure preserves the flexibility of modular market creation while solving liquidity fragmentation, offering users the best of both modular and monolithic lending systems.

Deep dive into our layered structures in [**Layered Bank Structure**](/core-concept/banks/layered-bank-structure) and [**Layered Market Structure**](/core-concept/markets/layered-market-structure) part.&#x20;


# Banks

At Untitled Bank, anyone can create a **Bank** in the form of an [ERC-4626 vault](https://ethereum.org/en/developers/docs/standards/tokens/erc-4626/). Each Bank functions as an independent lending vault, holding a single loan asset and serving specific lending markets within the platform.

Banks are created and managed by **Bank Operators**—which can include individuals, financial institutions, DAOs, or project treasuries. Untitled Bank’s **permissionless** design allows anyone to become a Bank Operator, fostering diverse participation.

The **Layered Bank Structure** ensures that all users, regardless of their DeFi expertise, can participate seamlessly. Untitled Bank combines the advantages of monolithic lending platforms like [AAVE](https://aave.com/) and [Compound](https://compound.finance/) with modular systems like [Morpho](https://morpho.org/) and [Euler](https://www.euler.finance/), introducing a new era of customizable lending.

**Users can:**

* **Earn passive income** by depositing their assets to the Bank
* **Select Core Bank to delegate risk management to the DAO** for a simplified experience.
* **Select Custom Banks** based on personalized risk appetites and strategies.

***

#### **Glossary**

* **Bank**: A vault containing an ERC-20 (or [ICrosschainERC20](https://specs.optimism.io/interop/token-bridging.html)) asset, representing a lending market on the platform.
* **Bank Operator**: The creator and owner of the Bank (vault) with full control over its management.


# Layered Bank Structure

{% hint style="info" %}
The cornerstone of Untitled Bank's design is its **Layered Bank structure**, which offers unparalleled flexibility and accessibility in asset management.
{% endhint %}

A major challenge with modular lending platforms is their complex earning process compared to monolithic platforms like Aave or Compound. On these platforms, users simply deposit assets into a single pool. However, in modular systems, users must navigate different Bank Operators, assess the risk level of each vault, and ensure they are entrusting their funds to reliable operators.

At Untitled Bank, we eliminate this complexity by introducing the **Core Bank**, where a DAO manages asset distribution across multiple Custom Banks—offering the simplicity of monolithic platforms with the flexibility of modular lending.

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2FKaa0FsvEPZU01wyftKjN%2F03.png?alt=media&amp;token=0c10c8ac-5701-4ca6-a93c-a8e7c8ee0ddb" alt=""><figcaption><p>Depositing experience for different user types</p></figcaption></figure>

***

#### **Core Bank**

Designed for users seeking simplicity, the Core Bank functions as a vault where users can easily deposit and lend assets without complex configurations.

* **Asset Distribution**: Funds from the Core Bank are distributed to various Custom Banks based on DAO voting, ensuring optimized and secure asset allocation.

#### **Custom Bank**

Built for advanced users and institutions, Custom Banks provide flexibility with configurable risk levels, managed independently by different Bank Operators.

***

#### **Benefits**

* **User-Friendly**: Simplifies the experience for users of all expertise levels.
* **Capital Efficiency**: Improves asset utilization by effectively pooling and distributing funds.
* **DAO Governance**: Encourages long-term commitment through DAO voting on asset distribution within the Core Bank.

Untitled Bank offers the best of both worlds, providing ease of use similar to Aave or Compound while harnessing the flexibility and customization of modular lending.


# Broad Asset Support

{% hint style="info" %}
Untitled Bank offers a diverse range of assets, surpassing traditional lending platforms by supporting both key DeFi assets and long-tail assets.&#x20;
{% endhint %}

Key DeFi assets include popular tokens backed by leading protocols, while long-tail assets are carefully selected based on manageable volatility, sufficient liquidity to minimize slippage, proven market maturity, and rigorous security audits to ensure safety.

**Benefits**:

* More options for diversification and risk management.
* Boosts platform liquidity and market depth.
* Supports broader participation across different asset types.


# ICrosschainERC20 Vault (TBD)

Previously SuperchainERC20 Vault

{% hint style="info" %}
To be updated 👀
{% endhint %}


# Markets

At Untitled Bank, anyone can create a **Market** by leveraging the platform's modular components. Each Market matches lenders, borrowers, and Bank Operators in a **permissionless and overcollateralized** manner. Markets are fully customizable with components like Interest Rate Models (IRM), Oracles, and asset selection, ensuring flexibility and optimization for various financial strategies.

* **Permissionless Market Creation**: Design efficient Markets with tools like IRMs, Oracles, and various loan and collateral assets.
* **Risk Isolation**: Each Market operates independently, with unique Loan-to-Value (LTV) ratios for specific loan and collateral assets, ensuring that risk is siloed within the individual Market.
* **Optimized Liquidity**: Modular structure ensures enhanced liquidity utilization, maximizing returns for participants.

Once a Market is live, Bank Operators can allocate a portion of their vault's assets as loan assets for the Market, tailoring their exposure to meet specific lending needs.

Untitled Bank introduces a **Layered Market Structure** to solve liquidity fragmentation in modular lending, where multiple markets with identical asset pairs create inefficiencies. Our Core Market feature aggregates markets with the same collateral-loan asset pairs and, governed by DAO whitelisting, optimally distributes borrow orders across approved markets, providing users with a unified liquidity experience that combines the benefits of both modular and monolithic lending.

#### **Users Can**

* **Create** efficient Markets with provided tools like IRMs, Oracles, and assets.
* **Borrow** assets from a Market, considering its unique risk profile and interest rate model.
* **Bundle** transactions for gas-efficient and hassle-free engagement.
* **Access** aggregated liquidity across whitelisted Markets through the Core Market.

***

#### **Glossary**

* **Market**: A lending marketplace built on the platform using modular components such as IRMs and Oracles.
* **Bank Operator**: A manager who allocates loan assets from their vault to a Market.

Untitled Bank’s modular Markets empower users to operate with flexibility while ensuring security through risk isolation, creating a scalable and inclusive DeFi ecosystem.


# Layered Market Structure

Untitled Bank's **Layered Market Structure** revolutionizes modular lending by solving the critical challenge of liquidity fragmentation. In traditional modular lending protocols, the coexistence of multiple markets with identical collateral-loan pairs leads to scattered liquidity and market inefficiencies. Our innovative approach combines the flexibility of modular lending with the efficiency of monolithic systems through our **Core Market** feature.

#### **Core Market Solution**&#x20;

Our **Core Market** feature aggregates markets with identical collateral-loan asset pairs, creating a unified lending experience:

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2FAYtTcJlDHpNXSziHRt2E%2F04.png?alt=media&amp;token=e75cd1b1-5b6b-4c31-a3a7-606af4e84a20" alt=""><figcaption><p>Collateralizing and Borrowing experience for different user types</p></figcaption></figure>

* **Smart Market Whitelisting**: Through DAO governance, markets are carefully vetted and whitelisted to join the Core Market ecosystem.
* **Optimal Order Distribution**: The platform intelligently routes borrow orders across whitelisted markets, maximizing efficiency and stabilizing rates.
* **Unified Liquidity**: Users access a single, aggregated liquidity pool for each asset pair, simplifying the lending experience while maintaining the benefits of modular design.

#### **Key Advantages**&#x20;

The Layered Market Structure delivers significant benefits to all participants:

* **Seamless User Experience**: Access to aggregated liquidity through a single interface eliminates the complexity of comparing multiple markets.
* **Maximum Capital Efficiency**: Unified liquidity pools ensure optimal utilization rates and stable interest rates across the platform.
* **Community-Driven Growth**: DAO governance of market whitelisting promotes quality control and active community participation in platform development.

Through this innovative architecture, Untitled Bank creates a lending platform that combines the customization of modular design with the efficiency of unified liquidity pools, setting a new standard for DeFi lending.


# Modular Architecture

{% hint style="info" %}
Untitled Bank's **Modular Architecture** allows for seamless expansion and customization of financial products and services.
{% endhint %}

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2Fgf8hrp9XDkwovIB0aAwD%2F05.png?alt=media&amp;token=d16b3bbd-737c-470e-9573-039c83c58cf2" alt=""><figcaption></figcaption></figure>

* **Custom Vault Creation**: \
  Developers and advanced users can build and deploy customized vaults that cater to specific investment strategies or market needs.<br>
* **Interoperability**: \
  The modular design follows ERC-4626 Standard to facilitate integration with other DeFi protocols and services, enhancing composability and enabling complex financial operations.<br>
* **Scalability**: \
  New features and asset classes can be added without disrupting existing services, ensuring the platform evolves alongside the rapidly changing DeFi landscape.

**Benefits**:

* Empowers innovation by allowing for the development of specialized financial products.
* Ensures the platform remains adaptable and future-proof.
* Enhances user experience by providing tailored solutions.


# Permissionless and Flexible

{% hint style="info" %}
Untitled Bank embraces a **Permissionless** ethos, ensuring openness and inclusivity across all platform operations.
{% endhint %}

* **Open Access**: Anyone can participate in the ecosystem, whether by depositing assets, creating vaults, or developing new financial products, without requiring explicit permission or centralized approval.
* **Flexible Participation**: Users have the freedom to choose how they engage with the platform, selecting from various vaults and strategies that align with their risk tolerance and investment goals.

**Benefits**:

* Fosters a decentralized and democratic financial environment.
* Encourages community-driven growth and innovation.
* Reduces barriers to entry, attracting a wider user base.


# Advanced Risk Management

{% hint style="info" %}
Risk management is integral to Untitled Bank's design, ensuring user funds are safeguarded through robust mechanisms.
{% endhint %}

* **Customizable Risk Parameters**: Vault creators can set specific risk parameters, including collateralization ratios, interest rates, and liquidation thresholds, tailoring the risk profile to the intended strategy.
* **Efficient Liquidation Mechanisms**: The platform employs optimized liquidation processes to minimize losses and maintain system stability, including automated triggers and fair penalty structures.

**Benefits**:

* Protects user assets through proactive and responsive safeguards.
* Maintains platform stability and trustworthiness.


# Multiply (Leverage) Feature

{% hint style="info" %}
Unlock the potential of yield-bearing assets by easily leveraging positions for higher returns.
{% endhint %}

* **Automated Leverage**: Multiply automates the borrowing and re-depositing process to increase exposure, allowing users to select their desired leverage level.
* **Integrated Risk Tools**: The platform provides tools for tracking and adjusting leverage positions, helping users manage risks such as liquidation or excessive borrowing costs.

**Benefits**:

* Maximizes potential returns on staking tokens and other yield-bearing assets.
* Simplifies complex strategies with a single-click solution.
* Provides clear insights and control over leveraged positions.


# Bundler

{% hint style="info" %}
Untitled Bank provides **bundling solutions** to improve gas efficiency and simplify engagement.
{% endhint %}

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2FPr9KFxHY4GYIAYlUPYgg%2F06.png?alt=media&amp;token=49b19867-1ea2-40cb-a0e8-038916fa396d" alt=""><figcaption></figcaption></figure>

#### **Streamlined User Experience with Bundlers**

* **One-Click Bundles**: Users can combine multiple actions—such as deposits, loans, repayments, and withdrawals—into a single transaction.
* **Multiply Feature** : Users can leverage assets for higher returns in a seamless, cost-effective process.


# Earn

Try Depositing on our testnet app

{% hint style="info" %}
**The feature is live on** [**our app**](https://app.untitledbank.co/)**.**
{% endhint %}

## Deposit and Withdraw

1. **Choose an asset you want to deposit or withdraw**

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2FD5Mpy66kp8Z4SHwS410o%2FEarn%201.png?alt=media&amp;token=a014106a-fed2-4b82-a93a-b3d4cfa4c1b9" alt=""><figcaption></figcaption></figure>

2. **Select either Untitled Bank's Aggregator or a Modular Bank to deposit or withdraw your asset.**

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2Fq9srk6BkBcQ5gnvJAY8u%2FEarn%202-1.png?alt=media&amp;token=529b16a8-8605-470d-bf5d-2f51458e4fcb" alt=""><figcaption></figcaption></figure>

* Aggregator (Core-vault) : the aggregated vault layer managed by the DAO
* Modular Bank (Custom-vault) : the vault operated by third-party creators.

*\*Learn more about our Layered Vault Structure* [*here*](/core-concept/banks/layered-bank-structure)*.*<br>

3. **Insert the amount of asset you want to deposit or withdraw and confirm.**

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2FbAqXP3rUZMWmpn0J5198%2FEarn%203.png?alt=media&amp;token=7afab125-a280-42b8-9670-a2b83aee3857" alt=""><figcaption></figcaption></figure>


# Borrow

{% hint style="info" %}
**The feature is live on** [**our app**](https://app.untitledbank.co/)**.**
{% endhint %}

1. **Choose the market which you want to borrow.**

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2F2WwmeS2VcxQZLejXOcHj%2FBorrow%201.png?alt=media&amp;token=09b46a10-2228-4fa1-9b6a-bcc3bea920b1" alt=""><figcaption></figcaption></figure>

2. **Select one or more actions below to create a bundle and press start. Chosen actions will be performed in a single transaction.** (Only depositing more collateral assets and Repaying loan assets are possible during liquidation.)

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2FFj1f88m7AjiFLYS8MIdC%2FBorrow%202.png?alt=media&amp;token=efc7f91c-dd37-427a-a599-73f45a6ef31f" alt=""><figcaption></figcaption></figure>

* Deposit Collateral
* Borrow Loan
* Repay Loan
* Withdraw Collateral

3. **Insert the amount of asset you want for each action and Approve.**

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2FRgdSLhEMK714S7uPeHSb%2FBorrow%203.png?alt=media&amp;token=731addbe-e197-494f-a715-ca7cee1e66d1" alt=""><figcaption></figcaption></figure>


# Leverage / Repay with Collateral

### **What Is Leverage and How Does It Work?**

A one-click strategy that automates the borrowing and re-depositing process. You can increase exposure to a greater-yield asset by depositing the additional collateral.

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2FkrShIjiK8EHEvGbkq8zZ%2FLeverage%201.png?alt=media&amp;token=9b1b34b9-9efb-4773-9945-00cf654ed2f0" alt=""><figcaption></figcaption></figure>

1. **Go to Borrow Page and choose the market you want to borrow and leverage.**

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2F2s4bQbfV0S7F787nC3Cy%2FLeverage%202.png?alt=media&amp;token=c3bd0574-32f8-4d7b-a8af-80799c49333f" alt=""><figcaption></figcaption></figure>

2. **Choose the ‘Leverage’ feature at the top of Actions bundles.**

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2F3lpOp5pwqhCs7E9TfrIh%2FLeverage%203.png?alt=media&amp;token=8f4b9aac-9edd-4686-bb59-ec7581e6e179" alt=""><figcaption></figcaption></figure>

3. **Insert the amount of asset you want to deposit(collateralize) and choose the leverage amount.**

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2FJy4mqmyqpnRxQOL489FO%2FLeverage%204.png?alt=media&amp;token=2acfff71-62b8-4dbd-a45b-2158d975e420" alt=""><figcaption></figcaption></figure>

4. **Approve transactions and check your leveraged position.**

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2FbOQFKhrt6Ji1ngNwzZho%2FLeverage%205.png?alt=media&amp;token=e76fef4c-3978-4361-999c-76c0992430c3" alt=""><figcaption></figcaption></figure>

### Repay with Collateral (Deleverage)

If you want to close your leveraged positions - you can either repay with funds from your wallet, or **repay with your collateral.**&#x20;

By choosing 'Repay with collateral' option, the collateral is withdrawn and swapped into the borrowed token to be repaid.

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2F3azMXCNeboFF5LYoxs0k%2FLeverage%206.png?alt=media&amp;token=70812936-fa3f-43b4-b0fb-54816009d5c2" alt=""><figcaption></figcaption></figure>


# Standard Lending and Borrowing

* **For Passive Investors**: Users can deposit assets into general vaults to earn stable, passive income through interest accrual.
* **For Borrowers**: Access to a wide range of assets enables users to borrow funds for various purposes, including liquidity needs, investment diversification, and strategic asset acquisition.


# Customized Vault Strategies

* **Tailored Investment Plans**: Advanced users can create specific vaults with customized parameters to implement unique strategies, such as targeting specific asset pairs or leveraging niche markets.
* **Institutional Use**: Financial institutions can utilize custom vaults for large-scale operations, portfolio management, and offering specialized financial products to their clients.


# Transform Treasury into a Profitable Vault

* **Revenue Generation**: DAO and protocol treasuries can convert their assets into revenue-generating vaults.
* **Full Control**: Treasury managers maintain direct control over risk and asset management.
* **Unlock Potential**: Treasuries earn interest on previously underutilized assets, growing funds while retaining autonomy.


# Yield Optimization

* **Leverage via Multiply**: Users can boost returns by leveraging high-yield assets, optimizing income during bullish markets.
* **Yield Aggregation**: By combining multiple yield sources, such as staking and lending, users can maximize returns while balancing risks.


# Impermanent Loss Hedge

* **LP Token Vaults**: Create LP token vaults (e.g., Velodrome CL100-USDC/WETH) to generate yield for LP depositors.
* **Hedge their asset position**: WETH and USDC holders can borrow LP tokens using their WETH or USDC as collateral to hedge their own position.


# How to create a market

To create a new market in the Bank contract, you need to call the `createMarket` function. This function requires specific parameters and a transaction fee. Follow these steps to create a market:

### Function Signature

{% code overflow="wrap" fullWidth="false" %}

```solidity
function createMarket(MarketConfigs memory marketConfigs) external payable returns (uint256)
```

{% endcode %}

### Parameters

The `createMarket` function takes a single parameter of type `MarketConfigs`, which is a struct containing the following fields:

<table><thead><tr><th width="165">Field</th><th width="96">Type</th><th>Description</th></tr></thead><tbody><tr><td>loanToken</td><td>address</td><td>The address of the ERC20 token used for loans in this market</td></tr><tr><td>collateralToken</td><td>address</td><td>The address of the ERC20 token used as collateral in this market</td></tr><tr><td>oracle</td><td>address</td><td>The address of the price oracle contract for this market</td></tr><tr><td>irm</td><td>address</td><td>The address of the Interest Rate Model contract for this market</td></tr><tr><td>lltv</td><td>uint256</td><td>The Liquidation Loan-to-Value ratio for this market (in WAD, e.g., 0.8 * 1e18 for 80%)</td></tr></tbody></table>

### Market Creation Fee

The `createMarket` function is `payable`, which means you need to send ETH along with the transaction. The required amount is stored in the `marketCreationFee` variable of the Bank contract. Make sure to include this fee when calling the function.

### Steps to Create a Market

1. Prepare the `MarketConfigs` struct with the necessary parameters.
2. Determine the current `marketCreationFee` by calling the `marketCreationFee()` function on the Bank contract.
3. Call the `createMarket` function with the prepared `MarketConfigs` and include the `marketCreationFee` as the transaction value.

### Example (using ethers.js)

```typescript
const Bank = // ... initialize Bank contract instance

// Prepare MarketConfigs
const marketConfigs = {
  loanToken: "0x...",       // Address of the loan token
  collateralToken: "0x...", // Address of the collateral token
  oracle: "0x...",          // Address of the price oracle
  irm: "0x...",             // Address of the Interest Rate Model
  lltv: ethers.utils.parseUnits("0.8", 18) // 80% LLTV
}

// Get the market creation fee
const marketCreationFee = await Bank.marketCreationFee()

// Create the market
const tx = await Bank.createMarket(marketConfigs, { value: marketCreationFee })
const receipt = await tx.wait()

// Get the new market ID from the event
const event = receipt.events.find(e => e.event === 'CreateMarket')
const newMarketId = event.args.id
console.log(`New market created with ID: ${newMarketId}`)
```

### Important Notes

* Ensure that the oracle and IRM addresses are valid and compatible with the Bank contract.
* The IRM (Interest Rate Model) must be registered with the Bank contract before creating a market. Use the `registerIrm` function to register a new IRM if needed.
* The LLTV (Liquidation Loan-to-Value) ratio should be set carefully as it affects the risk parameters of the market.
* Make sure you have sufficient ETH to cover the `marketCreationFee`.

After successfully creating a market, you can use the returned market ID for other operations such as supplying assets, borrowing, or managing collateral within that specific market.


# How to create a bank

You can create a new custom Bank using the BankFactory contract. This process involves calling the `createBank` function and specifying various parameters to configure the initial settings of the Bank.

### Function Signature

```solidity
function createBank(
    IERC20 asset,
    string memory name,
    string memory symbol,
    uint256 initialFee,
    address initialFeeRecipient,
    uint256 minDelay,
    IBank.BankType bankType
) external returns (Bank)
```

### Parameters

<table><thead><tr><th width="188">Parameter</th><th width="153">Type</th><th>Description</th></tr></thead><tbody><tr><td>asset</td><td>IERC20</td><td>The address of the base asset (token) to be used in the Bank</td></tr><tr><td>name</td><td>string</td><td>The name of the Bank</td></tr><tr><td>symbol</td><td>string</td><td>The symbol of the Bank</td></tr><tr><td>initialFee</td><td>uint256</td><td>Initial fee setting (max 1000, which represents 10%)</td></tr><tr><td>initialFeeRecipient</td><td>address</td><td>The initial address to receive fees</td></tr><tr><td>minDelay</td><td>uint256</td><td>Minimum delay for timelock operations (in seconds)</td></tr><tr><td>bankType</td><td>IBank.BankType</td><td>Type of the Bank (Public or Private)</td></tr></tbody></table>

### Returns

* `Bank`: The address of the newly created Bank contract

### Usage Example (using ethers.js)

```typescript
const BankFactory = // Initialize BankFactory contract instance

// Prepare parameters
const asset = "0x..."; // Base asset token address
const name = "My Bank";
const symbol = "MBNK";
const initialFee = 100; // 1% fee
const initialFeeRecipient = "0x..."; // Fee recipient address
const minDelay = 86400; // 1 day
const bankType = 0; // 0: Public, 1: Private

// Create Bank
const tx = await BankFactory.createBank(
    asset,
    name,
    symbol,
    initialFee,
    initialFeeRecipient,
    minDelay,
    bankType
);

const receipt = await tx.wait();

// Extract new Bank address from event
const bankCreatedEvent = receipt.events.find(e => e.event === 'BankCreated');
const newBankAddress = bankCreatedEvent.args.bank;
console.log(`New Bank created at: ${newBankAddress}`);
```

### Important Notes

* `initialFee` should be a value between 0 and 1000 (0% - 10%).
* `minDelay` should be set carefully. Too short may pose security risks, while too long may cause operational inconvenience. (minimum: 600 seconds)
* If creating a Private Bank (type: 1), subsequent whitelist management will be necessary.
* After creating the Bank, you need to add the required Markets and set allocations.

### Event

A `BankCreated` event is emitted when a Bank is created:

```solidity
event BankCreated(
    address indexed bank,
    address indexed asset,
    string name,
    string symbol
);
```

You can monitor this event to track the creation of new Banks.

After creating a Bank, you can use its address to perform additional setup and management operations.


# Interest Rate Model

### Overview

The Bank contract allows for the use of custom Interest Rate Models (IRMs) to calculate borrow rates for different markets. This feature enables flexible and dynamic interest rate calculations tailored to specific market conditions.

### InterestRateModel Interface

Custom IRMs must implement the `IInterestRateModel` interface:

```solidity
solidityCopyinterface IInterestRateModel {
    function isIrm() external view returns (bool);
    function borrowRate(MarketConfigs memory marketConfigs, Market memory market) external returns (uint256);
    function borrowRateView(MarketConfigs memory marketConfigs, Market memory market) external view returns (uint256);
}
```

#### Key Functions

1. `isIrm()`: Validates that the contract is a legitimate IRM.
2. `borrowRate()`: Calculates and returns the current borrow rate. This function may modify the contract state.
3. `borrowRateView()`: Similar to `borrowRate()`, but doesn't modify the contract state.

### Creating a Custom IRM

To create a custom IRM:

1. Implement the `IInterestRateModel` interface.
2. Define your interest rate calculation logic in the `borrowRate()` and `borrowRateView()` functions.
3. Ensure `isIrm()` returns `true`.

Example:

```solidity
solidityCopycontract MyCustomIRM is IInterestRateModel {
    using WadMath for uint128;

    function isIrm() external pure returns (bool) {
        return true;
    }

    function borrowRateView(MarketConfigs memory, Market memory market) public pure returns (uint256) {
        if (market.totalSupplyAssets == 0) return 0;
        uint256 utilization = market.totalBorrowAssets.divWadDown(market.totalSupplyAssets);
        return utilization / 365 days;
    }

    function borrowRate(MarketConfigs memory marketConfigs, Market memory market) external pure returns (uint256) {
        return borrowRateView(marketConfigs, market);
    }
}
```

### Registering and Using a Custom IRM

1. Deploy your custom IRM contract.
2. The DAO must register the IRM with the Bank contract using the `registerIrm()` function:

   ```solidity
   solidityCopyfunction registerIrm(address irm, bool isIrm) external onlyOwner;
   ```
3. Once registered, you can use the IRM when creating a new market:

   ```solidity
   solidityCopyfunction createMarket(MarketConfigs memory marketConfigs) external payable returns (uint256);
   ```

   Include the address of your registered IRM in the `marketConfigs.irm` field.

### Important Notes

* Only IRMs registered by the DAO can be used in market creation.
* Ensure your IRM calculations are accurate and gas-efficient.
* Test your IRM thoroughly before deployment to avoid potential issues in live markets.
* The Bank contract will call the IRM's `borrowRate()` function during interest accrual, so make sure it handles all possible market states correctly.

By following these guidelines, you can create and integrate custom Interest Rate Models to suit various market strategies and conditions within the Bank ecosystem.


# Oracle

### Overview

The Bank contract allows for the use of custom Price Providers (also known as Oracles) to provide price information for collateral tokens in different markets. This feature enables flexible and accurate price feeds tailored to specific assets and market conditions.

## Supported Oracles&#x20;

### Soneium Mainnet

#### Chainlink&#x20;

<table><thead><tr><th width="163">Pair</th><th>Address</th></tr></thead><tbody><tr><td>ASTR/USDC</td><td>0xd8cf9e97A5A695D778548F20317cBb8ac742EAcF</td></tr><tr><td>ETH/USDC</td><td>0xeF28882E99D08F19d6Bd2A6C3677b989DdDE02C2</td></tr><tr><td>LINK/USDC</td><td>0x8B7201C096c52D617Aef8c93111D20623Aa6D7d2</td></tr><tr><td>USDC/LINK</td><td>0xE4C355CFB514755845DcD8780eEF57924b3c280f</td></tr><tr><td>USDC/ETH</td><td>0x398b39819c133D40A5F09b82efAa5F62159F6C19</td></tr><tr><td>USDC/ASTR</td><td>0x26BD767fC3bd1DE7be92bfD31AD41D361C1B0560</td></tr><tr><td>ASTR/ETH</td><td>0x70cAFdABe3a39644450d12fd30A37C84440b2023</td></tr><tr><td>ETH/ASTR</td><td>0x2d57521A2aBd60f9d9E0BD76fd3dBBE75c982206</td></tr></tbody></table>

(Chainlink's Primary Oracle sources can be found [here](https://docs.chain.link/data-feeds/price-feeds/addresses?network=soneium\&page=1).)

#### Pyth

<table><thead><tr><th width="162">Pair</th><th>Address</th></tr></thead><tbody><tr><td>ASTR/USDC</td><td>0xF6401B78c514Ab49Cc28fAd71fe958889Df449Da</td></tr><tr><td>ETH/USDC</td><td>0xe5dfA038EeaD1c0C717b112AF72994cf271369e8</td></tr><tr><td>USDC/ETH</td><td>0x2e59F5C6A69B7Cc3C00d5918E1Eabd550A126D16</td></tr><tr><td>USDC/ASTR</td><td>0x94fdbde6030Ae150d83a19aEf28E3680bf7cEfdA</td></tr><tr><td>ASTR/ETH</td><td>0xc63C1A77414D5e0F9dFD19cfE30aF31FF75681d1</td></tr><tr><td>ETH/ASTR</td><td>0xf47A07422a0300fefeBE8c3442C8A8D7bf0aE5dd</td></tr></tbody></table>

### Soneium Minato Testnet

#### Chainlink&#x20;

<table><thead><tr><th width="163">Pair</th><th>Address</th></tr></thead><tbody><tr><td>ASTR/USDC</td><td>0x0878EAe664c025bA9973aefAb95c08472caE52Bd</td></tr><tr><td>ETH/USDC</td><td>0x92C87643c91CA8C1B3C1dC36f797Bf9856CBae79</td></tr><tr><td>LINK/USDC</td><td>0x12F91388568b21fC26A1c18f9a9996aDF08C0E6c</td></tr><tr><td>USDC/LINK</td><td>0x9644EeF4428CA5d1Da41EE8AE6473E9ddE97fd69</td></tr><tr><td>USDC/ETH</td><td>0xD3C18CE12bEC4D668b824089601f6ccAC6377Ba2</td></tr><tr><td>USDC/ASTR</td><td>0xFCc2b860Cb0844cafAdE640DD3424aDeC2e2e11C</td></tr><tr><td>ASTR/ETH</td><td>0x301477d93Da128ad8543F00CF84f3262a9B8A0A0</td></tr><tr><td>ETH/ASTR</td><td>0xB4Ff6D357CCc62bD37BeC22F0350219F00a5555b</td></tr></tbody></table>

#### Pyth

<table><thead><tr><th width="162">Pair</th><th>Address</th></tr></thead><tbody><tr><td>ASTR/USDC</td><td>0x2E435d5129709ACD69Eb32fffB196941cE82C09e</td></tr><tr><td>ETH/USDC</td><td>0x7fb8456a5482f1736EA3F77Ab64da356a17f5b45</td></tr><tr><td>USDC/ETH</td><td>0x4B6b6963328f33ca93Acad164E627A60A6938F5a</td></tr><tr><td>USDC/ASTR</td><td>0xB023666b82EAe12b99A4b9aAf320B5bfe34153C2</td></tr><tr><td>ASTR/ETH</td><td>0xa97cb0eD84F1Cf4a07bFD4f43Cfb6045674c6E99</td></tr><tr><td>ETH/ASTR</td><td>0x07f6693C8Cf6c5d019d328572dB89Fa063804bE0</td></tr></tbody></table>

### PriceProvider Interface

Custom Price Providers must implement the `IPriceProvider` interface:

```solidity
solidityCopyinterface IPriceProvider {
    function isPriceProvider() external view returns (bool);
    function getCollateralTokenPrice() external view returns (uint256 price);
}
```

#### Key Functions

1. `isPriceProvider()`: Validates that the contract is a legitimate Price Provider.
2. `getCollateralTokenPrice()`: Returns the current price of the collateral token denominated in the loan token.

### Creating a Custom Price Provider

To create a custom Price Provider:

1. Implement the `IPriceProvider` interface.
2. Define your price fetching logic in the `getCollateralTokenPrice()` function.
3. Ensure `isPriceProvider()` returns `true`.

Example:

```solidity
solidityCopycontract MyCustomPriceProvider is IPriceProvider {
    uint256 public price;
    address public owner;

    constructor() {
        owner = msg.sender;
    }

    function isPriceProvider() external pure returns (bool) {
        return true;
    }

    function getCollateralTokenPrice() external view returns (uint256) {
        return price;
    }

    function setCollateralTokenPrice(uint256 _price) external {
        require(msg.sender == owner, "Only owner can set price");
        price = _price;
    }
}
```

### Using a Custom Price Provider

1. Deploy your custom Price Provider contract.
2. When creating a new market, include the address of your Price Provider in the `marketConfigs.oracle` field:

   ```solidity
   solidityCopyfunction createMarket(MarketConfigs memory marketConfigs) external payable returns (uint256);
   ```

### Important Notes

* Unlike IRMs, Price Providers do not need to be registered with the Bank contract before use.
* Ensure your Price Provider returns prices in the correct denomination (collateral token price in terms of the loan token).
* The Bank contract will call the Price Provider's `getCollateralTokenPrice()` function during various operations, including liquidations, so make sure it's gas-efficient and always returns a valid price.
* For production use, consider implementing additional security measures such as:
  * Price update frequency limits
  * Multiple data sources for price information
  * Deviation checks to prevent sudden large price changes
  * Test your Price Provider thoroughly before deployment to avoid potential issues in live markets.
  * In the example above, the price is set manually. In a real-world scenario, you would typically fetch this data from reliable external sources.

### Security Considerations

* Ensure that only authorized entities can update the price in your Price Provider.
* Consider implementing circuit breakers or pause mechanisms for emergency situations.
* Regularly audit and monitor your Price Provider to ensure it's functioning correctly.

By following these guidelines, you can create and integrate custom Price Providers to provide accurate and reliable price data for various assets within the Bank ecosystem. This flexibility allows for the creation of markets with different collateral types while ensuring proper valuation for lending and liquidation purposes.


# Audit Report

Untitled Bank has been thoroughly audited by the leading global blockchain security companies, [ScaleBit](https://www.scalebit.xyz/) and [Besoin](https://beosin.com/).

{% file src="/files/3zB6zOAkkQ7ilWP2B4M0" %}
Audit Report from ScaleBit
{% endfile %}

{% file src="/files/jVae2Hjt8IjwWzj7gKU5" %}
Audit Report from Besoin
{% endfile %}


# Brand Asset

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2F3ahy10NBpFdwLLSqSKD4%2FSymbol_Logo_Primary%20(1).png?alt=media&amp;token=fcb4dcaa-877a-4d6f-a1cf-2be142f28a8f" alt="" width="188"><figcaption></figcaption></figure>

{% file src="/files/mX5uBJWlA9UC2TnP9CIe" %}

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2FVWbslYPQrxMHb6bakCvR%2FSignature_Logo_Horizontal_Light.svg?alt=media&amp;token=62eb84b7-3501-4c1f-9f1e-7b1a46b2999e" alt=""><figcaption></figcaption></figure>

{% file src="/files/tVy7jTTq3YqzJayj2qwm" %}

<figure><img src="https://3252989348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FN0J2kJZOrewonkLY6Dkj%2Fuploads%2Fjqh6acuE9pDH3HDEPjXV%2FSignature_Logo_Vertical_Light.svg?alt=media&amp;token=20af3440-3f6c-4aef-b4a2-30e5540a91bc" alt=""><figcaption></figcaption></figure>

{% file src="/files/XMWDV887cIbSkHXEzFDN" %}


# Risks for Lending Users

This section outlines the primary risks associated with Untitled Bank. By using this protocol, you acknowledge that you have read, understood, and accepted all risks outlined in this documentation.

#### **Smart contract risk**

Smart contract risk is inherent when using DeFi protocols. While smart contracts—self-executing code running on blockchains—are designed to be secure, they may contain vulnerabilities or bugs.

A flaw in smart contract code could allow attackers to exploit the protocol and steal funds, potentially resulting in losses for suppliers and borrowers. Given this significant risk in DeFi, users should thoroughly evaluate protocol security before participation.

#### **Liquidation**

When a borrowed amount exceeds the borrowing limit, the protocol allows liquidation—where a portion of the collateral is exchanged at market price with a liquidation discount. This mechanism incentivizes arbitrageurs to act quickly, reducing both borrower and protocol risk. The close factor (ranging from 0 to 1, typically 25%) determines how much of the borrowed asset can be repaid. Liquidations continue until the borrower's debt returns below their borrowing capacity. The liquidation incentive for our platform is min(50%, 1 - (1.4-0.4\*LLTV) ).

#### **Market risk of the protocol**

Borrowing from Untitled Bank's market requires "excess collateralization"—supplying collateral worth more than the borrowed amount. If collateral value falls below the borrowed amount before liquidators can act, borrowers lose the incentive to repay their position.

#### **100% Utilization Risk**

When an asset reaches 100% utilization (all supplied tokens are lent out), the pool becomes depleted. This prevents both withdrawals and new borrowing until the utilization rate decreases through loan repayments or new deposits. This risk particularly impacts users with large pool deposits or during periods of high borrowing demand.


