AN-2736 pools (#99)

* check in

* check in

* silver

* gold views

* remove dupe test, adjust silver logiv

* warning for pools with > 4 assets
This commit is contained in:
eric-laurello 2023-02-08 09:50:11 -05:00 committed by GitHub
parent 34d67f70d6
commit aff529847f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 1661 additions and 68 deletions

View File

@ -8,52 +8,30 @@ as
$$
snowflake.execute({sqlText: `BEGIN TRANSACTION;`});
try {
snowflake.execute({sqlText: `DROP DATABASE IF EXISTS ${DESTINATION_DB_NAME}`});
snowflake.execute({sqlText: `CREATE DATABASE ${DESTINATION_DB_NAME} CLONE ${SOURCE_DB_NAME}`});
snowflake.execute({sqlText: `DROP SCHEMA ${DESTINATION_DB_NAME}._INTERNAL`}); /* this only needs to be in prod */
snowflake.execute({sqlText: `CREATE OR REPLACE DATABASE ${DESTINATION_DB_NAME} CLONE ${SOURCE_DB_NAME}`});
snowflake.execute({sqlText: `DROP SCHEMA IF EXISTS ${DESTINATION_DB_NAME}._INTERNAL`}); /* this only needs to be in prod */
var existing_schemas = snowflake.execute({sqlText: `SELECT table_schema
FROM ${DESTINATION_DB_NAME}.INFORMATION_SCHEMA.TABLE_PRIVILEGES
WHERE grantor IS NOT NULL
GROUP BY 1;`});
snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL SCHEMAS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`});
snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL FUNCTIONS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`});
snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL PROCEDURES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`});
snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL VIEWS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`});
snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL STAGES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`});
snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL TABLES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`});
snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE FUNCTIONS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`});
snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE PROCEDURES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`});
snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE VIEWS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`});
snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE STAGES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`});
snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE TABLES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`});
while (existing_schemas.next()) {
var schema = existing_schemas.getColumnValue(1)
snowflake.execute({sqlText: `GRANT OWNERSHIP ON SCHEMA ${DESTINATION_DB_NAME}.${schema} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`});
snowflake.execute({sqlText: `GRANT OWNERSHIP ON DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`})
var existing_tags = snowflake.execute({sqlText: `SHOW TAGS IN DATABASE ${DESTINATION_DB_NAME};`});
while (existing_tags.next()) {
var schema = existing_tags.getColumnValue(4);
var tag_name = existing_tags.getColumnValue(2)
snowflake.execute({sqlText: `GRANT OWNERSHIP ON TAG ${DESTINATION_DB_NAME}.${schema}.${tag_name} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`});
}
var existing_tables = snowflake.execute({sqlText: `SELECT table_schema, table_name
FROM ${DESTINATION_DB_NAME}.INFORMATION_SCHEMA.TABLE_PRIVILEGES
WHERE grantor IS NOT NULL
GROUP BY 1,2;`});
while (existing_tables.next()) {
var schema = existing_tables.getColumnValue(1)
var table_name = existing_tables.getColumnValue(2)
snowflake.execute({sqlText: `GRANT OWNERSHIP ON TABLE ${DESTINATION_DB_NAME}.${schema}.${table_name} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`});
}
var existing_functions = snowflake.execute({sqlText: `SELECT function_schema, function_name, argument_signature
FROM ${DESTINATION_DB_NAME}.INFORMATION_SCHEMA.FUNCTIONS;`});
while (existing_functions.next()) {
var schema = existing_functions.getColumnValue(1)
var function_name = existing_functions.getColumnValue(2)
var argument_signature = existing_functions.getColumnValue(3)
snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUNCTION ${DESTINATION_DB_NAME}.${schema}.${function_name}${argument_signature} to role ${ROLE_NAME};`});
}
var existing_procedures = snowflake.execute({sqlText: `SELECT procedure_schema, procedure_name, argument_signature
FROM ${DESTINATION_DB_NAME}.INFORMATION_SCHEMA.PROCEDURES;`});
while (existing_procedures.next()) {
var schema = existing_procedures.getColumnValue(1)
var procedure_name = existing_procedures.getColumnValue(2)
var argument_signature = existing_procedures.getColumnValue(3)
snowflake.execute({sqlText: `GRANT OWNERSHIP ON PROCEDURE ${DESTINATION_DB_NAME}.${schema}.${procedure_name}${argument_signature} to role ${ROLE_NAME};`});
}
snowflake.execute({sqlText: `GRANT OWNERSHIP ON DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`})
snowflake.execute({sqlText: `COMMIT;`});
} catch (err) {
snowflake.execute({sqlText: `ROLLBACK;`});

View File

@ -1,12 +1,6 @@
{{ config(
materialized = 'view',
meta={
'database_tags':{
'table': {
'PURPOSE': 'PRICES'
}
}
}
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'PRICES' }}}
) }}
SELECT
@ -38,3 +32,19 @@ SELECT
'swaps' AS provider
FROM
{{ ref('silver__prices_swaps') }}
UNION ALL
SELECT
DATE_TRUNC(
'hour',
block_timestamp
) AS recorded_at,
project_name AS symbol,
price_usd AS price,
NULL AS total_supply,
NULL AS volume_24h,
'pool balance' AS provider
FROM
{{ ref('silver__pool_token_prices_usd') }} A
LEFT JOIN {{ ref('silver__asset_metadata') }}
b
ON A.token_address = b.address

View File

