@zkp2p/indexer-schema 0.2.0 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.ts CHANGED
@@ -1,380 +1,890 @@
1
1
  // Auto-generated from schema/domain.graphql — do not edit directly.
2
+ // Enriched with field documentation from docs/schema-field-reference.md.
2
3
  // Run `node scripts/copy-schema.js` to regenerate.
3
4
 
4
5
  export enum DepositStatus {
6
+ /** Deposit can still participate in the maker lifecycle. Whether it is currently quoteable also depends on `acceptingIntents`, remaining liquidity, payment-method activity, and a non-zero resolved rate. */
5
7
  ACTIVE = 'ACTIVE',
8
+ /** Deposit has been explicitly closed on-chain. Quote candidates for closed deposits are deleted. */
6
9
  CLOSED = 'CLOSED',
7
10
  }
8
11
 
9
12
  export enum IntentStatus {
13
+ /** Intent exists and funds may be locked, but settlement is not final yet. */
10
14
  SIGNALED = 'SIGNALED',
15
+ /** Intent completed normally. */
11
16
  FULFILLED = 'FULFILLED',
17
+ /** Intent was cancelled/unlocked on-chain. */
12
18
  PRUNED = 'PRUNED',
19
+ /** Funds were released through the manual-release path rather than the normal verifier path. */
13
20
  MANUALLY_RELEASED = 'MANUALLY_RELEASED',
14
21
  }
15
22
 
16
23
  export enum PriceSnapshotStatus {
24
+ /** Snapshot was fetched during normal live indexing. */
17
25
  LIVE = 'LIVE',
26
+ /** Snapshot was created during historical catch-up or another non-live backfill flow. */
18
27
  BACKFILL = 'BACKFILL',
19
28
  }
20
29
 
21
30
  export enum ProfitStatus {
31
+ /** Profit could be computed because a usable FX snapshot existed. */
22
32
  COMPUTED = 'COMPUTED',
33
+ /** Profit row exists, but the oracle side of the comparison was unavailable at write time. */
23
34
  PENDING = 'PENDING',
24
35
  }
25
36
 
37
+ /**
38
+ * Canonical maker-owned escrow position. This is the root entity for most business queries. Deposit rows are created from deposit-received events and then mutated by funding, withdrawal, closing, intent lock/unlock, delegated-rate-manager, and oracle-resolution flows.
39
+ *
40
+ * @id escrowAddress_depositId
41
+ *
42
+ * **Relationships:**
43
+ * - Parent of `Intent`, `DepositPaymentMethod`, `MethodCurrency`, `DepositFundActivity`, and `DepositDailySnapshot`
44
+ * - Indirect source for `QuoteCandidate`
45
+ * - Optional many-to-one relationship to `RateManager`
46
+ * - Source record for `MakerStats`, `ManagerStats`, and manager aggregate balances
47
+ */
26
48
  export interface Deposit {
49
+ /** Canonical deposit key `escrowAddress_depositId`. This exists because raw on-chain `depositId` is not globally unique across escrows. */
27
50
  id: string;
51
+ /** Chain where the escrow contract lives. */
28
52
  chainId: number;
53
+ /** Escrow contract address that owns the deposit funds and scopes the deposit namespace. */
29
54
  escrowAddress: string;
55
+ /** Raw on-chain deposit identifier emitted by the escrow contract. */
30
56
  depositId: string;
57
+ /** Maker address that created and owns the deposit. */
31
58
  depositor: string;
59
+ /** ERC20 token being sold. In practice the indexer only materializes supported USDC addresses. */
32
60
  token: string;
61
+ /** Address currently allowed to manage deposit settings on behalf of the maker. */
33
62
  delegate: string;
63
+ /** Smallest token amount the maker will accept for a single intent. */
34
64
  intentAmountMin: string;
65
+ /** Largest token amount the maker will accept for a single intent. */
35
66
  intentAmountMax: string;
67
+ /** Explicit maker toggle. Quotes should be suppressed when this is `false` even if liquidity still exists. */
36
68
  acceptingIntents: boolean;
69
+ /** Coarse lifecycle state. `CLOSED` means the deposit was explicitly closed; it is stronger than merely having no liquidity. */
37
70
  status: DepositStatus;
71
+ /** Immediately available maker liquidity that can still be locked into new intents or withdrawn. */
38
72
  remainingDeposits: string;
73
+ /** Liquidity currently reserved by signaled intents that have not been fully resolved yet. */
39
74
  outstandingIntentAmount: string;
75
+ /** All-time amount that actually left the deposit to takers through fulfillment or manual release. */
40
76
  totalAmountTaken: string;
77
+ /** All-time amount withdrawn back to the maker through withdrawal events. */
41
78
  totalWithdrawn: string;
79
+ /** Total number of intents ever locked against the deposit. */
42
80
  totalIntents: number;
81
+ /** Count of intent-lock events seen for this deposit. */
43
82
  signaledIntents: number;
83
+ /** Count of intents that finished successfully or via manual release. */
44
84
  fulfilledIntents: number;
85
+ /** Count of intents that were unlocked/cancelled without fulfillment. */
45
86
  prunedIntents: number;
87
+ /** Deposit-level quality score in basis points. New deposits start at `10000`; later it tracks `fulfilled / total` in basis points. */
46
88
  successRateBps: number;
89
+ /** Block in which the deposit was first seen. */
47
90
  blockNumber: string;
91
+ /** Creation timestamp from the deposit-received event. */
48
92
  timestamp: string;
93
+ /** Transaction that created the deposit row. */
49
94
  txHash: string;
95
+ /** Timestamp of the most recent mutation to this deposit row. */
50
96
  updatedAt: string;
97
+ /** Optional delegated rate-manager identifier currently assigned to the deposit. */
51
98
  rateManagerId?: string;
99
+ /** Optional rate-manager contract address paired with `rateManagerId`. */
52
100
  rateManagerAddress?: string;
101
+ /** Timestamp when the current delegated manager assignment was applied. */
53
102
  delegatedAt?: string;
103
+ /** Optional address of the active whitelist pre-intent hook for private orderbooks. When set, only whitelisted takers can signal intents against this deposit. */
104
+ whitelistHookAddress?: string;
54
105
  }
