kidaPool Assets
Updated 2022-06-14Copy 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 transfers_in_arrays AS (
SELECT
block_id,
block_timestamp,
tx_id,
msg_index,
MAX(IFF(attribute_key = 'sender', attribute_value, '')) as sender,
MAX(IFF(attribute_key = 'recipient', attribute_value, '')) as recipient,
SPLIT(MAX(IFF(attribute_key = 'amount', attribute_value, '')), ',') as amount_oris
FROM osmosis.core.fact_msg_attributes a
WHERE EXISTS (
SELECT 1
FROM osmosis.core.fact_msgs m
WHERE tx_status = 'SUCCEEDED'
AND a.tx_id = m.tx_id
)
AND msg_type = 'transfer'
AND msg_group is not null
GROUP BY
block_id,
block_timestamp,
tx_id,
msg_index
HAVING (sender = '{{pool_address}}' OR recipient = '{{pool_address}}')
),
transfers AS (
SELECT
block_id,
block_timestamp,
tx_id,
IFF(sender = '{{pool_address}}', 'out', 'in') as type,
REGEXP_SUBSTR(F.Value,'^\\d+') as amount,
RIGHT(F.Value, LEN(F.Value) - LEN(amount)) as denom
FROM transfers_in_arrays,
LATERAL FLATTEN (input => amount_oris) F
Run a query to Download Data