@@ -878,14 +878,18 @@ pub fn recipient_paid(env: &Env, invoice_id: u64, recipient: &Address, amount: i
878878/// Issue #333: Emitted when an invoice crosses a funding milestone (25%, 50%, 75%, 100%).
879879///
880880/// # Indexer Guide
881- /// `milestone_bps` encodes the threshold in basis points:
882- /// - 2500 = 25%
883- /// - 5000 = 50%
884- /// - 7500 = 75%
885- /// - 10000 = 100%
881+ /// Indexers can subscribe to milestone crossings by filtering events with
882+ /// topic[1] == "milestone" (optionally narrowed further by topic[2] == invoice_id). Each
883+ /// event carries:
884+ /// - `milestone_bps`: the crossed threshold in basis points relative to the invoice total —
885+ /// 2500 = 25%, 5000 = 50%, 7500 = 75%, 10000 = 100%.
886+ /// - `funded_amount`: the invoice's cumulative funded amount at the moment the threshold
887+ /// was crossed (in the invoice's payment token's base units).
888+ /// - `ledger`: the ledger sequence number at which the crossing was recorded.
886889///
887890/// Multiple events can be emitted in a single `pay()` call when a large payment
888- /// crosses several thresholds at once.
891+ /// crosses several thresholds at once — do not assume one event per payment; instead
892+ /// group by `invoice_id` and treat each `milestone_bps` as an independent crossing.
889893///
890894/// Topics: (split, milestone, invoice_id)
891895/// Data: (milestone_bps, funded_amount, ledger)
@@ -906,6 +910,23 @@ pub fn milestone_reached(env: &Env, invoice_id: u64, milestone_bps: u32, funded_
906910/// `10_000 = 100%`. A single payment can emit multiple checkpoint events when it
907911/// crosses several configured thresholds at once.
908912///
913+ /// # Indexer Guide
914+ /// Filter events with topic[1] == "fnd_chk" (topic[2] is the `invoice_id`, so narrow to a
915+ /// single invoice by matching that topic too). Unlike `milestone_reached`, whose thresholds
916+ /// are the fixed 25/50/75/100% set, `funding_checkpoint` thresholds are admin-configurable,
917+ /// so `threshold_bps` must always be read from the event data rather than assumed. The
918+ /// event's `FundingCheckpoint` payload carries:
919+ /// - `invoice_id`: redundant with topic[2], included in the data for convenience so the
920+ /// event can be decoded without also decoding topics.
921+ /// - `threshold_bps`: the configured checkpoint that was crossed, in basis points of the
922+ /// invoice total (`10_000 = 100%`).
923+ /// - `funded`: the invoice's cumulative funded amount at the moment of crossing.
924+ /// - `total`: the invoice's total amount, i.e. `funded / total` (scaled to bps) is
925+ /// approximately `threshold_bps` at the instant the event fires.
926+ ///
927+ /// As with `milestone_reached`, a single payment may cross several configured checkpoints,
928+ /// emitting one event per checkpoint — group by `invoice_id` and treat each as independent.
929+ ///
909930/// Topics: (split, fnd_chk, invoice_id)
910931/// Data: FundingCheckpoint { invoice_id, threshold_bps, funded, total }
911932#[ contracttype]
0 commit comments