ali_lifiBase - Collateral Swap
    Updated 2025-01-15
    WITH
    same_chain_txns as (
    SELECT a.*, 'Arbitrum' as chain FROM arbitrum.core.ez_decoded_event_logs a, arbitrum.core.ez_decoded_event_logs b, arbitrum.core.ez_decoded_event_logs c
    WHERE a.block_timestamp between current_date -31 AND current_date-1
    AND b.block_timestamp between current_date -31 AND current_date-1
    -- AND a.origin_to_address = '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae'
    AND a.tx_hash = b.tx_hash and a.tx_hash = c.tx_hash
    AND a.event_name = 'LiFiGenericSwapCompleted'
    AND b.event_name = 'ReserveUsedAsCollateralEnabled' -- in ('ReserveUsedAsCollateralEnabled', 'ReserveUsedAsCollateralDisabled')
    AND c.event_name = 'ReserveUsedAsCollateralDisabled' --in ('ReserveUsedAsCollateralEnabled', 'ReserveUsedAsCollateralDisabled')
    UNION ALL
    SELECT a.*, 'OP' as chain FROM optimism.core.ez_decoded_event_logs a,optimism.core.ez_decoded_event_logs b,optimism.core.ez_decoded_event_logs c
    WHERE a.block_timestamp between current_date -31 AND current_date-1
    AND b.block_timestamp between current_date -31 AND current_date-1
    -- AND a.origin_to_address = '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae'
    AND a.tx_hash = b.tx_hash and a.tx_hash = c.tx_hash
    and a.event_name = 'LiFiGenericSwapCompleted'
    AND b.event_name = 'ReserveUsedAsCollateralEnabled'
    AND c.event_name = 'ReserveUsedAsCollateralDisabled'
    UNION ALL
    SELECT a.*, 'BSC' as chain FROM bsc.core.ez_decoded_event_logs a, bsc.core.ez_decoded_event_logs b , bsc.core.ez_decoded_event_logs c
    WHERE a.block_timestamp between current_date -31 AND current_date-1
    AND b.block_timestamp between current_date -31 AND current_date-1
    -- AND a.origin_to_address = '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae'
    AND a.tx_hash = b.tx_hash and a.tx_hash = c.tx_hash
    and a.event_name = 'LiFiGenericSwapCompleted'
    AND b.event_name = 'ReserveUsedAsCollateralEnabled'
    AND c.event_name = 'ReserveUsedAsCollateralDisabled'
    UNION ALL
    SELECT a.*, 'BASE' as chain FROM base.core.ez_decoded_event_logs a, base.core.ez_decoded_event_logs b, base.core.ez_decoded_event_logs c
    WHERE a.block_timestamp between current_date -31 AND current_date-1
    AND b.block_timestamp between current_date -31 AND current_date-1
    -- AND a.origin_to_address = '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae'
    AND a.tx_hash = b.tx_hash and a.tx_hash = c.tx_hash
    and a.event_name = 'LiFiGenericSwapCompleted'
    AND b.event_name = 'ReserveUsedAsCollateralEnabled'
    QueryRunArchived: QueryRun has been archived