A lending limit order book is a non-custodial and permissionless order book that enables users to place and borrow the assets from limit orders. Borrowing positions are collateralized by sell orders.
We have presented in previous posts its advantages. To mention a few, it provides lenders with interest rate-bearing limit orders and borrowers with stop-loss and take profit orders. It reduces liquidation penalties and enables high leverage. In addition to these benefits, the protocol is natively protected against the risks of bad debt and can operate with minimal governance. In this post, we explain in more detail the operation of lending.
The diagram presents the double queue organization of a central limit order book to which a lending functionality is attached.

On the left-hand side, lenders place buy orders at the limit price they deem appropriate. Borrowers can borrow the assets deposited in the buy orders in exchange for an interest rate. Rectangles' height indicate the amount of assets lenders have deposited in the different pools of orders. The orange rectangles represent the assets which are borrowable from the pool of buy orders. On the right-hand side, borrowers place their collateral as sell orders.
To concentrate liquidity, lenders are permitted to deposit assets within a restricted set of limit prices. A pool of limit orders groups all assets deposited at the same limit price. Allowing users to deposit and borrow from the pools, rather than from individual orders enables capital efficiency and scalability. Lenders can withdraw their orders whenever they wish, unless the pool is fully borrowed, in which case the interest rate will be high.
Let's illustrate how a lending operation works in the simplest scenario of two actors and two orders. Market price is 3100.
Alice posts a buy order of 9000 USDC at limit price 3000. This order is placed in Pool₃₀₀₀. Its capital is added to the liquidity provided by all other buy orders posted at the same limit price.
Bob is willing to borrow USDC from the Pool₃₀₀₀. He deposits 2 ETH in sell order at limit price 3300 in the Pool₃₃₀₀ or any other pool of orders with a limit price greater than market price. With the collateral, Bob can borrow from the Pool₃₀₀₀ up to 6000 USDC (=2✕3000).

What happens if the price decreases below 3000?
A taker swaps some of the non-borrowed USDC from Pool₃₀₀₀ which triggers the liquidation of the borrowing positions from Pool₃₀₀₀ including Bob’s position. Bob keeps the borrowed USDC and his 2 ETH of collateral are transferred to the lenders of the Pool₃₀₀₀. Alice’s buy order is filled and Alice receives 3 ETH from takers and/or borrowers.

Nothing changes for Alice compared to a classical buy order. Importantly, Bob's assets are not sold in the market but directly transferred to lenders in Pool₃₀₀₀ who are repaid with the collateral. This way, the protocol ensures that any position borrowing from a pool of orders can be liquidated when remaining assets in the pool are taken. The alignment of the two events, the liquidation of Bob and the filling of Alice’s order, greatly streamlines the settlement process for all parties.
Now what happens if, instead, the price increases to 3300?
Bob's limit order, with 2 ETH serving as collateral, is filled. His borrowing position is automatically closed out, as illustrated in the next diagram.

Why does the filling of borrowers’ sell orders trigger the repayment of their debt?
For three reasons. First, closing the borrowing position guarantees that the type of assets serving as collateral always matches the type needed in case of liquidation. Second, by posting collateral at a limit price of their choice, borrowers expect the price to fall back after crossing the limit price. Given these expectations, there is no reason to maintain a long position in this scenario. Third, borrowers have the option to program the closing of their long in advance based on a price scenario. This way, they know from the start the price at which their position will be liquidated if the price decreases or closed for a profit if the price increases.
This post is part of a series aimed at explaining the various aspects of the protocol. Make sure to follow our X account and join the Discord for updates!
If you want to learn more about LendBook, check out the white paper or the documentation!

