ali_lifiBase- FlashLoan
    Updated 2025-01-15
    -- forked from Base @ https://flipsidecrypto.xyz/studio/queries/57c4b0db-ab5a-4b71-b727-d951e5ff6ed0

    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
    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.event_name = 'LiFiGenericSwapCompleted'
    AND b.event_name = 'FlashLoan' -- 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
    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.event_name = 'LiFiGenericSwapCompleted'
    AND b.event_name = 'FlashLoan'
    UNION ALL
    SELECT a.*, 'BSC' as chain FROM bsc.core.ez_decoded_event_logs a, bsc.core.ez_decoded_event_logs b
    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.event_name = 'LiFiGenericSwapCompleted'
    AND b.event_name = 'FlashLoan'
    UNION ALL
    SELECT a.*, 'BASE' as chain FROM base.core.ez_decoded_event_logs a, base.core.ez_decoded_event_logs b
    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.event_name = 'LiFiGenericSwapCompleted'
    AND b.event_name = 'FlashLoan'
    UNION ALL
    QueryRunArchived: QueryRun has been archived