Loading...
Loading...
Convert Dune (Trino) SQL queries to Allium (Snowflake) SQL. SQL dialect conversions (Trino → Snowflake) apply to all chains. Comprehensive Solana and EVM chain mappings included.
npx skill4agent add allium-labs/skills dune-to-allium~/.allium/credentialsAPI_KEY=allium_...
QUERY_ID=...QUERY_IDallium_query.pyDUNE_API_KEY.envdune_query.pyuv run ~/.claude/skills/dune-to-allium/scripts/dune_query.py QUERY_ID --json > dune_results.jsonNote: Dune API free tier only supports fetching results of saved queries by ID. It does NOT support executing arbitrary SQL.
{{param}}| Dune Table | Allium Table | Special Handling |
|---|---|---|
| | Always UNION both |
| | Different approach entirely |
| | Amount is pre-normalized |
| | Different granularity! |
| | Different column names |
| |
-- Dune: single table
FROM solana.instruction_calls
WHERE executing_account = '{program}' AND tx_success = true
-- Allium: UNION outer + inner, use parent_tx_success
WITH all_instructions AS (
SELECT * FROM solana.raw.instructions
WHERE program_id = '{program}' AND parent_tx_success = true
AND block_timestamp >= '{start}' AND block_timestamp < '{end}'
UNION ALL
SELECT * FROM solana.raw.inner_instructions
WHERE program_id = '{program}' AND parent_tx_success = true
AND block_timestamp >= '{start}' AND block_timestamp < '{end}'
)-- Dune: balance changes
FROM solana.account_activity
WHERE address = '{addr}' AND tx_success = true
-- Allium: use transfers table (do NOT use balances with LAG)
FROM solana.assets.transfers
WHERE to_address = '{addr}'
AND transfer_type IN ('spl_token_transfer', 'sol_transfer')| Find | Replace With |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
transfers_usd_valuetransfer_type IN ('spl_token_transfer', 'sol_transfer')amount/ pow(10, decimals)WHERE block_timestamp >= '2024-01-01'::TIMESTAMP
AND block_timestamp < '2024-01-02'::TIMESTAMP.sqluv run ~/.claude/skills/dune-to-allium/scripts/allium_query.py --file converted_query.sqluv run ~/.claude/skills/dune-to-allium/scripts/allium_query.py "SELECT * FROM ethereum.raw.blocks LIMIT 10"--jsonuv run ~/.claude/skills/dune-to-allium/scripts/allium_query.py --file converted_query.sql --json > /tmp/allium_results.json# Fetch Dune results
uv run ~/.claude/skills/dune-to-allium/scripts/dune_query.py QUERY_ID --json > /tmp/dune_results.json
# Run Allium query and save results
uv run ~/.claude/skills/dune-to-allium/scripts/allium_query.py --file converted_query.sql --json > /tmp/allium_results.json
# Compare
uv run ~/.claude/skills/dune-to-allium/scripts/compare_results.py /tmp/dune_results.json /tmp/allium_results.jsontx_idtxn_idgithub.com/duneanalytics/spellbookWHEREfilterblock_timeblock_timestampNOW()CURRENT_TIMESTAMP()INTERVAL '7' DAYINTERVAL '7 days'SUM(...) FILTER (WHERE ...)SUM(CASE WHEN ... THEN ... ELSE 0 END)CROSS JOIN UNNESTLATERAL FLATTENcardinality()ARRAY_SIZE()query_XXXXXget_href(){{param}}instruction_callstx_idtxn_idparent_tx_success = truetransfer_typesolana.assets.transfers/ pow(10, decimals)amount{chain}.transactions{chain}.raw.transactions{chain}.logs{chain}.raw.logs{chain}.decoded.logs{chain}.decoded.tracesstaking_ethereum.infoamount/ pow(10, decimals)dex.orderflowdex.tradesTRANSACTION_HASHTX_HASHUSD_AMOUNTAMOUNT_USDdex.tradesbsc.*bnb.*binance.*