Skip to content
Dune Analytics

@Brecht / Loopring Trades

SQL query

1WITH trades AS (
2    SELECT loopring.fn_process_trade_block(CAST(b."blockSize" AS INT), b._3, b.call_block_time) as trade,
3           call_tx_hash as tx_hash
4    FROM loopring."DEXBetaV1_call_commitBlock" b
5    WHERE b."blockType" = '0'
6), token_table AS (
7    SELECT 0 AS "tokenId", '\x0000000000000000000000000000000000000000' AS token, 'ETH' AS "symbol", 
8          18 AS decimals, (SELECT price FROM prices.usd WHERE symbol = 'ETH' ORDER BY minute desc LIMIT 1)  as price
9    UNION
10    SELECT 15 AS "tokenId", '\x85eee30c52b0b379b046fb0f85f4f3dc3009afec'::bytea AS token, 'KEEP' AS "symbol", 
11           18 AS decimals, 0.5 as price
12    UNION
13    SELECT 16 AS "tokenId", '\xa1d65E8fB6e87b60FECCBc582F7f97804B725521'::bytea AS token, 'DXD' AS "symbol", 
14           18 AS decimals, 80 as price
15    UNION
16    SELECT 17 AS "tokenId", '\x0Ba45A8b5d5575935B8158a88C631E9F9C95a2e5'::bytea AS token, 'TRB' AS "symbol", 
17           18 AS decimals, 5 as price
18    UNION
19    SELECT 20 AS "tokenId", '\xeb4c2781e4eba804ce9a9803c67d0893436bb27d'::bytea AS token, 'renBTC' AS "symbol", 
20           8 AS decimals, 9000 as price
21    UNION
22    SELECT 32 AS "tokenId", '\x89ab32156e46f46d02ade3fecbe5fc4243b9aaed'::bytea AS token, 'PNT' AS "symbol", 
23           18 AS decimals, 0.7 as price
24    UNION
25    SELECT 37 AS "tokenId", '\x56d811088235F11C8920698a204A5010a788f4b3'::bytea AS token, 'BZRX' AS "symbol", ...

SQL query results

Loading