MostlyData_Staking flow (Osmosis)
    Updated 2023-04-13
    with staking_info as(
    select
    block_timestamp,
    tx_id,
    action,
    delegator_address,
    validator_address,
    redelegate_source_validator_address,
    amount * pow(10,-decimal) as osmo

    from osmosis.core.fact_staking
    where block_timestamp > current_date() - interval '{{weeks}} week'
    ),

    delegation_info as (
    select
    date_trunc('week', block_timestamp) as date,
    sum(osmo) as delegation
    from staking_info
    where action = 'delegate'
    group by 1
    ),

    undelegation_info as(
    select
    date_trunc('week', block_timestamp) as date,
    sum(osmo) as undelegation
    from staking_info
    where action = 'undelegate'
    group by 1
    Run a query to Download Data