55
106
 
107
+ /**
108
+ * Deposit-scoped payment platform configuration. Each row says "this deposit accepts this payment-method hash, with these payee details and optional gating requirements."
109
+ *
110
+ * @id escrowAddress_depositId_paymentMethodHash
111
+ *
112
+ * **Relationships:**
113
+ * - Many-to-one to `Deposit` through `depositId`
114
+ * - Logical sibling of `MethodCurrency` on `(depositId, paymentMethodHash)`
115
+ * - One of the three source entities used to materialize `QuoteCandidate`
116
+ */
56
117
  export interface DepositPaymentMethod {
118
+ /** Composite key `escrowAddress_depositId_paymentMethodHash`. */
57
119
  id: string;
120
+ /** Chain where the parent deposit lives. */
58
121
  chainId: number;
122
+ /** Foreign-key string to `Deposit.id`. */
59
123
  depositId: string;
124
+ /** Raw on-chain deposit id copied for convenience and external correlation. */
60
125
  depositIdOnContract: string;
126
+ /** Canonical bytes32-like payment-method identifier used by contracts and quoting. */
61
127
  paymentMethodHash: string;
128
+ /** Optional external service address/string that must authorize or gate takers before they can use this method. */
62
129
  intentGatingService: string;
130
+ /** Hash of the off-chain payee details that the taker must prove they paid. */
63
131
  payeeDetailsHash: string;
132
+ /** Method-level on/off toggle. `QuoteCandidate.isActive` also depends on this value. */
64
133
  active: boolean;
65
134
  }
66
135
 
136
+ /**
137
+ * Per `(deposit, payment method, fiat currency)` pricing configuration. This is the most important rate-resolution entity in the schema. It stores the depositor's fixed floor, delegated manager input, oracle configuration and snapshots, and the final resolved rate that quoting and validation use.
138
+ *
139
+ * @id escrowAddress_depositId_paymentMethodHash_currencyCode
140
+ *
141
+ * **Relationships:**
142
+ * - Many-to-one to `Deposit`
143
+ * - Logical many-to-one to `DepositPaymentMethod` by `(depositId, paymentMethodHash)`
144
+ * - Optional many-to-one to `RateManager` through `rateManagerId` plus the deposit's `rateManagerAddress`
145
+ * - Source record for `QuoteCandidate`; the quote row reuses this entity's identity
146
+ */
67
147
  export interface MethodCurrency {
148
+ /** Composite key `escrowAddress_depositId_paymentMethodHash_currencyCode`. */
68
149
  id: string;
150
+ /** Chain where the parent deposit lives. */
69
151
  chainId: number;
152
+ /** Foreign-key string to `Deposit.id`. */
70
153
  depositId: string;
154
+ /** Raw on-chain deposit id for cross-checking with contract logs. */
71
155
  depositIdOnContract: string;
156
+ /** Payment-method component of the tuple. */
72
157
  paymentMethodHash: string;
158
+ /** Fiat currency component of the tuple. */
73
159
  currencyCode: string;
160
+ /** Maker-defined fixed floor for the tuple. In legacy flows this can also be the directly used static rate. */
74
161
  minConversionRate: string;
162
+ /** Delegated manager quote before floor enforcement and before manager fee is applied. */
75
163
  managerRate?: string;
164
+ /** Delegated manager fee rate in 1e18 precision. This does not lower `conversionRate`; it is turned into a taker-facing markup when computing `takerConversionRate`. */
76
165
  managerFee?: string;
166
+ /** Final gross resolved rate used for intent validation and contract-aligned quote logic. */
77
167
  conversionRate?: string;
168
+ /** Final all-in rate shown to takers. In delegated mode this incorporates manager fee on top of the gross rate. */
78
169
  takerConversionRate?: string;
170
+ /** Resolution reason for `conversionRate`, such as `MANAGER`, `ORACLE`, `ESCROW_FLOOR`, `MANAGER_DISABLED`, `ORACLE_HALTED`, or `NO_FLOOR`. */
79
171
  rateSource?: string;
172
+ /** Delegated manager id that supplied the current delegated rate, if any. */
80
173
  rateManagerId?: string;
174
+ /** Oracle adapter contract address used to interpret `adapterConfig`. */
81
175
  adapter?: string;
176
+ /** Encoded adapter config bytes stored exactly as emitted. */
82
177
  adapterConfig?: string;
178
+ /** Resolved oracle feed address or feed id after decoding the adapter config. */
83
179
  feed?: string;
180
+ /** Feed decimals used to normalize oracle answers into the shared 1e18 rate format. */
84
181
  feedDecimals?: number;
182
+ /** Maker-configured markup applied to raw oracle output before final floor/manager resolution. */
85
183
  spreadBps?: number;
184
+ /** Maximum acceptable oracle age in seconds before the tuple is considered stale. */
86
185
  maxStaleness?: string;
186
+ /** Whether the oracle answer must be inverted before being converted into the shared rate representation. */
87
187
  invert?: boolean;
188
+ /** Raw oracle-derived rate before spread markup. */
88
189
  oracleRate?: string;
190
+ /** Oracle rate after applying `spreadBps`. */
89
191
  effectiveOracleRate?: string;
192
+ /** Timestamp of the latest accepted oracle datapoint used by this row. */
90
193
  lastOracleUpdatedAt?: string;
194
+ /** Decoded oracle kind, currently `oracle_chainlink`, `oracle_pyth`, or `oracle_unknown`. */
91
195
  kind?: string;
92
196
  }
