Macros: Utility: Lookbacks - FlipsideCrypto/fsc-evm GitHub Wiki
The following macros are intended to be used to create and maintain various models. These macros can be accessed via version >=v1.0.0
of the fsc-evm
package. Please see the fsc-evm
installation instructions in the README for more details on how to access and utilize this macro effectively.
These Lookback macros are intended to be used to as support for Streamline, Observability or other models, and contain standardized SQL logic with flexible parameters.
block_lookback_24_hour
Usage
This macro retrieves the minimum block number from the last 24 hours based on the maximum block timestamp in the silver__blocks
table. It uses a CTE to determine the maximum timestamp and then filters blocks that fall within the 24 to 25-hour range. This is typically referenced alongside the Decoder History models.
fsc_evm.block_lookback_24_hour
Parameters
Note: Parameters with default
values must be ordered after non-default parameters.
This macro does not have any parameters.
Example:
{{ fsc_evm.block_lookback_24_hour() }}
block_lookback_72_hour
Usage
This macro retrieves the minimum block number from the last 72 hours. It filters blocks in the silver__blocks
table where the block timestamp is greater than or equal to 72 hours ago and less than 71 hours ago, effectively capturing the relevant block range. This is typically referenced within the Realtime and History Request models to filter requests before or after the last 3 days of blocks.
fsc_evm.block_lookback_72_hour
Parameters
Note: Parameters with default
values must be ordered after non-default parameters.
This macro does not have any parameters.
Example:
{{ fsc_evm.block_lookback_72_hour() }}
max_block_by_date
Usage
This macro retrieves the maximum block number for each date from the silver__blocks
table. It groups the results by date and excludes the most recent date. This is another method typically used in the Realtime and History Request models to filter requests before or after the last 3 days of blocks.
Parameters
Note: Parameters with default
values must be ordered after non-default parameters.
This macro does not have any parameters.
Example:
{{ fsc_evm.max_block_by_date() }}
max_block_by_hour
Usage
This macro retrieves the maximum block number for each hour from the silver__blocks
table over the last five days. It groups the results by hour and excludes the most recent hour. This is typically used in confirmed_blocks
models to delay requests by 6 hours.
Parameters
Note: Parameters with default
values must be ordered after non-default parameters.
This macro does not have any parameters.
Example:
{{ fsc_evm.max_block_by_hour() }}