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