93
197
 
198
+ /**
199
+ * Canonical taker intent row. An `Intent` starts when the taker signals intent and ends in fulfillment or prune. This entity intentionally separates on-chain lifecycle (`status`) from off-chain expiry reconciliation (`isExpired`).
200
+ *
201
+ * @id chainId_intentHash
202
+ *
203
+ * **Relationships:**
204
+ * - Many-to-one to `Deposit`
205
+ * - Parent of `ReferralFeeDistribution`
206
+ * - Feeds `TakerStats`, maker stats rollups, profit snapshots, and manager aggregates
207
+ */
94
208
  export interface Intent {
209
+ /** Canonical key `chainId_intentHash`. */
95
210
  id: string;
211
+ /** Raw on-chain intent hash. */
96
212
  intentHash: string;
213
+ /** Contract address that coordinated the intent. In legacy v2 this is effectively the escrow address; in newer flows it is the orchestrator. */
97
214
  orchestratorAddress: string;
215
+ /** Foreign-key string to `Deposit.id`. */
98
216
  depositId: string;
217
+ /** Verifier contract or address associated with the payment proof. In v21 it is updated again when payment verification arrives. */
99
218
  verifier: string;
219
+ /** Payment-method hash associated with the intent. Optional because some legacy flows populate it indirectly. */
100
220
  paymentMethodHash?: string;
221
+ /** Taker wallet that owns the intent. */
101
222
  owner: string;
223
+ /** Recipient address for the released token payout. */
102
224
  toAddress: string;
225
+ /** Token amount signaled for the intent. This is the nominal amount, not necessarily the realized release amount. */
103
226
  amount: string;
227
+ /** Fiat currency signaled at quote time. */
104
228
  fiatCurrency: string;
229
+ /** Quote-time rate captured on the intent. */
105
230
  conversionRate: string;
231
+ /** On-chain lifecycle state only. This does not encode off-chain expiry reconciliation. */
106
232
  status: IntentStatus;
233
+ /** Off-chain reconciler flag that says the lock has timed out and liquidity was already unlocked off-chain. An intent can be `status = SIGNALED` and `isExpired = true` at the same time. */
107
234
  isExpired: boolean;
235
+ /** Transaction that created/signaled the intent. */
108
236
  signalTxHash: string;
237
+ /** Signal timestamp taken from the emitted event/proof context. */
109
238
  signalTimestamp: string;
239
+ /** Transaction that fulfilled or manually released the intent. */
110
240
  fulfillTxHash?: string;
241
+ /** Timestamp of fulfillment/manual release. */
111
242
  fulfillTimestamp?: string;
243
+ /** Transaction that pruned/unlocked the intent. */
112
244
  pruneTxHash?: string;
245
+ /** Timestamp of prune/unlock. */
113
246
  pruneTimestamp?: string;
247
+ /** Canonical expiry timestamp used by the block reconciler. It is refined by lock/extend events after the signal event. */
114
248
  expiryTime: string;
249
+ /** Last mutation timestamp for this intent row. */
115
250
  updatedAt: string;
251
+ /** Actual fiat amount proven by the verifier. This may differ from `amount` in partial-payment scenarios. */
116
252
  paymentAmount?: string;
253
+ /** Actual fiat currency proven by the verifier. This may differ from `fiatCurrency`. */
117
254
  paymentCurrency?: string;
255
+ /** Timestamp contained in the verified payment proof. */
118
256
  paymentTimestamp?: string;
257
+ /** External payment identifier from the payment rail/provider. */
119
258
  paymentId?: string;
259
+ /** Gross token amount released from escrow before protocol or referral fees. May differ from `amount`. */
120
260
  releasedAmount?: string;
261
+ /** Net token amount actually received by the taker after protocol and referrer deductions. */
121
262
  takerAmountNetFees?: string;
263
+ /** Snapshotted delegated manager id relevant to this intent, if a manager fee applied. */
122
264
  rateManagerId?: string;
265
+ /** Snapshotted manager fee rate in 1e18 precision. */
123
266
  managerFee?: string;
267
+ /** Address that receives the manager fee on settlement. */
124
268
  managerFeeRecipient?: string;
269
+ /** Signal-time fee estimate based on the signaled intent amount. */
125
270
  managerFeeAmount?: string;
271
+ /** Release-time manager fee based on the actual released amount. */
126
272
  realizedManagerFeeAmount?: string;
273
+ /** Sum of all `ReferralFeeDistribution.feeAmount` rows written for this intent. */
127
274
  totalReferralFeeAmount?: string;
128
275
  }
129
276
 
277
+ /**
278
+ * Per-recipient referral-fee settlement rows for v2.2. The `Intent` stores the aggregate; this entity preserves recipient-level detail.
279
+ *
280
+ * @id chainId_intentHash_feeRecipient
281
+ *
282
+ * **Relationships:**
283
+ * - Many-to-one to `Intent` through `intentId`
284
+ */
130
285
  export interface ReferralFeeDistribution {
286
+ /** Composite key `chainId_intentHash_feeRecipient`. */
131
287
  id: string;
288
+ /** Chain where the parent intent settled. */
132
289
  chainId: number;
290
+ /** Raw on-chain intent hash. */
133
291
  intentHash: string;
292
+ /** Foreign-key string to `Intent.id`. */
134
293
  intentId: string;
294
+ /** Address that received this referral-fee slice. */
135
295
  feeRecipient: string;
296
+ /** Actual token amount distributed to `feeRecipient`. */
136
297
  feeAmount: string;
298
+ /** Transaction that emitted the distribution event. */
137
299
  txHash: string;
300
+ /** Settlement timestamp for this distribution row. */
138
301
  timestamp: string;
139
302
  }
