Orderbook

Overview

The Orderbook contains modified order-book functionality, matching lenders to borrower within the BloomPool .

Contract API

openDepth

function openDepth(uint256 amount) external;

Returns the current total depth of open orders in terms of asset tokens.

amountOpen

function amountOpen(address account) external view returns (uint256);

Returns the total amount of underlying assets in open orders for a users account.

lendOrder

function lendOrder(uint256 amount) external;

Opens a lend order for a user.

Users have the right at anytime to cancel their lend order and withdraw their assets.

Assets will be transferred to the BloomPool contract when executing this function, but no receipt token will be given. TBYs are only minted after orders have been matched and market makers have performed their swaps.

killOpenOrder

function killOpenOrder(uint256 amount) external;

Allows users to cancel their open lend order and withdraw their underlying assets.

matchedDepth

function matchedDepth() external view returns (uint256);

Returns the current total depth of matched orders.

amountMatched

function amountMatched(address account) external view returns (uint256 amount);

Returns the total amount of underlying assets in matched orders for a users account.

matchedOrder

function matchedOrder(address account, uint256 index) external view returns (MatchOrder memory);

Returns the matched order details for a users account in the form of a MatchOrder struct.

/**
 * @notice Struct to store the details of a lend order that has been matched.
 * @param lCollateral The amount of underlying assets the lender used as collateral.
 * @param bCollateral The amount of underlying assets the borrower used as collateral.
 * @param borrower The address of the borrower who filled the order.
*/
struct MatchOrder {
   uint128 lCollateral;
   uint128 bCollateral;
   address borrower;
}

matchedOrderCount

function matchedOrderCount(address account) external view returns (uint256);

Returns the number of matched orders for a users account.

killMatchOrder

function killMatchOrder(uint256 amount) external returns (uint256 totalRemoved);

Allows users to cancel their match lend orders and withdraw their underlying assets.

Returns the totalRemoved amount in terms of asset tokens.

killBorrowerMatch

function killBorrowerMatch(address lender) external returns (uint256 lenderAmount, uint256 borrowerReturn);

Allows borrowers to cancel their match orders and withdraw their underlying assets

Returns the lenderAmount and borrowerReturn in terms of underlying assets that were returned to the various users.

fillOrder

This is a permissioned function. Only KYCed borrowers can call this function.

function fillOrder(address account, uint256 amount) external returns (uint256 filled);

Allows borrowers to fill a single accounts lend order with a specified amount of underlying assets.

Returns the amount of liquidity filled in terms of asset tokens.

fillOrders

This is a permissioned function. Only KYCed borrowers can call this function.

function fillOrders(address[] calldata accounts, uint256 amount) external returns (uint256 filled);

Allows borrowers to fill a multiple accounts lend orders with a specified amount of underlying assets.

Returns the amount of liquidity filled in terms of asset tokens.

idleCapital

function idleCapital(address account) external view returns (uint256);

Returns the idle capital of the borrower.

withdrawIdleCapital

function withdrawIdleCapital(uint256 amount) external;

Allows borrowers to withdraw idle capital from the system.

Last updated