nitsCalls placed over time
    Updated 2022-02-10
    with deposit_details_eth as (select tx_id, max(amount_usd) as amt, max(block_timestamp)as b 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')
    and event_name = 'Deposit')
    and amount_usd is not NULL
    -- where tx_id = '0x322a5b945fcba30d259470d5d3a2c12e26b7a6fa6bdcda2ea30448770f9550fb'
    GROUP by 1),
    deposit_details_btc as (select tx_id, max(amount_usd) as amt, max(block_timestamp)as b 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')
    and event_name = 'Deposit')
    and amount_usd is not NULL
    -- where tx_id = '0x322a5b945fcba30d259470d5d3a2c12e26b7a6fa6bdcda2ea30448770f9550fb'
    GROUP by 1),
    btc_tvl as (select 'btc call' as pool_name, 'call' as option_type, date(b) as day, sum(amt) as amt_transfer,sum(amt_transfer) over (order by day) as tvl from
    (SELECT * FROM
    (select tx_id, max(amount_usd)*(-1) as amt, max(block_timestamp)as b 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
    -- where tx_id = '0x322a5b945fcba30d259470d5d3a2c12e26b7a6fa6bdcda2ea30448770f9550fb'
    GROUP by 1)
    UNION ALL
    SELECT * from deposit_details_btc)
    GROUP by 3),
    eth_tvl as
    (select 'eth call' as pool_name, 'call' as option_type,date(b) as day, sum(amt) as amt_transfer,sum(amt_transfer) over (order by day) as tvl from
    (SELECT * FROM
    (select tx_id, max(amount_usd)*(-1) as amt, max(block_timestamp)as b 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
    -- where tx_id = '0x322a5b945fcba30d259470d5d3a2c12e26b7a6fa6bdcda2ea30448770f9550fb'
    GROUP by 1)
    Run a query to Download Data