Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
time: "02:00"
open-pull-requests-limit: 2
groups:
minor-and-patch:
applies-to: version-updates
update-types:
- "patch"
- "minor"
major:
applies-to: version-updates
update-types:
- "major"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
time: "02:00"
open-pull-requests-limit: 2
groups:
all-actions:
applies-to: version-updates
patterns: ["*"]
2 changes: 1 addition & 1 deletion .github/workflows/diff-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
branches:
- master
- staging
- "release*"

env:
DBT_DEFAULT_PROFILE_TARGET: stellar_dbt_public
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/project_evaluator_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
branches:
- master
- staging
- "release*"

env:
DBT_DEFAULT_PROFILE_TARGET: stellar_dbt_public
Expand Down
6 changes: 5 additions & 1 deletion models/docs/marts/tvl/tvl_agg.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ The total value locked (TVL) denominated in raw asset value (token amounts) for
The total value locked (TVL) denominated in raw asset value (token amounts) for a given date. Aggregated across trustlines selling liabilities
{% enddocs %}

{% docs liquidity_pools_tvl %}
The total value locked (TVL) denominated in raw asset value (token amounts) for a given date. Aggregated across liquidity pool balances (AMM).
{% enddocs %}

{% docs total_tvl %}
The total value locked (TVL) denominated in raw asset value (token amounts) for a given date. Aggregated across relevant ledger entries (e.g., accounts, trustlines).
The total value locked (TVL) denominated in raw asset value (token amounts) for a given date. Aggregated across relevant ledger entries (e.g., accounts, trustlines, liquidity pools).
{% enddocs %}
52 changes: 46 additions & 6 deletions models/marts/tvl/tvl_agg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,62 @@ with
group by 1, 2, 3, 4
)

, liquidity_pools_tvl as (
select
day
, asset_type
, asset_code
, asset_issuer
, sum(liquidity_pool_balance) as liquidity_pools_tvl
from {{ ref('asset_balances__daily_agg') }}
where
asset_code is not null
and asset_issuer is not null
group by 1, 2, 3, 4
)

, combined as (
select
coalesce(a.day, t.day) as day
, coalesce(a.asset_type, t.asset_type) as asset_type
, coalesce(a.asset_code, t.asset_code) as asset_code
, coalesce(a.asset_issuer, t.asset_issuer) as asset_issuer
coalesce(a.day, t.day, l.day) as day
, coalesce(a.asset_type, t.asset_type, l.asset_type) as asset_type
, coalesce(a.asset_code, t.asset_code, l.asset_code) as asset_code
, coalesce(a.asset_issuer, t.asset_issuer, l.asset_issuer) as asset_issuer
, coalesce(a.accounts_tvl, 0) as accounts_tvl
, coalesce(t.trustlines_tvl, 0) as trustlines_tvl
, coalesce(a.accounts_tvl, 0) + coalesce(t.trustlines_tvl, 0) as total_tvl
, coalesce(l.liquidity_pools_tvl, 0) as liquidity_pools_tvl
, coalesce(a.accounts_tvl, 0)
+ coalesce(t.trustlines_tvl, 0)
+ coalesce(l.liquidity_pools_tvl, 0) as total_tvl
from accounts_tvl as a
full outer join trustlines_tvl as t
on a.day = t.day
and a.asset_type = t.asset_type
and a.asset_code = t.asset_code
and a.asset_issuer = t.asset_issuer
full outer join liquidity_pools_tvl as l
on coalesce(a.day, t.day) = l.day
and coalesce(a.asset_type, t.asset_type) = l.asset_type
and coalesce(a.asset_code, t.asset_code) = l.asset_code
and coalesce(a.asset_issuer, t.asset_issuer) = l.asset_issuer
)

, final as (
select
combined.day
, combined.asset_type
, combined.asset_code
, combined.asset_issuer
, a.asset_contract_id as contract_id
, combined.accounts_tvl
, combined.trustlines_tvl
, combined.liquidity_pools_tvl
, combined.total_tvl
from combined
left join {{ ref('stg_assets') }} as a
on combined.asset_type = a.asset_type
and combined.asset_code = a.asset_code
and combined.asset_issuer = a.asset_issuer
)

select *
from combined
from final
9 changes: 8 additions & 1 deletion models/marts/tvl/tvl_agg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2

models:
- name: tvl_agg
description: "This table aggregates TVL from accounts and trustlines to calculate total TVL"
description: "This table aggregates TVL from accounts, trustlines, and liquidity pools to calculate total TVL"
tests:
- elementary.schema_changes:
tags: [schema_changes]
Expand Down Expand Up @@ -59,6 +59,13 @@ models:
date_column_name: "day"
greater_than_equal_to: "2 day"

- name: liquidity_pools_tvl
description: '{{ doc("liquidity_pools_tvl") }}'
tests:
- stellar_dbt_public.incremental_not_null:
date_column_name: "day"
greater_than_equal_to: "2 day"

Comment on lines +62 to +68
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tvl_agg.sql now outputs a contract_id column (via the join to stg_assets), but this schema YAML doesn’t declare/document that column. This will leave the model docs incomplete and may also trigger the schema change monitoring test. Add a contract_id column entry here (likely with {{ doc("contract_id") }} or the appropriate doc) and decide whether it should have a nullability test (it may be legitimately null for some assets).

Copilot uses AI. Check for mistakes.
- name: total_tvl
description: '{{ doc("total_tvl") }}'
tests:
Expand Down
Loading