Skip to main content

lending_pool_summaries_for_company

Schema: lib_lending

Description

This function allows you to retrieve lending pool summaries for all lending pools within a lending protocol. These summaries include total supply, total borrows, total reserves, and the price of the underlying token. This information can be useful for analyzing the overall health and activity of a lending protocol.

Usage

Signature

lib_lending.lending_pool_summaries_for_company(
company text,
start_time timestamptz default now() - '1 week'::interval
)

Parameters

NameTypeDescription
companytextThe name of the company whose lending pool summaries you want to retrieve.
start_timetimestamptzOnly consider data points that occurred at or after this specific time. The assumption is lending pools are updated regularly, so you can generally set this to a value like now() - '1 week'::interval to get query results faster

Results

The function returns a table with the following columns:

NameTypeDescription
contracttextThe address of the lending pool contract
symboltextThe symbol of the lending pool
underlying_symboltextThe symbol of the underlying token.
updated_timetimestamptzThe timestamp of when the data was last updated.
pricenumericThe price of the underlying token.
total_supplynumericThe total amount of underlying token supplied to the lending pool.
total_cashnumericThe total amount of underlying token available for borrow.
total_borrowsnumericThe total amount of underlying token borrowed from the lending pool.
total_reservesnumericThe total amount of underlying token held in reserve by the lending protocol.
total_supply_usdnumericThe USD value of the total amount of underlying token supplied to the lending pool.
total_cashnumericThe USD value of the total underlying token available for borrow.
total_borrows_usdnumericThe USD value of the total underlying token borrowed from the lending pool.
total_reserves_usdnumericThe USD value underlying token held in reserve by the lending protocol.

Examples

Retrieve lending pool summaries for a specific company
select * from lib_lending.lending_pool_summaries_for_company('company_name');
Retrieve lending pool summaries for a company ABC with a custom start time
select * from lib_lending.lending_pool_summaries_for_company('ABC', now() - '3 days'::interval);