140
303
 
304
+ /**
305
+ * Per-owner behavioral aggregate. This row is updated from signaled, fulfilled/manual-release, and prune flows. In v21 it also carries a `lockScore` penalty based on how long cancelled intents kept liquidity locked.
306
+ *
307
+ * @id chainId_owner (owner lowercased)
308
+ *
309
+ * **Relationships:**
310
+ * - Implicit many-to-one from all `Intent` rows whose `owner` matches `TakerStats.owner`
311
+ */
141
312
  export interface TakerStats {
313
+ /** Composite key `chainId_owner`, with the owner lowercased. */
142
314
  id: string;
315
+ /** Chain on which the taker activity occurred. */
143
316
  chainId: number;
317
+ /** Lowercased taker address used as the aggregation key. */
144
318
  owner: string;
319
+ /** Number of intents ever signaled by this taker. */
145
320
  lifetimeSignaledCount: number;
321
+ /** Number of non-manual intents that fulfilled successfully. */
146
322
  lifetimeFulfilledCount: number;
323
+ /** Number of intents that ended via manual release. */
147
324
  lifetimeManualReleaseCount: number;
325
+ /** Number of intents that were pruned/cancelled. Same-tx prune-then-fulfill cases are rolled back. */
148
326
  lifetimePruneCount: number;
327
+ /** Sum of token amount from cancelled/pruned intents, with rollback if a same-tx prune later fulfills. */
149
328
  totalCancelledVolume: string;
329
+ /** Sum of token amount from fulfilled/manual-release intents. */
150
330
  totalFulfilledVolume: string;
331
+ /** Penalty-style score derived from cancelled intent lock duration. Currently meaningful only in the v21 path. */
151
332
  lockScore: string;
333
+ /** Timestamp of the taker's most recent intent signal. */
152
334
  lastIntentAt?: string;
335
+ /** Timestamp of the taker's most recent fulfillment/manual release. */
153
336
  lastFulfilledAt?: string;
337
+ /** Timestamp of the taker's first observed intent. */
154
338
  firstSeenAt?: string;
339
+ /** Last time this aggregate row changed. */
155
340
  updatedAt: string;
156
341
  }
157
342
 
343
+ /**
344
+ * Per-maker aggregate across every deposit owned by the maker on a chain. This is deposit-derived state plus realized-profit rollups.
345
+ *
346
+ * @id chainId_maker (maker lowercased)
347
+ *
348
+ * **Relationships:**
349
+ * - Implicit aggregation over all `Deposit` rows where `Deposit.depositor = MakerStats.maker`
350
+ * - Parent summary for `MakerPlatformStats` and `MakerCurrencyStats`
351
+ */
158
352
  export interface MakerStats {
353
+ /** Composite key `chainId_maker`, with maker lowercased in the id. */
159
354
  id: string;
355
+ /** Chain on which the maker operates. */
160
356
  chainId: number;
357
+ /** Maker/depositor address used as the aggregation key. */
161
358
  maker: string;
359
+ /** Sum of `Deposit.totalAmountTaken` across the maker's deposits. */
162
360
  totalAmountTaken: string;
361
+ /** All-time gross capital committed by the maker, derived per deposit as `remaining + outstanding + taken + withdrawn`. */
163
362
  grossDeposited: string;
363
+ /** Sum of maker withdrawals across all deposits. */
164
364
  totalWithdrawn: string;
365
+ /** Sum of liquidity currently locked in active intents across all deposits. */
165
366
  outstandingIntentAmount: string;
367
+ /** Number of deposits that are both `ACTIVE` and `acceptingIntents = true`. */
166
368
  activeDepositCount: number;
369
+ /** Number of deposit rows ever created for the maker. */
167
370
  totalDepositCount: number;
371
+ /** Sum of `Deposit.fulfilledIntents` across the maker's deposits. */
168
372
  fulfilledIntents: number;
373
+ /** Sum of `Deposit.prunedIntents` across the maker's deposits. */
169
374
  prunedIntents: number;
375
+ /** Sum of `Deposit.signaledIntents` across the maker's deposits. */
170
376
  signaledIntents: number;
377
+ /** Sum of `Deposit.totalIntents` across the maker's deposits. */
171
378
  totalIntents: number;
379
+ /** Number of maker fills that happened through manual release. */
172
380
  manualReleaseCount: number;
381
+ /** Maker-level fulfillment rate in basis points, derived from aggregate `fulfilledIntents / totalIntents`. */
173
382
  successRateBps: number;
383
+ /** Sum of computed realized profit across all maker profit snapshots. */
174
384
  realizedProfitUsdCents: string;
385
+ /** Reserved APR-style metric. It is present in the schema but not currently maintained by handlers. */
175
386
  aprBps?: number;
387
+ /** Timestamp of the maker's earliest observed deposit. */
176
388
  firstSeenAt?: string;
389
+ /** Last time the aggregate changed. */
177
390
  updatedAt: string;
178
391
  }
179
392
 
393
+ /**
394
+ * Per-maker, per-payment-method aggregate. This lets consumers break a maker's business down by payment rail or method hash.
395
+ *
396
+ * @id chainId_maker_paymentMethodHash
397
+ *
398
+ * **Relationships:**
399
+ * - Implicit aggregation over intents/fills for one maker and one `paymentMethodHash`
400
+ */
180
401
  export interface MakerPlatformStats {
402
+ /** Composite key `chainId_maker_paymentMethodHash`. */
181
403
  id: string;
404
+ /** Chain on which the activity occurred. */
182
405
  chainId: number;
406
+ /** Maker address. */
183
407
  maker: string;
408
+ /** Payment-method aggregation dimension. */
184
409
  paymentMethodHash: string;
410
+ /** Sum of fulfilled/manual-release volume for this maker-method pair. */
185
411
  totalAmountTaken: string;
412
+ /** Count of fulfilled/manual-release intents for this pair. */
186
413
  fulfilledIntents: number;
414
+ /** Count of pruned intents for this pair. */
187
415
  prunedIntents: number;
416
+ /** Count of manual-release fills for this pair. */
188
417
  manualReleaseCount: number;
418
+ /** Sum of realized profit allocated to this maker-method pair. */
189
419
  realizedProfitUsdCents: string;
420
+ /** Number of profit snapshots that successfully contributed realized profit to this pair. */
190
421
  computedProfitSnapshots: number;
422
+ /** Last time the row changed. */
191
423
  updatedAt: string;
192
424
  }
