lending_pool_total_supply
Schema: lib_lending
Description
This function is used to retrieve the latest total supply in each time bucket for lending pool contract(s). It returns the latest
total supply for each time bucket for each contract. Time window are driven by the start_time
, end_time
, and interval
inputs
A few variants of this function function exist:
lending_pool_total_supply
accepting a single contract address as input: This allows pulling total supply over time for a single lending pool contract- An overload for
lending_pool_total_supply
accepting an array of contract addresses: This allows pulling total supply over time for a list of lending pool contracts lending_pool_total_supply_for_company
: This allows pulling total supply over time for all lending pool contracts belonging to a specific company
Usage
Signature
Pull total supply over time for a single contract:
lib_lending.lending_pool_total_supply(contract text, start_time timestamptz, end_time timestamptz, bucket_width interval)
Pull total supply over time for a multiple contracts:
lib_lending.lending_pool_total_supply(contracts text[], start_time timestamptz, end_time timestamptz, bucket_width interval)
Pull total supply over time for all lending pool contracts belonging to a specific company:
lib_lending.lending_pool_total_supply_for_company(company text, start_time timestamptz, end_time timestamptz, bucket_width interval)
Parameters
Name | Type | Description |
---|---|---|
contract | text | The address of the lending pool contract |
start_time | timestamptz | The earliest datapoint time to use when filtering total supplies |
end_time | timestamptz | The latest datapoint time to use when filtering total supplies |
bucket_width | interval | The interval to use when grouping total supplies. Only the latest total supply in each interval will be returned |
Results
The function returns a table with the following columns:
Column | Type | Description |
---|---|---|
contract | text | The address of the lending pool contract |
bucket_time | timestamptz | The time bucket to use forgroup total supplies |
total_supply_in_underlying | numeric | The total supply in the underlying currency |
total_supply_in_usd | numeric | The total supply in USD |
Examples
Example 1: Retrieve daily total supply for a specific lending pool contract
select *
from lib_lending.lending_pool_total_supply(
'0x123abc',
now() - '1 week'::interval,
now(),
'1 day'
);
Example 2: Retrieve hourly total supply for multiple lending pool contracts
select * from lib_lending.lending_pool_total_supply(
array['0x123abc', '0x456def'],
now() - '2 days',
now(),
'1 hour'
);
Example 3: Retrieve hourly total supply for all lending pool contracts operated by company XYZ
select *
from lib_lending.lending_pool_total_supply_for_company(
'XYX',
now() - '2 days',
now(),
'1 hour'
);