Kruys-CollinsAptin Borrow and Repay
Updated 2024-10-15
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 APTIN AS (
SELECT
t1.block_timestamp,
t1.event_address,
t1.event_data,
t1.account_address,
t1.payload_function,
t1.success,
t1.tx_hash,
t1.event_data:amount::float AS amount_unadjusted,
t2.address,
t2.address_name,
t2.label,
ft.sender,
t3.token_address,
t3.decimals
FROM
aptos.core.fact_events t1
LEFT JOIN aptos.core.dim_labels t2 ON t1.event_address = t2.address
JOIN aptos.core.fact_transactions ft ON t1.tx_hash = ft.tx_hash
LEFT JOIN aptos.core.dim_tokens t3 ON t1.event_data:coin_name = t3.token_address
WHERE
initcap(t2.label) = 'Aptin Finance'
AND t1.payload_function IN (
'0x3c1d4a86594d681ff7e5d5a233965daeabdc6a15fe5672ceeda5260038857183::lend::borrow',
'0x3c1d4a86594d681ff7e5d5a233965daeabdc6a15fe5672ceeda5260038857183::lend::supply',
'0x3c1d4a86594d681ff7e5d5a233965daeabdc6a15fe5672ceeda5260038857183::lend::repay',
'0x3c1d4a86594d681ff7e5d5a233965daeabdc6a15fe5672ceeda5260038857183::lend::withdraw'
)
AND t1.success = 'TRUE'
),
PRICE AS (
SELECT
DATE_TRUNC('DAY', HOUR) AS DATE,
AVG(PRICE) AS PRICE,
QueryRunArchived: QueryRun has been archived