SocioCryptoUsers Groups by Action
    Updated 2023-09-01
    -- forked from Users Actions @ https://flipsidecrypto.xyz/edit/queries/09823c2f-5a14-4f90-b9d6-40795d02512d

    with swap_addliquidity as (
    SELECT
    DISTINCT tx_id as tx,
    block_timestamp,
    b.address_name
    FROM sei.core.fact_msg_attributes a
    LEFT JOIN sei.core.dim_labels b ON a.ATTRIBUTE_VALUE = b.address
    WHERE ATTRIBUTE_KEY = '_contract_address'
    AND ATTRIBUTE_VALUE IN (SELECT address FROM sei.core.dim_labels WHERE label ilike 'fuzio')
    ),
    total_user as (
    SELECT
    tx_id,
    ATTRIBUTE_VALUE as trader
    FROM sei.core.fact_msg_attributes
    WHERE tx_id IN (SELECT tx FROM swap_addliquidity)
    AND ATTRIBUTE_KEY = 'fee_payer'
    )
    ,
    swap as (
    SELECT b.*
    FROM sei.core.fact_msg_attributes a
    INNER JOIN swap_addliquidity b ON a.tx_id = b.tx
    WHERE ATTRIBUTE_KEY = 'action' AND ATTRIBUTE_VALUE = 'swap'
    )
    ,
    add_liquidity as (
    SELECT b.*
    FROM sei.core.fact_msg_attributes a
    INNER JOIN swap_addliquidity b ON a.tx_id = b.tx
    WHERE ATTRIBUTE_KEY = 'action' AND ATTRIBUTE_VALUE = 'add_liquidity'
    )
    ,
    remove_liqudity as (