193
425
 
426
+ /**
427
+ * Per-maker, per-fiat-currency aggregate.
428
+ *
429
+ * @id chainId_maker_currencyCode
430
+ *
431
+ * **Relationships:**
432
+ * - Implicit aggregation over intents/fills for one maker and one fiat currency
433
+ */
194
434
  export interface MakerCurrencyStats {
435
+ /** Composite key `chainId_maker_currencyCode`. */
195
436
  id: string;
437
+ /** Chain on which the activity occurred. */
196
438
  chainId: number;
439
+ /** Maker address. */
197
440
  maker: string;
441
+ /** Fiat-currency aggregation dimension. */
198
442
  currencyCode: string;
443
+ /** Sum of fulfilled/manual-release volume for this maker-currency pair. */
199
444
  totalAmountTaken: string;
445
+ /** Count of fulfilled/manual-release intents for this pair. */
200
446
  fulfilledIntents: number;
447
+ /** Count of pruned intents for this pair. */
201
448
  prunedIntents: number;
449
+ /** Count of manual releases for this pair. */
202
450
  manualReleaseCount: number;
451
+ /** Last time the row changed. */
203
452
  updatedAt: string;
204
453
  }
205
454
 
455
+ /**
456
+ * Daily FX snapshot used to translate local-fiat quote rates into a USD-denominated profitability view.
457
+ *
458
+ * @id currencyCode_timestampHour
459
+ *
460
+ * **Relationships:**
461
+ * - Referenced by `MakerProfitSnapshot.priceSnapshotId`
462
+ * - Used indirectly by manager aggregate PnL computation
463
+ */
206
464
  export interface PriceSnapshot {
465
+ /** Composite key `currencyCode_timestampDay`. */
207
466
  id: string;
467
+ /** Normalized fiat currency code of the quote being converted to USD. */
208
468
  currencyCode: string;
469
+ /** Start-of-day UTC bucket in seconds. */
209
470
  timestampDay: string;
471
+ /** Provider-supplied fiat-to-USD conversion rate in provider precision. */
210
472
  rateUsd: string;
473
+ /** Precision/scaling factor associated with `rateUsd`. */
211
474
  ratePrecision: number;
475
+ /** Upstream provider name used to fetch the quote. */
212
476
  provider: string;
477
+ /** Source string or provider endpoint label. */
213
478
  source: string;
479
+ /** Whether this snapshot came from live indexing or backfill. */
214
480
  status: PriceSnapshotStatus;
481
+ /** Timestamp at which the provider says the quote is valid/effective. */
215
482
  effectiveAt: string;
483
+ /** Timestamp when the indexer fetched the quote. */
216
484
  retrievedAt: string;
485
+ /** First time this snapshot row was written. */
217
486
  createdAt: string;
487
+ /** Last time this snapshot row was written. Usually equal to `createdAt`. */
218
488
  updatedAt: string;
219
489
  }
220
490
 
491
+ /**
492
+ * Per-intent realized-profit record for makers. This is the bridge between intent settlement and USD-denominated reporting.
493
+ *
494
+ * @id intentId
495
+ *
496
+ * **Relationships:**
497
+ * - One row per settled `Intent` (`id = intentId`)
498
+ * - Many-to-one to `Deposit`
499
+ * - Optional many-to-one to `PriceSnapshot`
500
+ */
221
501
  export interface MakerProfitSnapshot {
502
+ /** Equal to `intentId`, enforcing one profit row per intent. */
222
503
  id: string;
504
+ /** Chain where the intent settled. */
223
505
  chainId: number;
506
+ /** Maker address that owned the deposit. */
224
507
  maker: string;
508
+ /** Foreign-key string to `Intent.id`. */
225
509
  intentId: string;
510
+ /** Foreign-key string to `Deposit.id`. */
226
511
  depositId: string;
512
+ /** Fiat currency used for the quote/profit comparison. */
227
513
  fiatCurrency: string;
514
+ /** Quote-time rate captured from the intent. */
228
515
  quoteConversionRate: string;
516
+ /** USD-derived market reference rate computed from the linked `PriceSnapshot`. */
229
517
  oracleRate?: string;
518
+ /** Basis-point difference between `quoteConversionRate` and `oracleRate`. */
230
519
  spreadBps?: number;
520
+ /** Token amount used for the profit calculation. */
231
521
  amount: string;
522
+ /** USD-cent value of the local-fiat notional implied by the quote. */
232
523
  notionalFiatUsdCents?: string;
524
+ /** Reserved fee field. It is currently written as zero. */
233
525
  feeUsd?: string;
526
+ /** Realized profit in USD cents. Can be negative. */
234
527
  realizedProfitUsdCents?: string;
528
+ /** Optional reference to the `PriceSnapshot` used to compute `oracleRate`. */
235
529
  priceSnapshotId?: string;
530
+ /** `COMPUTED` when an FX reference existed, `PENDING` otherwise. */
236
531
  status: ProfitStatus;
532
+ /** Timestamp when the profit row was created. */
237
533
  createdAt: string;
534
+ /** Last update timestamp for the profit row. */
238
535
  updatedAt: string;
239
536
  }
