Skip to main content

participant_balances_for_company

Schema: lib_lending

Description

This function retrieves the lend and borrow balances for each participant in the lending protocol for a given company. It retrieves raw LP/underlying values for lend and borrow, but also converts those values into both decimaled underlying values and USD equivalents.

Usage

Signature

lib_lending.participant_balances_for_company(company text, include_lending_pool_as_participant boolean, include_zero_balances boolean)

Parameters

NameTypeDescription
companytextThe name of the company; participant balances will be pulled for all participants in any of the company's lending pools
include_lending_pool_as_participantbooleanOptional parameter to include the lending pool as a participant in the results
include_zero_balancesbooleanOptional parameter to include zero balances in the results

Results

The function returns a table with the following columns:

  • contract: The contract address of the lending pool
  • symbol: The symbol of the underlying token
  • participant: The address of the participant
  • raw_lp_token_lend_balance: The lend balance in LP tokens, represented as a fixed-point big number
  • underlying_lend_balance: The lend balance in the underlying token, represented with decimals applied
  • usd_lend_balance: The lend balance in USD
  • raw_underlying_borrow_balance: The borrow balance in underlying tokens, represented as a fixed-point big number
  • underlying_borrow_balance: The borrow balance in underlying tokens, represented with decimals applied
  • usd_borrow_balance: The borrow balance in USD

Examples

Get participant balances for all participants in company XYZ's pools
select *
from lib_lending.participant_balances_for_company('XYZ');
Get participant balances for all participants in company XYZ's pools including zero-balances and lending contracts
select *
from lib_lending.participant_balances_for_company(
'XYZ',
include_lending_pool_as_participant=>true,
include_zero_balances=>true
);