dbrgSONNE-LP max_min_sum_avg_remove-liquidity
    Updated 2023-03-28
    -- forked from 6968e0e8-6f27-4a71-95b9-bf8b8dcd6aa2

    with
    LP_TXs as (
    select
    tx.tx_hash,
    tx.block_timestamp,
    tx.raw_amount / power(10, 18) as lp_amount
    from
    optimism.core.fact_token_transfers tx
    WHERE
    1 = 1
    -- and tx.tx_hash = '0xe12422dbd7367ca3e0fe68d15c66e55452e841d49b0135ed8c9aa10b6933e071'
    and tx.to_address = '0x0000000000000000000000000000000000000000'
    and tx.contract_address = '0xc899c4d73ed8df2ead1543ab915888b0bf7d57a2'
    and tx.block_timestamp >= '{{start_time}}'::date
    and tx.block_timestamp < add_months(
    '{{start_time}}',
    {{duration_in_months}})
    ),
    USDc_LP as (
    SELECT
    tx.tx_hash,
    lp.block_timestamp,
    tx.TO_ADDRESS as user,
    tx.raw_amount / power(10, 6) as usdc_amount
    from
    optimism.core.fact_token_transfers tx
    inner join LP_TXs lp using (tx_hash)
    where
    1 = 1
    and tx.contract_address = '0x7f5c764cbc14f9669b88837ca1490cca17c31607'
    and tx.from_address = '0xc899c4d73ed8df2ead1543ab915888b0bf7d57a2'
    ),
    SONNE_lp as (
    SELECT
    Run a query to Download Data