mirror of
https://github.com/FlipsideCrypto/aptos-models.git
synced 2026-02-06 11:06:43 +00:00
rm gold
This commit is contained in:
parent
6500eeee3a
commit
bc9603b4f9
@ -1,25 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
tags = ['core']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
f.block_date,
|
||||
f.address,
|
||||
f.token_address,
|
||||
f.balance_unadj,
|
||||
f.balance,
|
||||
f.balance * p.price AS balance_usd,
|
||||
f.symbol,
|
||||
f.name,
|
||||
f.decimals,
|
||||
f.token_is_verified,
|
||||
f.frozen,
|
||||
f.fact_balances_id AS ez_balances_id,
|
||||
f.inserted_timestamp,
|
||||
f.modified_timestamp
|
||||
FROM
|
||||
{{ ref('core__fact_balances') }} f
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }} p
|
||||
ON LOWER(f.token_address) = LOWER(p.token_address)
|
||||
AND p.hour = f.block_date::TIMESTAMP
|
||||
@ -1,63 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: core__ez_balances
|
||||
|
||||
columns:
|
||||
- name: BLOCK_DATE
|
||||
tests:
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: ADDRESS
|
||||
description: '{{ doc("address") }}'
|
||||
tests:
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: TOKEN_ADDRESS
|
||||
description: '{{ doc("token_address") }}'
|
||||
tests:
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: BALANCE_UNADJ
|
||||
tests:
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: BALANCE
|
||||
|
||||
- name: BALANCE_USD
|
||||
|
||||
- name: SYMBOL
|
||||
description: '{{ doc("symbol") }}'
|
||||
|
||||
- name: NAME
|
||||
description: '{{ doc("name") }}'
|
||||
|
||||
- name: DECIMALS
|
||||
description: '{{ doc("decimals") }}'
|
||||
|
||||
- name: TOKEN_IS_VERIFIED
|
||||
tests:
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: FROZEN
|
||||
tests:
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: EZ_BALANCES_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
tests:
|
||||
- unique:
|
||||
where: block_date > current_date - 3
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
@ -1,45 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
tags = ['core']
|
||||
) }}
|
||||
|
||||
WITH balances_with_last_positive AS (
|
||||
SELECT
|
||||
block_date,
|
||||
address,
|
||||
token_address,
|
||||
post_balance,
|
||||
frozen,
|
||||
is_verified,
|
||||
balances_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
LAST_VALUE(CASE WHEN post_balance > 0 THEN block_date END IGNORE NULLS) OVER (
|
||||
PARTITION BY address, token_address
|
||||
ORDER BY block_date
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||
) AS last_positive_date
|
||||
FROM {{ ref('silver__balances') }}
|
||||
)
|
||||
|
||||
SELECT
|
||||
b.block_date,
|
||||
b.address,
|
||||
b.token_address,
|
||||
b.post_balance AS balance_unadj,
|
||||
b.post_balance / NULLIF(POW(10, COALESCE(t.decimals, 0)), 0) AS balance,
|
||||
COALESCE(t.symbol, NULL) AS symbol,
|
||||
t.name,
|
||||
t.decimals,
|
||||
b.is_verified AS token_is_verified,
|
||||
b.frozen,
|
||||
b.balances_id AS fact_balances_id,
|
||||
b.inserted_timestamp,
|
||||
b.modified_timestamp
|
||||
FROM
|
||||
balances_with_last_positive b
|
||||
LEFT JOIN {{ ref('core__dim_tokens') }} t
|
||||
ON LOWER(b.token_address) = LOWER(t.token_address)
|
||||
WHERE
|
||||
b.post_balance > 0
|
||||
OR (b.post_balance = 0 AND DATEDIFF('day', b.last_positive_date, b.block_date) <= 1) -- reducing 3d grace period for zero balances to only just 1d of 0's
|
||||
@ -1,61 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: core__fact_balances
|
||||
|
||||
columns:
|
||||
- name: BLOCK_DATE
|
||||
tests:
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: ADDRESS
|
||||
description: '{{ doc("address") }}'
|
||||
tests:
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: TOKEN_ADDRESS
|
||||
description: '{{ doc("token_address") }}'
|
||||
tests:
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: BALANCE_UNADJ
|
||||
tests:
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: BALANCE
|
||||
|
||||
- name: SYMBOL
|
||||
description: '{{ doc("symbol") }}'
|
||||
|
||||
- name: NAME
|
||||
description: '{{ doc("name") }}'
|
||||
|
||||
- name: DECIMALS
|
||||
description: '{{ doc("decimals") }}'
|
||||
|
||||
- name: TOKEN_IS_VERIFIED
|
||||
tests:
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: FROZEN
|
||||
tests:
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: FACT_BALANCES_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
tests:
|
||||
- unique:
|
||||
where: block_date > current_date - 3
|
||||
- not_null:
|
||||
where: block_date > current_date - 3
|
||||
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
Loading…
Reference in New Issue
Block a user