|
7 | 7 |
|
8 | 8 | - sql: select symbol, address from token where decimals > 10
|
9 | 9 | ok: >
|
10 |
| - select to_jsonb(sub.*) as data from ( |
11 | 10 | SELECT symbol, address FROM (
|
12 | 11 | SELECT id, address, symbol, name, decimals FROM "sgd0815"."token" WHERE block_range @> 2147483647) AS token
|
13 |
| - WHERE decimals > 10 ) as sub |
| 12 | + WHERE decimals > 10 |
14 | 13 | - sql: >
|
15 |
| - with tokens as ( |
16 |
| - select * from (values |
17 |
| - ('0x0000000000000000000000000000000000000000','ETH','Ethereum',18), |
18 |
| - ('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48','USDC','USD Coin',6) |
19 |
| - ) as t(address,symbol,name,decimals) |
20 |
| - ) |
21 |
| -
|
22 |
| - select date, t.symbol, SUM(amount)/pow(10,t.decimals) as amount |
23 |
| - from (select |
24 |
| - date(to_timestamp(block_timestamp) at time zone 'utc') as date, |
25 |
| - token, amount |
26 |
| - from swap as sm, |
27 |
| - unnest(sm.amounts_in,sm.tokens_in) as smi(amount,token) |
28 |
| - union all |
29 |
| - select |
30 |
| - date(to_timestamp(block_timestamp) at time zone 'utc') as date, |
31 |
| - token, amount |
32 |
| - from swap as sm, |
33 |
| - unnest(sm.amounts_out,sm.tokens_out) as smo(amount,token)) as tp |
34 |
| - inner join |
35 |
| - tokens as t on t.address = tp.token |
36 |
| - group by tp.date, t.symbol, t.decimals |
37 |
| - order by tp.date desc, amount desc |
| 14 | + with tokens as ( |
| 15 | + select * from (values |
| 16 | + ('0x0000000000000000000000000000000000000000','ETH','Ethereum',18), |
| 17 | + ('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48','USDC','USD Coin',6) |
| 18 | + ) as t(address,symbol,name,decimals)) |
| 19 | + select date, t.symbol, SUM(amount)/pow(10,t.decimals) as amount |
| 20 | + from (select |
| 21 | + date(to_timestamp(block_timestamp) at time zone 'utc') as date, |
| 22 | + token, amount |
| 23 | + from swap as sm, |
| 24 | + unnest(sm.amounts_in,sm.tokens_in) as smi(amount,token) |
| 25 | + union all |
| 26 | + select |
| 27 | + date(to_timestamp(block_timestamp) at time zone 'utc') as date, |
| 28 | + token, amount |
| 29 | + from swap as sm, |
| 30 | + unnest(sm.amounts_out,sm.tokens_out) as smo(amount,token)) as tp |
| 31 | + inner join |
| 32 | + tokens as t on t.address = tp.token |
| 33 | + group by tp.date, t.symbol, t.decimals |
| 34 | + order by tp.date desc, amount desc |
38 | 35 | ok: >
|
39 |
| - select to_jsonb(sub.*) as data from ( |
40 | 36 | WITH tokens AS (
|
41 | 37 | SELECT * FROM (
|
42 | 38 | VALUES ('0x0000000000000000000000000000000000000000', 'ETH', 'Ethereum', 18),
|
|
54 | 50 | UNNEST(sm.amounts_out, sm.tokens_out) AS smo (amount, token)) AS tp
|
55 | 51 | JOIN tokens AS t ON t.address = tp.token
|
56 | 52 | GROUP BY tp.date, t.symbol, t.decimals
|
57 |
| - ORDER BY tp.date DESC, amount DESC ) as sub |
| 53 | + ORDER BY tp.date DESC, amount DESC |
0 commit comments