mirror of
https://github.com/FlipsideCrypto/ethereum-models.git
synced 2026-02-06 13:46:47 +00:00
AN-4280/heal-logic (#896)
* tx_success, heal_models var, readme * heal logic for bridges * lending heal logic * dex heal * lst and lps heal logic * ambigious column name * missing columns * tx success * heal_models var in lst * explicit alias and lookback var format * pool name
This commit is contained in:
parent
17dda604fd
commit
83af404ce5
72
README.md
72
README.md
@ -35,49 +35,54 @@ ethereum:
|
||||
client_session_keep_alive: False
|
||||
query_tag: <TAG>
|
||||
```
|
||||
### Variables
|
||||
## Variables
|
||||
|
||||
To control which external table environment a model references, as well as, whether a Stream is invoked at runtime using control variables:
|
||||
* STREAMLINE_INVOKE_STREAMS
|
||||
When True, invokes streamline on model run as normal
|
||||
When False, NO-OP
|
||||
* When True, invokes streamline on model run as normal
|
||||
* When False, NO-OP
|
||||
* STREAMLINE_USE_DEV_FOR_EXTERNAL_TABLES
|
||||
When True, uses DEV schema Streamline.Ethereum_DEV
|
||||
When False, uses PROD schema Streamline.Ethereum
|
||||
* When True, uses DEV schema Streamline.Ethereum_DEV
|
||||
* When False, uses PROD schema Streamline.Ethereum
|
||||
* Default values are False
|
||||
|
||||
Default values are False
|
||||
|
||||
* Usage:
|
||||
dbt run --var '{"STREAMLINE_USE_DEV_FOR_EXTERNAL_TABLES":True, "STREAMLINE_INVOKE_STREAMS":True}' -m ...
|
||||
* Usage: `dbt run --var '{"STREAMLINE_USE_DEV_FOR_EXTERNAL_TABLES":True, "STREAMLINE_INVOKE_STREAMS":True}' -m ...`
|
||||
|
||||
To control the creation of UDF or SP macros with dbt run:
|
||||
* UPDATE_UDFS_AND_SPS
|
||||
When True, executes all macros included in the on-run-start hooks within dbt_project.yml on model run as normal
|
||||
When False, none of the on-run-start macros are executed on model run
|
||||
* Default values are False
|
||||
* When True, executes all macros included in the on-run-start hooks within dbt_project.yml on model run as normal
|
||||
* When False, none of the on-run-start macros are executed on model run
|
||||
|
||||
Default values are False
|
||||
* Usage: `dbt run --vars '{"UPDATE_UDFS_AND_SPS":True}' -m ...`
|
||||
|
||||
* Usage:
|
||||
dbt run --var '{"UPDATE_UDFS_AND_SPS":True}' -m ...
|
||||
Use a variable to heal a model incrementally:
|
||||
* HEAL_MODEL
|
||||
* Default is FALSE (Boolean)
|
||||
* When FALSE, logic will be negated
|
||||
* When TRUE, heal logic will apply
|
||||
* Include `heal` in model tags within the config block for inclusion in the `dbt_run_heal_models` workflow, e.g. `tags = 'heal'`
|
||||
|
||||
To reload records in a curated complete table without a full-refresh, such as `silver_bridge.complete_bridge_activity`:
|
||||
* HEAL_CURATED_MODEL
|
||||
Default is an empty array []
|
||||
When item is included in var array [], incremental logic will be skipped for that CTE / code block
|
||||
When item is not included in var array [] or does not match specified item in model, incremental logic will apply
|
||||
Example set up: `{% if is_incremental() and 'axelar' not in var('HEAL_CURATED_MODEL') %}`
|
||||
* Usage: `dbt run --vars '{"HEAL_MODEL":True}' -m ...`
|
||||
|
||||
* Usage:
|
||||
Single CTE: dbt run --var '{"HEAL_CURATED_MODEL":"axelar"}' -m ...
|
||||
Multiple CTEs: dbt run --var '{"HEAL_CURATED_MODEL":["axelar","across","celer_cbridge"]}' -m ...
|
||||
Use a variable to negate incremental logic:
|
||||
* Example use case: reload records in a curated complete table without a full-refresh, such as `silver_bridge.complete_bridge_activity`:
|
||||
* HEAL_MODELS
|
||||
* Default is an empty array []
|
||||
* When item is included in var array [], incremental logic will be skipped for that CTE / code block
|
||||
* When item is not included in var array [] or does not match specified item in model, incremental logic will apply
|
||||
* Example set up: `{% if is_incremental() and 'axelar' not in var('HEAL_MODELS') %}`
|
||||
|
||||
### Resources:
|
||||
* Usage:
|
||||
* Single CTE: `dbt run --vars '{"HEAL_MODELS":"axelar"}' -m ...`
|
||||
* Multiple CTEs: `dbt run --vars '{"HEAL_MODELS":["axelar","across","celer_cbridge"]}' -m ...`
|
||||
|
||||
* Learn more about dbt [in the docs](https://docs.getdbt.com/docs/introduction)
|
||||
* Check out [Discourse](https://discourse.getdbt.com/) for commonly asked questions and answers
|
||||
* Join the [chat](https://community.getdbt.com/) on Slack for live discussions and support
|
||||
* Find [dbt events](https://events.getdbt.com) near you
|
||||
* Check out [the blog](https://blog.getdbt.com/) for the latest news on dbt's development and best practices
|
||||
Use a variable to extend the incremental lookback period:
|
||||
* LOOKBACK
|
||||
* Default is a string representing the specified time interval e.g. '12 hours', '7 days' etc.
|
||||
* Example set up: `SELECT MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'`
|
||||
|
||||
* Usage: `dbt run --vars '{"LOOKBACK":"36 hours"}' -m ...`
|
||||
|
||||
## Applying Model Tags
|
||||
|
||||
@ -119,4 +124,11 @@ dbt run --var '{"UPDATE_SNOWFLAKE_TAGS":False}' -s models/core/core__fact_blocks
|
||||
```
|
||||
select *
|
||||
from table(ethereum.information_schema.tag_references('ethereum.core.fact_blocks', 'table'));
|
||||
```
|
||||
```
|
||||
|
||||
### Resources:
|
||||
* Learn more about dbt [in the docs](https://docs.getdbt.com/docs/introduction)
|
||||
* Check out [Discourse](https://discourse.getdbt.com/) for commonly asked questions and answers
|
||||
* Join the [chat](https://community.getdbt.com/) on Slack for live discussions and support
|
||||
* Find [dbt events](https://events.getdbt.com) near you
|
||||
* Check out [the blog](https://blog.getdbt.com/) for the latest news on dbt's development and best practices
|
||||
@ -67,7 +67,7 @@ vars:
|
||||
WAIT: 0
|
||||
OBSERV_FULL_TEST: False
|
||||
HEAL_MODEL: False
|
||||
HEAL_CURATED_MODEL: []
|
||||
HEAL_MODELS: []
|
||||
LOAD_CUSTOM_FUNCTIONS: False
|
||||
START_GHA_TASKS: False
|
||||
API_INTEGRATION: '{{ var("config")[target.name]["API_INTEGRATION"] if var("config")[target.name] else var("config")["dev"]["API_INTEGRATION"] }}'
|
||||
|
||||
@ -61,6 +61,7 @@ WITH deposit_evt AS (
|
||||
contract_address = '0x00000000219ab540356cbb839cbe05303d7705fa' --BeaconDepositContract
|
||||
AND topics [0] :: STRING = '0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5' --DepositEvent
|
||||
AND block_number >= 11185300
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -100,6 +101,8 @@ FINAL AS (
|
||||
ON d.block_number = t.block_number
|
||||
AND d.tx_hash = t.tx_hash
|
||||
AND d.deposit_amount :: FLOAT = t.eth_value :: FLOAT
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND trace_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND t._inserted_timestamp >= (
|
||||
|
||||
@ -29,7 +29,13 @@ SELECT
|
||||
token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
amount_usd,
|
||||
ROUND(
|
||||
CASE
|
||||
WHEN amount_usd < 1e+15 THEN amount_usd
|
||||
ELSE NULL
|
||||
END,
|
||||
2
|
||||
) AS amount_usd,
|
||||
COALESCE (
|
||||
complete_bridge_activity_id,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
|
||||
@ -2,17 +2,11 @@
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'SUSHI, UNISWAP, CURVE, SYNTHETIX, BALANCER, DODO, FRAX, HASHFLOW, KYBERSWAP, MAVERICK, PANCAKESWAP, SHIBASWAP, TRADER JOE, VERSE',
|
||||
'PURPOSE': 'DEX, SWAPS'
|
||||
}
|
||||
}
|
||||
}
|
||||
meta ={ 'database_tags':{ 'table':{ 'PROTOCOL': 'SUSHI, UNISWAP, CURVE, SYNTHETIX, BALANCER, DODO, FRAX, HASHFLOW, KYBERSWAP, MAVERICK, PANCAKESWAP, SHIBASWAP, TRADER JOE, VERSE',
|
||||
'PURPOSE': 'DEX, SWAPS' } } }
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
@ -24,10 +18,26 @@
|
||||
event_name,
|
||||
amount_in_unadj,
|
||||
amount_in,
|
||||
amount_in_usd,
|
||||
ROUND(
|
||||
CASE
|
||||
WHEN amount_out_usd IS NULL
|
||||
OR ABS((amount_in_usd - amount_out_usd) / NULLIF(amount_out_usd, 0)) > 0.75
|
||||
OR ABS((amount_in_usd - amount_out_usd) / NULLIF(amount_in_usd, 0)) > 0.75 THEN NULL
|
||||
ELSE amount_in_usd
|
||||
END,
|
||||
2
|
||||
) AS amount_in_usd,
|
||||
amount_out_unadj,
|
||||
amount_out,
|
||||
amount_out_usd,
|
||||
ROUND(
|
||||
CASE
|
||||
WHEN amount_in_usd IS NULL
|
||||
OR ABS((amount_out_usd - amount_in_usd) / NULLIF(amount_in_usd, 0)) > 0.75
|
||||
OR ABS((amount_out_usd - amount_in_usd) / NULLIF(amount_out_usd, 0)) > 0.75 THEN NULL
|
||||
ELSE amount_out_usd
|
||||
END,
|
||||
2
|
||||
) AS amount_out_usd,
|
||||
sender,
|
||||
tx_to,
|
||||
event_index,
|
||||
@ -50,6 +60,6 @@
|
||||
COALESCE(
|
||||
modified_timestamp,
|
||||
'2000-01-01'
|
||||
) AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver_dex__complete_dex_swaps') }}
|
||||
) AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver_dex__complete_dex_swaps') }}
|
||||
|
||||
@ -2,36 +2,36 @@
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'ANKR, BINANCE, COINBASE, CREAM, FRAX, HORD, LIDO, NODEDAO, ROCKETPOOL, SHAREDSTAKE, STADER, STAFI, STAKEHOUND, STAKEWISE, SWELL, UNIETH',
|
||||
'PURPOSE': 'LIQUID STAKING, LSD'
|
||||
}
|
||||
}
|
||||
}
|
||||
meta ={ 'database_tags':{ 'table':{ 'PROTOCOL': 'ANKR, BINANCE, COINBASE, CREAM, FRAX, HORD, LIDO, NODEDAO, ROCKETPOOL, SHAREDSTAKE, STADER, STAFI, STAKEHOUND, STAKEWISE, SWELL, UNIETH',
|
||||
'PURPOSE': 'LIQUID STAKING, LSD' } } }
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
tx_hash,
|
||||
event_index,
|
||||
event_name,
|
||||
contract_address,
|
||||
recipient AS staker,
|
||||
platform,
|
||||
token_symbol,
|
||||
token_address,
|
||||
token_amount_unadj,
|
||||
token_amount_adj AS token_amount,
|
||||
token_amount_usd,
|
||||
eth_amount_unadj,
|
||||
eth_amount_adj AS eth_amount,
|
||||
eth_amount_usd,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
tx_hash,
|
||||
event_index,
|
||||
event_name,
|
||||
contract_address,
|
||||
recipient AS staker,
|
||||
platform,
|
||||
token_symbol,
|
||||
token_address,
|
||||
token_amount_unadj,
|
||||
token_amount_adj AS token_amount,
|
||||
ROUND(
|
||||
token_amount_usd,
|
||||
2
|
||||
) AS token_amount_usd,
|
||||
eth_amount_unadj,
|
||||
eth_amount_adj AS eth_amount,
|
||||
ROUND(
|
||||
eth_amount_usd,
|
||||
2
|
||||
) AS eth_amount_usd,
|
||||
COALESCE (
|
||||
complete_lsd_deposits_id,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
@ -45,6 +45,6 @@ SELECT
|
||||
COALESCE(
|
||||
modified_timestamp,
|
||||
'2000-01-01'
|
||||
) AS modified_timestamp
|
||||
) AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver_lsd__complete_lsd_deposits') }}
|
||||
{{ ref('silver_lsd__complete_lsd_deposits') }}
|
||||
|
||||
@ -28,10 +28,16 @@ SELECT
|
||||
token_address,
|
||||
token_amount_unadj,
|
||||
token_amount_adj AS token_amount,
|
||||
token_amount_usd,
|
||||
eth_amount_unadj,
|
||||
eth_amount_adj AS eth_amount,
|
||||
eth_amount_usd,
|
||||
ROUND(
|
||||
token_amount_usd,
|
||||
2
|
||||
) AS token_amount_usd,
|
||||
eth_amount_unadj,
|
||||
eth_amount_adj AS eth_amount,
|
||||
ROUND(
|
||||
eth_amount_usd,
|
||||
2
|
||||
) AS eth_amount_usd,
|
||||
COALESCE (
|
||||
complete_lsd_withdrawals_id,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
|
||||
@ -35,7 +35,7 @@ AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -170,7 +170,7 @@ heal_model AS (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -196,7 +196,7 @@ heal_model AS (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
|
||||
@ -52,6 +52,7 @@ WITH base_evt AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xafc4df6845a4ab948b492800d3d8a25d538a102a2bc07cd01f1cfa097fddcff6'
|
||||
AND contract_address = '0x5c7bcd6e7de5423a257d81b442095a1a6ced35c5'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -94,6 +95,7 @@ bridge_to AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x0cf77fd2585a4d672259e86a6adb2f6b05334cbb420727afcfbc689d018bb456'
|
||||
AND contract_address = '0x1a9f622dfafad5373741d821f1431abb23c30529'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -60,6 +60,7 @@ WITH base_evt AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xa123dc29aebf7d0c3322c8eeb5b999e859f39937950ed31056532713d0de396f'
|
||||
AND contract_address = '0x5c7bcd6e7de5423a257d81b442095a1a6ced35c5'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -53,6 +53,7 @@ WITH base_evt AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x884a8def17f0d5bbb3fef53f3136b5320c9b39f75afb8985eeab9ea1153ee56d'
|
||||
AND contract_address = '0xbbbd1bbb4f9b936c3604906d7592a644071de884'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -42,6 +42,7 @@ WITH base_evt AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x7e50569d26be643bda7757722291ec66b1be66d8283474ae3fab5a98f878a7a2'
|
||||
AND contract_address = '0x4f4495243837681061c4743b74b3eedf548d56a5'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -89,6 +90,7 @@ native_gas_paid AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x999d431b58761213cf53af96262b67a069cbd963499fd8effd1e21556217b841'
|
||||
AND contract_address = '0x2d5d7d31f671f86c782533cc367f14109a082712'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -46,6 +46,7 @@ WITH base_evt AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x89d8051e597ab4178a863a5190407b98abfeff406aa8db90c59af76612e58f01'
|
||||
AND contract_address = '0x5427fefa711eff984124bfbb1ab6fbf5e3da1820'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -70,6 +70,7 @@ WITH base_evt AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xfc8703fd57380f9dd234a89dce51333782d49c5902f307b02f03e014d18fe471' --CreatedOrder
|
||||
AND contract_address = '0xef4fb24ad0916217251f553c0596f8edc630eb66' --Dln: Source
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -40,6 +40,7 @@ WITH base_evt AS (
|
||||
--PortalV2
|
||||
'0xbf0b5d561b986809924f88099c4ff0e6bcce60c9' --PortalV2
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -14,6 +14,7 @@ WITH base_contracts AS (
|
||||
{{ ref('silver__logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x0a0607688c86ec1775abcdbab7b33a3a35a6c9cde677c9be880150c231cc6b0b'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -47,6 +47,7 @@ WITH base_evt AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x0a0607688c86ec1775abcdbab7b33a3a35a6c9cde677c9be880150c231cc6b0b'
|
||||
AND origin_to_address IS NOT NULL
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -126,6 +126,7 @@ dst_info AS (
|
||||
WHERE
|
||||
contract_address = '0x25ab3efd52e6470681ce037cd546dc60726948d3'
|
||||
AND topics [0] :: STRING = '0x5ce4019f772fda6cb703b26bce3ec3006eb36b73f1d3a0eb441213317d9f5e9d'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -43,6 +43,7 @@ WITH base_evt AS (
|
||||
'0x1633d66ca91ce4d81f63ea047b7b19beb92df7f3',
|
||||
'0x93251f98acb0c83904320737aec091bce287f8f5'
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
-- depends_on: {{ ref('silver__complete_token_prices') }}
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = ['block_number','platform','version'],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['curated','reorg']
|
||||
tags = ['curated','reorg','heal']
|
||||
) }}
|
||||
|
||||
WITH across AS (
|
||||
@ -33,18 +34,17 @@ WITH across AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__across_fundsdeposited') }}
|
||||
|
||||
{% if is_incremental() and 'across' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'across' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
across_v3 AS (
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
@ -70,11 +70,11 @@ across_v3 AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__across_v3fundsdeposited') }}
|
||||
|
||||
{% if is_incremental() and 'across_v3' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'across_v3' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -106,11 +106,11 @@ allbridge AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__allbridge_sent') }}
|
||||
|
||||
{% if is_incremental() and 'allbridge' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'allbridge' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -142,11 +142,11 @@ axelar AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__axelar_contractcallwithtoken') }}
|
||||
|
||||
{% if is_incremental() and 'axelar' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'axelar' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -178,11 +178,11 @@ celer_cbridge AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__celer_cbridge_send') }}
|
||||
|
||||
{% if is_incremental() and 'celer_cbridge' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'celer_cbridge' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -214,11 +214,11 @@ dln_debridge AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__dln_debridge_createdorder') }}
|
||||
|
||||
{% if is_incremental() and 'dln_debridge' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'dln_debridge' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -250,11 +250,11 @@ eywa AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__eywa_requestsent') }}
|
||||
|
||||
{% if is_incremental() and 'eywa' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'eywa' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -286,11 +286,11 @@ hop AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__hop_transfersenttol2') }}
|
||||
|
||||
{% if is_incremental() and 'hop' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'hop' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -322,11 +322,11 @@ meson AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__meson_transfers') }}
|
||||
|
||||
{% if is_incremental() and 'meson' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'meson' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -358,11 +358,11 @@ multichain AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__multichain_v7_loganyswapout') }}
|
||||
|
||||
{% if is_incremental() and 'multichain' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'multichain' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -394,11 +394,11 @@ stargate AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__stargate_swap') }}
|
||||
|
||||
{% if is_incremental() and 'stargate' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'stargate' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -430,11 +430,11 @@ symbiosis AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__symbiosis_synthesizerequest') }}
|
||||
|
||||
{% if is_incremental() and 'symbiosis' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'symbiosis' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -466,11 +466,11 @@ synapse_tb AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__synapse_token_bridge') }}
|
||||
|
||||
{% if is_incremental() and 'synapse_tb' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'synapse_tb' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -502,11 +502,11 @@ synapse_tbs AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__synapse_tokenbridgeandswap') }}
|
||||
|
||||
{% if is_incremental() and 'synapse_tbs' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'synapse_tbs' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -538,11 +538,11 @@ wormhole AS (
|
||||
FROM
|
||||
{{ ref('silver_bridge__wormhole_transfers') }}
|
||||
|
||||
{% if is_incremental() and 'wormhole' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'wormhole' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -657,16 +657,16 @@ native_bridges AS (
|
||||
all_protocols
|
||||
)
|
||||
|
||||
{% if is_incremental() and 'native_bridges' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'native_bridges' not in var('HEAL_MODELS') %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
|
||||
{% if is_incremental() and 'native_bridges' in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'native_bridges' in var('HEAL_MODELS') %}
|
||||
AND tx_hash NOT IN (
|
||||
SELECT
|
||||
DISTINCT tx_hash
|
||||
@ -688,7 +688,7 @@ all_bridges AS (
|
||||
FROM
|
||||
native_bridges
|
||||
),
|
||||
FINAL AS (
|
||||
complete_bridge_activity AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
@ -744,12 +744,12 @@ FINAL AS (
|
||||
2
|
||||
)
|
||||
ELSE NULL
|
||||
END AS amount_usd_unadj,
|
||||
END AS amount_usd,
|
||||
_id,
|
||||
b._inserted_timestamp
|
||||
FROM
|
||||
all_bridges b
|
||||
LEFT JOIN {{ ref('core__dim_contracts') }} C
|
||||
LEFT JOIN {{ ref('silver__contracts') }} C
|
||||
ON b.token_address = C.address
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
@ -769,6 +769,186 @@ FINAL AS (
|
||||
) = LOWER(
|
||||
b.destination_chain
|
||||
)
|
||||
),
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
heal_model AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
tx_hash,
|
||||
event_index,
|
||||
bridge_address,
|
||||
event_name,
|
||||
platform,
|
||||
version,
|
||||
sender,
|
||||
receiver,
|
||||
destination_chain_receiver,
|
||||
destination_chain_id,
|
||||
destination_chain,
|
||||
t0.token_address,
|
||||
C.symbol AS token_symbol,
|
||||
C.decimals AS token_decimals,
|
||||
amount_unadj,
|
||||
CASE
|
||||
WHEN C.decimals IS NOT NULL THEN (amount_unadj / pow(10, C.decimals))
|
||||
ELSE amount_unadj
|
||||
END AS amount_heal,
|
||||
CASE
|
||||
WHEN C.decimals IS NOT NULL THEN ROUND(
|
||||
amount_heal * p.price,
|
||||
2
|
||||
)
|
||||
ELSE NULL
|
||||
END AS amount_usd_heal,
|
||||
_id,
|
||||
t0._inserted_timestamp
|
||||
FROM
|
||||
{{ this }}
|
||||
t0
|
||||
LEFT JOIN {{ ref('silver__contracts') }} C
|
||||
ON t0.token_address = C.address
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON t0.token_address = p.token_address
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
WHERE
|
||||
CONCAT(
|
||||
t0.block_number,
|
||||
'-',
|
||||
t0.platform,
|
||||
'-',
|
||||
t0.version
|
||||
) IN (
|
||||
SELECT
|
||||
CONCAT(
|
||||
t1.block_number,
|
||||
'-',
|
||||
t1.platform,
|
||||
'-',
|
||||
t1.version
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
t1
|
||||
WHERE
|
||||
t1.token_decimals IS NULL
|
||||
AND t1._inserted_timestamp < (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
{{ ref('silver__contracts') }} C
|
||||
WHERE
|
||||
C._inserted_timestamp > DATEADD('DAY', -14, SYSDATE())
|
||||
AND C.decimals IS NOT NULL
|
||||
AND C.address = t1.token_address)
|
||||
GROUP BY
|
||||
1
|
||||
)
|
||||
OR CONCAT(
|
||||
t0.block_number,
|
||||
'-',
|
||||
t0.platform,
|
||||
'-',
|
||||
t0.version
|
||||
) IN (
|
||||
SELECT
|
||||
CONCAT(
|
||||
t2.block_number,
|
||||
'-',
|
||||
t2.platform,
|
||||
'-',
|
||||
t2.version
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
t2
|
||||
WHERE
|
||||
t2.amount_usd IS NULL
|
||||
AND t2._inserted_timestamp < (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
{{ ref('silver__complete_token_prices') }}
|
||||
p
|
||||
WHERE
|
||||
p._inserted_timestamp > DATEADD('DAY', -14, SYSDATE())
|
||||
AND p.price IS NOT NULL
|
||||
AND p.token_address = t2.token_address
|
||||
AND p.hour = DATE_TRUNC(
|
||||
'hour',
|
||||
t2.block_timestamp
|
||||
)
|
||||
)
|
||||
GROUP BY
|
||||
1
|
||||
)
|
||||
),
|
||||
{% endif %}
|
||||
|
||||
FINAL AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
complete_bridge_activity
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
UNION ALL
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
tx_hash,
|
||||
event_index,
|
||||
bridge_address,
|
||||
event_name,
|
||||
platform,
|
||||
version,
|
||||
sender,
|
||||
receiver,
|
||||
destination_chain_receiver,
|
||||
destination_chain_id,
|
||||
destination_chain,
|
||||
token_address,
|
||||
token_symbol,
|
||||
token_decimals,
|
||||
amount_unadj,
|
||||
amount_heal AS amount,
|
||||
amount_usd_heal AS amount_usd,
|
||||
_id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
heal_model
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
block_number,
|
||||
@ -792,10 +972,7 @@ SELECT
|
||||
token_decimals,
|
||||
amount_unadj,
|
||||
amount,
|
||||
CASE
|
||||
WHEN amount_usd_unadj < 1e+15 THEN amount_usd_unadj
|
||||
ELSE NULL
|
||||
END AS amount_usd,
|
||||
amount_usd,
|
||||
_id,
|
||||
_inserted_timestamp,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
|
||||
@ -20,7 +20,8 @@ WITH base_contracts AS (
|
||||
WHERE
|
||||
from_address = '0x06d538690af257da524f25d0cd52fd85b1c2173e'
|
||||
AND TYPE ILIKE 'create%'
|
||||
AND tx_status ILIKE 'success'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND trace_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -66,6 +66,7 @@ base_evt AS (
|
||||
ON d.contract_address = p.pool_address
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x34660fc8af304464529f48a778e03d03e4d34bcd5f9b6f0cfbf3cd238c642f7f'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -44,6 +44,7 @@ WITH base_evt AS (
|
||||
'0xb80fdaa74dda763a8a158ba85798d373a5e84d84',
|
||||
'0xb8f275fbf7a959f4bce59999a2ef122a099e81a8'
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -43,6 +43,7 @@ WITH base_evt AS (
|
||||
)
|
||||
AND contract_address = '0x2796317b0ff8538f253012862c06787adfb8ceb6'
|
||||
AND origin_to_address IS NOT NULL
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -50,6 +50,7 @@ WITH base_evt AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x79c15604b92ef54d3f61f0c40caab8857927ca3d5092367163b4562c1699eb5f'
|
||||
AND contract_address = '0x2796317b0ff8538f253012862c06787adfb8ceb6'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -31,6 +31,7 @@ WITH pools_registered AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x3c13bc30b8e878c53fd2a36b679409c073afd75950be43d8858768e956fbc20e' --PoolRegistered
|
||||
AND contract_address = '0xba12222222228d8ba445958a75a0704d566bf2c8'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -72,6 +73,7 @@ tokens_registered AS (
|
||||
FROM
|
||||
pools_registered
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
),
|
||||
function_sigs AS (
|
||||
SELECT
|
||||
|
||||
@ -60,6 +60,7 @@ swaps_base AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x2170c741c41531aec20e7c107c24eecfdd15e69c9bb0a8dd37b1840b9e0b207b'
|
||||
AND contract_address = '0xba12222222228d8ba445958a75a0704d566bf2c8'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -43,7 +43,8 @@ WITH contract_deployments AS (
|
||||
'0x0c0e5f2ff0ff18a3be9b835635039256dc4b4963'
|
||||
)
|
||||
AND TYPE ILIKE 'create%'
|
||||
AND tx_status ILIKE 'success'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND trace_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -73,6 +73,7 @@ curve_base AS (
|
||||
'0xd013ca23e77a65003c2c659c5442c00c805371b7fc1ebd4c206c41d1536bd90b',
|
||||
'0x143f1f8e861fbdeddd5b46e844b7d3ac7b86a122f36e8c463859ee6811b1f29c'
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -141,6 +142,7 @@ token_transfers AS (
|
||||
curve_base
|
||||
)
|
||||
AND CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) <> '0x0000000000000000000000000000000000000000'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -28,6 +28,7 @@ WITH pool_events AS (
|
||||
'0x3a97247df274a17c59a3bd12735ea3fcdfb49950'
|
||||
) --DODOZoo
|
||||
AND topics [0] :: STRING = '0x5c428a2e12ecaa744a080b25b4cda8b86359c82d726575d7d747e07708071f93' --DODOBirth
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -71,6 +71,7 @@ sell_base_token AS (
|
||||
FROM
|
||||
proxies
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -41,6 +41,7 @@ WITH pools AS (
|
||||
--NewDSP
|
||||
'0xaf5c5f12a80fc937520df6fcaed66262a4cc775e0f3fceaf7a7cfe476d9a751d' --NewDVM
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -95,6 +95,7 @@ swaps_base AS (
|
||||
FROM
|
||||
proxies
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -31,6 +31,7 @@ WITH pool_creation AS (
|
||||
'0x43ec799eadd63848443e2347c49f5f52e8fe0f6f' --v2 factory
|
||||
)
|
||||
AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --pairCreated
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -59,6 +59,7 @@ swaps_base AS (
|
||||
ON l.contract_address = pool_address
|
||||
WHERE
|
||||
l.topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' --Swap
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -24,7 +24,8 @@ WITH contract_deployments AS (
|
||||
'0x596d32f9b7c1f2e73f5071c66b5e336e27d00da4'
|
||||
)
|
||||
AND TYPE ILIKE 'create%'
|
||||
AND tx_status ILIKE 'success'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND trace_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -67,6 +67,7 @@ router_swaps_base AS (
|
||||
ON l.contract_address = p.pool_address
|
||||
WHERE
|
||||
l.topics [0] :: STRING = '0xb709ddcc6550418e9b89df1f4938071eeaa3f6376309904c77e15d46b16066f5' --swap
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -131,6 +132,7 @@ swaps_base AS (
|
||||
ON l.contract_address = p.pool_address
|
||||
WHERE
|
||||
l.topics [0] :: STRING = '0x8cf3dec1929508e5677d7db003124e74802bfba7250a572205a9986d86ca9f1e' --swap
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -21,6 +21,7 @@ WITH contract_deployments AS (
|
||||
WHERE
|
||||
contract_address = '0xde828fdc3f497f16416d1bb645261c7c6a62dab5'
|
||||
AND topics [0] :: STRING = '0xdbd2a1ea6808362e6adbec4db4969cbc11e3b0b28fb6c74cb342defaaf1daada'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -53,6 +53,7 @@ swaps AS (
|
||||
ON l.contract_address = p.pool_address
|
||||
WHERE
|
||||
l.topics [0] :: STRING = '0x34f57786fb01682fb4eec88d340387ef01a168fe345ea5b76f709d4e560c10eb' --Trade
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -34,6 +34,7 @@ WITH pool_creation AS (
|
||||
WHERE
|
||||
contract_address = LOWER('0x833e4083B7ae46CeA85695c4f7ed25CDAd8886dE') --dynamic fee factory
|
||||
AND topics [0] :: STRING = '0xfc574402c445e75f2b79b67884ff9c662244dce454c5ae68935fcd0bebb7c8ff' --created pool
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -64,6 +64,7 @@ swaps_base AS (
|
||||
ON p.pool_address = l.contract_address
|
||||
WHERE
|
||||
l.topics [0] :: STRING = '0x606ecd02b3e3b4778f8e97b2e03351de14224efaa5fa64e62200afc9395c2499' --Dynamic Swap
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -39,6 +39,7 @@ WITH pool_creation AS (
|
||||
WHERE
|
||||
contract_address = LOWER('0x1c758aF0688502e49140230F6b0EBd376d429be5') --static pool factory
|
||||
AND topics [0] :: STRING = '0xb6bce363b712c921bead4bcc977289440eb6172eb89e258e3a25bd49ca806de6' --create pool
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -64,6 +64,7 @@ swaps_base AS (
|
||||
ON p.pool_address = l.contract_address
|
||||
WHERE
|
||||
l.topics [0] :: STRING = '0x606ecd02b3e3b4778f8e97b2e03351de14224efaa5fa64e62200afc9395c2499' -- static swap
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -30,6 +30,7 @@ WITH pool_creation AS (
|
||||
WHERE
|
||||
contract_address = '0x5f1dddbf348ac2fbe22a163e30f99f9ece3dd50a' --Elastic Pool Deployer
|
||||
AND topics [0] :: STRING = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118' --Create pool
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -77,6 +77,7 @@ swaps_base AS (
|
||||
ON p.pool_address = l.contract_address
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67' -- elastic swap
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -53,6 +53,7 @@ WITH pools AS (
|
||||
'0xa5ebd82503c72299073657957f41b9cea6c0a43a'
|
||||
)
|
||||
AND topics [0] :: STRING = '0x9b3fb3a17b4e94eb4d1217257372dcc712218fcd4bc1c28482bd8a6804a7c775'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -85,6 +85,7 @@ swaps_base AS (
|
||||
ON l.contract_address = pool_address
|
||||
WHERE
|
||||
l.topics [0] :: STRING = '0x3b841dc9ab51e3104bda4f61b41e4271192d22cd19da5ee6e292dc8e2744f713' --Swap
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -27,6 +27,7 @@ WITH pool_creation AS (
|
||||
WHERE
|
||||
contract_address = '0x1097053fd2ea711dad45caccc45eff7548fcb362' --factory
|
||||
AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --PairCreated
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -58,6 +58,7 @@ WITH swaps_base AS (
|
||||
WHERE
|
||||
contract_address = '0x9ca2a439810524250e543ba8fb6e88578af242bc' --router
|
||||
AND topics [0] :: STRING = '0xe7d6f812e1a54298ddef0b881cd08a4d452d9de35eb18b5145aa580fdda18b26' --swap
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -36,6 +36,7 @@ WITH created_pools AS (
|
||||
WHERE
|
||||
contract_address = '0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865' --factory
|
||||
AND topics [0] :: STRING = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118' --paircreated
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -27,6 +27,7 @@ WITH pool_creation AS (
|
||||
WHERE
|
||||
contract_address = LOWER('0x115934131916C8b277DD010Ee02de363c09d037c')
|
||||
AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --PairCreated
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -9,14 +9,13 @@
|
||||
WITH swaps_base AS (
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
contract_address,
|
||||
NULL AS pool_name,
|
||||
'SynthExchange' AS event_name,
|
||||
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
|
||||
CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS sender,
|
||||
@ -26,16 +25,26 @@ WITH swaps_base AS (
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [3] :: STRING
|
||||
) :: INTEGER AS amount_out_unadj,
|
||||
REGEXP_REPLACE(utils.udf_hex_to_string(
|
||||
segmented_data [0] :: STRING
|
||||
),'[^a-zA-Z0-9]+') AS symbol_in,
|
||||
REGEXP_REPLACE(utils.udf_hex_to_string(
|
||||
segmented_data [2] :: STRING
|
||||
),'[^a-zA-Z0-9]+') AS symbol_out,
|
||||
CONCAT('0x', SUBSTR(segmented_data [4] :: STRING, 25, 40))AS tx_to,
|
||||
REGEXP_REPLACE(
|
||||
utils.udf_hex_to_string(
|
||||
segmented_data [0] :: STRING
|
||||
),
|
||||
'[^a-zA-Z0-9]+'
|
||||
) AS symbol_in,
|
||||
REGEXP_REPLACE(
|
||||
utils.udf_hex_to_string(
|
||||
segmented_data [2] :: STRING
|
||||
),
|
||||
'[^a-zA-Z0-9]+'
|
||||
) AS symbol_out,
|
||||
CONCAT('0x', SUBSTR(segmented_data [4] :: STRING, 25, 40)) AS tx_to,
|
||||
event_index,
|
||||
'synthetix' AS platform,
|
||||
CONCAT(tx_hash,'-',event_index) AS _log_id,
|
||||
CONCAT(
|
||||
tx_hash,
|
||||
'-',
|
||||
event_index
|
||||
) AS _log_id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
@ -44,7 +53,8 @@ WITH swaps_base AS (
|
||||
'0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f',
|
||||
'0xc011a72400e58ecd99ee497cf89e3775d4bd732f'
|
||||
) -- synthetix proxy contracts (new / old)
|
||||
AND topics[0] = '0x65b6972c94204d84cffd3a95615743e31270f04fdf251f3dccc705cfbad44776'
|
||||
AND topics [0] = '0x65b6972c94204d84cffd3a95615743e31270f04fdf251f3dccc705cfbad44776'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -54,22 +64,21 @@ AND _inserted_timestamp >= (
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
|
||||
)
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
contract_address,
|
||||
pool_name,
|
||||
event_name,
|
||||
sender,
|
||||
amount_in_unadj,
|
||||
amount_out_unadj,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
symbol_out,
|
||||
tx_to,
|
||||
@ -78,4 +87,22 @@ SELECT
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
swaps_base
|
||||
swaps_base s
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
synth_symbol AS synth_symbol_in,
|
||||
synth_proxy_address AS token_in,
|
||||
decimals AS decimals_in
|
||||
FROM
|
||||
{{ ref('silver__synthetix_synths_20230313') }}
|
||||
) sc1
|
||||
ON sc1.synth_symbol_in = s.symbol_in
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
synth_symbol AS synth_symbol_out,
|
||||
synth_proxy_address AS token_out,
|
||||
decimals AS decimals_out
|
||||
FROM
|
||||
{{ ref('silver__synthetix_synths_20230313') }}
|
||||
) sc2
|
||||
ON sc2.synth_symbol_out = s.symbol_out
|
||||
|
||||
@ -79,6 +79,7 @@ swaps_base AS (
|
||||
ON lb_pair = l.contract_address
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xad7d6f97abf51ce18e17a38f4d70e975be9c0708474987bb3e26ad21bd93ca70' --Swap
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -30,6 +30,7 @@ WITH pool_creation AS (
|
||||
WHERE
|
||||
contract_address = '0xdc8d77b69155c7e68a95a4fb0f06a71ff90b943a'
|
||||
AND topics [0] :: STRING = '0x2c8d104b27c6b7f4492017a6f5cf3803043688934ebcaa6a03540beeaf976aff' --LB PairCreated
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -35,6 +35,7 @@ WITH univ2_sushi_pairs AS (
|
||||
'0xc0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac'
|
||||
)
|
||||
AND topics [0] = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -72,6 +73,7 @@ uniswap_v3_pools AS (
|
||||
WHERE
|
||||
contract_address = '0x1f98431c8ad98523631ae4a59f267346ea31f984'
|
||||
AND topics [0] = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -29,6 +29,7 @@ WITH pool_creation AS (
|
||||
WHERE
|
||||
contract_address = '0xee3e9e46e34a27dc755a63e2849c9913ee1a06e2'
|
||||
AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --pairCreated
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -59,6 +59,7 @@ swaps_base AS (
|
||||
ON l.contract_address = pool_address
|
||||
WHERE
|
||||
l.topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' --Swap
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
-- depends_on: {{ ref('silver__complete_token_prices') }}
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = ['block_number','platform'],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['reorg','curated']
|
||||
tags = ['reorg','curated','heal']
|
||||
) }}
|
||||
|
||||
WITH aave AS (
|
||||
@ -21,30 +22,29 @@ WITH aave AS (
|
||||
aave_token AS protocol_market,
|
||||
aave_market AS token_address,
|
||||
symbol AS token_symbol,
|
||||
borrowed_tokens_unadj as amount_unadj,
|
||||
borrowed_tokens as amount,
|
||||
borrowed_usd as amount_usd,
|
||||
aave_version as platform,
|
||||
borrowed_tokens_unadj AS amount_unadj,
|
||||
borrowed_tokens AS amount,
|
||||
borrowed_usd AS amount_usd,
|
||||
aave_version AS platform,
|
||||
'ethereum' AS blockchain,
|
||||
A._LOG_ID,
|
||||
A._INSERTED_TIMESTAMP
|
||||
FROM
|
||||
{{ ref('silver__aave_borrows') }} A
|
||||
|
||||
{% if is_incremental() and 'aave' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'aave' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
A._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '12 hours'
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
spark AS (
|
||||
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -68,20 +68,19 @@ spark AS (
|
||||
FROM
|
||||
{{ ref('silver__spark_borrows') }} A
|
||||
|
||||
{% if is_incremental() and 'spark' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'spark' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
A._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
radiant AS (
|
||||
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -105,20 +104,19 @@ radiant AS (
|
||||
FROM
|
||||
{{ ref('silver__radiant_borrows') }} A
|
||||
|
||||
{% if is_incremental() and 'radiant' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'radiant' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
A._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
sturdy AS (
|
||||
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -142,20 +140,19 @@ sturdy AS (
|
||||
FROM
|
||||
{{ ref('silver__sturdy_borrows') }} A
|
||||
|
||||
{% if is_incremental() and 'sturdy' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'sturdy' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
A._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
uwu AS (
|
||||
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -179,13 +176,13 @@ uwu AS (
|
||||
FROM
|
||||
{{ ref('silver__uwu_borrows') }} A
|
||||
|
||||
{% if is_incremental() and 'uwu' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'uwu' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
A._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -215,13 +212,13 @@ flux AS (
|
||||
FROM
|
||||
{{ ref('silver__flux_borrows') }} A
|
||||
|
||||
{% if is_incremental() and 'flux' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'flux' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
A._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -251,13 +248,13 @@ cream AS (
|
||||
FROM
|
||||
{{ ref('silver__cream_borrows') }} A
|
||||
|
||||
{% if is_incremental() and 'cream' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'cream' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
A._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -287,19 +284,19 @@ strike AS (
|
||||
FROM
|
||||
{{ ref('silver__strike_borrows') }} A
|
||||
|
||||
{% if is_incremental() and 'strike' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'strike' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
A._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
silo as (
|
||||
silo AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -324,19 +321,19 @@ silo as (
|
||||
{{ ref('silver__silo_borrows') }}
|
||||
l
|
||||
|
||||
{% if is_incremental() and 'silo' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
l._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'silo' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
l._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
fraxlend as (
|
||||
fraxlend AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -348,7 +345,7 @@ fraxlend as (
|
||||
contract_address,
|
||||
borrower,
|
||||
frax_market_address AS protocol_market,
|
||||
borrow_asset as token_address,
|
||||
borrow_asset AS token_address,
|
||||
borrow_symbol AS symbol,
|
||||
borrow_amount_unadj AS amount_unadj,
|
||||
borrow_amount AS amount,
|
||||
@ -360,19 +357,19 @@ fraxlend as (
|
||||
FROM
|
||||
{{ ref('silver__fraxlend_borrows') }} A
|
||||
|
||||
{% if is_incremental() and 'fraxlend' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
A._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'fraxlend' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
A._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
comp as (
|
||||
comp AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -399,19 +396,19 @@ comp as (
|
||||
FROM
|
||||
{{ ref('silver__comp_borrows') }}
|
||||
|
||||
{% if is_incremental() and 'comp' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'comp' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
borrow_union as (
|
||||
borrow_union AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
@ -467,7 +464,7 @@ borrow_union as (
|
||||
FROM
|
||||
uwu
|
||||
),
|
||||
FINAL AS (
|
||||
complete_lending_borrows AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -488,11 +485,13 @@ FINAL AS (
|
||||
b.token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
CASE
|
||||
WHEN platform NOT IN ('Aave','Compound')
|
||||
THEN ROUND((amount * price), 2)
|
||||
ELSE amount_usd
|
||||
END as amount_usd,
|
||||
CASE
|
||||
WHEN platform NOT IN (
|
||||
'Aave',
|
||||
'Compound'
|
||||
) THEN ROUND((amount * price), 2)
|
||||
ELSE amount_usd
|
||||
END AS amount_usd,
|
||||
platform,
|
||||
b.blockchain,
|
||||
b._LOG_ID,
|
||||
@ -506,8 +505,129 @@ FINAL AS (
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
LEFT JOIN {{ ref('silver__contracts') }} C
|
||||
ON b.token_address = C.address
|
||||
),
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
heal_model AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
event_index,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
borrower,
|
||||
event_name,
|
||||
protocol_market,
|
||||
t0.token_address,
|
||||
t0.token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
CASE
|
||||
WHEN platform NOT IN (
|
||||
'Aave',
|
||||
'Compound'
|
||||
) THEN ROUND((amount * price), 2)
|
||||
ELSE amount_usd
|
||||
END AS amount_usd_heal,
|
||||
platform,
|
||||
t0.blockchain,
|
||||
t0._LOG_ID,
|
||||
t0._INSERTED_TIMESTAMP
|
||||
FROM
|
||||
{{ this }}
|
||||
t0
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON t0.token_address = p.token_address
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
WHERE
|
||||
CONCAT(
|
||||
t0.block_number,
|
||||
'-',
|
||||
t0.platform
|
||||
) IN (
|
||||
SELECT
|
||||
CONCAT(
|
||||
t1.block_number,
|
||||
'-',
|
||||
t1.platform
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
t1
|
||||
WHERE
|
||||
t1.amount_usd IS NULL
|
||||
AND t1._inserted_timestamp < (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
{{ ref('silver__complete_token_prices') }}
|
||||
p
|
||||
WHERE
|
||||
p._inserted_timestamp > DATEADD('DAY', -14, SYSDATE())
|
||||
AND p.price IS NOT NULL
|
||||
AND p.token_address = t1.token_address
|
||||
AND p.hour = DATE_TRUNC(
|
||||
'hour',
|
||||
t1.block_timestamp
|
||||
)
|
||||
)
|
||||
GROUP BY
|
||||
1
|
||||
)
|
||||
),
|
||||
{% endif %}
|
||||
|
||||
FINAL AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
complete_lending_borrows
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
UNION ALL
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
event_index,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
borrower,
|
||||
event_name,
|
||||
protocol_market,
|
||||
token_address,
|
||||
token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
amount_usd_heal AS amount_usd,
|
||||
platform,
|
||||
blockchain,
|
||||
_LOG_ID,
|
||||
_INSERTED_TIMESTAMP
|
||||
FROM
|
||||
heal_model
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
-- depends_on: {{ ref('silver__complete_token_prices') }}
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = ['block_number','platform'],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['reorg','curated']
|
||||
tags = ['reorg','curated','heal']
|
||||
) }}
|
||||
|
||||
WITH aave AS (
|
||||
@ -20,7 +21,7 @@ WITH aave AS (
|
||||
depositor_address,
|
||||
aave_token AS protocol_market,
|
||||
aave_market AS token_address,
|
||||
symbol as token_symbol,
|
||||
symbol AS token_symbol,
|
||||
issued_tokens_unadj AS amount_unadj,
|
||||
issued_tokens AS amount,
|
||||
supplied_usd AS amount_usd,
|
||||
@ -31,11 +32,11 @@ WITH aave AS (
|
||||
FROM
|
||||
{{ ref('silver__aave_deposits') }}
|
||||
|
||||
{% if is_incremental() and 'aave' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'aave' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -65,11 +66,11 @@ radiant AS (
|
||||
FROM
|
||||
{{ ref('silver__radiant_deposits') }}
|
||||
|
||||
{% if is_incremental() and 'radiant' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'radiant' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -99,11 +100,11 @@ spark AS (
|
||||
FROM
|
||||
{{ ref('silver__spark_deposits') }}
|
||||
|
||||
{% if is_incremental() and 'spark' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'spark' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -133,11 +134,11 @@ sturdy AS (
|
||||
FROM
|
||||
{{ ref('silver__sturdy_deposits') }}
|
||||
|
||||
{% if is_incremental() and 'sturdy' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'sturdy' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -167,11 +168,11 @@ uwu AS (
|
||||
FROM
|
||||
{{ ref('silver__uwu_deposits') }}
|
||||
|
||||
{% if is_incremental() and 'uwu' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'uwu' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -201,11 +202,11 @@ cream AS (
|
||||
FROM
|
||||
{{ ref('silver__cream_deposits') }}
|
||||
|
||||
{% if is_incremental() and 'cream' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'cream' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -235,11 +236,11 @@ flux AS (
|
||||
FROM
|
||||
{{ ref('silver__flux_deposits') }}
|
||||
|
||||
{% if is_incremental() and 'flux' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'flux' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -269,17 +270,17 @@ strike AS (
|
||||
FROM
|
||||
{{ ref('silver__strike_deposits') }}
|
||||
|
||||
{% if is_incremental() and 'strike' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'strike' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
comp as (
|
||||
comp AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -306,17 +307,17 @@ comp as (
|
||||
FROM
|
||||
{{ ref('silver__comp_deposits') }}
|
||||
|
||||
{% if is_incremental() and 'comp' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'comp' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
fraxlend as (
|
||||
fraxlend AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -328,10 +329,10 @@ fraxlend as (
|
||||
contract_address,
|
||||
caller AS depositor_address,
|
||||
frax_market_address AS protocol_market,
|
||||
deposit_asset as token_address,
|
||||
deposit_asset AS token_address,
|
||||
underlying_symbol AS token_symbol,
|
||||
deposit_amount_unadj as amount_unadj,
|
||||
deposit_amount as amount,
|
||||
deposit_amount_unadj AS amount_unadj,
|
||||
deposit_amount AS amount,
|
||||
NULL AS amount_usd,
|
||||
'Fraxlend' AS platform,
|
||||
'ethereum' AS blockchain,
|
||||
@ -340,19 +341,19 @@ fraxlend as (
|
||||
FROM
|
||||
{{ ref('silver__fraxlend_deposits') }}
|
||||
|
||||
{% if is_incremental() and 'fraxlend' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'fraxlend' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
silo as (
|
||||
silo AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -376,74 +377,73 @@ silo as (
|
||||
FROM
|
||||
{{ ref('silver__silo_deposits') }}
|
||||
|
||||
{% if is_incremental() and 'silo' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'silo' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
deposit_union as (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
aave
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
comp
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
cream
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
flux
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
fraxlend
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
radiant
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
silo
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
spark
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
strike
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sturdy
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
uwu
|
||||
deposit_union AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
aave
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
comp
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
cream
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
flux
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
fraxlend
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
radiant
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
silo
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
spark
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
strike
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sturdy
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
uwu
|
||||
),
|
||||
|
||||
FINAL AS (
|
||||
complete_lending_deposits AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -456,13 +456,12 @@ FINAL AS (
|
||||
CASE
|
||||
WHEN platform = 'Fraxlend' THEN 'AddCollateral'
|
||||
WHEN platform = 'Compound V3' THEN 'SupplyCollateral'
|
||||
WHEN platform IN
|
||||
(
|
||||
WHEN platform IN (
|
||||
'Compound V2',
|
||||
'Cream',
|
||||
'Flux',
|
||||
'Strike'
|
||||
) THEN 'Mint'
|
||||
) THEN 'Mint'
|
||||
WHEN platform IN (
|
||||
'Spark',
|
||||
'Aave V3',
|
||||
@ -472,17 +471,19 @@ FINAL AS (
|
||||
) THEN 'Supply'
|
||||
ELSE 'Deposit'
|
||||
END AS event_name,
|
||||
depositor_address as depositor,
|
||||
depositor_address AS depositor,
|
||||
protocol_market,
|
||||
a.token_address,
|
||||
A.token_address,
|
||||
A.token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
CASE
|
||||
WHEN platform NOT IN ('Aave','Compound')
|
||||
THEN ROUND((amount * price), 2)
|
||||
ELSE amount_usd
|
||||
END as amount_usd,
|
||||
CASE
|
||||
WHEN platform NOT IN (
|
||||
'Aave',
|
||||
'Compound'
|
||||
) THEN ROUND((amount * price), 2)
|
||||
ELSE amount_usd
|
||||
END AS amount_usd,
|
||||
platform,
|
||||
A.blockchain,
|
||||
A._LOG_ID,
|
||||
@ -491,13 +492,134 @@ FINAL AS (
|
||||
deposit_union A
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON a.token_address = p.token_address
|
||||
ON A.token_address = p.token_address
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
LEFT JOIN {{ ref('silver__contracts') }} C
|
||||
ON a.token_address = C.address
|
||||
),
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
heal_model AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
event_index,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
event_name,
|
||||
depositor,
|
||||
protocol_market,
|
||||
t0.token_address,
|
||||
t0.token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
CASE
|
||||
WHEN platform NOT IN (
|
||||
'Aave',
|
||||
'Compound'
|
||||
) THEN ROUND((amount * price), 2)
|
||||
ELSE amount_usd
|
||||
END AS amount_usd_heal,
|
||||
platform,
|
||||
t0.blockchain,
|
||||
t0._LOG_ID,
|
||||
t0._INSERTED_TIMESTAMP
|
||||
FROM
|
||||
{{ this }}
|
||||
t0
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON t0.token_address = p.token_address
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
WHERE
|
||||
CONCAT(
|
||||
t0.block_number,
|
||||
'-',
|
||||
t0.platform
|
||||
) IN (
|
||||
SELECT
|
||||
CONCAT(
|
||||
t1.block_number,
|
||||
'-',
|
||||
t1.platform
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
t1
|
||||
WHERE
|
||||
t1.amount_usd IS NULL
|
||||
AND t1._inserted_timestamp < (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
{{ ref('silver__complete_token_prices') }}
|
||||
p
|
||||
WHERE
|
||||
p._inserted_timestamp > DATEADD('DAY', -14, SYSDATE())
|
||||
AND p.price IS NOT NULL
|
||||
AND p.token_address = t1.token_address
|
||||
AND p.hour = DATE_TRUNC(
|
||||
'hour',
|
||||
t1.block_timestamp
|
||||
)
|
||||
)
|
||||
GROUP BY
|
||||
1
|
||||
)
|
||||
),
|
||||
{% endif %}
|
||||
|
||||
FINAL AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
complete_lending_deposits
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
UNION ALL
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
event_index,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
event_name,
|
||||
depositor,
|
||||
protocol_market,
|
||||
token_address,
|
||||
token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
amount_usd_heal AS amount_usd,
|
||||
platform,
|
||||
blockchain,
|
||||
_LOG_ID,
|
||||
_INSERTED_TIMESTAMP
|
||||
FROM
|
||||
heal_model
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
-- depends_on: {{ ref('silver__complete_token_prices') }}
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = ['block_number','platform'],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['reorg','curated']
|
||||
tags = ['reorg','curated','heal']
|
||||
) }}
|
||||
|
||||
WITH aave AS (
|
||||
@ -28,24 +29,24 @@ WITH aave AS (
|
||||
initiator_address,
|
||||
target_address,
|
||||
aave_version AS platform,
|
||||
symbol as token_symbol,
|
||||
symbol AS token_symbol,
|
||||
blockchain,
|
||||
_LOG_ID,
|
||||
_INSERTED_TIMESTAMP
|
||||
FROM
|
||||
{{ ref('silver__aave_flashloans') }}
|
||||
|
||||
{% if is_incremental() and 'aave' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'aave' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
spark as (
|
||||
spark AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -73,17 +74,17 @@ spark as (
|
||||
FROM
|
||||
{{ ref('silver__spark_flashloans') }}
|
||||
|
||||
{% if is_incremental() and 'spark' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'spark' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
radiant as (
|
||||
radiant AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -111,17 +112,17 @@ radiant as (
|
||||
FROM
|
||||
{{ ref('silver__radiant_flashloans') }}
|
||||
|
||||
{% if is_incremental() and 'radiant' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'radiant' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
uwu as (
|
||||
uwu AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -149,38 +150,38 @@ uwu as (
|
||||
FROM
|
||||
{{ ref('silver__uwu_flashloans') }}
|
||||
|
||||
{% if is_incremental() and 'uwu' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'uwu' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
flashloan_union as (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
aave
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
radiant
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
spark
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
uwu
|
||||
flashloan_union AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
aave
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
radiant
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
spark
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
uwu
|
||||
),
|
||||
FINAL AS (
|
||||
complete_lending_flashloans AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -191,40 +192,209 @@ FINAL AS (
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
'FlashLoan' AS event_name,
|
||||
protocol_token as protocol_market,
|
||||
a.token_address as flashloan_token,
|
||||
token_symbol as flashloan_token_symbol,
|
||||
protocol_token AS protocol_market,
|
||||
A.token_address AS flashloan_token,
|
||||
token_symbol AS flashloan_token_symbol,
|
||||
flashloan_amount_unadj,
|
||||
flashloan_amount,
|
||||
CASE
|
||||
WHEN platform <> 'Aave'
|
||||
THEN ROUND((flashloan_amount * price), 2)
|
||||
ELSE flashloan_amount_usd
|
||||
END as flashloan_amount_usd,
|
||||
CASE
|
||||
WHEN platform <> 'Aave' THEN ROUND((flashloan_amount * price), 2)
|
||||
ELSE flashloan_amount_usd
|
||||
END AS flashloan_amount_usd,
|
||||
premium_amount_unadj,
|
||||
premium_amount,
|
||||
CASE
|
||||
WHEN platform <> 'Aave'
|
||||
THEN ROUND((premium_amount * price), 2)
|
||||
ELSE premium_amount_usd
|
||||
END as premium_amount_usd,
|
||||
initiator_address as initiator,
|
||||
target_address as target,
|
||||
CASE
|
||||
WHEN platform <> 'Aave' THEN ROUND((premium_amount * price), 2)
|
||||
ELSE premium_amount_usd
|
||||
END AS premium_amount_usd,
|
||||
initiator_address AS initiator,
|
||||
target_address AS target,
|
||||
platform,
|
||||
a.blockchain,
|
||||
a._LOG_ID,
|
||||
a._INSERTED_TIMESTAMP
|
||||
A.blockchain,
|
||||
A._LOG_ID,
|
||||
A._INSERTED_TIMESTAMP
|
||||
FROM
|
||||
flashloan_union a
|
||||
flashloan_union A
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON a.token_address = p.token_address
|
||||
ON A.token_address = p.token_address
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
LEFT JOIN {{ ref('silver__contracts') }} C
|
||||
ON a.token_address = C.address
|
||||
),
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
heal_model AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
event_index,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
event_name,
|
||||
protocol_market,
|
||||
flashloan_token,
|
||||
flashloan_token_symbol,
|
||||
flashloan_amount_unadj,
|
||||
flashloan_amount,
|
||||
CASE
|
||||
WHEN platform <> 'Aave' THEN ROUND((flashloan_amount * price), 2)
|
||||
ELSE flashloan_amount_usd
|
||||
END AS flashloan_amount_usd_heal,
|
||||
premium_amount_unadj,
|
||||
premium_amount,
|
||||
CASE
|
||||
WHEN platform <> 'Aave' THEN ROUND((premium_amount * price), 2)
|
||||
ELSE premium_amount_usd
|
||||
END AS premium_amount_usd_heal,
|
||||
initiator,
|
||||
target,
|
||||
platform,
|
||||
t0.blockchain,
|
||||
t0._LOG_ID,
|
||||
t0._INSERTED_TIMESTAMP
|
||||
FROM
|
||||
{{ this }}
|
||||
t0
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON t0.flashloan_token = p.token_address
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
WHERE
|
||||
CONCAT(
|
||||
t0.block_number,
|
||||
'-',
|
||||
t0.platform
|
||||
) IN (
|
||||
SELECT
|
||||
CONCAT(
|
||||
t1.block_number,
|
||||
'-',
|
||||
t1.platform
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
t1
|
||||
WHERE
|
||||
t1.flashloan_amount_usd IS NULL
|
||||
AND t1._inserted_timestamp < (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
{{ ref('silver__complete_token_prices') }}
|
||||
p
|
||||
WHERE
|
||||
p._inserted_timestamp > DATEADD('DAY', -14, SYSDATE())
|
||||
AND p.price IS NOT NULL
|
||||
AND p.token_address = t1.flashloan_token
|
||||
AND p.hour = DATE_TRUNC(
|
||||
'hour',
|
||||
t1.block_timestamp
|
||||
)
|
||||
)
|
||||
GROUP BY
|
||||
1
|
||||
)
|
||||
OR CONCAT(
|
||||
t0.block_number,
|
||||
'-',
|
||||
t0.platform
|
||||
) IN (
|
||||
SELECT
|
||||
CONCAT(
|
||||
t2.block_number,
|
||||
'-',
|
||||
t2.platform
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
t2
|
||||
WHERE
|
||||
t2.premium_amount_usd IS NULL
|
||||
AND t2._inserted_timestamp < (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
{{ ref('silver__complete_token_prices') }}
|
||||
p
|
||||
WHERE
|
||||
p._inserted_timestamp > DATEADD('DAY', -14, SYSDATE())
|
||||
AND p.price IS NOT NULL
|
||||
AND p.token_address = t2.flashloan_token
|
||||
AND p.hour = DATE_TRUNC(
|
||||
'hour',
|
||||
t2.block_timestamp
|
||||
)
|
||||
)
|
||||
GROUP BY
|
||||
1
|
||||
)
|
||||
),
|
||||
{% endif %}
|
||||
|
||||
FINAL AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
complete_lending_flashloans
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
UNION ALL
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
event_index,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
event_name,
|
||||
protocol_market,
|
||||
flashloan_token,
|
||||
flashloan_token_symbol,
|
||||
flashloan_amount_unadj,
|
||||
flashloan_amount,
|
||||
flashloan_amount_usd_heal AS flashloan_amount_usd,
|
||||
premium_amount_unadj,
|
||||
premium_amount,
|
||||
premium_amount_usd_heal AS premium_amount_usd,
|
||||
initiator,
|
||||
target,
|
||||
platform,
|
||||
blockchain,
|
||||
_LOG_ID,
|
||||
_INSERTED_TIMESTAMP
|
||||
FROM
|
||||
heal_model
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
-- depends_on: {{ ref('silver__complete_token_prices') }}
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = ['block_number','platform'],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['reorg','curated']
|
||||
tags = ['reorg','curated','heal']
|
||||
) }}
|
||||
|
||||
WITH aave as (
|
||||
SELECT
|
||||
WITH aave AS (
|
||||
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
@ -33,18 +35,17 @@ WITH aave as (
|
||||
FROM
|
||||
{{ ref('silver__aave_liquidations') }}
|
||||
|
||||
{% if is_incremental() and 'aave' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'aave' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
|
||||
radiant as (
|
||||
radiant AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -71,17 +72,17 @@ radiant as (
|
||||
FROM
|
||||
{{ ref('silver__radiant_liquidations') }}
|
||||
|
||||
{% if is_incremental() and 'radiant' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'radiant' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
spark as (
|
||||
spark AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -108,17 +109,17 @@ spark as (
|
||||
FROM
|
||||
{{ ref('silver__spark_liquidations') }}
|
||||
|
||||
{% if is_incremental() and 'spark' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'spark' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
sturdy as (
|
||||
sturdy AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -145,17 +146,17 @@ sturdy as (
|
||||
FROM
|
||||
{{ ref('silver__sturdy_liquidations') }}
|
||||
|
||||
{% if is_incremental() and 'sturdy' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'sturdy' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
uwu as (
|
||||
uwu AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -182,17 +183,17 @@ uwu as (
|
||||
FROM
|
||||
{{ ref('silver__uwu_liquidations') }}
|
||||
|
||||
{% if is_incremental() and 'uwu' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'uwu' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
cream as (
|
||||
cream AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -220,17 +221,17 @@ cream as (
|
||||
{{ ref('silver__cream_liquidations') }}
|
||||
l
|
||||
|
||||
{% if is_incremental() and 'cream' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'cream' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
l._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
flux as (
|
||||
flux AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -258,17 +259,17 @@ flux as (
|
||||
{{ ref('silver__flux_liquidations') }}
|
||||
l
|
||||
|
||||
{% if is_incremental() and 'flux' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'flux' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
l._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
strike as (
|
||||
strike AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -296,19 +297,17 @@ strike as (
|
||||
{{ ref('silver__strike_liquidations') }}
|
||||
l
|
||||
|
||||
{% if is_incremental() and 'strike' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'strike' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
l._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
|
||||
comp AS (
|
||||
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -336,11 +335,11 @@ comp AS (
|
||||
{{ ref('silver__comp_liquidations') }}
|
||||
l
|
||||
|
||||
{% if is_incremental() and 'comp' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'comp' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
l._inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -373,19 +372,19 @@ fraxlend AS (
|
||||
FROM
|
||||
{{ ref('silver__fraxlend_liquidations') }}
|
||||
|
||||
{% if is_incremental() and 'fraxlend' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'fraxlend' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
silo as (
|
||||
silo AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -412,110 +411,73 @@ silo as (
|
||||
FROM
|
||||
{{ ref('silver__silo_liquidations') }}
|
||||
|
||||
{% if is_incremental() and 'silo' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'silo' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
liquidation_union as (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
aave
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
comp
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
cream
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
flux
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
fraxlend
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
radiant
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
silo
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
spark
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
strike
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sturdy
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
uwu
|
||||
),
|
||||
contracts AS (
|
||||
liquidation_union AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__contracts') }}
|
||||
WHERE
|
||||
address IN (
|
||||
SELECT
|
||||
DISTINCT(collateral_asset) AS asset
|
||||
FROM
|
||||
liquidation_union
|
||||
UNION ALL
|
||||
SELECT
|
||||
DISTINCT(debt_asset) AS asset
|
||||
FROM
|
||||
liquidation_union
|
||||
)
|
||||
),
|
||||
prices AS (
|
||||
aave
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
WHERE
|
||||
token_address IN (
|
||||
SELECT
|
||||
DISTINCT(collateral_asset) AS asset
|
||||
FROM
|
||||
liquidation_union)
|
||||
AND HOUR > (
|
||||
SELECT
|
||||
MIN(block_timestamp)
|
||||
FROM
|
||||
liquidation_union
|
||||
)
|
||||
comp
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
cream
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
flux
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
fraxlend
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
radiant
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
silo
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
spark
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
strike
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sturdy
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
uwu
|
||||
),
|
||||
FINAL AS (
|
||||
complete_lending_liquidations AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -532,42 +494,170 @@ FINAL AS (
|
||||
'Compound V2',
|
||||
'Cream',
|
||||
'Flux',
|
||||
'Strike') THEN 'LiquidateBorrow'
|
||||
'Strike'
|
||||
) THEN 'LiquidateBorrow'
|
||||
ELSE 'LiquidationCall'
|
||||
END AS event_name,
|
||||
liquidator,
|
||||
borrower,
|
||||
protocol_collateral_asset as protocol_market,
|
||||
collateral_asset as collateral_token,
|
||||
collateral_asset_symbol as collateral_token_symbol,
|
||||
protocol_collateral_asset AS protocol_market,
|
||||
collateral_asset AS collateral_token,
|
||||
collateral_asset_symbol AS collateral_token_symbol,
|
||||
liquidated_amount_unadj AS amount_unadj,
|
||||
liquidated_amount AS amount,
|
||||
CASE
|
||||
WHEN platform NOT LIKE '%Aave%' OR platform NOT LIKE '%Compound%'
|
||||
THEN ROUND((liquidated_amount * p.price), 2)
|
||||
WHEN platform NOT LIKE '%Aave%'
|
||||
OR platform NOT LIKE '%Compound%' THEN ROUND((liquidated_amount * p.price), 2)
|
||||
ELSE ROUND(
|
||||
liquidated_amount_usd,
|
||||
2
|
||||
)
|
||||
END AS amount_usd,
|
||||
debt_asset as debt_token,
|
||||
debt_asset_symbol as debt_token_symbol,
|
||||
debt_asset AS debt_token,
|
||||
debt_asset_symbol AS debt_token_symbol,
|
||||
platform,
|
||||
A.blockchain,
|
||||
A._LOG_ID,
|
||||
A._INSERTED_TIMESTAMP
|
||||
FROM
|
||||
liquidation_union A
|
||||
LEFT JOIN prices p
|
||||
ON a.collateral_asset = p.token_address
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON A.collateral_asset = p.token_address
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
LEFT JOIN contracts C
|
||||
ON a.collateral_asset = C.address
|
||||
LEFT JOIN contracts c2
|
||||
ON a.debt_asset = C.address
|
||||
),
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
heal_model AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
event_index,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
event_name,
|
||||
liquidator,
|
||||
borrower,
|
||||
protocol_market,
|
||||
collateral_token,
|
||||
collateral_token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
CASE
|
||||
WHEN platform NOT LIKE '%Aave%'
|
||||
OR platform NOT LIKE '%Compound%' THEN ROUND((amount * p.price), 2)
|
||||
ELSE ROUND(
|
||||
amount_usd,
|
||||
2
|
||||
)
|
||||
END AS amount_usd_heal,
|
||||
debt_token,
|
||||
debt_token_symbol,
|
||||
platform,
|
||||
t0.blockchain,
|
||||
t0._LOG_ID,
|
||||
t0._INSERTED_TIMESTAMP
|
||||
FROM
|
||||
{{ this }}
|
||||
t0
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON t0.collateral_token = p.token_address
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
WHERE
|
||||
CONCAT(
|
||||
t0.block_number,
|
||||
'-',
|
||||
t0.platform
|
||||
) IN (
|
||||
SELECT
|
||||
CONCAT(
|
||||
t1.block_number,
|
||||
'-',
|
||||
t1.platform
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
t1
|
||||
WHERE
|
||||
t1.amount_usd IS NULL
|
||||
AND t1._inserted_timestamp < (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
{{ ref('silver__complete_token_prices') }}
|
||||
p
|
||||
WHERE
|
||||
p._inserted_timestamp > DATEADD('DAY', -14, SYSDATE())
|
||||
AND p.price IS NOT NULL
|
||||
AND p.token_address = t1.collateral_token
|
||||
AND p.hour = DATE_TRUNC(
|
||||
'hour',
|
||||
t1.block_timestamp
|
||||
)
|
||||
)
|
||||
GROUP BY
|
||||
1
|
||||
)
|
||||
),
|
||||
{% endif %}
|
||||
|
||||
FINAL AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
complete_lending_liquidations
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
UNION ALL
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
event_index,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
event_name,
|
||||
liquidator,
|
||||
borrower,
|
||||
protocol_market,
|
||||
collateral_token,
|
||||
collateral_token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
amount_usd_heal AS amount_usd,
|
||||
debt_token,
|
||||
debt_token_symbol,
|
||||
platform,
|
||||
blockchain,
|
||||
_LOG_ID,
|
||||
_INSERTED_TIMESTAMP
|
||||
FROM
|
||||
heal_model
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
-- depends_on: {{ ref('silver__complete_token_prices') }}
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = ['block_number','platform'],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['reorg','curated']
|
||||
tags = ['reorg','curated','heal']
|
||||
) }}
|
||||
|
||||
WITH aave AS (
|
||||
@ -32,18 +33,17 @@ WITH aave AS (
|
||||
FROM
|
||||
{{ ref('silver__aave_repayments') }}
|
||||
|
||||
{% if is_incremental() and 'aave' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'aave' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
radiant as (
|
||||
|
||||
radiant AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -68,18 +68,17 @@ radiant as (
|
||||
FROM
|
||||
{{ ref('silver__radiant_repayments') }}
|
||||
|
||||
{% if is_incremental() and 'radiant' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'radiant' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
spark as (
|
||||
|
||||
spark AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -104,18 +103,17 @@ spark as (
|
||||
FROM
|
||||
{{ ref('silver__spark_repayments') }}
|
||||
|
||||
{% if is_incremental() and 'spark' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'spark' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
sturdy as (
|
||||
|
||||
sturdy AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -140,18 +138,17 @@ sturdy as (
|
||||
FROM
|
||||
{{ ref('silver__sturdy_repayments') }}
|
||||
|
||||
{% if is_incremental() and 'sturdy' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'sturdy' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
uwu as (
|
||||
|
||||
uwu AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -176,17 +173,17 @@ uwu as (
|
||||
FROM
|
||||
{{ ref('silver__uwu_repayments') }}
|
||||
|
||||
{% if is_incremental() and 'uwu' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'uwu' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
cream as (
|
||||
cream AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -211,17 +208,17 @@ cream as (
|
||||
FROM
|
||||
{{ ref('silver__cream_repayments') }}
|
||||
|
||||
{% if is_incremental() and 'cream' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'cream' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
flux as (
|
||||
flux AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -246,17 +243,17 @@ flux as (
|
||||
FROM
|
||||
{{ ref('silver__flux_repayments') }}
|
||||
|
||||
{% if is_incremental() and 'flux' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'flux' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
strike as (
|
||||
strike AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -281,17 +278,17 @@ strike as (
|
||||
FROM
|
||||
{{ ref('silver__strike_repayments') }}
|
||||
|
||||
{% if is_incremental() and 'strike' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'strike' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
comp as (
|
||||
comp AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -319,17 +316,17 @@ comp as (
|
||||
FROM
|
||||
{{ ref('silver__comp_repayments') }}
|
||||
|
||||
{% if is_incremental() and 'comp' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'comp' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
fraxlend as (
|
||||
fraxlend AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -339,7 +336,7 @@ fraxlend as (
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
repay_asset as tokem_address,
|
||||
repay_asset AS tokem_address,
|
||||
frax_market_address AS protocol_token,
|
||||
repay_amount_unadj AS amount_unadj,
|
||||
repay_amount AS amount,
|
||||
@ -354,19 +351,19 @@ fraxlend as (
|
||||
FROM
|
||||
{{ ref('silver__fraxlend_repayments') }}
|
||||
|
||||
{% if is_incremental() and 'fraxlend' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'fraxlend' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
silo as (
|
||||
silo AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -391,73 +388,73 @@ silo as (
|
||||
FROM
|
||||
{{ ref('silver__silo_repayments') }}
|
||||
|
||||
{% if is_incremental() and 'silo' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'silo' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
repay_union as (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
aave
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
comp
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
cream
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
flux
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
fraxlend
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
radiant
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
silo
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
spark
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
strike
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sturdy
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
uwu
|
||||
repay_union AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
aave
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
comp
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
cream
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
flux
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
fraxlend
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
radiant
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
silo
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
spark
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
strike
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sturdy
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
uwu
|
||||
),
|
||||
FINAL AS (
|
||||
complete_lending_repayments AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -474,23 +471,24 @@ FINAL AS (
|
||||
'Compound V2',
|
||||
'Cream',
|
||||
'Flux',
|
||||
'Strike') THEN 'RepayBorrow'
|
||||
'Strike'
|
||||
) THEN 'RepayBorrow'
|
||||
ELSE 'Repay'
|
||||
END AS event_name,
|
||||
protocol_token AS protocol_market,
|
||||
a.token_address,
|
||||
A.token_address,
|
||||
amount_unadj,
|
||||
amount,
|
||||
CASE
|
||||
WHEN platform NOT LIKE '%Aave%' OR platform NOT LIKE '%Compound%'
|
||||
THEN ROUND((amount * price), 2)
|
||||
WHEN platform NOT LIKE '%Aave%'
|
||||
OR platform NOT LIKE '%Compound%' THEN ROUND((amount * price), 2)
|
||||
ELSE ROUND(
|
||||
amount_usd,
|
||||
2
|
||||
)
|
||||
END AS amount_usd,
|
||||
token_symbol,
|
||||
payer_address as payer,
|
||||
payer_address AS payer,
|
||||
borrower,
|
||||
platform,
|
||||
A.blockchain,
|
||||
@ -500,13 +498,137 @@ FINAL AS (
|
||||
repay_union A
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON a.token_address = p.token_address
|
||||
ON A.token_address = p.token_address
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
LEFT JOIN {{ ref('silver__contracts') }} C
|
||||
ON a.token_address = C.address
|
||||
),
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
heal_model AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
event_index,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
event_name,
|
||||
protocol_market,
|
||||
t0.token_address,
|
||||
amount_unadj,
|
||||
amount,
|
||||
CASE
|
||||
WHEN platform NOT LIKE '%Aave%'
|
||||
OR platform NOT LIKE '%Compound%' THEN ROUND((amount * price), 2)
|
||||
ELSE ROUND(
|
||||
amount_usd,
|
||||
2
|
||||
)
|
||||
END AS amount_usd_heal,
|
||||
token_symbol,
|
||||
payer,
|
||||
borrower,
|
||||
platform,
|
||||
t0.blockchain,
|
||||
t0._LOG_ID,
|
||||
t0._INSERTED_TIMESTAMP
|
||||
FROM
|
||||
{{ this }}
|
||||
t0
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON t0.token_address = p.token_address
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
WHERE
|
||||
CONCAT(
|
||||
t0.block_number,
|
||||
'-',
|
||||
t0.platform
|
||||
) IN (
|
||||
SELECT
|
||||
CONCAT(
|
||||
t1.block_number,
|
||||
'-',
|
||||
t1.platform
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
t1
|
||||
WHERE
|
||||
t1.amount_usd IS NULL
|
||||
AND t1._inserted_timestamp < (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
{{ ref('silver__complete_token_prices') }}
|
||||
p
|
||||
WHERE
|
||||
p._inserted_timestamp > DATEADD('DAY', -14, SYSDATE())
|
||||
AND p.price IS NOT NULL
|
||||
AND p.token_address = t1.token_address
|
||||
AND p.hour = DATE_TRUNC(
|
||||
'hour',
|
||||
t1.block_timestamp
|
||||
)
|
||||
)
|
||||
GROUP BY
|
||||
1
|
||||
)
|
||||
),
|
||||
{% endif %}
|
||||
|
||||
FINAL AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
complete_lending_repayments
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
UNION ALL
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
event_index,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
event_name,
|
||||
protocol_market,
|
||||
token_address,
|
||||
amount_unadj,
|
||||
amount,
|
||||
amount_usd_heal AS amount_usd,
|
||||
token_symbol,
|
||||
payer,
|
||||
borrower,
|
||||
platform,
|
||||
blockchain,
|
||||
_LOG_ID,
|
||||
_INSERTED_TIMESTAMP
|
||||
FROM
|
||||
heal_model
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
-- depends_on: {{ ref('silver__complete_token_prices') }}
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = ['block_number','platform'],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['reorg','curated']
|
||||
tags = ['reorg','curated','heal']
|
||||
) }}
|
||||
|
||||
WITH aave AS (
|
||||
@ -19,7 +20,7 @@ WITH aave AS (
|
||||
contract_address,
|
||||
aave_token AS protocol_token,
|
||||
aave_market AS token_address,
|
||||
symbol as token_symbol,
|
||||
symbol AS token_symbol,
|
||||
withdrawn_tokens_unadj AS amount_unadj,
|
||||
withdrawn_tokens AS amount,
|
||||
withdrawn_usd AS amount_usd,
|
||||
@ -31,20 +32,19 @@ WITH aave AS (
|
||||
FROM
|
||||
{{ ref('silver__aave_withdraws') }}
|
||||
|
||||
{% if is_incremental() and 'aave' not in var('HEAL_CURATED_MODEL') %}
|
||||
{% if is_incremental() and 'aave' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '12 hours'
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
radiant as (
|
||||
|
||||
radiant AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -68,20 +68,19 @@ radiant as (
|
||||
FROM
|
||||
{{ ref('silver__radiant_withdraws') }}
|
||||
|
||||
{% if is_incremental() and 'radiant' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'radiant' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
spark as (
|
||||
|
||||
spark AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -105,21 +104,19 @@ spark as (
|
||||
FROM
|
||||
{{ ref('silver__spark_withdraws') }}
|
||||
|
||||
{% if is_incremental() and 'spark' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'spark' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
|
||||
sturdy as (
|
||||
|
||||
sturdy AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -143,21 +140,19 @@ sturdy as (
|
||||
FROM
|
||||
{{ ref('silver__sturdy_withdraws') }}
|
||||
|
||||
{% if is_incremental() and 'sturdy' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'sturdy' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
|
||||
uwu as (
|
||||
|
||||
uwu AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -181,21 +176,19 @@ uwu as (
|
||||
FROM
|
||||
{{ ref('silver__uwu_withdraws') }}
|
||||
|
||||
{% if is_incremental() and 'uwu' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'uwu' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
|
||||
cream as (
|
||||
|
||||
cream AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -207,7 +200,7 @@ cream as (
|
||||
contract_address,
|
||||
token_address AS protocol_market,
|
||||
received_contract_address AS token_address,
|
||||
received_contract_symbol token_symbol,
|
||||
received_contract_symbol AS token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
NULL AS amount_usd,
|
||||
@ -219,21 +212,19 @@ cream as (
|
||||
FROM
|
||||
{{ ref('silver__cream_withdraws') }}
|
||||
|
||||
{% if is_incremental() and 'cream' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'cream' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
|
||||
flux as (
|
||||
|
||||
flux AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -245,7 +236,7 @@ flux as (
|
||||
contract_address,
|
||||
token_address AS protocol_market,
|
||||
received_contract_address AS token_address,
|
||||
received_contract_symbol token_symbol,
|
||||
received_contract_symbol AS token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
NULL AS amount_usd,
|
||||
@ -257,21 +248,19 @@ flux as (
|
||||
FROM
|
||||
{{ ref('silver__flux_withdraws') }}
|
||||
|
||||
{% if is_incremental() and 'flux' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'flux' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
|
||||
strike as (
|
||||
|
||||
strike AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -283,7 +272,7 @@ strike as (
|
||||
contract_address,
|
||||
token_address AS protocol_market,
|
||||
received_contract_address AS token_address,
|
||||
received_contract_symbol token_symbol,
|
||||
received_contract_symbol AS token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
NULL AS amount_usd,
|
||||
@ -295,19 +284,19 @@ strike as (
|
||||
FROM
|
||||
{{ ref('silver__strike_withdraws') }}
|
||||
|
||||
{% if is_incremental() and 'strike' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'strike' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
comp as (
|
||||
comp AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -334,19 +323,19 @@ comp as (
|
||||
FROM
|
||||
{{ ref('silver__comp_redemptions') }}
|
||||
|
||||
{% if is_incremental() and 'comp' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'comp' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
fraxlend as (
|
||||
fraxlend AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -370,19 +359,19 @@ fraxlend as (
|
||||
FROM
|
||||
{{ ref('silver__fraxlend_withdraws') }}
|
||||
|
||||
{% if is_incremental() and 'fraxlend' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'fraxlend' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
silo as (
|
||||
silo AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -406,19 +395,19 @@ silo as (
|
||||
FROM
|
||||
{{ ref('silver__silo_withdraws') }}
|
||||
|
||||
{% if is_incremental() and 'silo' not in var('HEAL_CURATED_MODEL') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
{% if is_incremental() and 'silo' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
withdraw_union as (
|
||||
withdraw_union AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
@ -474,7 +463,7 @@ withdraw_union as (
|
||||
FROM
|
||||
uwu
|
||||
),
|
||||
FINAL AS (
|
||||
complete_lending_withdraws AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
@ -491,24 +480,25 @@ FINAL AS (
|
||||
'Compound V2',
|
||||
'Cream',
|
||||
'Flux',
|
||||
'Strike') THEN 'Redeem'
|
||||
'Strike'
|
||||
) THEN 'Redeem'
|
||||
WHEN platform = 'Aave V1' THEN 'RedeemUnderlying'
|
||||
ELSE 'Withdraw'
|
||||
END AS event_name,
|
||||
protocol_token AS protocol_market,
|
||||
a.token_address,
|
||||
A.token_address,
|
||||
token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
CASE
|
||||
WHEN platform NOT LIKE '%Aave%' OR platform NOT LIKE '%Compound%'
|
||||
THEN ROUND((amount * p.price), 2)
|
||||
WHEN platform NOT LIKE '%Aave%'
|
||||
OR platform NOT LIKE '%Compound%' THEN ROUND((amount * p.price), 2)
|
||||
ELSE ROUND(
|
||||
amount_usd,
|
||||
2
|
||||
)
|
||||
END AS amount_usd,
|
||||
depositor_address as depositor,
|
||||
depositor_address AS depositor,
|
||||
platform,
|
||||
A.blockchain,
|
||||
A._log_id,
|
||||
@ -517,13 +507,135 @@ FINAL AS (
|
||||
withdraw_union A
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON a.token_address = p.token_address
|
||||
ON A.token_address = p.token_address
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
LEFT JOIN {{ ref('silver__contracts') }} C
|
||||
ON a.token_address = C.address
|
||||
),
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
heal_model AS (
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
event_index,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
event_name,
|
||||
protocol_market,
|
||||
t0.token_address,
|
||||
token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
CASE
|
||||
WHEN platform NOT LIKE '%Aave%'
|
||||
OR platform NOT LIKE '%Compound%' THEN ROUND((amount * p.price), 2)
|
||||
ELSE ROUND(
|
||||
amount_usd,
|
||||
2
|
||||
)
|
||||
END AS amount_usd_heal,
|
||||
depositor,
|
||||
platform,
|
||||
t0.blockchain,
|
||||
t0._log_id,
|
||||
t0._inserted_timestamp
|
||||
FROM
|
||||
{{ this }}
|
||||
t0
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON t0.token_address = p.token_address
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
WHERE
|
||||
CONCAT(
|
||||
t0.block_number,
|
||||
'-',
|
||||
t0.platform
|
||||
) IN (
|
||||
SELECT
|
||||
CONCAT(
|
||||
t1.block_number,
|
||||
'-',
|
||||
t1.platform
|
||||
)
|
||||
FROM
|
||||
{{ this }}
|
||||
t1
|
||||
WHERE
|
||||
t1.amount_usd IS NULL
|
||||
AND t1._inserted_timestamp < (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
{{ ref('silver__complete_token_prices') }}
|
||||
p
|
||||
WHERE
|
||||
p._inserted_timestamp > DATEADD('DAY', -14, SYSDATE())
|
||||
AND p.price IS NOT NULL
|
||||
AND p.token_address = t1.token_address
|
||||
AND p.hour = DATE_TRUNC(
|
||||
'hour',
|
||||
t1.block_timestamp
|
||||
)
|
||||
)
|
||||
GROUP BY
|
||||
1
|
||||
)
|
||||
),
|
||||
{% endif %}
|
||||
|
||||
FINAL AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
complete_lending_withdraws
|
||||
|
||||
{% if is_incremental() and var(
|
||||
'HEAL_MODEL'
|
||||
) %}
|
||||
UNION ALL
|
||||
SELECT
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
event_index,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
contract_address,
|
||||
event_name,
|
||||
protocol_market,
|
||||
token_address,
|
||||
token_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
amount_usd_heal AS amount_usd,
|
||||
depositor,
|
||||
platform,
|
||||
blockchain,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
heal_model
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
|
||||
@ -55,6 +55,7 @@ cream_borrows AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab80'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -52,6 +52,7 @@ cream_deposits AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -54,6 +54,7 @@ cream_liquidations AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb52'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -50,6 +50,7 @@ cream_repayments AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -52,6 +52,7 @@ cream_redemptions AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -55,6 +55,7 @@ flux_borrows AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab80'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -52,6 +52,7 @@ flux_deposits AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -54,6 +54,7 @@ flux_liquidations AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb52'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -50,6 +50,7 @@ flux_repayments AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -52,6 +52,7 @@ flux_redemptions AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -51,6 +51,7 @@ WITH log_join AS (
|
||||
ON f.frax_market_address = l.contract_address
|
||||
WHERE
|
||||
topics [0] = '0x01348584ec81ac7acd52b7d66d9ade986dd909f3d513881c190fc31c90527efe'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND l._inserted_timestamp >= (
|
||||
|
||||
@ -42,6 +42,7 @@ WITH log_join AS (
|
||||
ON f.frax_market_address = l.contract_address
|
||||
WHERE
|
||||
topics [0] = '0xa32435755c235de2976ed44a75a2f85cb01faf0c894f639fe0c32bb9455fea8f'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND l._inserted_timestamp >= (
|
||||
|
||||
@ -70,6 +70,7 @@ WITH log_join AS (
|
||||
ON f.frax_market_address = l.contract_address
|
||||
WHERE
|
||||
topics [0] = '0x35f432a64bd3767447a456650432406c6cacb885819947a202216eeea6820ecf'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND l._inserted_timestamp >= (
|
||||
|
||||
@ -52,6 +52,7 @@ WITH log_join AS (
|
||||
ON f.frax_market_address = l.contract_address
|
||||
WHERE
|
||||
topics [0] = '0x9dc1449a0ff0c152e18e8289d865b47acc6e1b76b1ecb239c13d6ee22a9206a7'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND l._inserted_timestamp >= (
|
||||
|
||||
@ -43,6 +43,7 @@ WITH log_join AS (
|
||||
ON f.frax_market_address = l.contract_address
|
||||
WHERE
|
||||
topics [0] = '0xbc290bb45104f73cf92115c9603987c3f8fd30c182a13603d8cffa49b5f59952'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND l._inserted_timestamp >= (
|
||||
|
||||
@ -55,6 +55,7 @@ strike_borrows AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab80'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -52,6 +52,7 @@ strike_deposits AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -54,6 +54,7 @@ strike_liquidations AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb52'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -50,6 +50,7 @@ strike_repayments AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -52,6 +52,7 @@ strike_redemptions AS (
|
||||
asset_details
|
||||
)
|
||||
AND topics [0] :: STRING = '0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -33,6 +33,7 @@ WITH deposits AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x995d6cdbf356b73aa4dff24e951558cc155c9bb0397786ec4a142f9470f50007' --StakeConfirmed
|
||||
AND contract_address = '0x84db6ee82b7cf3b47e8f19270abde5718b936670' --ankr ETH2 Staking
|
||||
AND tx_status = 'SUCCESS'
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
|
||||
@ -43,6 +43,7 @@ WITH withdrawals AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xc5130045b6f6c9e2944ccea448ad17c279db68237b8aa856ee12cbfaa25f7715' --PendingUnstake
|
||||
AND contract_address = '0x84db6ee82b7cf3b47e8f19270abde5718b936670' --ankr ETH2 Staking
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -81,6 +82,7 @@ burns AS (
|
||||
topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Transfer (Burn)
|
||||
AND contract_address = '0xe95a203b1a91a908f9b9ce46459d101078c2c3cb' --Ankr Staked ETH (ankrETH)
|
||||
AND to_address = '0x0000000000000000000000000000000000000000'
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -34,6 +34,7 @@ WITH deposit_logs AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f8' --Mint/Deposit
|
||||
AND contract_address = '0xa2e3356610840701bdf5611a53974510ae27e2e1' --Wrapped Binance Beacon ETH (wBETH)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -74,6 +75,8 @@ deposit_traces AS (
|
||||
FROM
|
||||
deposit_logs
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND trace_status = 'SUCCESS'
|
||||
)
|
||||
SELECT
|
||||
l.block_number,
|
||||
|
||||
@ -34,6 +34,7 @@ WITH mints AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f8' --Mint
|
||||
AND contract_address = '0xbe9895146f7af43049ca1c1ae358b0541ea49704' --Coinbase Wrapped Staked ETH (cbETH)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -33,6 +33,7 @@ WITH burns AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5' --Burn
|
||||
AND contract_address = '0xbe9895146f7af43049ca1c1ae358b0541ea49704' --Coinbase Wrapped Staked ETH (cbETH)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -46,6 +46,7 @@ WITH deposits AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xad40ae5dc69974ba932d08b0a608e89109412d41d04850f5196f144875ae2660' --DepositEvent
|
||||
AND contract_address = '0xcbc1065255cbc3ab41a6868c22d1f1c573ab89fd' --Cream ETH 2 (CRETH2)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -46,6 +46,7 @@ WITH withdrawals AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x5bb95829671915ece371da722f91d5371159095dcabf2f75cd6c53facb7e1bab' --WithdrawEvent
|
||||
AND contract_address = '0xcbc1065255cbc3ab41a6868c22d1f1c573ab89fd' --Cream ETH 2 (CRETH2)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -34,6 +34,7 @@ WITH deposits AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x7034bb05cfe54b0d147fc0574ed166101e7f0313eb404e113974fbe2a998ca83' --DepositEth
|
||||
AND contract_address = '0x7623e9dc0da6ff821ddb9ebaba794054e078f8c4' --Ether.fi Early Adopter Program (eETH LSD token not yet deployed)
|
||||
AND tx_status = 'SUCCESS'
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
|
||||
@ -38,6 +38,8 @@ WITH withdrawals AS (
|
||||
topics [0] :: STRING = '0xf45a04d08a70caa7eb4b747571305559ad9fdf4a093afd41506b35c8a306fa94' --Withdrawn
|
||||
AND l.contract_address = '0x7623e9dc0da6ff821ddb9ebaba794054e078f8c4' --Ether.fi Early Adopter Program (eETH LSD token not yet deployed)
|
||||
AND CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) = t.to_address
|
||||
AND l.tx_status = 'SUCCESS'
|
||||
AND t.trace_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND l._inserted_timestamp >= (
|
||||
|
||||
@ -40,6 +40,7 @@ WITH deposits AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7' --Deposit
|
||||
AND contract_address = '0xac3e018457b222d93114458476f3e3416abbe38f' --Staked Frax Ether (sfrxETH)
|
||||
AND tx_status = 'SUCCESS'
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
|
||||
@ -41,6 +41,7 @@ WITH withdrawals AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xfbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db' --Withdraw
|
||||
AND contract_address = '0xac3e018457b222d93114458476f3e3416abbe38f' --Staked Frax Ether (sfrxETH)
|
||||
AND tx_status = 'SUCCESS'
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
|
||||
@ -36,6 +36,7 @@ WITH deposit_logs AS (
|
||||
AND contract_address = '0x3802c218221390025bceabbad5d8c59f40eb74b8' --Guarded Ether (GETH)
|
||||
AND from_address = '0x0000000000000000000000000000000000000000'
|
||||
AND origin_to_address IS NOT NULL
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -76,6 +77,8 @@ deposit_traces AS (
|
||||
FROM
|
||||
deposit_logs
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND trace_status = 'SUCCESS'
|
||||
)
|
||||
SELECT
|
||||
l.block_number,
|
||||
|
||||
@ -33,6 +33,7 @@ WITH deposits AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c' --Deposit
|
||||
AND contract_address = '0x5bbe36152d3cd3eb7183a82470b39b29eedf068b' --Hord (hETH)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -69,6 +70,7 @@ mints AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x7fc2fd3fd75a3920468e7ebb35c1c6c24d63052113a15ce8a4d461bf9b8c7f84' --HETHMinted
|
||||
AND contract_address = '0x5bbe36152d3cd3eb7183a82470b39b29eedf068b' --HordETH (hETH)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -34,6 +34,7 @@ WITH deposits AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x96a25c8ce0baabc1fdefd93e9ed25d8e092a3332f3aa9a41722b5697231d1d1a' --Submitted
|
||||
AND contract_address = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84' --Lido stETH Token (stETH)
|
||||
AND tx_status = 'SUCCESS'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -45,6 +45,7 @@ WITH requests AS (
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xf0cb471f23fb74ea44b8252eb1881a2dca546288d9f6e90d1a0e82fe0ed342ab' --WithdrawalRequested
|
||||
AND contract_address = '0x889edc2edab5f40e902b864ad4d7ade8e412f9b1' --Lido: stETH Withdrawal NFT (unstETH)
|
||||
AND tx_status = 'SUCCESS'
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user