Query 11 - Terminal USDM Summary
Result
ADA quantities are decimal ADA. USDM quantities are decimal USDM.
| usdmTerminalUtxos | ada | usdm |
|---|---|---|
| 4 | 127.217272 | 6381.618692 |
What
This query is the compact terminal-USDM balance for the network_compliance address.
It counts only terminal UTxOs that carry USDM. Query 14 shows all five terminal UTxOs, including the one with no USDM.
Why
The user's concrete balance question is the 6,381.618692 USDM
remainder. This query isolates just that remainder and the ADA sitting
with it.
It is a smaller companion to Query 16, which compares graph terminal state to the live snapshot.
Diagram
flowchart LR
produced[network_compliance outputs]
spent[spent by loaded txs]
terminal[terminal outputs]
usdm[USDM-carrying terminal outputs]
total[6,381.618692 USDM]
produced --> terminal
spent --> terminal
terminal --> usdm
usdm --> total
How
The query resolves network_compliance by label, selects outputs at that
address, and filters out any output whose (txid, index) is consumed by
another loaded transaction.
It then keeps terminal outputs with the USDM asset id and sums their ADA and USDM quantities.
Run
From the repository root, run this query through the tutorial setup script:
bash docs/may-2026-amaru-lattice/setup.sh \
docs/may-2026-amaru-lattice/final-network-compliance-state/11-terminal-usdm-summary.rq
SPARQL
PREFIX cardano: <https://lambdasistemi.github.io/cardano-knowledge-maps/vocab/cardano#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
# Summary of terminal network_compliance outputs that carry USDM.
SELECT (COUNT(?txId) AS ?usdmTerminalUtxos)
((xsd:decimal(SUM(?lovelace)) / 1000000) AS ?ada)
((xsd:decimal(SUM(?usdmRaw)) / 1000000) AS ?usdm)
WHERE {
VALUES ?usdmAssetId {
"c48cbb3d5e57ed56e276bc45f99ab39abe94e6cd7ac39fb402da47ad0014df105553444d"
}
?networkCompliance rdfs:label "amaru-treasury.network_compliance" ;
cardano:bech32 ?networkComplianceBech32 .
?tx cardano:hasTxId/cardano:bytesHex ?txId ;
cardano:hasOutput ?out .
?out cardano:hasIndex ?ix ;
cardano:atAddress/cardano:bech32 ?networkComplianceBech32 ;
cardano:lovelace ?lovelace ;
cardano:hasAssetValue/rdf:rest*/rdf:first ?asset .
?asset cardano:hasIdentifier/cardano:bytesHex ?usdmAssetId ;
cardano:quantity ?usdmRaw .
FILTER NOT EXISTS {
?spendingTx cardano:hasInput ?input .
?input cardano:fromTxOutRef ?ref .
?ref cardano:hasTxId/cardano:bytesHex ?txId ;
cardano:hasIndex ?ix .
}
}