0xCd2d8965A1D3cb529B2E4C3AF6C558676e362739Aptos General Bridges copy
Updated 2024-10-06
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
›
⌄
-- forked from cristinatinto / Aptos General Bridges @ https://flipsidecrypto.xyz/cristinatinto/q/BmAzTG8EiuVA/aptos-general-bridges
with
prices as (
SELECT
TO_TIMESTAMP(value[0]::string) as hour,
'APT' as symbol,
value[1] as price
FROM (
SELECT livequery.live.udf_api(
'https://api.coingecko.com/api/v3/coins/aptos/market_chart?vs_currency=usd&days=max&interval=hourly&precision=3') as resp
),LATERAL FLATTEN(input => resp:data:prices)
UNION
SELECT
hour,
symbol,
avg(price) as price
FROM crosschain.price.ez_prices_hourly
WHERE BLOCKCHAIN = 'ethereum'
GROUP BY 1 ,2
),
info as (
select
distinct tx_hash, platform, direction,
case when direction='inbound' then receiver else sender end as user,
z.symbol,
price,
decimals,
avg(amount_unadj) as amount_unadj,
min(block_timestamp) as block_timestamp
from aptos.defi.fact_bridge_activity x
JOIN aptos.core.dim_tokens z on x.token_address=z.token_address
join prices y on lower(z.symbol)=lower(y.symbol) and date_trunc('hour',block_timestamp)=hour
group by 1,2,3,4,5,6,7
QueryRunArchived: QueryRun has been archived