240
537
 
538
+ /**
539
+ * Registry row for a delegated rate manager. A deposit can point at one of these via `(rateManagerAddress, rateManagerId)`.
540
+ *
541
+ * @id chainId_rateManagerAddress_rateManagerId
542
+ *
543
+ * **Relationships:**
544
+ * - Parent of `RateManagerRate`
545
+ * - Parent/source of `ManagerAggregateStats`, `ManagerDailySnapshot`, and `ManagerStats`
546
+ * - Optional target of deposit delegation
547
+ */
241
548
  export interface RateManager {
549
+ /** Composite key `chainId_rateManagerAddress_rateManagerId`. */
242
550
  id: string;
551
+ /** Chain where the manager contract exists. */
243
552
  chainId: number;
553
+ /** Rate-manager contract address. */
244
554
  rateManagerAddress: string;
555
+ /** On-contract manager identifier. */
245
556
  rateManagerId: string;
557
+ /** Account recognized as the logical manager/operator. */
246
558
  manager: string;
559
+ /** Account that receives manager fees on settlement. */
247
560
  feeRecipient: string;
561
+ /** Maximum allowed fee configured at manager creation. */
248
562
  maxFee: string;
563
+ /** Current fee rate in 1e18 precision. */
249
564
  fee: string;
565
+ /** Configured minimum liquidity threshold advertised by the manager contract. */
250
566
  minLiquidity: string;
567
+ /** Optional human-readable name. */
251
568
  name?: string;
569
+ /** Optional metadata URI. */
252
570
  uri?: string;
571
+ /** First-seen timestamp. */
253
572
  createdAt: string;
573
+ /** Last config update timestamp. */
254
574
  updatedAt: string;
255
575
  }
256
576
 
577
+ /**
578
+ * Per-manager quote sheet. Each row is a manager-supplied rate for one payment-method/currency pair. Deposits delegated to that manager read these rows when resolving `MethodCurrency.conversionRate`.
579
+ *
580
+ * @id chainId_rateManagerAddress_rateManagerId_paymentMethodHash_currencyCode
581
+ */
257
582
  export interface RateManagerRate {
583
+ /** Composite key `chainId_rateManagerAddress_rateManagerId_paymentMethodHash_currencyCode`. */
258
584
  id: string;
585
+ /** Chain where the manager contract exists. */
259
586
  chainId: number;
587
+ /** Manager contract address. */
260
588
  rateManagerAddress: string;
589
+ /** Manager identifier. */
261
590
  rateManagerId: string;
591
+ /** Payment-method dimension for the manager quote. */
262
592
  paymentMethodHash: string;
593
+ /** Fiat-currency dimension for the manager quote. */
263
594
  currencyCode: string;
595
+ /** Gross manager-provided rate before floor enforcement. */
264
596
  managerRate: string;
597
+ /** Timestamp of the last rate update event for this pair. */
265
598
  updatedAt: string;
266
599
  }
267
600
 
601
+ /**
602
+ * Portfolio-level aggregate for one delegated rate manager. This is the top-level manager reporting row.
603
+ *
604
+ * @id chainId_rateManagerAddress_rateManagerId
605
+ *
606
+ * **Relationships:**
607
+ * - One-to-one logical summary for one `RateManager`
608
+ * - Source for `ManagerDailySnapshot`
609
+ * - Updated from delegated deposit balance changes and fulfilled intents
610
+ */
268
611
  export interface ManagerAggregateStats {
612
+ /** Same identity as the corresponding `RateManager.id`. */
269
613
  id: string;
614
+ /** Chain on which the manager operates. */
270
615
  chainId: number;
616
+ /** Manager contract address. */
271
617
  rateManagerAddress: string;
618
+ /** Manager identifier. */
272
619
  rateManagerId: string;
620
+ /** Manager account/operator. */
273
621
  manager: string;
622
+ /** Cumulative token volume filled across all delegated deposits. */
274
623
  totalFilledVolume: string;
624
+ /** Cumulative manager fee amount actually earned across fills. */
275
625
  totalFeeAmount: string;
626
+ /** Cumulative USD-cent PnL measured against daily FX snapshots. */
276
627
  totalPnlUsdCents: string;
628
+ /** Number of fulfilled delegated intents. */
277
629
  fulfilledIntents: number;
630
+ /** Current delegated TVL, computed as the sum of `remainingDeposits + outstandingIntentAmount` across delegated deposits. */
278
631
  currentDelegatedBalance: string;
632
+ /** Number of deposits currently delegated to this manager. */
279
633
  currentDelegatedDeposits: number;
634
+ /** First timestamp the manager aggregate was created. */
280
635
  firstSeenAt?: string;
636
+ /** Last time the aggregate changed. */
281
637
  updatedAt: string;
282
638
  }
283
639
 
640
+ /**
641
+ * Daily bucketed snapshot for `ManagerAggregateStats`.
642
+ *
643
+ * @id chainId_rateManagerAddress_rateManagerId_dayTimestamp
644
+ */
284
645
  export interface ManagerDailySnapshot {
646
+ /** Composite key `chainId_rateManagerAddress_rateManagerId_dayTimestamp`. */
285
647
  id: string;
648
+ /** Chain on which the manager operates. */
286
649
  chainId: number;
650
+ /** Manager contract address. */
287
651
  rateManagerAddress: string;
652
+ /** Manager identifier. */
288
653
  rateManagerId: string;
654
+ /** Start-of-day UTC bucket in seconds. */
289
655
  dayTimestamp: string;
656
+ /** End-of-update delegated balance for that day. */
290
657
  tvl: string;
658
+ /** Number of currently delegated deposits at snapshot time. */
291
659
  delegatedDeposits: number;
660
+ /** Volume filled during that day. */
292
661
  dailyVolume: string;
662
+ /** Manager fees earned during that day. */
293
663
  dailyFees: string;
664
+ /** Daily PnL in USD cents. */
294
665
  dailyPnlUsdCents: string;
666
+ /** Number of fulfilled intents on that day. */
295
667
  dailyFulfilledIntents: number;
668
+ /** Cumulative filled volume up to this snapshot. */
296
669
  cumulativeVolume: string;
670
+ /** Cumulative manager fees up to this snapshot. */
297
671
  cumulativeFees: string;
672
+ /** Cumulative PnL up to this snapshot. */
298
673
  cumulativePnlUsdCents: string;
674
+ /** Cumulative fulfilled-intent count up to this snapshot. */
299
675
  cumulativeFulfilledIntents: number;
676
+ /** Last mutation time for the day's bucket. */
300
677
  updatedAt: string;
301
678
  }
