adriaparcerisasMatic liquid staking
    Updated 2022-09-23
    WITH
    xmatic as (
    Select
    trunc(x.block_timestamp,'day') as date,
    count(distinct x.tx_hash) as staking_actions,
    sum(raw_amount/power(10, 18)) as volume_staked,
    sum(tx_fee) as fees_paid,
    avg(tx_fee) as avg_fee_per_tx
    from polygon.core.fact_token_transfers x
    join polygon.core.fact_transactions y on x.tx_hash=y.tx_hash
    where x.from_address = '0x0000000000000000000000000000000000000000' and contract_address =lower('0x3aD736904E9e65189c3000c7DD2c8AC8bB7cD4e3')
    group By 1
    order By 1
    ),
    stmatic as (
    Select
    trunc(x.block_timestamp,'day') as date,
    count(distinct x.tx_hash) as staking_actions,
    Sum(raw_amount/power(10, 18)) as volume_staked,
    sum(tx_fee) as fees_paid,
    avg(tx_fee) as avg_fee_per_tx
    from polygon.core.fact_token_transfers x
    join polygon.core.fact_transactions y on x.tx_hash=y.tx_hash
    where x.from_address = '0x0000000000000000000000000000000000000000' and contract_address =lower('0x3A58a54C066FdC0f2D55FC9C89F0415C92eBf3C4')
    group By 1
    order By 1
    ),
    csmatic as (
    Select
    trunc(x.block_timestamp,'day') as date,
    count(distinct x.tx_hash) as staking_actions,
    Sum(raw_amount/power(10, 18)) as volume_staked,
    sum(tx_fee) as fees_paid,
    avg(tx_fee) as avg_fee_per_tx
    from polygon.core.fact_token_transfers x
    join polygon.core.fact_transactions y on x.tx_hash=y.tx_hash