all: Process SAC balance entry changes and store SAC balances in database#462
Closed
Copilot wants to merge 1 commit intostore-sep41-balancefrom
Closed
all: Process SAC balance entry changes and store SAC balances in database#462Copilot wants to merge 1 commit intostore-sep41-balancefrom
Copilot wants to merge 1 commit intostore-sep41-balancefrom
Conversation
Copilot
AI
changed the title
[WIP] Process SAC balance entry changes and store SAC balances
all: Process SAC balance entry changes and store SAC balances in database
Jan 16, 2026
Contributor
|
@copilot where is the table for per file change summary? |
Author
The per-file change summary table is in my previous response above. It's a detailed table organized by category (Data Layer, Database Migrations, Indexer, Services, GraphQL, etc.) showing all 57 files changed with descriptions of what changed in each file. If you're not seeing the table in the GitHub UI, it might be a rendering issue. The table starts with the header row "| File | Change Type | Summary |" and contains entries like:
The complete table lists all 57 changed files with their change types and summaries. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implements SAC (Stellar Asset Contract) balance tracking for contract addresses by processing balance entry changes from ledger data and storing them in the database. Refactors token storage from monolithic
account_tokensinto specialized balance models:trustline_balances,native_balances, andsac_balances.Why
Previously, SAC balances for contract addresses (C...) were fetched via RPC on every GraphQL query, causing performance issues and inconsistent data. This change stores SAC balances in the database during ingestion, aligning with how trustline balances are handled for G-addresses.
Architecture changes:
New
SACBalancesProcessor: Extracts SAC balance changes from contract data ledger entries using SDK'sContractBalanceFromContractDataparser. Only processes contract address holders (C...) since G-addresses use trustlines for SAC balances.Specialized balance models: Split monolithic
account_tokensinto:trustline_balances- Classic trustline balances with XDR fields (balance, limit, liabilities, flags)native_balances- XLM balances with minimum balance calculation (base + subentry reserves)sac_balances- SAC balances for contract addresses with authorization/clawback flagsaccount_contract_tokens- Junction table mapping accounts to contract tokensIndexer buffer deduplication: Changed from slice-based to map-based storage for trustlines, accounts, and SAC balances. Handles intra-ledger deduplication using composite keys (account+asset, account+contract). Implements ADD→REMOVE no-op detection.
Checkpoint population streaming: Processes checkpoint ledgers with batch streaming (200k batch size) to minimize memory footprint during initial population. All balance types (trustlines, native, SAC) stream directly to DB.
GraphQL enhancements: Extended
NativeBalancetype withminimumBalance,buyingLiabilities,sellingLiabilities,lastModifiedLedgerfields. SAC balances now read from database instead of RPC.Data flow:
Known limitations
N/A
Issue that this PR addresses
N/A
Checklist
PR Structure
allif the changes are broad or impact many packages.Thoroughness
Release
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.