Skip to main content

active_address_associations_for_protocol

Schema: lib

Description

This function retrieves the latest address associations for a given protocol. It can also be constrained by association type and chain. Address associations help map an address to other associated addresses. For example, if a loan protocol creates a dedicated contract for your loan, address associations can map your address to the loan contract's address. This allows modeling more complicated relationships between accounts.

Usage

Signature

lib.active_address_associations_for_protocol(
protocol_to_find text,
association_type_to_find text,
chain_to_find text
)

Parameters

NameTypeDescription
protocol_to_findtextThe name of the protocol to find associations for (e.g. 'DeltaPrime')
association_type_to_findtext(Optional) The type of association to search for (e.g. 'Smart loan')
chain_to_findtext(Optional) The chain to search for (e.g. 'arbitrum')

Results

This function returns a table with the following columns:

ColumnTypeDescription
idcharacterThe ID of the address association
updated_timetimestamptzThe time the association was last updated
chaintextThe chain of the association
addresstextThe address for the association
associated_addresstextThe address associated with the previous address
protocoltextThe protocol (e.g. 'DeltaPrime')
association_typetextThe type of association (e.g. 'Smart loan')
contextjsonbAny additional context for the association

Examples

Retrieve all address associations for the protocol "DeltaPrime"
select *
from lib.active_address_associations_for_protocol('DeltaPrime');
Retrieve all address associations for the protocol "DeltaPrime" with the association type "Smart loan" on the "arbitrum" chain
select *
from lib.active_address_associations_for_protocol(
'DeltaPrime',
'Smart loan',
'arbitrum'
);

Similarly, with named parameters

select *
from lib.active_address_associations_for_protocol(
protocol_to_find => 'DeltaPrime',
association_type_to_find => 'Smart loan',
chain_to_find => 'arbitrum'
);
Retrieve all address associations for the protocol "DeltaPrime" with the association type "Smart loan" on all chains
select *
from lib.active_address_associations_for_protocol(
'DeltaPrime',
'Smart loan'
);

Similarly, with named parameters

select *
from lib.active_address_associations_for_protocol(
protocol_to_find => 'DeltaPrime',
association_type_to_find => 'Smart loan'
);