mirror of
https://github.com/FlipsideCrypto/kaia-models.git
synced 2026-02-06 13:51:46 +00:00
add gold,docs, and GHA curated run
This commit is contained in:
parent
c9a2ae8288
commit
b78aed3e3b
47
.github/workflows/dbt_run_scheduled_curated copy.yml
vendored
Normal file
47
.github/workflows/dbt_run_scheduled_curated copy.yml
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
name: dbt_run_scheduled_curated
|
||||
run-name: dbt_run_scheduled_curated
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
branches:
|
||||
- "main"
|
||||
|
||||
env:
|
||||
DBT_PROFILES_DIR: ./
|
||||
|
||||
ACCOUNT: "${{ vars.ACCOUNT }}"
|
||||
ROLE: "${{ vars.ROLE }}"
|
||||
USER: "${{ vars.USER }}"
|
||||
PASSWORD: "${{ secrets.PASSWORD }}"
|
||||
REGION: "${{ vars.REGION }}"
|
||||
DATABASE: "${{ vars.DATABASE }}"
|
||||
WAREHOUSE: "${{ vars.WAREHOUSE }}"
|
||||
SCHEMA: "${{ vars.SCHEMA }}"
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}
|
||||
cancel-in-progress: true
|
||||
|
||||
|
||||
|
||||
jobs:
|
||||
run_dbt_jobs:
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: workflow_prod
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.10"
|
||||
cache: "pip"
|
||||
|
||||
- name: install dependencies
|
||||
run: |
|
||||
pip install -r requirements.txt
|
||||
dbt deps
|
||||
- name: Run DBT Jobs
|
||||
run: |
|
||||
dbt run -m "kaia_models,tag:curated"
|
||||
@ -65,7 +65,7 @@ vars:
|
||||
OBSERV_FULL_TEST: False
|
||||
WAIT: 0
|
||||
HEAL_MODEL: False
|
||||
HEAL_CURATED_MODEL: []
|
||||
HEAL_MODELS: []
|
||||
START_GHA_TASKS: False
|
||||
API_INTEGRATION: '{{var("config")["dev"]["API_INTEGRATION"]}}'
|
||||
EXTERNAL_FUNCTION_URI: '{{var("config")["dev"]["EXTERNAL_FUNCTION_URI"]}}'
|
||||
|
||||
192
models/doc_descriptions/dex/complete_dex_docs.md
Normal file
192
models/doc_descriptions/dex/complete_dex_docs.md
Normal file
@ -0,0 +1,192 @@
|
||||
{% docs kaia_dex_creation_block %}
|
||||
|
||||
The block number of when this pool was created.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_creation_time %}
|
||||
|
||||
The block timestamp of when this pool was created.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_creation_tx %}
|
||||
|
||||
The transaction where this contract was created.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_factory_address %}
|
||||
|
||||
The address that created or deployed this pool, where available.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_lp_decimals %}
|
||||
|
||||
The # of decimals for the token included in the liquidity pool, as a JSON object, where available.
|
||||
|
||||
Query example to access the key:value pairing within the object:
|
||||
SELECT
|
||||
DISTINCT pool_address AS unique_pools,
|
||||
tokens :token0 :: STRING AS token0,
|
||||
symbols: token0 :: STRING AS token0_symbol,
|
||||
decimals: token0 :: STRING AS token0_decimal
|
||||
FROM base.defi.dim_dex_liquidity_pools
|
||||
WHERE token0_decimal = 6
|
||||
;
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_lp_symbols %}
|
||||
|
||||
The symbol for the token included in the liquidity pool, as a JSON object, where available.
|
||||
|
||||
Query example to access the key:value pairing within the object:
|
||||
SELECT
|
||||
DISTINCT pool_address AS unique_pools,
|
||||
tokens :token0 :: STRING AS token0,
|
||||
symbols: token0 :: STRING AS token0_symbol,
|
||||
decimals: token0 :: STRING AS token0_decimal
|
||||
FROM base.defi.dim_dex_liquidity_pools
|
||||
WHERE token0_symbol = 'WETH'
|
||||
;
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_lp_table_doc %}
|
||||
|
||||
This table contains details on decentralized exchange (DEX) liquidity pools (LP) on the base blockchain, including the tokens, symbols and decimals within each pool alongside the following protocols: DRAGONSWAP, KAIASWAP, KLAYSWAP, AND NEOPIN.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_lp_tokens %}
|
||||
|
||||
The address for the token included in the liquidity pool, as a JSON object.
|
||||
|
||||
Query example to access the key:value pairing within the object:
|
||||
SELECT
|
||||
DISTINCT pool_address AS unique_pools,
|
||||
tokens :token0 :: STRING AS token0,
|
||||
symbols: token0 :: STRING AS token0_symbol,
|
||||
decimals: token0 :: STRING AS token0_decimal
|
||||
FROM base.defi.dim_dex_liquidity_pools
|
||||
WHERE token0 = '0x4200000000000000000000000000000000000006'
|
||||
;
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_platform %}
|
||||
|
||||
The protocol or platform that the liquidity pool belongs to or swap occurred on.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_pool_address %}
|
||||
|
||||
The contract address for the liquidity pool.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_pool_name %}
|
||||
|
||||
The name of the liquidity pool, where available. In some cases, the pool name is a concatenation of symbols or token addresses.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_swaps_amount_in %}
|
||||
|
||||
The amount of tokens put into the swap.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_swaps_amount_in_unadj %}
|
||||
|
||||
The non-decimal adjusted amount of tokens put into the swap.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_swaps_amount_in_usd %}
|
||||
|
||||
The amount of tokens put into the swap converted to USD using the price of the token.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_swaps_amount_out %}
|
||||
|
||||
The amount of tokens taken out of or received from the swap.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_swaps_amount_out_unadj %}
|
||||
|
||||
The non-decimal adjusted amount of tokens taken out of or received from the swap.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_swaps_amount_out_usd %}
|
||||
|
||||
The amount of tokens taken out of or received from the swap converted to USD using the price of the token.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_swaps_sender %}
|
||||
|
||||
The Router is the Sender in the swap function.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_swaps_symbol_in %}
|
||||
|
||||
The symbol of the token sent for swap.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_swaps_symbol_out %}
|
||||
|
||||
The symbol of the token being swapped to.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_swaps_token_in %}
|
||||
|
||||
The address of the token sent for swap.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_swaps_token_out %}
|
||||
|
||||
The address of the token being swapped to.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_swaps_tx_to %}
|
||||
|
||||
The tx_to is the address who receives the swapped token. This corresponds to the "to" field in the swap function.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_token0 %}
|
||||
|
||||
Token 0 is the first token in the pair, and will show up first within the event logs for relevant transactions.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_token1 %}
|
||||
|
||||
Token 1 is the second token in the pair, and will show up second within the event logs for relevant transactions.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs kaia_dex_tokens %}
|
||||
|
||||
This field contains the tokens within the liquidity pool as a JSON objects.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs eth_ez_dex_swaps_table_doc %}
|
||||
|
||||
This table currently contains swap events from the ```fact_event_logs``` table for DRAGONSWAP, KAIASWAP, KLAYSWAP, AND NEOPIN. along with other helpful columns including an amount USD where possible.
|
||||
Note: A rule has been put in place to null out the amount_USD if that number is too divergent between amount_in_USD and amount_out_usd. This can happen for swaps of less liquid tokens during very high fluctuation of price.
|
||||
|
||||
{% enddocs %}
|
||||
30
models/gold/defi/defi__dim_dex_liquidity_pools.sql
Normal file
30
models/gold/defi/defi__dim_dex_liquidity_pools.sql
Normal file
@ -0,0 +1,30 @@
|
||||
{{ config(
|
||||
materialized = "view",
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'DRAGONSWAP, KAIASWAP, KLAYSWAP, NEOPIN',
|
||||
'PURPOSE': 'DEX, LIQUIDITY, POOLS, LP, SWAPS',
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_number AS creation_block,
|
||||
block_timestamp AS creation_time,
|
||||
tx_hash AS creation_tx,
|
||||
platform,
|
||||
contract_address AS factory_address,
|
||||
pool_address,
|
||||
pool_name,
|
||||
tokens,
|
||||
symbols,
|
||||
decimals,
|
||||
complete_dex_liquidity_pools_id AS dim_dex_liquidity_pools_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver_dex__complete_dex_liquidity_pools') }}
|
||||
32
models/gold/defi/defi__dim_dex_liquidity_pools.yml
Normal file
32
models/gold/defi/defi__dim_dex_liquidity_pools.yml
Normal file
@ -0,0 +1,32 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: defi__dim_dex_liquidity_pools
|
||||
description: '{{ doc("kaia_dex_lp_table_doc") }}'
|
||||
|
||||
columns:
|
||||
- name: CREATION_BLOCK
|
||||
description: '{{ doc("kaia_dex_creation_block") }}'
|
||||
- name: CREATION_TIME
|
||||
description: '{{ doc("kaia_dex_creation_time") }}'
|
||||
- name: CREATION_TX
|
||||
description: '{{ doc("kaia_dex_creation_tx") }}'
|
||||
- name: FACTORY_ADDRESS
|
||||
description: '{{ doc("kaia_dex_factory_address") }}'
|
||||
- name: PLATFORM
|
||||
description: '{{ doc("kaia_dex_platform") }}'
|
||||
- name: POOL_ADDRESS
|
||||
description: '{{ doc("kaia_dex_pool_address") }}'
|
||||
- name: POOL_NAME
|
||||
description: '{{ doc("kaia_dex_pool_name") }}'
|
||||
- name: TOKENS
|
||||
description: '{{ doc("kaia_dex_lp_tokens") }}'
|
||||
- name: SYMBOLS
|
||||
description: '{{ doc("kaia_dex_lp_symbols") }}'
|
||||
- name: DECIMALS
|
||||
description: '{{ doc("kaia_dex_lp_decimals") }}'
|
||||
- name: DIM_DEX_LIQUIDITY_POOLS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
60
models/gold/defi/defi__ez_dex_swaps.sql
Normal file
60
models/gold/defi/defi__ez_dex_swaps.sql
Normal file
@ -0,0 +1,60 @@
|
||||
{{ config(
|
||||
materialized = "view",
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'DRAGONSWAP, KAIASWAP, KLAYSWAP, NEOPIN',
|
||||
'PURPOSE': 'DEX, SWAPS'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
contract_address,
|
||||
pool_name,
|
||||
event_name,
|
||||
amount_in_unadj,
|
||||
amount_in,
|
||||
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,
|
||||
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,
|
||||
platform,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
symbol_out,
|
||||
_log_id,
|
||||
complete_dex_swaps_id AS ez_dex_swaps_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver_dex__complete_dex_swaps') }}
|
||||
58
models/gold/defi/defi__ez_dex_swaps.yml
Normal file
58
models/gold/defi/defi__ez_dex_swaps.yml
Normal file
@ -0,0 +1,58 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: defi__ez_dex_swaps
|
||||
description: '{{ doc("eth_ez_dex_swaps_table_doc") }}'
|
||||
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
description: '{{ doc("kaia_block_number") }}'
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: '{{ doc("kaia_block_timestamp") }}'
|
||||
- name: TX_HASH
|
||||
description: '{{ doc("kaia_logs_tx_hash") }}'
|
||||
- name: CONTRACT_ADDRESS
|
||||
description: '{{ doc("kaia_logs_contract_address") }}'
|
||||
- name: EVENT_NAME
|
||||
description: '{{ doc("kaia_event_name") }}'
|
||||
- name: AMOUNT_IN
|
||||
description: '{{ doc("kaia_dex_swaps_amount_in") }}'
|
||||
- name: AMOUNT_OUT
|
||||
description: '{{ doc("kaia_dex_swaps_amount_out") }}'
|
||||
- name: AMOUNT_IN_USD
|
||||
description: '{{ doc("kaia_dex_swaps_amount_in_usd") }}'
|
||||
- name: AMOUNT_OUT_USD
|
||||
description: '{{ doc("kaia_dex_swaps_amount_out_usd") }}'
|
||||
- name: TOKEN_IN
|
||||
description: '{{ doc("kaia_dex_swaps_token_in") }}'
|
||||
- name: TOKEN_OUT
|
||||
description: '{{ doc("kaia_dex_swaps_token_out") }}'
|
||||
- name: SYMBOL_IN
|
||||
description: '{{ doc("kaia_dex_swaps_symbol_in") }}'
|
||||
- name: SYMBOL_OUT
|
||||
description: '{{ doc("kaia_dex_swaps_symbol_out") }}'
|
||||
- name: SENDER
|
||||
description: '{{ doc("kaia_dex_swaps_sender") }}'
|
||||
- name: TX_TO
|
||||
description: '{{ doc("kaia_dex_swaps_tx_to") }}'
|
||||
- name: PLATFORM
|
||||
description: '{{ doc("kaia_dex_platform") }}'
|
||||
- name: EVENT_INDEX
|
||||
description: '{{ doc("kaia_event_index") }}'
|
||||
- name: _LOG_ID
|
||||
description: '{{ doc("internal_column") }}'
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
description: '{{ doc("kaia_tx_origin_sig") }}'
|
||||
- name: ORIGIN_FROM_ADDRESS
|
||||
description: '{{ doc("kaia_origin_from") }}'
|
||||
- name: ORIGIN_TO_ADDRESS
|
||||
description: '{{ doc("kaia_origin_to") }}'
|
||||
- name: AMOUNT_IN_UNADJ
|
||||
description: '{{ doc("kaia_dex_swaps_amount_in_unadj") }}'
|
||||
- name: AMOUNT_OUT_UNADJ
|
||||
description: '{{ doc("kaia_dex_swaps_amount_out_unadj") }}'
|
||||
- name: EZ_DEX_SWAPS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
Loading…
Reference in New Issue
Block a user