@ -1,12 +1,6 @@
{{ config(
materialized = 'view',
meta={
'database_tags':{
'table': {
'PURPOSE': 'PRICES'
}
}
}
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'PRICES' }}}
) }}
WITH p_base AS (
@ -25,7 +19,8 @@ WITH p_base AS (
A.provider
WHEN 'coin gecko' THEN 1
WHEN 'coin market cap' THEN 2
ELSE 3
WHEN 'pool balances' THEN 3
ELSE 4
END AS pro_rank
FROM
{{ ref('core__dim_prices') }} A qualify(ROW_NUMBER() over(PARTITION BY recorded_hour, UPPER(symbol)

View File

@ -2,20 +2,13 @@ version: 2
models:
- name: core__fact_daily_balances
description: A table that contains a daily balance entry for both staked and liquid balance of wallets on the Osmosis chain.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- DATE
- ADDRESS
- BALANCE_TYPE
- CURRENCY
columns:
- name: DATE
description: The day the balance was recorded on.
tests:
- not_null
- name: BALANCE_TYPE
description: Either "staked" or "liquid" corresponding to how the currency is in the wallet.
description: One of "staked", "liquid", "locked liquidity", "superfluid staked" or "pool" corresponding to how the currency is in the wallet.
tests:
- not_null
- name: ADDRESS

View File

@ -0,0 +1,15 @@
{{ config(
materialized = 'view',
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'DEFI' }} }
) }}
SELECT
block_id,
block_date,
pool_id,
currency,
fees,
fees_usd,
fee_type
FROM
{{ ref('silver__pool_fee_summary_day') }}

View File

@ -0,0 +1,34 @@
version: 2
models:
- name: core__fact_pool_fee_day
description: The table is an daily summary of fees accumulated each pool within Osmosis
columns:
- name: BLOCK_ID
description: "{{ doc('block_id') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: BLOCK_DATE
description: "{{ doc('block_timestamp') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: POOL_ID
description: "{{ doc('pool_id') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: CURRENCY
description: "The currency the fee was paid in"
tests:
- dbt_expectations.expect_column_to_exist
- name: FEES
description: "The decimal adjusted amount of the fee paid"
tests:
- dbt_expectations.expect_column_to_exist
- name: FEES_USD
description: "The USD amount of the fee paid"
tests:
- dbt_expectations.expect_column_to_exist
- name: FEE_TYPE
description: "The type of fee paid. Will be either 'swap' or 'exit'"
tests:
- dbt_expectations.expect_column_to_exist

View File

@ -0,0 +1,27 @@
{{ config(
materialized = 'view',
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'DEFI, PRICES' }} }
) }}
SELECT
block_id,
block_timestamp,
pool_id,
token_0_denom AS token_0_currency,
token_0_amount,
token_1_denom AS token_1_currency,
token_1_amount,
price,
price_usd,
twap,
twap_usd,
liquidity,
liquidity_usd,
volume,
volume_usd,
token_2_denom AS token_2_currency,
token_2_amount,
token_3_denom AS token_3_currency,
token_3_amount
FROM
{{ ref('silver__pool_summary_hour') }}

View File

@ -0,0 +1,81 @@
version: 2
models:
- name: core__fact_pool_hour
description: "The table is an hourly summary of each pool within Osmosis. The table is currently limited to show at most four tokens. For pools that contain more than four tokens, those tokens are omitted."
columns:
- name: BLOCK_ID
description: "{{ doc('block_id') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: BLOCK_TIMESTAMP
description: "{{ doc('block_timestamp') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: POOL_ID
description: "{{ doc('pool_id') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: TOKEN_0_CURRENCY
description: "The first token address contained within this liquidity pool"
tests:
- dbt_expectations.expect_column_to_exist
- name: TOKEN_0_AMOUNT
description: "The decimal adjusted amount of the first token within this liquidity pool"
tests:
- dbt_expectations.expect_column_to_exist
- name: TOKEN_1_CURRENCY
description: "The second token address contained within this liquidity pool"
tests:
- dbt_expectations.expect_column_to_exist
- name: TOKEN_1_AMOUNT
description: "The decimal adjusted amount of the second token within this liquidity pool"
tests:
- dbt_expectations.expect_column_to_exist
- name: PRICE
description: "The price of the first token as denominated in the token_1_currency. This only applies to two-token pools where one of the tokens is osmos"
tests:
- dbt_expectations.expect_column_to_exist
- name: PRICE_USD
description: "The price of the token in USD"
tests:
- dbt_expectations.expect_column_to_exist
- name: TWAP
description: "The time weighted asset price, denominated in osmos. This is calculated by averaging the high, low, open, and close of the day"
tests:
- dbt_expectations.expect_column_to_exist
- name: TWAP_USD
description: The time weighted asset price, denominated in USD. This is calculated by averaging the high, low, open, and close of the day
tests:
- dbt_expectations.expect_column_to_exist
- name: LIQUIDITY
description: "The total value of tokens within the pool, denominated in osmos"
tests:
- dbt_expectations.expect_column_to_exist
- name: LIQUIDITY_USD
description: "The total value of tokens within the pool, denominated in osmos"
tests:
- dbt_expectations.expect_column_to_exist
- name: VOLUME
description: "The total value of tokens swapped in and out of the pool, denominated in osmos"
tests:
- dbt_expectations.expect_column_to_exist
- name: VOLUME_USD
description: "The total value of tokens swapped in and out of the pool, denominated in USD"
tests:
- dbt_expectations.expect_column_to_exist
- name: TOKEN_2_CURRENCY
description: "The third token address contained within this liquidity pool"
tests:
- dbt_expectations.expect_column_to_exist
- name: TOKEN_2_AMOUNT
description: "The decimal adjusted amount of the third token within this liquidity pool (if exists)"
tests:
- dbt_expectations.expect_column_to_exist
- name: TOKEN_3_CURRENCY
description: "The fourth token address contained within this liquidity pool"
tests:
- dbt_expectations.expect_column_to_exist
- name: TOKEN_3_AMOUNT
description: "The decimal adjusted amount of the fourth token within this liquidity pool (if exists)"
tests:
- dbt_expectations.expect_column_to_exist

