elsina✅ DeFi: 1. Total - single number
    Updated 2023-03-27
    -- credit to Abbas_ra21: https://app.flipsidecrypto.com/velocity/queries/699fa39b-8da5-4b4d-be3d-5945d79bbae7
    -- credit to whaen: https://app.flipsidecrypto.com/velocity/queries/808469ed-6c97-432e-84d6-3b7d21d694f3
    with
    uniswap_swaps_log as (
    select
    block_timestamp,
    tx_hash, origin_function_signature,
    router_address,
    swapper, index_group,
    max_row_num,
    tx_fee,
    max(sender) as sender,
    max(recipient) as recipient,
    max(pool_address) as pool_address,
    max(in_amount) as in_amount,
    max(in_decimals) as in_decimals,
    max(in_token_address) as in_token_address,
    max(in_token_symbol) as in_token_symbol,
    max(out_amount) as out_amount,
    max(out_decimals) as out_decimals,
    max(out_token_address) as out_token_address,
    max(out_token_symbol) as out_token_symbol,
    min(index_group) over (partition by tx_hash) as min_index_grp,
    max(index_group) over (partition by tx_hash) as max_index_grp
    from (
    select *, max(row_num) over (partition by tx_hash) as max_row_num
    from (
    select
    a.block_timestamp,
    a.tx_hash, a.origin_function_signature,
    origin_to_address as router_address,
    row_number() over (partition by a.tx_hash order by event_index asc) as row_num,
    row_num%3 as index, ceil(row_num/3) as index_group,
    origin_from_address as swapper,
    contract_address,
    iff(index = 1 and event_name = 'Transfer' and event_inputs:value is not null, event_inputs:value, null) as out_amount,