nitsPools Retaining the Most
    Updated 2022-02-11
    with
    btc_tvl as
    (select tx_id, (block_timestamp)as b, to_address from ethereum.udm_events where tx_id in
    (select tx_id from ethereum.udm_events
    where contract_address = lower('0x65a833afDc250D9d38f8CD9bC2B1E3132dB13B2F') or contract_address = lower('0x8b5876f5B0Bf64056A89Aa7e97511644758c3E8c') --0x65a833afDc250D9d38f8CD9bC2B1E3132dB13B2F
    and event_name ilike 'withdraw')
    and amount_usd is not NULL ),
    eth_tvl as
    (select tx_id, (block_timestamp)as b, to_address from ethereum.udm_events where tx_id in
    (select tx_id from ethereum.udm_events
    where contract_address = lower('0x25751853Eab4D0eB3652B5eB6ecB102A2789644B') or contract_address = lower('0x0FABaF48Bbf864a3947bdd0Ba9d764791a60467A') --0x65a833afDc250D9d38f8CD9bC2B1E3132dB13B2F
    and event_name ilike 'withdraw')
    and amount_usd is not NULL ),
    eth_tvl_put as
    (select tx_id, (block_timestamp)as b, to_address from ethereum.udm_events where tx_id in
    (select tx_id from ethereum.udm_events
    where contract_address = lower('0x16772a7f4a3ca291C21B8AcE76F9332dDFfbb5Ef')
    and event_name ilike 'withdraw')
    and amount_usd is not NULL ),
    eth_tvl_put_yvusdc as
    (select tx_id, (block_timestamp)as b, to_address from ethereum.udm_events where tx_id in
    (select tx_id from ethereum.udm_events
    where contract_address = lower('0x8FE74471F198E426e96bE65f40EeD1F8BA96e54f')
    and event_name ilike 'withdraw')
    and amount_usd is not NULL ),
    all_contracts as (select * from ethereum.udm_events where from_address in
    (select to_address from eth_tvl_put
    UNION ALL
    select to_address from eth_tvl_put_yvusdc
    UNION ALL
    select to_address from eth_tvl
    UNION ALL
    select to_address from btc_tvl
    )),
    Run a query to Download Data