View File

@ -0,0 +1,18 @@
{{ config(
materialized = 'view',
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'DEFI, PRICES' }} }
) }}
SELECT
block_id,
block_date,
currency,
market_cap,
price,
price_usd,
liquidity,
liquidity_usd,
volume,
volume_usd
FROM
{{ ref('silver__token_summary_day') }}

View File

@ -0,0 +1,45 @@
version: 2
models:
- name: core__fact_token_day
description: The table is an daily summary of each asset within Osmosis
columns:
- name: BLOCK_ID
description: "{{ doc('block_id') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: BLOCK_DATE
description: The block
tests:
- dbt_expectations.expect_column_to_exist
- name: CURRENCY
description: "{{ doc('currency') }}"
tests:
- dbt_expectations.expect_column_to_exist
- name: MARKET_CAP
description: This is always null
tests:
- dbt_expectations.expect_column_to_exist
- name: PRICE
description: "The price of the token as denominated in osmos"
tests:
- dbt_expectations.expect_column_to_exist
- name: PRICE_USD
description: "The price of the token in USD"
tests:
- dbt_expectations.expect_column_to_exist
- name: LIQUIDITY
description: "The total value of tokens within the pools, denominated in osmos"
tests:
- dbt_expectations.expect_column_to_exist
- name: LIQUIDITY_USD
description: "The total value of tokens within the pools, denominated in osmos"
tests:
- dbt_expectations.expect_column_to_exist
- name: VOLUME
description: "The total value of tokens swapped in and out of the pools, denominated in osmos"
tests:
- dbt_expectations.expect_column_to_exist
- name: VOLUME_USD
description: "The total value of tokens swapped in and out of the pools, denominated in USD"
tests:
- dbt_expectations.expect_column_to_exist

View File

@ -0,0 +1,107 @@
{{ config(
materialized = 'incremental',
unique_key = ["token_address","pool_id","block_id"],
incremental_strategy = 'merge',
) }}
WITH top_pools AS (
SELECT
A.block_id,
A.block_timestamp,
token_0_denom,
COALESCE(
token_0_amount / pow(
10,
CASE
WHEN token_0_denom LIKE 'gamm/pool/%' THEN 18
ELSE t0.decimal
END
),
token_0_amount
) AS token_0_amount,
token_1_denom,
COALESCE(
token_1_amount / pow(
10,
CASE
WHEN token_1_denom LIKE 'gamm/pool/%' THEN 18
ELSE t1.decimal
END
),
token_1_amount
) AS token_1_amount,
pool_id,
A._inserted_timestamp
FROM
{{ ref('silver__pool_balances') }} A
LEFT JOIN {{ ref('silver__asset_metadata') }}
t0
ON A.token_0_denom = t0.address
LEFT JOIN {{ ref('silver__asset_metadata') }}
t1
ON A.token_1_denom = t1.address
WHERE
pool_type = '/osmosis.gamm.v1beta1.Pool'
AND token_2_denom IS NULL
AND (
t0.decimal IS NOT NULL
OR token_0_denom LIKE 'gamm/pool/%'
OR t1.decimal IS NOT NULL
OR token_1_denom LIKE 'gamm/pool/%'
)
{% if is_incremental() %}
AND A._inserted_timestamp >= (
SELECT
MAX(
_inserted_timestamp
)
FROM
{{ this }}
)
{% endif %}
),
fin AS (
SELECT
block_id,
block_timestamp,
token_0_denom AS token_address,
token_0_amount / token_1_amount AS price,
token_1_denom AS price_denom,
pool_id,
token_0_amount + token_1_amount AS pool_total,
_inserted_timestamp
FROM
top_pools
UNION ALL
SELECT
block_id,
block_timestamp,
token_1_denom AS token_address,
token_1_amount / token_0_amount AS price,
token_0_denom AS price_denom,
pool_id,
token_0_amount + token_1_amount AS pool_total,
_inserted_timestamp
FROM
top_pools
)
SELECT
block_id,
block_timestamp,
token_address,
price,
price_denom,
pool_id,
pool_total,
ROW_NUMBER() over(
PARTITION BY block_id,
token_address,
price_denom
ORDER BY
pool_total DESC
) AS token_pool_rank,
_inserted_timestamp
FROM
fin

View File

@ -0,0 +1,40 @@
version: 2
models:
- name: silver__pool_token_prices
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- BLOCK_ID
- TOKEN_ADDRESS
- POOL_ID
columns:
- name: BLOCK_ID
tests:
- not_null
- name: BLOCK_TIMESTAMP
tests:
- not_null
- name: TOKEN_ADDRESS
tests:
- not_null
- name: PRICE
tests:
- not_null
- name: PRICE_DENOM
description: the denomination price is listed in
tests:
- not_null
- name: POOL_ID
tests:
- not_null
- name: POOL_TOTAL
description: total assets in the pool
tests:
- not_null
- name: TOKEN_POOL_RANK
description: rank of the pool by token -- allows for filtering out low liquidity pools in pricing
tests:
- not_null
- name: _INSERTED_TIMESTAMP
tests:
- not_null

View File

