WITH solend_events AS(
SELECT BLOCK_TIMESTAMP,
VALUE:parsed:type AS type,
VALUE:parsed:amount AS amount,
VALUE:parsed:info:authority AS authority,
value
FROM solana.core.fact_events , table (flatten (input=> INNER_INSTRUCTION:instructions)) AS tbl
WHERE program_id = 'So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo'
)
SELECT date_trunc('day', BLOCK_TIMESTAMP) AS days, CASE WHEN type is null THEN 'no type' ELSE type END AS type, COUNT(*) AS "total unique users"
FROM solend_events
GROUP BY 1, 2
ORDER BY 1