mirror of
https://github.com/FlipsideCrypto/blast-models.git
synced 2026-02-06 14:11:55 +00:00
pr updates -add new column standards
This commit is contained in:
parent
d7a17d57e0
commit
5c579d353a
@ -44,6 +44,10 @@ underlying AS (
|
||||
tx_hash,
|
||||
block_timestamp,
|
||||
block_number,
|
||||
CASE
|
||||
WHEN trace_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS trace_succeeded,
|
||||
from_address AS token_address,
|
||||
to_address AS underlying_asset_address
|
||||
FROM
|
||||
@ -54,7 +58,7 @@ underlying AS (
|
||||
input,
|
||||
10
|
||||
) = '0x095ea7b3'
|
||||
AND trace_status = 'SUCCESS'
|
||||
AND trace_succeeded
|
||||
AND from_address IN (
|
||||
SELECT
|
||||
address
|
||||
@ -65,7 +69,11 @@ underlying AS (
|
||||
unwrapped AS (
|
||||
SELECT
|
||||
from_address AS underlying_asset_address,
|
||||
to_address AS underlying_unwrap_address
|
||||
to_address AS underlying_unwrap_address,
|
||||
CASE
|
||||
WHEN trace_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS trace_succeeded
|
||||
FROM
|
||||
{{ ref('core__fact_traces') }}
|
||||
WHERE
|
||||
@ -74,7 +82,7 @@ unwrapped AS (
|
||||
input,
|
||||
10
|
||||
) = '0x1a33757d'
|
||||
AND trace_status = 'SUCCESS'
|
||||
AND trace_succeeded
|
||||
AND from_address IN (
|
||||
SELECT
|
||||
underlying_asset_address
|
||||
|
||||
@ -48,25 +48,33 @@ init_borrows AS (
|
||||
contract_address AS token,
|
||||
'INIT Capital' AS platform,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
contract_address = '0xa7d36f2106b5a5d528a7e2e7a3f436d703113a10'
|
||||
AND topics [0] :: STRING = '0x49dd87b26edb1c92c93f83b092bd5a425c6bf7a562c0fed02f2576c49f477ba4'
|
||||
AND tx_status = 'SUCCESS'
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
max(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
token_transfer AS (
|
||||
|
||||
SELECT
|
||||
tx_hash,
|
||||
contract_address,
|
||||
@ -107,13 +115,16 @@ token_transfer AS (
|
||||
)
|
||||
),
|
||||
native_transfer AS (
|
||||
|
||||
SELECT
|
||||
tx_hash,
|
||||
from_address AS wrapped_address,
|
||||
to_address,
|
||||
value_precise_raw AS eth_value,
|
||||
'WETH' AS eth_symbol,
|
||||
CASE
|
||||
WHEN trace_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS trace_succeeded,
|
||||
18 AS eth_decimals,
|
||||
'0x4300000000000000000000000000000000000004' AS eth_address
|
||||
FROM
|
||||
@ -127,7 +138,7 @@ native_transfer AS (
|
||||
init_borrows
|
||||
)
|
||||
AND TYPE = 'CALL'
|
||||
AND trace_status = 'SUCCESS'
|
||||
AND trace_succeeded
|
||||
AND input = '0x'
|
||||
),
|
||||
init_combine AS (
|
||||
@ -210,4 +221,4 @@ SELECT
|
||||
FROM
|
||||
init_combine qualify(ROW_NUMBER() over(PARTITION BY _log_id
|
||||
ORDER BY
|
||||
modified_timestamp DESC)) = 1
|
||||
modified_timestamp DESC)) = 1
|
||||
|
||||
@ -50,22 +50,31 @@ init_deposits AS (
|
||||
-- receipt token
|
||||
'INIT Capital' AS platform,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
contract_address = '0xa7d36f2106b5a5d528a7e2e7a3f436d703113a10'
|
||||
AND topics [0] :: STRING = '0x722732c12c1c1ba3942aef8ee6e0357b01908558e142501c5f85b356c4dcadf8'
|
||||
AND tx_status = 'SUCCESS'
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
max(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
token_transfer1 AS (
|
||||
SELECT
|
||||
@ -91,7 +100,7 @@ token_transfer1 AS (
|
||||
t3
|
||||
ON t2.contract_address = t3.contract_address
|
||||
WHERE
|
||||
t1.contract_address IN (
|
||||
t1.contract_address IN (
|
||||
SELECT
|
||||
underlying_asset_address
|
||||
FROM
|
||||
@ -217,6 +226,10 @@ native_transfer AS (
|
||||
to_address,
|
||||
value_precise_raw AS eth_value,
|
||||
'WETH' AS eth_symbol,
|
||||
CASE
|
||||
WHEN trace_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS trace_succeeded,
|
||||
18 AS eth_decimals,
|
||||
'0x4300000000000000000000000000000000000004' AS eth_address
|
||||
FROM
|
||||
@ -230,7 +243,7 @@ native_transfer AS (
|
||||
init_deposits
|
||||
)
|
||||
AND TYPE = 'CALL'
|
||||
AND trace_status = 'SUCCESS'
|
||||
AND trace_succeeded
|
||||
AND input = '0x6ad481f3'
|
||||
),
|
||||
init_combine AS (
|
||||
@ -307,4 +320,4 @@ SELECT
|
||||
FROM
|
||||
init_combine qualify(ROW_NUMBER() over(PARTITION BY _log_id
|
||||
ORDER BY
|
||||
modified_timestamp DESC)) = 1
|
||||
modified_timestamp DESC)) = 1
|
||||
|
||||
@ -51,13 +51,21 @@ init_liquidations AS (
|
||||
contract_address AS token,
|
||||
'INIT Capital' AS platform,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
contract_address = '0xa7d36f2106b5a5d528a7e2e7a3f436d703113a10'
|
||||
AND topics [0] :: STRING = '0x6df71caf4cddb1620bcf376243248e0077da98913d65a7e9315bc9984e5fff72'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
@ -123,13 +131,22 @@ position_owner AS (
|
||||
CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS borrower,
|
||||
utils.udf_hex_to_int(
|
||||
topics [2] :: STRING
|
||||
) :: STRING AS posId -- using string as it handles better than float
|
||||
) :: STRING AS posId, -- using string as it handles better than float
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
contract_address = '0xa7d36f2106b5a5d528a7e2e7a3f436d703113a10'
|
||||
AND topics [0] :: STRING = '0xe6a96441ecc85d0943a914f4750f067a912798ec2543bc68c00e18291da88d14' -- createposition
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
AND posId IN (
|
||||
SELECT
|
||||
posId
|
||||
@ -146,24 +163,25 @@ SELECT
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
l.contract_address,
|
||||
l.contract_address as token,
|
||||
l.contract_address AS token,
|
||||
liquidator,
|
||||
borrower,
|
||||
protocol_market,
|
||||
collateral_token,
|
||||
collateral_token_symbol,
|
||||
tokens_seized_raw as amount_unadj,
|
||||
tokens_seized as amount,
|
||||
tokens_seized_raw AS amount_unadj,
|
||||
tokens_seized AS amount,
|
||||
debt_token,
|
||||
debt_token_symbol,
|
||||
platform,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
l._log_id
|
||||
FROM
|
||||
liquidation_union l
|
||||
LEFT JOIN position_owner po ON l.posId = po.posId
|
||||
LEFT JOIN init_repayment r ON l.posId = r.posId
|
||||
AND l.tx_hash = r.tx_hash
|
||||
qualify(ROW_NUMBER() over(PARTITION BY _log_id
|
||||
LEFT JOIN position_owner po
|
||||
ON l.posId = po.posId
|
||||
LEFT JOIN init_repayment r
|
||||
ON l.posId = r.posId
|
||||
AND l.tx_hash = r.tx_hash qualify(ROW_NUMBER() over(PARTITION BY l._log_id
|
||||
ORDER BY
|
||||
modified_timestamp DESC)) = 1
|
||||
|
||||
@ -51,13 +51,21 @@ init_repayments AS (
|
||||
contract_address AS token,
|
||||
'INIT Capital' AS platform,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
contract_address = '0xa7d36f2106b5a5d528a7e2e7a3f436d703113a10'
|
||||
AND topics [0] :: STRING = '0x77673b670822baca14a7caf6f8038f811649ab73e4c06083b0e58a53389bece7'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
@ -76,6 +84,10 @@ native_transfer AS (
|
||||
to_address AS wrapped_address,
|
||||
value_precise_raw AS eth_value,
|
||||
'WETH' AS eth_symbol,
|
||||
CASE
|
||||
WHEN trace_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS trace_succeeded,
|
||||
18 AS eth_decimals,
|
||||
'0x4300000000000000000000000000000000000004' AS eth_address
|
||||
FROM
|
||||
@ -89,7 +101,7 @@ native_transfer AS (
|
||||
init_repayments
|
||||
)
|
||||
AND TYPE = 'CALL'
|
||||
AND trace_status = 'SUCCESS'
|
||||
AND trace_succeeded
|
||||
AND input = '0x6ad481f3'
|
||||
),
|
||||
token_transfer AS (
|
||||
@ -143,18 +155,33 @@ init_combine AS (
|
||||
origin_function_signature,
|
||||
posId,
|
||||
b.contract_address,
|
||||
b.pool as protocol_market,
|
||||
b.pool AS protocol_market,
|
||||
borrower,
|
||||
repayer as payer,
|
||||
repayer AS payer,
|
||||
amttorepay,
|
||||
sharesAmt,
|
||||
C.underlying_asset_address AS repay_contract_address,
|
||||
C.underlying_symbol AS repay_contract_symbol,
|
||||
underlying_decimals as underlying_wrap_decimals,
|
||||
COALESCE(eth_value, underlying_amount_raw ) as underlying_amount_raw,
|
||||
COALESCE(eth_symbol, d.token_symbol, C.underlying_symbol) as underlying_symbol,
|
||||
COALESCE(eth_decimals, d.token_decimals, C.underlying_decimals) as underlying_decimals,
|
||||
COALESCE(eth_address, d.contract_address, C.underlying_asset_address) as underlying_asset_address,
|
||||
underlying_decimals AS underlying_wrap_decimals,
|
||||
COALESCE(
|
||||
eth_value,
|
||||
underlying_amount_raw
|
||||
) AS underlying_amount_raw,
|
||||
COALESCE(
|
||||
eth_symbol,
|
||||
d.token_symbol,
|
||||
C.underlying_symbol
|
||||
) AS underlying_symbol,
|
||||
COALESCE(
|
||||
eth_decimals,
|
||||
d.token_decimals,
|
||||
C.underlying_decimals
|
||||
) AS underlying_decimals,
|
||||
COALESCE(
|
||||
eth_address,
|
||||
d.contract_address,
|
||||
C.underlying_asset_address
|
||||
) AS underlying_asset_address,
|
||||
b.platform,
|
||||
b._log_id,
|
||||
b.modified_timestamp
|
||||
@ -162,8 +189,7 @@ init_combine AS (
|
||||
init_repayments b
|
||||
LEFT JOIN asset_details C
|
||||
ON b.pool = C.token_address
|
||||
LEFT JOIN native_transfer
|
||||
USING(tx_hash)
|
||||
LEFT JOIN native_transfer USING(tx_hash)
|
||||
LEFT JOIN token_transfer d
|
||||
ON b.tx_hash = d.tx_hash
|
||||
)
|
||||
@ -182,8 +208,8 @@ SELECT
|
||||
payer,
|
||||
repay_contract_address,
|
||||
repay_contract_symbol,
|
||||
underlying_asset_address as token_address,
|
||||
underlying_symbol as token_symbol,
|
||||
underlying_asset_address AS token_address,
|
||||
underlying_symbol AS token_symbol,
|
||||
amtToRepay AS amount_unadj,
|
||||
amttorepay / pow(
|
||||
10,
|
||||
@ -199,4 +225,4 @@ SELECT
|
||||
FROM
|
||||
init_combine qualify(ROW_NUMBER() over(PARTITION BY _log_id
|
||||
ORDER BY
|
||||
modified_timestamp DESC)) = 1
|
||||
modified_timestamp DESC)) = 1
|
||||
|
||||
@ -49,13 +49,21 @@ init_redemption AS (
|
||||
) :: FLOAT AS redeemed_token_raw,
|
||||
'INIT Capital' AS platform,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
contract_address = '0xa7d36f2106b5a5d528a7e2e7a3f436d703113a10'
|
||||
AND topics [0] :: STRING = '0x09c2e7b3728acfd99b3f71e4c1a55bcd48019bcc0e45c741f7c2f3393f49ea91'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
@ -164,19 +172,18 @@ token_transfer2 AS (
|
||||
tx_hash
|
||||
FROM
|
||||
init_redemption
|
||||
)
|
||||
{# AND t1.tx_hash NOT IN (
|
||||
SELECT
|
||||
tx_hash
|
||||
FROM
|
||||
token_transfer1
|
||||
) #} --think we would want to remove this
|
||||
AND t1.from_address IN (
|
||||
SELECT
|
||||
token_address
|
||||
FROM
|
||||
asset_details
|
||||
)
|
||||
) {# AND t1.tx_hash NOT IN (
|
||||
SELECT
|
||||
tx_hash
|
||||
FROM
|
||||
token_transfer1
|
||||
) #} --think we would want to remove this
|
||||
AND t1.from_address IN (
|
||||
SELECT
|
||||
token_address
|
||||
FROM
|
||||
asset_details
|
||||
)
|
||||
),
|
||||
token_transfer AS (
|
||||
SELECT
|
||||
@ -225,11 +232,15 @@ native_transfer AS (
|
||||
from_address AS wrapped_address,
|
||||
to_address,
|
||||
value_precise_raw AS eth_value,
|
||||
CASE
|
||||
WHEN trace_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS trace_succeeded,
|
||||
'WETH' AS eth_symbol,
|
||||
18 AS eth_decimals,
|
||||
'0x4300000000000000000000000000000000000004' AS eth_address
|
||||
FROM
|
||||
blast.core.fact_traces
|
||||
{{ ref('core__fact_traces') }}
|
||||
WHERE
|
||||
from_address IN ('0xf683ce59521aa464066783d78e40cd9412f33d21')
|
||||
AND tx_hash IN (
|
||||
@ -239,7 +250,7 @@ native_transfer AS (
|
||||
init_redemption
|
||||
)
|
||||
AND TYPE = 'CALL'
|
||||
AND trace_status = 'SUCCESS'
|
||||
AND trace_succeeded
|
||||
AND input = '0x'
|
||||
),
|
||||
init_combine AS (
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
) }}
|
||||
|
||||
WITH asset_list AS (
|
||||
|
||||
SELECT
|
||||
'0x44f33bc796f7d3df55040cd3c631628b560715c2' AS pool_address
|
||||
UNION ALL
|
||||
@ -37,7 +38,7 @@ juice_contracts AS (
|
||||
FROM
|
||||
contracts
|
||||
WHERE
|
||||
NAME like 'Juice%Collateral%'
|
||||
NAME LIKE 'Juice%Collateral%'
|
||||
),
|
||||
collateral_tokens AS (
|
||||
SELECT
|
||||
@ -77,8 +78,15 @@ tx_pull AS (
|
||||
topics,
|
||||
DATA,
|
||||
event_removed,
|
||||
tx_status,
|
||||
_log_id,
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
fact_event_logs_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
@ -87,16 +95,22 @@ tx_pull AS (
|
||||
WHERE
|
||||
origin_from_address = '0x0ee09b204ffebf9a1f14c99e242830a09958ba34'
|
||||
AND origin_to_address = '0x4e59b44847b379578588920ca78fbf26c0b4956c'
|
||||
AND concat('0x',substr(topics[1], 27,40)) in (select pool_address from asset_list)
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
AND CONCAT('0x', SUBSTR(topics [1], 27, 40)) IN (
|
||||
SELECT
|
||||
max(modified_timestamp)
|
||||
pool_address
|
||||
FROM
|
||||
{{ this }}
|
||||
asset_list
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
trace_pull AS (
|
||||
SELECT
|
||||
@ -117,7 +131,10 @@ trace_pull AS (
|
||||
DATA,
|
||||
tx_status,
|
||||
sub_traces,
|
||||
trace_status,
|
||||
CASE
|
||||
WHEN trace_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS trace_succeeded,
|
||||
error_reason,
|
||||
trace_index,
|
||||
fact_traces_id,
|
||||
@ -163,9 +180,9 @@ token AS (
|
||||
NAME AS token_name,
|
||||
decimals AS token_decimals,
|
||||
symbol AS token_symbol,
|
||||
a.modified_timestamp
|
||||
A.modified_timestamp
|
||||
FROM
|
||||
trace_pull a
|
||||
trace_pull A
|
||||
LEFT JOIN contracts
|
||||
ON address = token_address
|
||||
WHERE
|
||||
@ -184,7 +201,7 @@ underlying AS (
|
||||
topics,
|
||||
DATA,
|
||||
event_removed,
|
||||
tx_status,
|
||||
tx_succeeded,
|
||||
_log_id,
|
||||
fact_event_logs_id,
|
||||
inserted_timestamp,
|
||||
@ -220,9 +237,30 @@ underlying_asset AS (
|
||||
),
|
||||
logs_pull AS (
|
||||
SELECT
|
||||
*,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
event_index,
|
||||
contract_address,
|
||||
topics,
|
||||
DATA,
|
||||
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
|
||||
CONCAT('0x', SUBSTR(segmented_data [0], 25, 40)) AS contract_address,
|
||||
event_removed,
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
fact_event_logs_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
@ -249,8 +287,15 @@ get_underlying AS (
|
||||
topics,
|
||||
DATA,
|
||||
event_removed,
|
||||
tx_status,
|
||||
_log_id,
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
fact_event_logs_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
|
||||
@ -9,24 +9,24 @@
|
||||
WITH asset_details AS (
|
||||
|
||||
SELECT
|
||||
underlying_asset_address,
|
||||
underlying_name,
|
||||
underlying_decimals,
|
||||
underlying_symbol,
|
||||
pool_address,
|
||||
token_address,
|
||||
token_name,
|
||||
token_decimals,
|
||||
token_symbol,
|
||||
debt_address,
|
||||
debt_name,
|
||||
debt_decimals,
|
||||
debt_symbol
|
||||
underlying_asset_address,
|
||||
underlying_name,
|
||||
underlying_decimals,
|
||||
underlying_symbol,
|
||||
pool_address,
|
||||
token_address,
|
||||
token_name,
|
||||
token_decimals,
|
||||
token_symbol,
|
||||
debt_address,
|
||||
debt_name,
|
||||
debt_decimals,
|
||||
debt_symbol
|
||||
FROM
|
||||
{{ ref('silver__juice_asset_details') }}
|
||||
),
|
||||
juice_borrows AS (
|
||||
SELECT
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
@ -36,31 +36,46 @@ juice_borrows AS (
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
|
||||
CONCAT('0x', SUBSTR(topics[1] :: STRING, 25, 40)) AS borrower,
|
||||
utils.udf_hex_to_int (segmented_data[0]) as loan_amount_raw,
|
||||
CONCAT('0x', SUBSTR(topics [1] :: STRING, 25, 40)) AS borrower,
|
||||
utils.udf_hex_to_int (
|
||||
segmented_data [0]
|
||||
) AS loan_amount_raw,
|
||||
contract_address AS pool_address,
|
||||
'Juice' AS platform,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }} a
|
||||
LEFT JOIN
|
||||
asset_details on contract_address=pool_address
|
||||
{{ ref('core__fact_event_logs') }} A
|
||||
LEFT JOIN asset_details
|
||||
ON contract_address = pool_address
|
||||
WHERE
|
||||
contract_address IN (select pool_address from asset_details)
|
||||
contract_address IN (
|
||||
SELECT
|
||||
pool_address
|
||||
FROM
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0xcbc04eca7e9da35cb1393a6135a199ca52e450d5e9251cbd99f7847d33a36750'
|
||||
AND tx_status = 'SUCCESS'
|
||||
{% if is_incremental() %}
|
||||
AND a.modified_timestamp > (
|
||||
SELECT
|
||||
max(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND a.modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND A.modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND A.modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
juice_combine AS (
|
||||
SELECT
|
||||
block_number,
|
||||
@ -75,7 +90,7 @@ juice_combine AS (
|
||||
loan_amount_raw,
|
||||
C.underlying_asset_address AS borrows_contract_address,
|
||||
C.underlying_symbol AS borrows_symbol,
|
||||
contract_address as token,
|
||||
contract_address AS token,
|
||||
C.token_symbol,
|
||||
C.underlying_decimals,
|
||||
debt_name,
|
||||
@ -90,7 +105,6 @@ juice_combine AS (
|
||||
LEFT JOIN asset_details C
|
||||
ON b.contract_address = C.pool_address
|
||||
)
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
@ -103,9 +117,9 @@ SELECT
|
||||
borrower,
|
||||
borrows_contract_address,
|
||||
borrows_symbol,
|
||||
debt_name as token_name,
|
||||
debt_address as token_address,
|
||||
debt_symbol as token_symbol,
|
||||
debt_name AS token_name,
|
||||
debt_address AS token_address,
|
||||
debt_symbol AS token_symbol,
|
||||
loan_amount_raw AS amount_unadj,
|
||||
loan_amount_raw / pow(
|
||||
10,
|
||||
@ -117,4 +131,4 @@ SELECT
|
||||
FROM
|
||||
juice_combine qualify(ROW_NUMBER() over(PARTITION BY _log_id
|
||||
ORDER BY
|
||||
modified_timestamp DESC)) = 1
|
||||
modified_timestamp DESC)) = 1
|
||||
|
||||
@ -38,13 +38,20 @@ deposit_logs AS (
|
||||
topics,
|
||||
DATA,
|
||||
event_removed,
|
||||
tx_status,
|
||||
_log_id,
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
fact_event_logs_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }} a
|
||||
{{ ref('core__fact_event_logs') }} A
|
||||
WHERE
|
||||
(
|
||||
contract_address IN (
|
||||
@ -65,15 +72,16 @@ deposit_logs AS (
|
||||
'0xd88c5369d398bea6a7390a17ce98af43f4aacc78fd3587bc368993d98206a304',
|
||||
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
|
||||
)
|
||||
{% if is_incremental() %}
|
||||
AND a.modified_timestamp > (
|
||||
SELECT
|
||||
max(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND a.modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND A.modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND A.modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
juice_deposits AS (
|
||||
SELECT
|
||||
@ -109,7 +117,7 @@ juice_deposits AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
),
|
||||
juice_collateraldeposits AS (
|
||||
SELECT
|
||||
@ -140,7 +148,7 @@ juice_collateraldeposits AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0xd88c5369d398bea6a7390a17ce98af43f4aacc78fd3587bc368993d98206a304'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
),
|
||||
token_transfer AS (
|
||||
SELECT
|
||||
@ -170,7 +178,7 @@ token_transfer AS (
|
||||
FROM
|
||||
juice_deposits
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
),
|
||||
juice_combine AS (
|
||||
SELECT
|
||||
|
||||
@ -51,7 +51,15 @@ juice_liquidations AS (
|
||||
) :: INTEGER AS debtamountneeded_raw,
|
||||
'Juice' AS platform,
|
||||
l.modified_timestamp,
|
||||
l._log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
l
|
||||
@ -61,7 +69,7 @@ juice_liquidations AS (
|
||||
)
|
||||
WHERE
|
||||
l.topics [0] :: STRING = '0xe32ec3ea3154879f27d5367898ab3a5ac6b68bf921d7cc610720f417c5cb243c'
|
||||
AND l.tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp >= (
|
||||
@ -79,7 +87,15 @@ token_transfer AS (
|
||||
tx_hash,
|
||||
utils.udf_hex_to_int(DATA) AS seizeTokens_raw,
|
||||
event_index,
|
||||
_log_id,
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
ROW_NUMBER() over (
|
||||
PARTITION BY _log_id
|
||||
ORDER BY
|
||||
@ -102,7 +118,7 @@ token_transfer AS (
|
||||
FROM
|
||||
juice_liquidations
|
||||
)
|
||||
AND tx_status = 'SUCCESS' qualify(ROW_NUMBER() over(PARTITION BY tx_hash
|
||||
AND tx_succeeded qualify(ROW_NUMBER() over(PARTITION BY tx_hash
|
||||
ORDER BY
|
||||
event_index ASC)) = 1
|
||||
),
|
||||
@ -113,7 +129,16 @@ debt_transfer AS (
|
||||
utils.udf_hex_to_int(DATA) AS debtamount,
|
||||
debt_name,
|
||||
debt_address AS debt_token,
|
||||
debt_symbol AS debt_token_symbol
|
||||
debt_symbol AS debt_token_symbol,
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
l
|
||||
@ -128,7 +153,7 @@ debt_transfer AS (
|
||||
FROM
|
||||
juice_liquidations
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
),
|
||||
liquidation_union AS (
|
||||
SELECT
|
||||
|
||||
@ -43,7 +43,15 @@ juice_repayments AS (
|
||||
) :: INTEGER AS repayed_amount_raw,
|
||||
'Juice' AS platform,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }} a
|
||||
WHERE
|
||||
@ -54,7 +62,7 @@ juice_repayments AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x5c16de4f8b59bd9caf0f49a545f25819a895ed223294290b408242e72a594231'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
{% if is_incremental() %}
|
||||
AND a.modified_timestamp > (
|
||||
SELECT
|
||||
|
||||
@ -39,9 +39,17 @@ withdraw_logs AS (
|
||||
topics,
|
||||
tx_status,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }} a
|
||||
{{ ref('core__fact_event_logs') }} A
|
||||
WHERE
|
||||
(
|
||||
contract_address IN (
|
||||
@ -62,15 +70,16 @@ withdraw_logs AS (
|
||||
'0x0b260cc77140cab3405675836fc971314e656137208b77414be51fafd58ae34b',
|
||||
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
|
||||
)
|
||||
{% if is_incremental() %}
|
||||
AND a.modified_timestamp > (
|
||||
SELECT
|
||||
max(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND a.modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND A.modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND A.modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
juice_redemption AS (
|
||||
SELECT
|
||||
@ -101,7 +110,7 @@ juice_redemption AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x0b260cc77140cab3405675836fc971314e656137208b77414be51fafd58ae34b'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
),
|
||||
juice_collateralredeems AS (
|
||||
SELECT
|
||||
@ -132,7 +141,7 @@ juice_collateralredeems AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x0b260cc77140cab3405675836fc971314e656137208b77414be51fafd58ae34b'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
),
|
||||
token_transfer AS (
|
||||
SELECT
|
||||
@ -162,7 +171,7 @@ token_transfer AS (
|
||||
FROM
|
||||
juice_collateralredeems
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
),
|
||||
juice_combine AS (
|
||||
SELECT
|
||||
@ -174,7 +183,7 @@ juice_combine AS (
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
b.token as token_address,
|
||||
b.token AS token_address,
|
||||
redeemer,
|
||||
received_amount_raw,
|
||||
redeemed_token_raw,
|
||||
|
||||
@ -9,12 +9,20 @@
|
||||
WITH log_pull_1 AS (
|
||||
|
||||
SELECT
|
||||
l.tx_hash,
|
||||
l.block_number,
|
||||
l.block_timestamp,
|
||||
l.contract_address,
|
||||
l.modified_timestamp,
|
||||
l._log_id
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
contract_address,
|
||||
modified_timestamp,
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
l
|
||||
@ -23,13 +31,13 @@ WITH log_pull_1 AS (
|
||||
AND origin_from_address = '0x6315f65843e7582508e4f0aac20a7203e7b09f02'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND l.modified_timestamp > (
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND l.modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
traces_pull AS (
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = "block_number",
|
||||
unique_key = "block_number",
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['reorg','curated']
|
||||
) }}
|
||||
|
||||
WITH asset_details AS (
|
||||
|
||||
SELECT
|
||||
token_address,
|
||||
token_name,
|
||||
token_name,
|
||||
token_symbol,
|
||||
token_decimals,
|
||||
underlying_asset_address,
|
||||
@ -43,7 +44,15 @@ orbit_borrows AS (
|
||||
contract_address AS token,
|
||||
'Orbit' AS platform,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
@ -54,16 +63,17 @@ orbit_borrows AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab80'
|
||||
AND tx_status = 'SUCCESS'
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
max(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
orbit_combine AS (
|
||||
SELECT
|
||||
@ -102,7 +112,7 @@ SELECT
|
||||
borrower,
|
||||
borrows_contract_address,
|
||||
borrows_symbol,
|
||||
token as token_address,
|
||||
token AS token_address,
|
||||
token_symbol,
|
||||
loan_amount_raw AS amount_unadj,
|
||||
loan_amount_raw / pow(
|
||||
|
||||
@ -1,23 +1,24 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = "block_number",
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['reorg','curated']
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = "block_number",
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['reorg','curated']
|
||||
) }}
|
||||
|
||||
WITH asset_details AS (
|
||||
SELECT
|
||||
token_address,
|
||||
token_name,
|
||||
token_symbol,
|
||||
token_decimals,
|
||||
underlying_asset_address,
|
||||
underlying_name,
|
||||
underlying_symbol,
|
||||
underlying_decimals
|
||||
FROM
|
||||
{{ ref('silver__orbit_asset_details') }}
|
||||
|
||||
SELECT
|
||||
token_address,
|
||||
token_name,
|
||||
token_symbol,
|
||||
token_decimals,
|
||||
underlying_asset_address,
|
||||
underlying_name,
|
||||
underlying_symbol,
|
||||
underlying_decimals
|
||||
FROM
|
||||
{{ ref('silver__orbit_asset_details') }}
|
||||
),
|
||||
orbit_deposits AS (
|
||||
SELECT
|
||||
@ -40,7 +41,15 @@ orbit_deposits AS (
|
||||
CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS supplier,
|
||||
'Orbit' AS platform,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
@ -51,16 +60,17 @@ orbit_deposits AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f'
|
||||
AND tx_status = 'SUCCESS'
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
max(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
orbit_combine AS (
|
||||
SELECT
|
||||
@ -89,7 +99,6 @@ orbit_combine AS (
|
||||
LEFT JOIN asset_details C
|
||||
ON b.token_address = C.token_address
|
||||
)
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
@ -119,4 +128,4 @@ SELECT
|
||||
FROM
|
||||
orbit_combine qualify(ROW_NUMBER() over(PARTITION BY _log_id
|
||||
ORDER BY
|
||||
modified_timestamp DESC)) = 1
|
||||
modified_timestamp DESC)) = 1
|
||||
|
||||
@ -43,7 +43,15 @@ orbit_liquidations AS (
|
||||
CONCAT('0x', SUBSTR(segmented_data [3] :: STRING, 25, 40)) AS tokenCollateral,
|
||||
'Orbit' AS platform,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
@ -54,7 +62,7 @@ orbit_liquidations AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb52'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp >= (
|
||||
|
||||
@ -38,7 +38,15 @@ orbit_repayments AS (
|
||||
) :: INTEGER AS repayed_amount_raw,
|
||||
'Orbit' AS platform,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
@ -49,7 +57,7 @@ orbit_repayments AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
) }}
|
||||
|
||||
WITH asset_details AS (
|
||||
|
||||
SELECT
|
||||
token_address,
|
||||
token_name,
|
||||
@ -40,7 +41,15 @@ orbit_redemptions AS (
|
||||
CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS redeemer,
|
||||
'Orbit' AS platform,
|
||||
modified_timestamp,
|
||||
_log_id
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
@ -51,16 +60,16 @@ orbit_redemptions AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
max(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
AND modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
orbit_combine AS (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user