kidaFlipside Terra Payments
Updated 2023-03-20Copy Reference Fork
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
WITH prices AS (
SELECT
TRUNC(block_timestamp, 'day') as date,
currency,
AVG(price_usd) as price_usd
FROM
terra.oracle_prices
GROUP BY
date, currency
)
SELECT
*,
amount * price_usd as amount_usd,
0 as current_amount_usd
FROM (
SELECT
block_timestamp,
tx_id,
COALESCE(msg_value:execute_msg:transfer:recipient, msg_value:to_address)::string as to_address,
COALESCE(label, msg_value:amount[0]:denom)::string as symbol,
COALESCE(msg_value:contract, msg_value:amount[0]:denom)::string as contract,
COALESCE(msg_value:execute_msg:transfer:amount, msg_value:amount[0]:amount) / 1e6 as amount
FROM
terra.msgs m
LEFT JOIN
terra.labels l
ON
msg_value:contract = address
WHERE
(msg_value:from_address IN ('terra1d4nmxwzpd0ygwtmdmx7jsdxt37e09y279r9jwe', 'terra13v8hmfld6747h7fx9gzzqvv80qwz24uvcqwrap','terra1vnh24saljvu39xuhmxqedl9wag0dweezp93nxn')
OR msg_value:sender IN ('terra1d4nmxwzpd0ygwtmdmx7jsdxt37e09y279r9jwe', 'terra13v8hmfld6747h7fx9gzzqvv80qwz24uvcqwrap','terra1vnh24saljvu39xuhmxqedl9wag0dweezp93nxn'))
AND tx_status = 'SUCCEEDED'
HAVING to_address <> ''
Run a query to Download Data