Query 21 - Treasury USDM Payers
Result
This table is the CSV result produced by Apache Jena over the state-audit graph. USDM quantities are decimal USDM.
| payerLabel | payerEvidence | treasuryLabel | treasuryAddress | receiptTxs | receiptOutputs | usdmReceived |
|---|---|---|---|---|---|---|
| sundae.swap.v3.order-consumers | producer consumes Sundae V3 order UTxO and emits USDM to network_compliance | amaru-treasury.network_compliance | addr1xyezq8wpaqnssdjvd3p220uf7e6nzjae44w6yu625y965rfjyqwur6p8pqmycmzz55lcnan4x99mnt2a5fe54ggt4gxs8thzgk |
51 | 54 | 425131.618692 |
This aggregate matches Query 17's swapReceiptsUsdm value and Query
19's full receipt-by-receipt drill-down.
What
This query answers the incoming-side question: who paid USDM into the
amaru-treasury.network_compliance treasury?
The answer is not an account address. Cardano transactions spend UTxOs and create new UTxOs, so the graph proves the payer as a producer class: SundaeSwap V3 order consumers that settle the treasury's swap orders.
For May 2026, the graph returns one incoming payer class:
sundae.swap.v3.order-consumers.
Why
A raw query over "all USDM outputs to network_compliance" is too broad. It includes:
- swap receipts from external settlement transactions,
- treasury change back to the same address,
- payment change left over after beneficiary payments.
Only the first category is someone paying USDM into the treasury. The other two categories are internal state continuing through treasury transactions.
This query is the incoming counterpart to Query 02. Query 02 asks "who did the treasury pay?" by requiring a treasury input and a payee output. Query 21 asks "who paid the treasury?" by requiring a SundaeSwap order input and a treasury USDM output.
Diagram
flowchart LR
orders[Sundae V3 order UTxOs]
producers[Order consumer txs]
treasury[network_compliance treasury]
aggregate[Incoming payer total]
orders -->|consumed by| producers
producers -->|emit USDM| treasury
treasury --> aggregate
How
The query pins the full on-chain USDM asset id in a VALUES block and
resolves the network_compliance treasury address through the
rules.yaml label.
It scans USDM outputs to that treasury address, then applies an
EXISTS payer proof:
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/treasury-usdm-movement/21-treasury-usdm-payers.rq
SPARQL
FILTER EXISTS {
?receiptTx cardano:hasInput ?in .
?in cardano:fromTxOutRef ?ref .
?ref cardano:hasTxId/cardano:bytesHex ?orderTxId ;
cardano:hasIndex ?orderIx .
?orderTx cardano:hasTxId/cardano:bytesHex ?orderTxId ;
cardano:hasOutput ?orderOut .
?orderOut cardano:hasIndex ?orderIx ;
cardano:atAddress/cardano:hasPaymentCredential/cardano:hasIdentifier/cardano:bytesHex
?orderScriptHash .
}
That clause keeps only producer transactions that consume a resolved SundaeSwap V3 order UTxO. Treasury change and payment change do not pass that test, so they are excluded from the incoming-payer answer.
The inner subquery groups by receipt output before the outer payer aggregation. That prevents multiple asset-value nodes on one output from multiplying the receipt amount.
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#>
# USDM payers into the network_compliance treasury.
#
# This is the incoming-side counterpart to Query 02. Query 02 proves who the
# treasury paid by requiring a treasury input and a payee output. This query
# proves who paid the treasury by requiring a swap-settlement input and a
# treasury USDM output.
#
# Do not count every USDM output at network_compliance here. Treasury change
# and payment change also land at the treasury address, but those outputs are
# our own state continuing through a transaction, not someone paying us.
#
# The external incoming source is proven structurally:
#
# - the producer transaction consumes one or more SundaeSwap V3 order UTxOs;
# - the same producer transaction emits USDM to network_compliance.
#
# Cardano is a UTxO ledger, so there is no account-style "from address" field
# for a payment. The payer this graph can prove is therefore a producer class:
# SundaeSwap V3 order consumers settling the treasury's swap orders.
SELECT ?payerLabel ?payerEvidence
?treasuryLabel ?treasuryAddress
(COUNT(DISTINCT ?receiptTxId) AS ?receiptTxs)
(COUNT(DISTINCT ?receiptOutputRef) AS ?receiptOutputs)
((xsd:decimal(SUM(?receiptUsdm)) / 1000000) AS ?usdmReceived)
WHERE {
BIND("sundae.swap.v3.order-consumers" AS ?payerLabel)
BIND("producer consumes Sundae V3 order UTxO and emits USDM to network_compliance" AS ?payerEvidence)
BIND("amaru-treasury.network_compliance" AS ?treasuryLabel)
# Resolve the receiving treasury address from rules.yaml.
?networkCompliance rdfs:label "amaru-treasury.network_compliance" ;
cardano:bech32 ?treasuryAddress .
{
# One row per treasury USDM receipt output. The EXISTS clause is the payer
# proof: the same producer transaction must consume a resolved UTxO at the
# SundaeSwap V3 order script. This excludes treasury/payment change because
# those producer transactions do not spend Sundae V3 order outputs.
SELECT ?treasuryAddress ?receiptTxId ?receiptOutputRef
(SUM(?qty) AS ?receiptUsdm)
WHERE {
# Full USDM asset id, not ticker text.
VALUES ?usdmAssetId {
"c48cbb3d5e57ed56e276bc45f99ab39abe94e6cd7ac39fb402da47ad0014df105553444d"
}
# Resolve the SundaeSwap order script once from the named graph entity.
{
SELECT DISTINCT ?orderScriptHash
WHERE {
?orderScript rdfs:label "sundae.swap.v3.order" ;
cardano:hasIdentifier/cardano:bytesHex ?orderScriptHash .
}
}
?receiptTx cardano:hasTxId/cardano:bytesHex ?receiptTxId ;
cardano:hasOutput ?out .
?out cardano:hasIndex ?outIx ;
cardano:atAddress/cardano:bech32 ?treasuryAddress ;
cardano:hasAssetValue/rdf:rest*/rdf:first ?asset .
?asset cardano:hasIdentifier/cardano:bytesHex ?usdmAssetId ;
cardano:quantity ?qty .
FILTER EXISTS {
?receiptTx cardano:hasInput ?in .
?in cardano:fromTxOutRef ?ref .
?ref cardano:hasTxId/cardano:bytesHex ?orderTxId ;
cardano:hasIndex ?orderIx .
?orderTx cardano:hasTxId/cardano:bytesHex ?orderTxId ;
cardano:hasOutput ?orderOut .
?orderOut cardano:hasIndex ?orderIx ;
cardano:atAddress/cardano:hasPaymentCredential/cardano:hasIdentifier/cardano:bytesHex
?orderScriptHash .
}
BIND(CONCAT(?receiptTxId, "#", STR(?outIx)) AS ?receiptOutputRef)
}
GROUP BY ?treasuryAddress ?receiptTxId ?receiptOutputRef
}
}
GROUP BY ?payerLabel ?payerEvidence ?treasuryLabel ?treasuryAddress