@ -0,0 +1,77 @@
{{ config(
materialized = 'incremental',
unique_key = ["token_address","block_id"],
incremental_strategy = 'merge',
) }}
WITH osmo_price AS (
SELECT
block_id,
block_timestamp,
price AS osmo_price,
price_denom token_address,
_inserted_timestamp
FROM
{{ ref('silver__pool_token_prices') }} A
WHERE
price_denom = 'uosmo'
AND token_address = 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858' --axUSDC
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(
_inserted_timestamp
)
FROM
{{ this }}
)
{% endif %}
),
osmo_pools AS (
SELECT
t0.project_name,
osmo_price / price AS price_usd,
A.block_id,
A.block_timestamp,
A.token_address,
A._inserted_timestamp
FROM
{{ ref('silver__pool_token_prices') }} A
JOIN osmo_price b
ON A.block_id = b.block_id
JOIN silver.asset_metadata t0
ON A.token_address = t0.address
WHERE
price_denom = 'uosmo'
AND token_pool_rank = 1
{% if is_incremental() %}
AND A._inserted_timestamp >= (
SELECT
MAX(
_inserted_timestamp
)
FROM
{{ this }}
)
{% endif %}
)
SELECT
block_id,
block_timestamp,
token_address,
osmo_price AS price_usd,
_inserted_timestamp
FROM
osmo_price
UNION ALL
SELECT
block_id,
block_timestamp,
token_address,
price_usd,
_inserted_timestamp
FROM
osmo_pools

View File

@ -0,0 +1,24 @@
version: 2
models:
- name: silver__pool_token_prices_usd
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- BLOCK_ID
- TOKEN_ADDRESS
columns:
- name: BLOCK_ID
tests:
- not_null
- name: BLOCK_TIMESTAMP
tests:
- not_null
- name: TOKEN_ADDRESS
tests:
- not_null
- name: PRICE_USD
tests:
- not_null
- name: _INSERTED_TIMESTAMP
tests:
- not_null

View File

@ -1,6 +1,6 @@
{{ config(
materialized = 'incremental',
unique_key = "CONCAT_WS('-', date, address, balance_type, currency)",
unique_key = ["date", "address", "balance_type", "currency"],
incremental_strategy = 'delete+insert',
cluster_by = ['date'],
) }}
@ -301,3 +301,111 @@ SELECT
) AS balance
FROM
balance_temp
WHERE
balance_type <> 'pool'
UNION ALL
SELECT
A.block_timestamp :: DATE AS DATE,
'pool' AS balance_type,
A.pool_address AS address,
token_0_denom currency,
DECIMAL,
token_0_amount balance
FROM
{{ ref('silver__pool_balances') }} A
LEFT JOIN {{ ref('silver__asset_metadata') }}
am
ON A.token_0_denom = am.address
{% if is_incremental() %}
WHERE
A.block_timestamp :: DATE >= (
SELECT
DATEADD('day', -1, MAX(DATE))
FROM
{{ this }})
{% endif %}
qualify(ROW_NUMBER() over(PARTITION BY block_timestamp :: DATE, pool_id, token_0_denom
ORDER BY
block_timestamp DESC) = 1)
UNION ALL
SELECT
A.block_timestamp :: DATE AS DATE,
'pool' AS balance_type,
A.pool_address AS address,
token_1_denom currency,
DECIMAL,
token_1_amount balance
FROM
{{ ref('silver__pool_balances') }} A
LEFT JOIN {{ ref('silver__asset_metadata') }}
am
ON A.token_1_denom = am.address
{% if is_incremental() %}
WHERE
A.block_timestamp :: DATE >= (
SELECT
DATEADD('day', -1, MAX(DATE))
FROM
{{ this }})
{% endif %}
qualify(ROW_NUMBER() over(PARTITION BY block_timestamp :: DATE, pool_id, token_1_denom
ORDER BY
block_timestamp DESC) = 1)
UNION ALL
SELECT
A.block_timestamp :: DATE AS DATE,
'pool' AS balance_type,
A.pool_address AS address,
token_2_denom currency,
DECIMAL,
token_2_amount balance
FROM
{{ ref('silver__pool_balances') }} A
LEFT JOIN {{ ref('silver__asset_metadata') }}
am
ON A.token_2_denom = am.address
WHERE
token_2_denom IS NOT NULL
{% if is_incremental() %}
AND A.block_timestamp :: DATE >= (
SELECT
DATEADD('day', -1, MAX(DATE))
FROM
{{ this }})
{% endif %}
qualify(ROW_NUMBER() over(PARTITION BY block_timestamp :: DATE, pool_id, token_2_denom
ORDER BY
block_timestamp DESC) = 1)
UNION ALL
SELECT
A.block_timestamp :: DATE AS DATE,
'pool' AS balance_type,
A.pool_address AS address,
token_3_denom currency,
DECIMAL,
token_3_amount balance
FROM
{{ ref('silver__pool_balances') }} A
LEFT JOIN {{ ref('silver__asset_metadata') }}
am
ON A.token_3_denom = am.address
WHERE
token_3_denom IS NOT NULL
{% if is_incremental() %}
AND A.block_timestamp :: DATE >= (
SELECT
DATEADD('day', -1, MAX(DATE))
FROM
{{ this }})
{% endif %}
qualify(ROW_NUMBER() over(PARTITION BY block_timestamp :: DATE, pool_id, token_3_denom
ORDER BY
block_timestamp DESC) = 1)

View File

@ -35,7 +35,7 @@ models:
- STRING
- VARCHAR
- dbt_expectations.expect_column_values_to_be_in_set:
value_set: ['staked', 'liquid', 'locked liquidity', 'superfluid staked']
value_set: ['staked', 'liquid', 'locked liquidity', 'superfluid staked', 'pool']
- name: ADDRESS
description: "{{ doc('address') }}"
tests:

View File

