SocioAnalyticaFees on LSTs Pool
    Updated 2024-05-07
    with protocol_fee as (
    select
    date_trunc('day',block_timestamp) as day,
    pool_address,
    token,
    protocolFeeAmount
    from (
    select
    block_timestamp,
    DECODED_LOG : poolId as pool_id,
    substr(DECODED_LOG : poolId, 1, 42) as pool_address,
    decoded_log : tokens[0] :: string as token,
    decoded_log : protocolFeeAmounts [0] :: int as protocolFeeAmount
    from avalanche.core.ez_decoded_event_logs
    where event_name = 'PoolBalanceChanged'
    and contract_address = '0xba12222222228d8ba445958a75a0704d566bf2c8'
    and
    TX_STATUS = 'SUCCESS'
    union all
    select
    block_timestamp,
    DECODED_LOG : poolId as pool_id,
    substr(DECODED_LOG : poolId, 1, 42) as pool_address,
    decoded_log : tokens[1] :: string as token,
    decoded_log : protocolFeeAmounts [1] :: int as protocolFeeAmount
    from avalanche.core.ez_decoded_event_logs
    where event_name = 'PoolBalanceChanged'
    and contract_address = '0xba12222222228d8ba445958a75a0704d566bf2c8'
    and
    TX_STATUS = 'SUCCESS'
    union all
    select
    block_timestamp,
    DECODED_LOG : poolId as pool_id,
    substr(DECODED_LOG : poolId, 1, 42) as pool_address,
    decoded_log : tokens[2] :: string as token,
    QueryRunArchived: QueryRun has been archived