-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C911 [TON]: updating ton stablecoin pipelines part 1 (#606)
- Loading branch information
1 parent
bb6fdfc
commit 0a52b52
Showing
15 changed files
with
138 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
models/dimensions/current_balances/dim_ton_current_balances.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- depends_on: {{ ref("fact_ton_address_balances_by_token") }} | ||
{{ config(materialized="incremental", unique_key=["address", "contract_address"]) }} | ||
|
||
|
||
{{ current_balances("ton") }} |
7 changes: 7 additions & 0 deletions
7
models/metrics/stablecoins/contracts/fact_ton_stablecoin_contracts.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{{ config(materialized="table") }} | ||
select symbol, contract_address, num_decimals, coingecko_id, initial_supply | ||
from | ||
( | ||
values | ||
('USDT', '0:B113A994B5024A16719F69139328EB759596C38A25F59028B146FECDC3621DFE', 6, 'tether', 0) | ||
) as results(symbol, contract_address, num_decimals, coingecko_id, initial_supply) |
12 changes: 12 additions & 0 deletions
12
models/metrics/stablecoins/contracts/fact_ton_stablecoin_premint_addresses.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{ config(materialized="table") }} | ||
-- Premint address can be an account owner or a token account | ||
select contract_address, premint_address | ||
from | ||
( | ||
values | ||
-- USDT | ||
( | ||
'0:B113A994B5024A16719F69139328EB759596C38A25F59028B146FECDC3621DFE', | ||
'0:23FA979918F1FE702DB9100BF843E87C7015ECCD39A4721E9B6BAC170BC04CE3' | ||
) | ||
) as results(contract_address, premint_address) |
8 changes: 3 additions & 5 deletions
8
models/projects/ton/core/ez_ton_address_balances_by_token.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
-- depends_on: {{ ref("fact_ton_address_credit_by_token") }} | ||
-- depends_on: {{ ref("fact_ton_address_debit_by_token") }} | ||
-- depends_on: {{ source("BALANCES", "ez_ton_current_balances") }} | ||
{{ | ||
config( | ||
materialized="table", | ||
materialized="view", | ||
database="ton", | ||
schema="core", | ||
name="ez_address_balances_by_token", | ||
snowflake_warehouse="TON_MD", | ||
) | ||
}} | ||
|
||
{{ address_balances("ton") }} | ||
select * | ||
from {{ ref("fact_ton_address_balances_by_token") }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
-- depends_on: {{ ref("ez_ton_address_balances_by_token") }} | ||
{{ | ||
config( | ||
materialized="table", | ||
materialized="view", | ||
database="ton", | ||
schema="core", | ||
name="ez_current_balances", | ||
snowflake_warehouse="TON_MD", | ||
) | ||
}} | ||
|
||
{{ current_balances("ton") }} | ||
select * | ||
from {{ ref("dim_ton_current_balances") }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,11 @@ | ||
{{ | ||
config( | ||
materialized="incremental", | ||
unique_key="tx_hash", | ||
materialized="view", | ||
snowflake_warehouse="TON", | ||
database="ton", | ||
schema="raw", | ||
alias="ez_stablecoin_transfers", | ||
) | ||
}} | ||
|
||
select | ||
block_timestamp, | ||
trunc(block_timestamp, 'day') as date, | ||
null as block_number, | ||
trace_id as index, | ||
trace_id, | ||
tx_hash, | ||
from_address, | ||
from_type, | ||
to_address, | ||
to_type, | ||
-- Mint: From: Premint, To: Contract | ||
from_address in ( | ||
select distinct (premint_address) | ||
from pc_dbt_db.prod.fact_ton_stablecoin_contracts | ||
) | ||
and to_address not in ( | ||
select distinct (premint_address) | ||
from pc_dbt_db.prod.fact_ton_stablecoin_contracts | ||
) | ||
as is_mint, | ||
-- BURN: From: Contract, To: Premint | ||
from_address not in ( | ||
select distinct (premint_address) | ||
from pc_dbt_db.prod.fact_ton_stablecoin_contracts | ||
) | ||
and to_address in ( | ||
select distinct (premint_address) | ||
from pc_dbt_db.prod.fact_ton_stablecoin_contracts | ||
) | ||
as is_burn, | ||
coalesce(amount / POWER(10, decimal), 0) as amount, | ||
case | ||
when is_mint then amount / POWER(10, decimal) when is_burn then -1 * amount / POWER(10, decimal) else 0 | ||
end as inflow, | ||
case | ||
when | ||
not is_mint | ||
and not is_burn | ||
then amount / POWER(10, decimal) | ||
else 0 | ||
end as transfer_volume, | ||
fact_ton_stablecoin_contracts.symbol, | ||
fact_ton_stablecoin_contracts.contract_address | ||
from | ||
{{ ref('fact_ton_stablecoin_transfers') }} as transfers | ||
left join | ||
pc_dbt_db.prod.fact_ton_stablecoin_contracts | ||
on lower(transfers.symbol) | ||
= lower(fact_ton_stablecoin_contracts.symbol) | ||
where dest_verified and source_verified and account_verified | ||
select * | ||
from {{ ref("fact_ton_stablecoin_transfers") }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
models/staging/ton/_test_fact_ton_stablecoin_transfers.yml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- depends_on: {{ ref("fact_ton_address_credit_by_token") }} | ||
-- depends_on: {{ ref("fact_ton_address_debit_by_token") }} | ||
-- depends_on: {{ source("BALANCES", "dim_ton_current_balances") }} | ||
{{ | ||
config( | ||
materialized="table", | ||
snowflake_warehouse="TON_MD", | ||
) | ||
}} | ||
|
||
{{ address_balances("ton") }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.