@ -0,0 +1,119 @@
{{ config(
materialized = 'incremental',
unique_key = ["pool_id","block_id"],
incremental_strategy = 'merge',
cluster_by = ['block_timestamp']
) }}
SELECT
A.block_id,
C.block_timestamp,
b.value :"@type" :: STRING AS pool_type,
b.value :address :: STRING AS pool_address,
b.value :future_pool_governor :: STRING AS future_pool_governor,
b.value :id :: INT AS pool_id,
COALESCE(
b.value :pool_assets [0] :token :amount,
b.value :poolAssets [0] :token :amount,
b.value :pool_liquidity [0] :amount
) :: bigint AS token_0_amount,
COALESCE(
b.value :pool_assets [0] :token :denom,
b.value :poolAssets [0] :token :denom,
b.value :pool_liquidity [0] :denom
) :: STRING AS token_0_denom,
COALESCE(
b.value :pool_assets [0] :weight,
b.value :poolAssets [0] :weight
) :: bigint AS token_0_weight,
COALESCE(
b.value :pool_assets [1] :token :amount,
b.value :poolAssets [1] :token :amount,
b.value :pool_liquidity [1] :amount
) :: bigint AS token_1_amount,
COALESCE(
b.value :pool_assets [1] :token :denom,
b.value :poolAssets [1] :token :denom,
b.value :pool_liquidity [1] :denom
) :: STRING AS token_1_denom,
COALESCE(
b.value :pool_assets [1] :weight,
b.value :poolAssets [1] :weight
) :: bigint AS token_1_weight,
COALESCE(
b.value :pool_assets [2] :token :amount,
b.value :poolAssets [2] :token :amount,
b.value :pool_liquidity [2] :amount
) :: bigint AS token_2_amount,
COALESCE(
b.value :pool_assets [2] :token :denom,
b.value :poolAssets [2] :token :denom,
b.value :pool_liquidity [2] :denom
) :: STRING AS token_2_denom,
COALESCE(
b.value :pool_assets [2] :weight,
b.value :poolAssets [2] :weight
) :: bigint AS token_2_weight,
COALESCE(
b.value :pool_assets [3] :token :amount,
b.value :poolAssets [3] :token :amount,
b.value :pool_liquidity [3] :amount
) :: bigint AS token_3_amount,
COALESCE(
b.value :pool_assets [3] :token :denom,
b.value :poolAssets [3] :token :denom,
b.value :pool_liquidity [3] :denom
) :: STRING AS token_3_denom,
COALESCE(
b.value :pool_assets [3] :weight,
b.value :poolAssets [3] :weight
) :: bigint AS token_3_weight,
COALESCE(
b.value :pool_params :exit_fee,
b.value :poolParams :exitFee
) :: FLOAT AS exit_fee,
COALESCE(
b.value :pool_params :smooth_weight_change_params,
b.value :poolParams :smoothWeightChangeParams
) :: STRING AS smooth_weight_change_params,
COALESCE(
b.value :pool_params :swap_fee,
b.value :poolParams :swapFee
) :: FLOAT AS swap_fee,
COALESCE(
b.value :total_shares :amount,
b.value :totalShares :amount
) :: bigint AS total_shares_amount,
COALESCE(
b.value :total_shares :denom,
b.value :totalShares :denom
) :: STRING AS total_shares_denom,
COALESCE(
b.value :total_weight,
b.value :totalWeight
) :: bigint AS total_weight,
b.value :scaling_factor_controller :: STRING AS scaling_factor_controller,
b.value :scaling_factors AS scaling_factors,
_INSERTED_DATE AS _inserted_timestamp
FROM
{{ source(
'bronze_streamline',
'pool_balances_api'
) }} A
JOIN LATERAL FLATTEN(
A.pools
) b
JOIN {{ ref('silver__blocks') }} C
ON A.block_id = C.block_id
{% if is_incremental() %}
WHERE
_INSERTED_DATE >= (
SELECT
MAX(
_inserted_timestamp
)
FROM
{{ this }}
)
{% endif %}

View File

@ -0,0 +1,58 @@
version: 2
models:
- name: silver__pool_balances
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- BLOCK_ID
- POOL_ID
columns:
- name: BLOCK_ID
tests:
- not_null
- name: POOL_TYPE
tests:
- not_null
- name: POOL_ADDRESS
tests:
- not_null
- name: FUTURE_POOL_GOVERNOR
- name: POOL_ID
tests:
- not_null
- name: TOKEN_0_AMOUNT
tests:
- not_null
- name: TOKEN_0_DENOM
tests:
- not_null
- name: TOKEN_0_WEIGHT
- name: TOKEN_1_AMOUNT
tests:
- not_null
- name: TOKEN_1_DENOM
tests:
- not_null
- name: TOKEN_1_WEIGHT
- name: TOKEN_2_AMOUNT
- name: TOKEN_2_DENOM
- name: TOKEN_2_WEIGHT
- name: TOKEN_3_AMOUNT
- name: TOKEN_3_DENOM
- name: TOKEN_3_WEIGHT
- name: EXIT_FEE
tests:
- not_null
- name: SMOOTH_WEIGHT_CHANGE_PARAMS
- name: SWAP_FEE
tests:
- not_null
- name: TOTAL_SHARES_AMOUNT
tests:
- not_null
- name: TOTAL_SHARES_DENOM
tests:
- not_null
- name: TOTAL_WEIGHT
- name: SCALING_FACTOR_CONTROLLER
- name: SCALING_FACTORS

View File

