kidaSynapse LP Activities (BSC)
    Updated 2023-01-05
    with
    lp_addresses as (
    select distinct
    event_inputs:swapAddress::string as lp_address
    from bsc.core.fact_event_logs
    where event_name = 'NewSwapPool' and origin_from_address = '0x0af91fa049a7e1894f480bfe5bba20142c6c29a9'
    ),

    liquidity_actions as (
    select distinct tx_hash
    from bsc.core.fact_event_logs
    where (event_name = 'AddLiquidity' or event_name = 'RemoveLiquidity' or event_name = 'AddLiquidityOneToken' or event_name = 'RemoveLiquidityOneToken') and exists(select 1 from lp_addresses where lp_address = origin_to_address)
    ),
    decimals as (
    select
    token_in as contract_address,
    median(case when event_inputs:amount1In::decimal < event_inputs:amount0In::decimal then event_inputs:amount0In else event_inputs:amount1In end / amount_in) as decimals
    from bsc.sushi.ez_swaps s
    join bsc.core.fact_event_logs t
    on t.event_index = s.event_index and s.tx_hash = t.tx_hash
    group by 1
    ),

    prices as (
    select
    date(block_timestamp) as date,
    token_in as token_address,
    symbol_in as symbol,
    avg(amount_in_usd / amount_in) as price
    from bsc.sushi.ez_swaps
    group by 1, 2, 3
    )

    select
    t.block_timestamp::date as date,
    Run a query to Download Data