winnie-fsTotal Swap copy copy
999
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
›
⌄
-- forked from Total Swap copy @ https://staging.flipsidecrypto.xyz/edit/queries/e0c21a93-0690-45f3-bc2e-e7b51b480449
-- forked from SocioCrypto / Total Swap @ https://flipsidecrypto.xyz/SocioCrypto/q/tB4XE4ZDLZwp/total-swap
with t_txs as(
SELECT
DISTINCT tx_id ,
block_timestamp
FROM sei.core.fact_msg_attributes
WHERE ATTRIBUTE_KEY = '_contract_address'
AND ATTRIBUTE_VALUE = 'sei1d9fgdm2vgcknz5prdumkg5apml0vv3lfulkfd0gn07uesysek74sn34hjw'
)
,
swap as (
SELECT
DISTINCT tx_id
FROM sei.core.fact_msg_attributes
WHERE tx_id IN (SELECT tx_id FROM t_txs)
EXCEPT
SELECT
DISTINCT tx_id
FROM sei.core.fact_msg_attributes
WHERE tx_id IN (SELECT tx_id FROM t_txs)
AND (ATTRIBUTE_VALUE = 'mint' OR ATTRIBUTE_VALUE = 'burn_from')
)
,
token_in as (
SELECT
tx_id,
ATTRIBUTE_VALUE as token_in
FROM sei.core.fact_msg_attributes
WHERE tx_id IN (SELECT tx_id FROM swap)
AND ATTRIBUTE_KEY = 'amount' AND msg_type = 'coin_received' AND msg_index = 7
),
token_out as (
SELECT
Run a query to Download Data