@ -0,0 +1,172 @@
{{ config(
materialized = 'incremental',
unique_key = ["block_date","pool_id","currency"],
incremental_strategy = 'merge',
cluster_by = ['block_date']
) }}
WITH last_block_of_day AS (
SELECT
block_timestamp :: DATE AS block_date,
MAX(block_id) AS block_id
FROM
{{ ref('silver__blocks') }}
WHERE
block_id >= 2300000
GROUP BY
block_date
),
pool_token_prices_usd AS (
SELECT
block_timestamp,
block_id,
token_address,
price_usd
FROM
{{ ref('silver__pool_token_prices_usd') }}
{% if is_incremental() %}
WHERE
block_timestamp :: DATE >= (
SELECT
MAX(
block_date
)
FROM
{{ this }}
) - INTERVAL '7 days'
{% endif %}
),
fees AS (
SELECT
block_timestamp :: DATE block_date,
swap_fee,
exit_fee,
pool_id
FROM
{{ ref('silver__pool_balances') }}
{% if is_incremental() %}
WHERE
block_timestamp :: DATE >= (
SELECT
MAX(
block_date
)
FROM
{{ this }}
) - INTERVAL '7 days'
{% endif %}
qualify(ROW_NUMBER() over(PARTITION BY pool_id, block_timestamp :: DATE
ORDER BY
block_id) = 1)
),
pre_agg AS (
SELECT
A.pool_id,
b.block_date,
b.block_id,
A.from_currency AS currency,
COALESCE(
from_amount / pow(
10,
CASE
WHEN from_currency LIKE 'gamm/pool/%' THEN 18
ELSE am.decimal
END
),
from_amount
) * COALESCE(
fees.swap_fee,
0
) AS fees,
fees * price_usd AS fees_usd,
'swap' AS fee_type,
A._inserted_timestamp
FROM
{{ ref('silver__token_swapped') }} A
LEFT JOIN fees
ON A.pool_id = fees.pool_id
AND A.block_timestamp :: DATE = fees.block_date
JOIN last_block_of_day b
ON A.block_timestamp :: DATE = b.block_date
LEFT JOIN {{ ref('silver__asset_metadata') }}
am
ON A.from_currency = am.address
LEFT JOIN pool_token_prices_usd prices
ON A.from_currency = prices.token_address
AND A.block_id_hour = prices.block_id
WHERE
A.block_id >= 2300000
{% if is_incremental() %}
AND b.block_date >= (
SELECT
MAX(
block_date
)
FROM
{{ this }}
) - INTERVAL '7 days'
{% endif %}
UNION ALL
SELECT
A.pool_id,
b.block_date,
b.block_id,
A.currency,
amount / pow(
10,
18
) * COALESCE(
fees.exit_fee,
0
) AS fees,
NULL AS fees_usd,
'exit' AS fee_type,
A._inserted_timestamp
FROM
{{ ref('silver__liquidity_provider_actions') }} A
JOIN fees
ON A.pool_id = fees.pool_id
AND A.block_timestamp :: DATE = fees.block_date
JOIN last_block_of_day b
ON A.block_timestamp :: DATE = b.block_date
WHERE
A.action = 'lp_tokens_burned'
AND COALESCE(
fees.exit_fee,
0
) <> 0
AND A.block_id >= 2300000
{% if is_incremental() %}
AND b.block_date >= (
SELECT
MAX(
block_date
)
FROM
{{ this }}
) - INTERVAL '7 days'
{% endif %}
)
SELECT
pool_id,
block_date,
block_id,
currency,
SUM(fees) AS fees,
SUM(fees_usd) AS fees_usd,
fee_type,
MAX(_inserted_timestamp) AS _inserted_timestamp
FROM
pre_agg A
GROUP BY
pool_id,
block_date,
block_id,
currency,
fee_type

View File

@ -0,0 +1,33 @@
version: 2
models:
- name: silver__pool_fee_summary_day
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- BLOCK_DATE
- POOL_ID
- CURRENCY
columns:
- name: BLOCK_ID
tests:
- not_null
- name: BLOCK_DATE
tests:
- not_null
- name: POOL_ID
tests:
- not_null
- name: CURRENCY
tests:
- not_null
- name: FEES
tests:
- not_null
- name: FEES_USD
- name: FEE_TYPE
tests:
- not_null
- name: _INSERTED_TIMESTAMP
tests:
- not_null

View File