302
679
 
680
+ /**
681
+ * Append-only normalized ledger of deposit funding activity. This is easier to query than replaying all raw event families.
682
+ *
683
+ * @id txHash_logIndex
684
+ *
685
+ * **Relationships:**
686
+ * - Many-to-one to `Deposit`
687
+ */
303
688
  export interface DepositFundActivity {
689
+ /** Composite key `txHash_logIndex`. */
304
690
  id: string;
691
+ /** Chain where the activity happened. */
305
692
  chainId: number;
693
+ /** Foreign-key string to `Deposit.id`. */
306
694
  depositId: string;
695
+ /** Maker address that owns the deposit. */
307
696
  depositor: string;
697
+ /** Normalized activity class: `DEPOSIT_RECEIVED`, `FUNDS_ADDED`, `WITHDRAWN`, or `CLOSED`. */
308
698
  activityType: string;
699
+ /** Token amount relevant to the activity. `CLOSED` can legitimately record zero amount. */
309
700
  amount: string;
701
+ /** Block number for the activity. */
310
702
  blockNumber: string;
703
+ /** Timestamp for the activity. */
311
704
  timestamp: string;
705
+ /** Transaction hash for the activity. */
312
706
  txHash: string;
313
707
  }
314
708
 
709
+ /**
710
+ * Daily bucketed snapshot of one deposit's state and realized profitability.
711
+ *
712
+ * @id depositId_dayTimestamp
713
+ *
714
+ * **Relationships:**
715
+ * - Many-to-one to `Deposit`
716
+ * - Receives daily-volume and daily-PnL deltas from fulfillment flows
717
+ */
315
718
  export interface DepositDailySnapshot {
719
+ /** Composite key `depositId_dayTimestamp`. */
316
720
  id: string;
721
+ /** Chain where the deposit exists. */
317
722
  chainId: number;
723
+ /** Foreign-key string to `Deposit.id`. */
318
724
  depositId: string;
725
+ /** Maker address that owns the deposit. */
319
726
  depositor: string;
727
+ /** Start-of-day UTC bucket in seconds. */
320
728
  dayTimestamp: string;
729
+ /** Deposit liquidity available at the time of the last update to that bucket. */
321
730
  remainingDeposits: string;
731
+ /** Deposit liquidity currently locked in intents at the last update. */
322
732
  outstandingIntentAmount: string;
733
+ /** Cumulative taken volume at the last update. */
323
734
  totalAmountTaken: string;
735
+ /** Cumulative withdrawn volume at the last update. */
324
736
  totalWithdrawn: string;
737
+ /** Cumulative signal count at the last update. */
325
738
  signaledIntents: number;
739
+ /** Cumulative fulfillment count at the last update. */
326
740
  fulfilledIntents: number;
741
+ /** Cumulative prune count at the last update. */
327
742
  prunedIntents: number;
743
+ /** Deposit success rate at the last update. */
328
744
  successRateBps: number;
745
+ /** Volume taken during that day only. */
329
746
  dailyVolume: string;
747
+ /** Realized PnL accrued during that day only. */
330
748
  dailyPnlUsdCents: string;
749
+ /** All-time volume through the deposit as of this bucket. */
331
750
  cumulativeVolume: string;
751
+ /** All-time realized PnL through the deposit as of this bucket. */
332
752
  cumulativePnlUsdCents: string;
753
+ /** Last mutation time for the day's bucket. */
333
754
  updatedAt: string;
334
755
  }
335
756
 
757
+ /**
758
+ * Per-deposit stats row for a delegated manager. Where `ManagerAggregateStats` is portfolio-level, `ManagerStats` is deposit-level attribution.
759
+ *
760
+ * @id chainId_rateManagerAddress_rateManagerId_depositId
761
+ *
762
+ * **Relationships:**
763
+ * - Many-to-one to `Deposit`
764
+ * - Many-to-one to `RateManager`
765
+ */
336
766
  export interface ManagerStats {
767
+ /** Composite key `chainId_rateManagerAddress_rateManagerId_depositId`. */
337
768
  id: string;
769
+ /** Chain on which the delegation exists. */
338
770
  chainId: number;
771
+ /** Manager contract address. */
339
772
  rateManagerAddress: string;
773
+ /** Manager identifier. */
340
774
  rateManagerId: string;
775
+ /** Foreign-key string to `Deposit.id`. */
341
776
  depositId: string;
777
+ /** Maker that owns the delegated deposit. */
342
778
  depositor: string;
779
+ /** Current delegated balance for this one deposit: `remainingDeposits + outstandingIntentAmount`. */
343
780
  currentDelegatedBalance: string;
781
+ /** Deposit's all-time taken amount while tracked under the manager. */
344
782
  totalAmountTaken: string;
783
+ /** Deposit's all-time withdrawn amount while tracked under the manager. */
345
784
  totalWithdrawn: string;
785
+ /** Deposit-level fulfillment count. */
346
786
  fulfilledIntents: number;
787
+ /** Deposit-level prune count. */
347
788
  prunedIntents: number;
789
+ /** Deposit-level success rate. */
348
790
  successRateBps: number;
791
+ /** Last mutation time for the row. */
349
792
  updatedAt: string;
350
793
  }
