dwellonchainOrderly - Total Deposit and Withdraw copy
Updated 2023-09-13Copy Reference Fork
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 Yousefi_1994 / Orderly - Total Deposit and Withdraw @ https://flipsidecrypto.xyz/Yousefi_1994/q/OzAksnL5B8UZ/orderly---total-deposit-and-withdraw
with token_list as (
(
select
distinct actions['predecessor_id']::string as token_contract
from near.core.fact_receipts
where receiver_id = 'asset-manager.orderly-network.near'
and actions['receipt']['Action']['actions'][0]['FunctionCall']['method_name']::string = 'ft_on_transfer'
and object_keys(status_value)[0]::string != 'Failure'
and block_timestamp::date >= '2022-09-13'
and block_timestamp::date <= current_date - 1
)
union
(
select 'wrap.near'::string as token_contract
)
),
tokens_details as (
select
case
when token_contract = 'a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near' then 'USDC'
when token_contract = 'aurora' then 'ETH'
when token_contract = 'wrap.near' then 'NEAR'
else symbol
end as token_symbol,
token_contract,
decimals
from near.core.dim_token_labels
where token_contract in (select token_contract from token_list)
group by 1, 2, 3
),
deposit_tokens as (
select
tx_hash,
block_timestamp,
Run a query to Download Data