@ -0,0 +1,339 @@
{{ config(
materialized = 'incremental',
unique_key = ["pool_id","block_id"],
incremental_strategy = 'merge',
cluster_by = ['block_timestamp']
) }}
WITH pool_token_prices AS (
SELECT
block_timestamp,
block_id,
token_address,
pool_id,
price
FROM
{{ ref('silver__pool_token_prices') }}
{% if is_incremental() %}
WHERE
block_timestamp >= (
SELECT
MAX(
block_timestamp
)
FROM
{{ this }}
) - INTERVAL '7 days'
{% endif %}
),
pool_token_prices_usd AS (
SELECT
block_timestamp,
block_id,
token_address,
price_usd
FROM
{{ ref('silver__pool_token_prices_usd') }}
{% if is_incremental() %}
WHERE
block_timestamp >= (
SELECT
MAX(
block_timestamp
)
FROM
{{ this }}
) - INTERVAL '7 days'
{% endif %}
),
twap AS (
SELECT
block_date,
token_address,
pool_id,
AVG(price) price
FROM
(
SELECT
block_timestamp :: DATE block_date,
token_address,
pool_id,
MIN(price) price
FROM
pool_token_prices
GROUP BY
block_date,
token_address,
pool_id
UNION ALL
SELECT
block_timestamp :: DATE block_date,
token_address,
pool_id,
MAX(price) price_usd
FROM
pool_token_prices
GROUP BY
block_date,
token_address,
pool_id
UNION ALL
SELECT
block_timestamp :: DATE,
token_address,
pool_id,
price
FROM
pool_token_prices qualify (ROW_NUMBER() over(PARTITION BY block_timestamp :: DATE, token_address
ORDER BY
block_id) = 1)
UNION ALL
SELECT
block_timestamp :: DATE,
token_address,
pool_id,
price
FROM
pool_token_prices qualify (ROW_NUMBER() over(PARTITION BY block_timestamp :: DATE, token_address
ORDER BY
block_id DESC) = 1)
)
GROUP BY
block_date,
token_address,
pool_id
),
twap_usd AS (
SELECT
block_date,
token_address,
AVG(price_usd) price_usd
FROM
(
SELECT
block_timestamp :: DATE block_date,
token_address,
MIN(price_usd) price_usd
FROM
pool_token_prices_usd
GROUP BY
block_date,
token_address
UNION ALL
SELECT
block_timestamp :: DATE block_date,
token_address,
MAX(price_usd) price_usd
FROM
pool_token_prices_usd
GROUP BY
block_date,
token_address
UNION ALL
SELECT
block_timestamp :: DATE,
token_address,
price_usd
FROM
pool_token_prices_usd qualify (ROW_NUMBER() over(PARTITION BY block_timestamp :: DATE, token_address
ORDER BY
block_id) = 1)
UNION ALL
SELECT
block_timestamp :: DATE,
token_address,
price_usd
FROM
pool_token_prices_usd qualify (ROW_NUMBER() over(PARTITION BY block_timestamp :: DATE, token_address
ORDER BY
block_id DESC) = 1)
)
GROUP BY
block_date,
token_address
),
volume AS (
SELECT
block_id_hour,
pool_id,
SUM(amount) amount
FROM
(
SELECT
block_id_hour,
pool_id,
to_amount / pow(
10,
6
) amount
FROM
{{ ref('silver__token_swapped') }}
WHERE
to_currency = 'uosmo'
{% if is_incremental() %}
AND block_timestamp >= (
SELECT
MAX(
block_timestamp
)
FROM
{{ this }}
) - INTERVAL '7 days'
{% endif %}
UNION ALL
SELECT
block_id_hour,
pool_id,
from_amount / pow(
10,
6
) AS amount
FROM
{{ ref('silver__token_swapped') }}
WHERE
from_currency = 'uosmo'
{% if is_incremental() %}
AND block_timestamp >= (
SELECT
MAX(
block_timestamp
)
FROM
{{ this }}
) - INTERVAL '7 days'
{% endif %}
)
GROUP BY
block_id_hour,
pool_id
),
adjust AS (
SELECT
A.block_id,
A.block_timestamp,
A.pool_id,
token_0_denom,
COALESCE(
token_0_amount / pow(
10,
CASE
WHEN token_0_denom LIKE 'gamm/pool/%' THEN 18
ELSE t0.decimal
END
),
token_0_amount
) AS token_0_amount,
token_1_denom,
COALESCE(
token_1_amount / pow(
10,
CASE
WHEN token_1_denom LIKE 'gamm/pool/%' THEN 18
ELSE t1.decimal
END
),
token_1_amount
) AS token_1_amount,
token_2_denom,
COALESCE(
token_2_amount / pow(
10,
CASE
WHEN token_2_amount LIKE 'gamm/pool/%' THEN 18
ELSE t2.decimal
END
),
token_2_amount
) AS token_2_amount,
token_3_denom,
COALESCE(
token_3_amount / pow(
10,
CASE
WHEN token_3_amount LIKE 'gamm/pool/%' THEN 18
ELSE t3.decimal
END
),
token_3_amount
) AS token_3_amount,
_inserted_timestamp
FROM
{{ ref('silver__pool_balances') }} A
LEFT JOIN {{ ref('silver__asset_metadata') }}
t0
ON A.token_0_denom = t0.address
LEFT JOIN {{ ref('silver__asset_metadata') }}
t1
ON A.token_1_denom = t1.address
LEFT JOIN {{ ref('silver__asset_metadata') }}
t2
ON A.token_2_denom = t2.address
LEFT JOIN {{ ref('silver__asset_metadata') }}
t3
ON A.token_3_denom = t3.address
{% if is_incremental() %}
WHERE
A.block_timestamp >= (
SELECT
MAX(
block_timestamp
)
FROM
{{ this }}
) - INTERVAL '7 days'
{% endif %}
)
SELECT
A.block_id,
A.block_timestamp,
A.pool_id,
token_0_denom,
token_0_amount,
token_1_denom,
token_1_amount,
b.price,
C.price_usd,
twap.price AS twap,
twap_usd.price_usd AS twap_usd,
CASE
WHEN token_1_denom = 'uosmo' THEN token_1_amount * 2
END AS liquidity,
CASE
WHEN token_1_denom = 'uosmo' THEN token_1_amount * 2 * op.price_usd
END AS liquidity_usd,
v.amount AS volume,
v.amount * op.price_usd AS volume_usd,
token_2_denom,
token_2_amount,
token_3_denom,
token_3_amount,
A._inserted_timestamp
FROM
adjust A
LEFT JOIN pool_token_prices b
ON A.block_id = b.block_id
AND A.pool_id = b.pool_id
AND A.token_0_denom = b.token_address
AND token_2_denom IS NULL
LEFT JOIN pool_token_prices_usd C
ON A.block_id = C.block_id
AND A.token_0_denom = C.token_address
JOIN pool_token_prices_usd op
ON A.block_id = op.block_id
AND op.token_address = 'uosmo'
LEFT JOIN twap
ON A.token_0_denom = twap.token_address
AND A.block_timestamp :: DATE = twap.block_date
AND A.pool_id = twap.pool_id
LEFT JOIN twap_usd
ON A.token_0_denom = twap_usd.token_address
AND A.block_timestamp :: DATE = twap_usd.block_date
LEFT JOIN volume v
ON A.block_id = v.block_id_hour
AND A.pool_id = v.pool_id

View File

@ -0,0 +1,42 @@
version: 2
models:
- name: silver__pool_hour_summary
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- BLOCK_ID
- POOL_ID
columns:
- name: BLOCK_ID
tests:
- not_null
- name: POOL_ID
tests:
- not_null
- name: TOKEN_0_DENOM
tests:
- not_null
- name: TOKEN_0_AMOUNT
tests:
- not_null
- name: TOKEN_1_DENOM
tests:
- not_null
- name: TOKEN_1_AMOUNT
tests:
- not_null
- name: PRICE
- name: PRICE_USD
- name: TWAP
- name: TWAP_USD
- name: LIQUIDITY
- name: LIQUIDITY_USD
- name: VOLUME
- name: VOLUME_USD
- name: TOKEN_2_DENOM
- name: TOKEN_2_AMOUNT
- name: TOKEN_3_DENOM
- name: TOKEN_3_AMOUNT
- name: _INSERTED_TIMESTAMP
tests:
- not_null