351
794
 
795
+ /**
796
+ * Read-optimized quoting view. This is intentionally denormalized so curator/quote APIs do not need to join `Deposit`, `DepositPaymentMethod`, and `MethodCurrency` at request time.
797
+ *
798
+ * @id escrowAddress_depositId_paymentMethodHash_currencyCode
799
+ *
800
+ * **Relationships:**
801
+ * - Derived from exactly one `(Deposit, DepositPaymentMethod, MethodCurrency)` tuple
802
+ * - `id` intentionally equals the corresponding `MethodCurrency.id`
803
+ */
352
804
  export interface QuoteCandidate {
805
+ /** Same composite identity as the backing `MethodCurrency`: `escrowAddress_depositId_paymentMethodHash_currencyCode`. */
353
806
  id: string;
807
+ /** Chain where the quoteable deposit lives. */
354
808
  chainId: number;
809
+ /** Raw on-chain deposit id. */
355
810
  depositIdOnContract: string;
811
+ /** Foreign-key string to `Deposit.id`. */
356
812
  depositId: string;
813
+ /** Escrow contract address copied from `Deposit`. */
357
814
  escrowAddress: string;
815
+ /** Maker address copied from `Deposit`. */
358
816
  depositor: string;
817
+ /** Token address copied from `Deposit`. */
359
818
  token: string;
819
+ /** Payment-method hash copied from the tuple. */
360
820
  paymentMethodHash: string;
821
+ /** Fiat currency copied from the tuple. */
361
822
  currencyCode: string;
823
+ /** Final gross resolved rate copied from `MethodCurrency`. */
362
824
  conversionRate?: string;
825
+ /** Final all-in taker-facing rate copied from `MethodCurrency`. */
363
826
  takerConversionRate?: string;
827
+ /** Manager fee rate copied from `MethodCurrency`, defaulting to zero if absent. */
364
828
  managerFee?: string;
829
+ /** Current immediately available maker liquidity, copied from `Deposit.remainingDeposits`. */
365
830
  availableTokenAmount: string;
831
+ /** `min(availableTokenAmount, intentAmountMax)`, used for quote ordering and max-per-intent checks. */
366
832
  maxTokenAvailablePerIntent: string;
833
+ /** Fiat value of `maxTokenAvailablePerIntent` using the taker-facing rate. */
367
834
  maxFiatAvailablePerIntent: string;
835
+ /** Fiat value of the full currently available liquidity using the taker-facing rate. */
368
836
  maxQuoteableFiat: string;
837
+ /** Minimum quoteable token amount copied from `Deposit`. */
369
838
  intentAmountMin: string;
839
+ /** Maximum quoteable token amount copied from `Deposit`. */
370
840
  intentAmountMax: string;
841
+ /** Deposit-level success signal copied from `Deposit`. */
371
842
  successRateBps: number;
843
+ /** Hashed payee details copied from `DepositPaymentMethod`. */
372
844
  payeeDetailsHash: string;
845
+ /** Optional gating service copied from `DepositPaymentMethod`. */
373
846
  intentGatingService?: string;
847
+ /** Optional whitelist hook address denormalized from `Deposit`. When non-null, this deposit is private and only whitelisted takers can access it. */
848
+ whitelistHookAddress?: string;
849
+ /** Final quoteability flag. It is `true` only when the payment method is active, the deposit is accepting intents, and the taker-facing rate is non-zero. */
374
850
  isActive: boolean;
851
+ /** Whether `availableTokenAmount >= intentAmountMin`. */
375
852
  hasMinLiquidity: boolean;
853
+ /** Fiat value of `intentAmountMin` using the taker-facing rate. */
376
854
  minFiatSupported: string;
855
+ /** Fiat value of `intentAmountMax` using the taker-facing rate. */
377
856
  maxFiatSupported: string;
857
+ /** Fiat value of `availableTokenAmount` using the taker-facing rate. */
378
858
  maxFiatAvail: string;
859
+ /** Last time the denormalized row was recomputed. */
860
+ updatedAt: string;
861
+ }
862
+
863
+ /**
864
+ * Per-deposit taker whitelist entry for private orderbooks. Created when the `WhitelistPreIntentHook` contract emits a `TakerWhitelisted` event and the emitting hook matches the deposit's active `whitelistHookAddress`. Purged when the hook is rotated/cleared via `DepositWhitelistHookSet` or when the taker is explicitly removed.
865
+ *
866
+ * @id escrowAddress_depositId_taker
867
+ *
868
+ * **Relationships:**
869
+ * - Many-to-one to `Deposit` via `depositId`
870
+ */
871
+ export interface WhitelistEntry {
872
+ /** Composite key `escrowAddress_depositId_taker` (all lowercased). */
873
+ id: string;
874
+ /** Chain where the deposit lives. */
875
+ chainId: number;
876
+ /** Address of the `WhitelistPreIntentHook` contract that emitted the event. */
877
+ hookAddress: string;
878
+ /** Escrow contract address scoping the deposit. */
879
+ escrowAddress: string;
880
+ /** Foreign-key string to `Deposit.id` (composite: `escrowAddress_depositId`). */
881
+ depositId: string;
882
+ /** Raw on-chain deposit identifier. */
883
+ depositIdOnContract: string;
884
+ /** Lowercased address of the whitelisted taker. */
885
+ taker: string;
886
+ /** Timestamp when the taker was first whitelisted. */
887
+ createdAt: string;
888
+ /** Timestamp of the most recent mutation to this entry. */
379
889
  updatedAt: string;
380
890
  }