KeyrockUniV2 -- usdc/weth TVL Overtime --backup
    Updated 2024-02-01
    /* Extract and categorize transfers involving weth (weth)
    ('0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc') -- pool
    Token0 ('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'), -- weth
    Token1 ('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48') -- usdc
    )
    */
    WITH transfers AS (
    SELECT
    BLOCK_TIMESTAMP,
    CASE
    WHEN tr.contract_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' -- token 1
    AND tr.to_address = '0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc' THEN TRY_CAST(raw_amount_precise AS DOUBLE) -- pool addy
    WHEN tr.contract_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' -- token 1
    AND tr.from_address = '0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc' THEN - TRY_CAST(raw_amount_precise AS DOUBLE) -- pooly addy
    END AS weth
    FROM
    ethereum.core.fact_token_transfers AS tr
    WHERE
    (
    tr.to_address = '0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc' -- pool addy
    )
    OR (
    tr.from_address = '0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc' -- pool addy
    )
    AND tr.contract_address IN (
    '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' -- token 1
    )
    ),
    -- Group and sum weth transfers by date
    grouped_transfers AS (
    SELECT
    DATE_TRUNC('day', BLOCK_TIMESTAMP) AS evt_date,
    SUM(weth) AS weth
    FROM
    Last run: over 1 year ago
    DAY
    WETH_BAL
    USDC_BAL
    1
    2024-02-01 00:00:00.00048927910.824630849567494.6042732
    2
    2024-01-31 00:00:00.00050172232.932474149370825.7686249
    3
    2024-01-30 00:00:00.00049775062.326466450073349.8814478
    4
    2024-01-29 00:00:00.00048830765.352049149791155.3096283
    5
    2024-01-28 00:00:00.00049522794.807971749076606.6788836
    6
    2024-01-27 00:00:00.00049189483.344322749269909.3182096
    7
    2024-01-26 00:00:00.00048573441.46214949221399.6149889
    8
    2024-01-25 00:00:00.00048507474.415831248685819.2737904
    9
    2024-01-24 00:00:00.00048754992.312740248793585.1114966
    10
    2024-01-23 00:00:00.00049335203.988124348870982.8982839
    11
    2024-01-22 00:00:00.00051443870.099142449576174.3686867
    12
    2024-01-21 00:00:00.00051562627.153054151164397.2859019
    13
    2024-01-20 00:00:00.00051439217.477257551268980.4827887
    14
    2024-01-19 00:00:00.00051185117.366808851483108.8133505
    15
    2024-01-18 00:00:00.00052031691.917222951236432.0356901
    16
    2024-01-17 00:00:00.00052457496.607531451828007.7372323
    17
    2024-01-16 00:00:00.00051583319.570622652550042.3321883
    18
    2024-01-15 00:00:00.00051886376.982757651744699.057758
    19
    2024-01-14 00:00:00.00052771092.797040551330085.1465315
    20
    2024-01-13 00:00:00.00049001464.044494949554897.8901867
    ...
    1127
    68KB
    23s