ioanPalma ratio
    Updated 2023-04-13
    with wallet_balances as (
    WITH addresses AS (
    SELECT lower('0xDA0c94c73D127eE191955FB46bACd7FF999b2bcd') AS address
    , lower('0xba319f6f6ac8f45e556918a0c9ecdde64335265c') AS staking_address
    , datediff(day, '2021-10-22'::DATE, CURRENT_TIMESTAMP(0)) AS days
    ),
    transfers AS (
    -- stakers
    select date_trunc('day', BLOCK_TIMESTAMP) as day
    , raw_amount as amount
    , from_address as wallet
    FROM ethereum.core.fact_token_transfers, addresses
    where to_address = staking_address
    and contract_address = address
    union all
    select date_trunc('day', BLOCK_TIMESTAMP) as day
    , -raw_amount as amount
    , to_address as wallet
    FROM ethereum.core.fact_token_transfers, addresses
    where from_address = staking_address
    and contract_address = address
    union all
    -- holders
    SELECT date_trunc('day', BLOCK_TIMESTAMP) as day
    , to_address as wallet
    , raw_amount as amount
    FROM ethereum.core.fact_token_transfers, addresses
    WHERE contract_address = address
    UNION ALL
    SELECT date_trunc('day', BLOCK_TIMESTAMP) as day
    , from_address as wallet
    , raw_amount as amount
    FROM ethereum.core.fact_token_transfers, addresses
    WHERE contract_address = address
    ),
    Run a query to Download Data