akbaridriaList Opening Position Transactions on Mean Finance
Updated 2022-06-27Copy 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 data_logs as (
select
tx_hash,
event_inputs:value as amount
from
polygon.core.fact_event_logs
where
origin_function_signature in ('0x6b29e1bd', '0x1cd701f1') -- open position deposit erc20 and matic native
and
event_name = 'Transfer'
and
event_inputs:from != '0x0000000000000000000000000000000000000000'
)
, data_asset as (
select
from_address, concat('0x', substring(input, 35, 40)) as selling_tokens, concat('0x', substring(input, 99, 40)) as receiving_tokens, tx_hash
from
polygon.core.fact_traces
where
-- tx_hash = '0x4f60ba18104e2fb0a1f0ab3f2651ed566f184340ffcc08d24de701fdc434cd6b' and
to_address = '0x059d306a25c4ce8d7437d25743a8b94520536bd5' -- mean finance dca hub
and
substring(input, 0, 10) = '0x6b29e1bd' -- open position
)
select
from_address,
case
when selling_tokens = '0x2791bca1f2de4661ed88a30c99a7a9449aa84174' then 'USDC'
when selling_tokens = '0xc2132d05d31c914a87c6611c10748aeb04b58e8f' then 'USDT'
when selling_tokens = '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619' then 'WETH'
when selling_tokens = '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270' then 'MATIC'
when selling_tokens = '0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6' then 'WBTC'
when selling_tokens = '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063' then 'DAI'
when c.address_name is null then selling_tokens
else c.address_name
Run a query to Download Data