SELECT
DISTINCT date_trunc('day',erd.block_timestamp) as block_date,
LOWER(REGEXP_REPLACE(inputs:c_token_address,'\"','')) as ctoken_address,
sum(erd.value_numeric / 1e18) as comp_speed
FROM ethereum.reads erd
WHERE
contract_address = '0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b'
and block_timestamp > getdate() - interval '31 days'
and function_name = 'compSpeeds'
GROUP BY 1,2
ORDER BY block_date desc;