lagandispenserRUNE Holding
    Updated 2022-06-28
    with transfers_in as (
    select
    date_trunc('week',block_timestamp) as week,
    to_address as wallet,
    sum(rune_amount) as rune_deposits,
    sum(0) as rune_withdraws,
    rune_deposits as res,
    res as w_res,
    0 as lp_res
    from thorchain.transfers
    group by 1,2
    ),
    transfers_out as (
    select
    date_trunc('week',block_timestamp) as week,
    from_address as wallet,
    0 as rune_deposits,
    sum(rune_amount) as rune_withdraws,
    rune_withdraws * -1 as res,
    res as w_res,
    0 as lp_res
    from thorchain.transfers
    group by 1,2
    ),
    lps as (
    select
    date_trunc('week',block_timestamp) as week,
    from_address as wallet,
    sum(case when lp_action = 'add_liquidity' then rune_amount else 0 end) as rune_deposits,
    sum(case when lp_action = 'remove_liquidity' then rune_amount else 0 end) as rune_withdraws,
    case when rune_withdraws - rune_deposits > 0 then rune_withdraws - rune_deposits else 0 end as res,
    0 as w_res,
    res as lp_res
    from thorchain.liquidity_actions
    Run a query to Download Data