# How Bloom V2 Works

### Overview

The mechanics of Bloom V2 work similarly to a lending orderbook but with a multi-stage approach to support the three types of participants that make up the protocol, lenders, borrowers, and market makers.&#x20;

### Open Order

Open Orders are created whenever lenders lend to the `BloomPool`. When this occurs `USDC` is transferred to the `BloomPool` and held until the lender either cancels their order or a borrower matches their order request. Orders are grouped by the lenders address.

### Matched Order

Matched Orders are created whenever a borrower fills a lender's open order. Borrower's matches are leveraged, so they are not required to match the lender's full order size. Matched Orders are grouped by the lender's addresses as well as a secondary grouping of borrower's addresses who filled that specific lender's orders.&#x20;

Both lenders and borrowers can cancel match orders. If a lender cancels their matched order, the order will be closed out in a LIFO sequential method by the borrower that filled the order. During lender cancellations, the capital for borrowers does not get transferred back to them. Instead it will be converted to idle capital that can be used to fill future open orders, which can be withdrawn by the borrower at any time. If the borrower cancels an order, borrower's funds are transferred back to them and the lender's matched order gets converted to an open order.

Once an order is matched it is eligible to be turned into a `TBY` and start generating yield. This is done by market makers filling this request in batches lasting `48 hours`.

### Live Orders

Matched Orders are converted into live orders as the market maker begins swapping `bIb01` tokens into the `BloomPool` in exchanged for `USDC` . The market maker has `48 hours` to complete as many orders as they would like. As the swaps occur, lenders will be minted `TBY`s representing their deposit into the system that will generate interest. These `TBY`s have a start time of `48 hours` after the first swap in a batch has occurred and a maturity date `180 days` after the start time.&#x20;

Live orders; `TBY`s cannot be canceled or redeemed early as it is a fixed-maturity commercial loan and is locked for that time period.&#x20;

### Matured Orders

At the end of the `180 days` `TBY`s will mature and market makers can fulfill their duties swapping `USDC` back into the `BloomPool` for `bIb01` tokens. This can occur at any time and in any number of batches. Lender's and borrower's must wait for all rwa collateral to be swapped from a given `tbyId` before their collateral and yield is redeemable.