View File

@ -0,0 +1,53 @@
{{ config(
materialized = 'incremental',
unique_key = ["currency","block_date"],
incremental_strategy = 'merge',
cluster_by = ['block_date']
) }}
WITH last_block_of_day AS (
SELECT
block_timestamp :: DATE AS block_date,
MAX(block_id) AS block_id
FROM
{{ ref('silver__blocks') }}
WHERE
block_id >= 2300000
GROUP BY
block_date
)
SELECT
blc.block_id,
blc.block_date,
token_0_denom AS currency,
NULL AS market_Cap,
AVG(
twap
) price,
AVG(twap_USD) price_usd,
MAX(liquidity) liquidity,
MAX(liquidity_usd) liquidity_usd,
SUM(volume) volume,
SUM(volume_usd) volume_usd,
MAX(_inserted_timestamp) AS _inserted_timestamp
FROM
last_block_of_day blc
JOIN {{ ref('silver__pool_summary_hour') }} A
ON blc.block_date = A.block_timestamp :: DATE
{% if is_incremental() %}
WHERE
block_date >= (
SELECT
MAX(
block_date
)
FROM
{{ this }}
) - INTERVAL '7 days'
{% endif %}
GROUP BY
blc.block_id,
blc.block_Date,
token_0_denom

View File

@ -0,0 +1,28 @@
version: 2
models:
- name: silver__token_summary_day
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- BLOCK_ID
- CURRENCY
columns:
- name: BLOCK_ID
tests:
- not_null
- name: BLOCK_DATE
tests:
- not_null
- name: CURRENCY
tests:
- not_null
- name: PRICE
- name: PRICE_USD
- name: LIQUIDITY
- name: LIQUIDITY_USD
- name: VOLUME
- name: VOLUME_USD
- name: TOKEN_3_AMOUNT
- name: _INSERTED_TIMESTAMP
tests:
- not_null

View File

@ -0,0 +1,102 @@
{{ config(
materialized = 'incremental',
unique_key = ["tx_id","msg_index"],
incremental_strategy = 'merge',
cluster_by = ['block_timestamp::DATE'],
) }}
WITH bhour AS (
SELECT
DATE_TRUNC(
'hour',
block_timestamp
) AS block_hour,
MAX(block_id) AS block_id_hour
FROM
{{ ref('silver__blocks') }}
WHERE
block_id >= 2300000 {# AND block_timestamp :: DATE <= CURRENT_DATE - 1 #}
GROUP BY
block_hour
),
token_swapped AS (
SELECT
block_id,
block_timestamp,
tx_id,
msg_index,
tx_succeeded,
_inserted_timestamp,
OBJECT_AGG(
attribute_key :: STRING,
attribute_value :: variant
) AS j,
j :sender :: STRING AS trader,
j :pool_id :: STRING AS pool_id,
j :tokens_in :: STRING AS tokens_in,
j :tokens_out :: STRING AS tokens_out
FROM
{{ ref('silver__msg_attributes') }}
WHERE
msg_type = 'token_swapped'
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(
_inserted_timestamp
)
FROM
{{ this }}
)
{% endif %}
GROUP BY
block_id,
block_timestamp,
tx_id,
msg_index,
tx_succeeded,
_inserted_timestamp
)
SELECT
block_id,
block_id_hour,
block_timestamp,
tx_id,
msg_index,
tx_succeeded,
trader,
pool_id,
RIGHT(tokens_in, LENGTH(tokens_in) - LENGTH(SPLIT_PART(TRIM(REGEXP_REPLACE(tokens_in, '[^[:digit:]]', ' ')), ' ', 0))) AS from_currency,
SPLIT_PART(
TRIM(
REGEXP_REPLACE(
tokens_in,
'[^[:digit:]]',
' '
)
),
' ',
0
) :: FLOAT AS from_amount,
RIGHT(tokens_out, LENGTH(tokens_out) - LENGTH(SPLIT_PART(TRIM(REGEXP_REPLACE(tokens_out, '[^[:digit:]]', ' ')), ' ', 0))) AS to_currency,
SPLIT_PART(
TRIM(
REGEXP_REPLACE(
tokens_out,
'[^[:digit:]]',
' '
)
),
' ',
0
) :: FLOAT AS to_amount,
_inserted_timestamp
FROM
token_swapped A
JOIN bhour b
ON DATE_TRUNC(
'hour',
A.block_timestamp
) = b.block_hour

View File

@ -0,0 +1,95 @@
version: 2
models:
- name: silver__token_swapped
description: Records of token_swapped events
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- TX_ID
- MSG_INDEX
columns:
- name: BLOCK_ID
description: "{{ doc('block_id') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: BLOCK_TIMESTAMP
description: "{{ doc('block_timestamp') }}"
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 1
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ
- name: TX_ID
description: "{{ doc('tx_id') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: TX_SUCCEEDED
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- BOOLEAN
- name: TRADER
description: "{{ doc('trader') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- dbt_expectations.expect_column_values_to_match_regex:
regex: osmo1[0-9a-z]{38,38}
- name: POOL_ID
description: "{{ doc('pool_id') }}"
tests:
- not_null
- name: FROM_CURRENCY
description: "{{ doc('from_currency') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: FROM_AMOUNT
description: "{{ doc('from_amount') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: TO_CURRENCY
description: "{{ doc('to_currency') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: TO_AMOUNT
description: "{{ doc('to_amount') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: _INSERTED_TIMESTAMP
description: "{{ doc('inserted_timestamp') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