Skip to content

[645] Create amm tvl metrics (liquidity_pools_tvl) in tvl_agg#222

Merged
taha-aziz merged 3 commits intorelease-v20260413from
645-create-amm-tvl-metrics
Apr 9, 2026
Merged

[645] Create amm tvl metrics (liquidity_pools_tvl) in tvl_agg#222
taha-aziz merged 3 commits intorelease-v20260413from
645-create-amm-tvl-metrics

Conversation

@taha-aziz
Copy link
Copy Markdown
Contributor

@taha-aziz taha-aziz commented Apr 2, 2026

PR Checklist

PR Structure

  • This PR has reasonably narrow scope (if not, break it down into smaller PRs).
  • This PR avoids mixing refactoring changes with feature changes (split into two PRs
    otherwise).
  • This PR's title starts with the jira ticket associated with the PR.

Thoroughness

  • This PR adds tests for the most critical parts of the new functionality or fixes.
  • I've updated the docs and README with the added features, breaking changes, new instructions on how to use the repository.

Release planning

  • I've decided if this PR requires a new major/minor/patch version accordingly to
    semver, and I've changed the name of the BRANCH to major/* , minor/* or patch/* .

What

https://github.com/stellar/stellar-dbt/issues/645

Why

SDF is taking over reporting TVL of our AMM from Lumenswap. This PR creates the liquidity_pools_tvl which is the raw asset balance of each asset locked for AMM.

Currently, tvl_agg only tracks DEX orderbook TVL via selling_liabilities from accounts (XLM) and trustlines (non-XLM). It completely misses AMM/liquidity pool TVL — the actual token amounts locked in pools. The asset_balances__daily_agg model already computes liquidity_pool_balance per asset per day (sourced from int_account_balances__liquidity_pools, which decomposes pool shares into underlying asset amounts). We're pulling this column into tvl_agg as a new liquidity_pools_tvl column.

Known limitations

We will have to fully rebuild our tvl_agg model to include this new column so it has it historically

@taha-aziz taha-aziz marked this pull request as ready for review April 2, 2026 06:46
@taha-aziz taha-aziz requested a review from a team as a code owner April 2, 2026 06:46
Copilot AI review requested due to automatic review settings April 2, 2026 06:46
@taha-aziz taha-aziz changed the base branch from master to release-v20260407 April 2, 2026 06:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds AMM/liquidity pool TVL into the existing tvl_agg mart so downstream reporting can include assets locked in Stellar AMM pools (in raw token amounts), not just DEX orderbook selling-liabilities TVL.

Changes:

  • Adds a new liquidity_pools_tvl metric sourced from asset_balances__daily_agg.liquidity_pool_balance.
  • Updates tvl_agg to include liquidity_pools_tvl and incorporate it into total_tvl.
  • Extends schema + docs to describe and test the new column.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
models/marts/tvl/tvl_agg.sql Adds AMM TVL CTE and joins it into the aggregated TVL output.
models/marts/tvl/tvl_agg.yml Updates model description and adds schema tests for liquidity_pools_tvl.
models/docs/marts/tvl/tvl_agg.md Adds documentation block for liquidity_pools_tvl and updates total_tvl docs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@amishas157 amishas157 left a comment

Choose a reason for hiding this comment

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

Looks good to me

Copy link
Copy Markdown
Contributor

@amishas157 amishas157 left a comment

Choose a reason for hiding this comment

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

@taha-aziz Can you also rebase against latest release-v20260407

I pushed some changes, recency tests should look differently https://github.com/stellar/stellar-dbt-public/blob/release-v20260407/models/marts/tvl/tvl_agg.yml

@taha-aziz taha-aziz force-pushed the 645-create-amm-tvl-metrics branch from c5505b4 to abaab05 Compare April 3, 2026 16:48
@taha-aziz taha-aziz changed the base branch from release-v20260407 to release-v20260413 April 9, 2026 05:50
@taha-aziz taha-aziz force-pushed the 645-create-amm-tvl-metrics branch from 4d87947 to b3d8767 Compare April 9, 2026 16:20
@amishas157 amishas157 self-requested a review April 9, 2026 17:08
@taha-aziz taha-aziz merged commit 72f996a into release-v20260413 Apr 9, 2026
2 checks passed
@taha-aziz taha-aziz deleted the 645-create-amm-tvl-metrics branch April 9, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants