# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.untitledbank.co/developer-docs/how-to-create-a-bank.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
