Factory issuance → offer detection
How the indexer knows “this transaction created a new lending offer.”
Two separate problems
| Problem | Solution |
|---|---|
| Mint fresh role NFTs per offer | IssuanceFactory — IssueAssets path |
| Lock collateral + publish terms | LendingOffer covenant in the same tx |
| Find new offers among all Liquid txs | Indexer gate: only parse txs that just issued from a known factory |
One transaction, both steps
Creating an offer is typically one transaction that does both:
- Spends the borrower’s factory + auth NFT → mints new borrower/lender NFTs via Liquid issuance inputs
- Locks collateral in a
pending_offeroutput + writes OP_RETURN metadata (rate, expiry, principal)
CREATE-OFFER TRANSACTION (simplified)
INPUTS OUTPUTS
─────── ───────
auth NFT (1 unit) → auth NFT back
factory covenant UTXO → factory covenant back
issuance input(s) → borrower NFT (output 2)
collateral (LBTC…) → lender NFT (output 3)
OP_RETURN (output 4) ← terms metadata
… (output 5)
pending_offer (output 5) ← collateral locked here
Indexer logic (per transaction)
1. Did this tx spend a tracked FACTORY program UTXO? AND did the factory program reappear in outputs? → Yes: mark effect = AssetsIssued(factory_id)
Did this tx spend an existing OFFER UTXO? → Yes: update status (accept / cancel / repay / liquidate). STOP.
If effect = AssetsIssued AND no offer was spent: → Try LendingOffer::try_from_tx(tx) → If valid: insert new offer (status = pending), watch pending_offer UTXO → If invalid: ignore (factory issued assets but not an offer tx)
Source: tracker registry, offer creation tracker.
Why gate on factory issuance?
- Efficiency — don’t run offer parsing on every tx in every block
- Provenance — every offer links to
issuance_factory_id(which borrower account) - Correct minting — role NFTs only exist if factory authorized them; offer covenant expects those asset IDs
What try_from_tx checks
Even after the factory gate, the indexer still verifies the tx is a real offer:
- ≥ 7 outputs; output 4 is OP_RETURN with valid creation metadata
- Program id in metadata matches
LendingOffer - Collateral amount from pending-offer output; principal/rate/expiry from metadata
- Borrower/lender NFT asset IDs from outputs 2–3
Memory hook
Factory issuance = “new NFTs were minted for this borrower.” Offer detection = “those NFTs were immediately used to lock collateral with valid metadata.” Same tx, two checks.