@zkp2p/sdk 0.0.1

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.
@@ -0,0 +1,1962 @@
1
+ import { AccessList, AuthorizationList, WalletClient, Hash, Address, PublicClient } from 'viem';
2
+ import { Abi } from 'abitype';
3
+
4
+ /**
5
+ * Supported fiat currency codes.
6
+ *
7
+ * Use these constants when specifying currencies in conversion rates:
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { Currency } from '@zkp2p/client-sdk';
12
+ *
13
+ * const rates = [
14
+ * { currency: Currency.USD, conversionRate: '1020000000000000000' },
15
+ * { currency: Currency.EUR, conversionRate: '1100000000000000000' },
16
+ * ];
17
+ * ```
18
+ */
19
+ declare const Currency: {
20
+ readonly AED: "AED";
21
+ readonly ARS: "ARS";
22
+ readonly AUD: "AUD";
23
+ readonly CAD: "CAD";
24
+ readonly CHF: "CHF";
25
+ readonly CNY: "CNY";
26
+ readonly CZK: "CZK";
27
+ readonly DKK: "DKK";
28
+ readonly EUR: "EUR";
29
+ readonly GBP: "GBP";
30
+ readonly HKD: "HKD";
31
+ readonly HUF: "HUF";
32
+ readonly IDR: "IDR";
33
+ readonly ILS: "ILS";
34
+ readonly INR: "INR";
35
+ readonly JPY: "JPY";
36
+ readonly KES: "KES";
37
+ readonly MXN: "MXN";
38
+ readonly MYR: "MYR";
39
+ readonly NOK: "NOK";
40
+ readonly NZD: "NZD";
41
+ readonly PHP: "PHP";
42
+ readonly PLN: "PLN";
43
+ readonly RON: "RON";
44
+ readonly SAR: "SAR";
45
+ readonly SEK: "SEK";
46
+ readonly SGD: "SGD";
47
+ readonly THB: "THB";
48
+ readonly TRY: "TRY";
49
+ readonly UGX: "UGX";
50
+ readonly USD: "USD";
51
+ readonly VND: "VND";
52
+ readonly ZAR: "ZAR";
53
+ };
54
+ /**
55
+ * Union type of all supported currency codes.
56
+ */
57
+ type CurrencyType = (typeof Currency)[keyof typeof Currency];
58
+ /**
59
+ * Complete currency information including name, symbol, and hash.
60
+ */
61
+ type CurrencyData = {
62
+ currency: CurrencyType;
63
+ currencyCode: string;
64
+ currencyName: string;
65
+ currencySymbol: string;
66
+ currencyCodeHash: string;
67
+ countryCode: string;
68
+ };
69
+ /**
70
+ * Lookup table containing metadata for all supported currencies.
71
+ *
72
+ * Includes currency name, symbol, keccak256 hash (for on-chain use),
73
+ * and ISO country code for flag display.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * import { currencyInfo, Currency } from '@zkp2p/client-sdk';
78
+ *
79
+ * const usd = currencyInfo[Currency.USD];
80
+ * console.log(usd.currencyName); // "United States Dollar"
81
+ * console.log(usd.currencySymbol); // "$"
82
+ * console.log(usd.currencyCodeHash); // "0x..."
83
+ * ```
84
+ */
85
+ declare const currencyInfo: Record<CurrencyType, CurrencyData>;
86
+ /**
87
+ * UI-friendly currency rate structure used in SDK methods.
88
+ */
89
+ type UICurrencyRate = {
90
+ currency: CurrencyType;
91
+ conversionRate: string;
92
+ };
93
+ /**
94
+ * On-chain currency structure with minimum conversion rate (V3 escrow format).
95
+ */
96
+ type OnchainCurrencyMinRate = {
97
+ code: `0x${string}`;
98
+ minConversionRate: bigint;
99
+ };
100
+ /**
101
+ * Maps UI currency rates to on-chain V3 escrow format with minConversionRate.
102
+ *
103
+ * @param groups - Nested array of currency rates per payment method
104
+ * @param expectedGroups - Expected number of groups (for validation)
105
+ * @returns On-chain formatted currency arrays for V3 escrow
106
+ * @throws Error if groups structure is invalid or lengths don't match
107
+ */
108
+ declare function mapConversionRatesToOnchainMinRate(groups: UICurrencyRate[][], expectedGroups?: number): OnchainCurrencyMinRate[][];
109
+ /**
110
+ * Looks up currency info by its keccak256 hash.
111
+ *
112
+ * @param hash - The currency code hash (0x-prefixed)
113
+ * @returns Currency data if found, undefined otherwise
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * const info = getCurrencyInfoFromHash('0x...');
118
+ * if (info) {
119
+ * console.log(info.currencyCode); // "USD"
120
+ * }
121
+ * ```
122
+ */
123
+ declare function getCurrencyInfoFromHash(hash: string): CurrencyData | undefined;
124
+ /**
125
+ * Looks up currency info by ISO country code.
126
+ *
127
+ * @param code - The ISO country code (e.g., 'US', 'GB')
128
+ * @returns Currency data if found, undefined otherwise
129
+ */
130
+ declare function getCurrencyInfoFromCountryCode(code: string): CurrencyData | undefined;
131
+ /**
132
+ * Converts a currency hash to its ISO currency code.
133
+ *
134
+ * @param hash - The currency code hash (0x-prefixed)
135
+ * @returns Currency code string (e.g., 'USD') or undefined if not found
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * const code = getCurrencyCodeFromHash('0x...');
140
+ * console.log(code); // "USD"
141
+ * ```
142
+ */
143
+ declare function getCurrencyCodeFromHash(hash: string): string | undefined;
144
+ /**
145
+ * Checks if a currency hash is recognized by the SDK.
146
+ *
147
+ * @param hash - The currency code hash to check
148
+ * @returns true if the hash corresponds to a supported currency
149
+ */
150
+ declare function isSupportedCurrencyHash(hash: string): boolean;
151
+
152
+ /**
153
+ * Contract resolution utilities for the SDK.
154
+ *
155
+ * Provides access to deployed contract addresses and ABIs for different
156
+ * networks (Base, Base Sepolia) and environments (production, staging).
157
+ *
158
+ * @module contracts
159
+ */
160
+
161
+ /**
162
+ * Contract addresses for a specific deployment.
163
+ */
164
+ type V2ContractAddresses = {
165
+ /** Escrow contract (holds deposits and manages intents) */
166
+ escrow: `0x${string}`;
167
+ /** Orchestrator contract (handles intent signaling and fulfillment) */
168
+ orchestrator?: `0x${string}`;
169
+ /** UnifiedPaymentVerifier contract (verifies payment proofs) */
170
+ unifiedPaymentVerifier?: `0x${string}`;
171
+ /** ProtocolViewer contract (batch read operations) */
172
+ protocolViewer?: `0x${string}`;
173
+ /** USDC token address */
174
+ usdc?: `0x${string}`;
175
+ };
176
+ /**
177
+ * Contract ABIs for a specific deployment.
178
+ */
179
+ type V2ContractAbis = {
180
+ escrow: Abi;
181
+ orchestrator?: Abi;
182
+ unifiedPaymentVerifier?: Abi;
183
+ protocolViewer?: Abi;
184
+ };
185
+ /**
186
+ * Runtime environment: 'production' for mainnet, 'staging' for testnet/dev.
187
+ */
188
+ type RuntimeEnv = 'production' | 'staging';
189
+ /**
190
+ * Retrieves deployed contract addresses and ABIs for a given chain and environment.
191
+ *
192
+ * @param chainId - The chain ID (8453 for Base, 84532 for Base Sepolia)
193
+ * @param env - Runtime environment ('production' or 'staging')
194
+ * @returns Object containing addresses and ABIs
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * import { getContracts } from '@zkp2p/client-sdk';
199
+ *
200
+ * const { addresses, abis } = getContracts(8453, 'production');
201
+ * console.log(addresses.escrow); // "0x..."
202
+ * console.log(addresses.usdc); // "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
203
+ * ```
204
+ */
205
+ declare function getContracts(chainId: number, env?: RuntimeEnv): {
206
+ addresses: V2ContractAddresses;
207
+ abis: V2ContractAbis;
208
+ };
209
+ /**
210
+ * Catalog of payment methods with their hashes and supported currencies.
211
+ */
212
+ type PaymentMethodCatalog = Record<string, {
213
+ paymentMethodHash: `0x${string}`;
214
+ currencies?: `0x${string}`[];
215
+ }>;
216
+ /**
217
+ * Retrieves the payment methods catalog for a given chain and environment.
218
+ *
219
+ * The catalog maps payment platform names (e.g., 'wise', 'revolut') to their
220
+ * on-chain hashes and supported currency hashes.
221
+ *
222
+ * @param chainId - The chain ID
223
+ * @param env - Runtime environment
224
+ * @returns Payment method catalog keyed by platform name
225
+ *
226
+ * @example
227
+ * ```typescript
228
+ * import { getPaymentMethodsCatalog } from '@zkp2p/client-sdk';
229
+ *
230
+ * const catalog = getPaymentMethodsCatalog(8453, 'production');
231
+ * console.log(Object.keys(catalog)); // ['wise', 'venmo', 'revolut', ...]
232
+ * console.log(catalog.wise.paymentMethodHash); // "0x..."
233
+ * console.log(catalog.wise.currencies); // ["0x...", "0x..."] (currency hashes)
234
+ * ```
235
+ */
236
+ declare function getPaymentMethodsCatalog(chainId: number, env?: RuntimeEnv): PaymentMethodCatalog;
237
+ /**
238
+ * Returns the gating service address for a given chain and environment.
239
+ *
240
+ * The gating service signs intent parameters before they can be submitted
241
+ * on-chain, providing an additional validation layer.
242
+ *
243
+ * @param chainId - The chain ID
244
+ * @param env - Runtime environment
245
+ * @returns Gating service signer address
246
+ */
247
+ declare function getGatingServiceAddress(chainId: number, env?: RuntimeEnv): `0x${string}`;
248
+
249
+ type PV_Deposit = {
250
+ depositor: string;
251
+ delegate: string;
252
+ token: string;
253
+ amount: bigint;
254
+ intentAmountRange: {
255
+ min: bigint;
256
+ max: bigint;
257
+ };
258
+ acceptingIntents: boolean;
259
+ remainingDeposits: bigint;
260
+ outstandingIntentAmount: bigint;
261
+ makerProtocolFee: bigint;
262
+ reservedMakerFees: bigint;
263
+ accruedMakerFees: bigint;
264
+ accruedReferrerFees: bigint;
265
+ intentGuardian: string;
266
+ referrer: string;
267
+ referrerFee: bigint;
268
+ };
269
+ type PV_Currency = {
270
+ code: string;
271
+ minConversionRate: bigint;
272
+ };
273
+ type PV_PaymentMethodData = {
274
+ paymentMethod: string;
275
+ verificationData: {
276
+ intentGatingService: string;
277
+ payeeDetails: string;
278
+ data: string;
279
+ };
280
+ currencies: PV_Currency[];
281
+ };
282
+ type PV_DepositView = {
283
+ depositId: bigint;
284
+ deposit: PV_Deposit;
285
+ availableLiquidity: bigint;
286
+ paymentMethods: PV_PaymentMethodData[];
287
+ intentHashes: string[];
288
+ };
289
+ type PV_Intent = {
290
+ owner: string;
291
+ to: string;
292
+ escrow: string;
293
+ depositId: bigint;
294
+ amount: bigint;
295
+ timestamp: bigint;
296
+ paymentMethod: string;
297
+ fiatCurrency: string;
298
+ conversionRate: bigint;
299
+ referrer: string;
300
+ referrerFee: bigint;
301
+ postIntentHook: string;
302
+ data: string;
303
+ };
304
+ type PV_IntentView = {
305
+ intentHash: string;
306
+ intent: PV_Intent;
307
+ deposit: Omit<PV_DepositView, 'intentHashes'>;
308
+ };
309
+ declare function parseDepositView(raw: any): PV_DepositView;
310
+ declare function parseIntentView(raw: any): PV_IntentView;
311
+
312
+ declare function enrichPvDepositView(view: PV_DepositView, chainId: number, env?: RuntimeEnv): {
313
+ paymentMethods: {
314
+ processorName: string | undefined;
315
+ currencies: {
316
+ currencyInfo: CurrencyData | undefined;
317
+ code: string;
318
+ minConversionRate: bigint;
319
+ }[];
320
+ paymentMethod: string;
321
+ verificationData: {
322
+ intentGatingService: string;
323
+ payeeDetails: string;
324
+ data: string;
325
+ };
326
+ }[];
327
+ depositId: bigint;
328
+ deposit: PV_Deposit;
329
+ availableLiquidity: bigint;
330
+ intentHashes: string[];
331
+ };
332
+ declare function enrichPvIntentView(view: PV_IntentView, chainId: number, env?: RuntimeEnv): any;
333
+
334
+ /**
335
+ * Minimal fetch-based GraphQL client for the ZKP2P indexer.
336
+ * No external GraphQL dependencies; works in Node and browser.
337
+ */
338
+ type GraphQLRequest = {
339
+ query: string;
340
+ variables?: Record<string, unknown>;
341
+ };
342
+ declare class IndexerClient {
343
+ private endpoint;
344
+ constructor(endpoint: string);
345
+ private _post;
346
+ query<T = any>(request: GraphQLRequest, init?: RequestInit & {
347
+ retries?: number;
348
+ }): Promise<T>;
349
+ }
350
+ type DeploymentEnv = 'PRODUCTION' | 'PREPRODUCTION' | 'STAGING' | 'DEV' | 'LOCAL' | 'STAGING_TESTNET';
351
+ declare function defaultIndexerEndpoint(env?: DeploymentEnv): string;
352
+
353
+ /**
354
+ * Indexer entity types (GraphQL schema-aligned)
355
+ */
356
+ type DepositStatus$1 = 'ACTIVE' | 'CLOSED';
357
+ interface DepositEntity {
358
+ id: string;
359
+ chainId: number;
360
+ escrowAddress: string;
361
+ depositId: string;
362
+ depositor: string;
363
+ token: string;
364
+ remainingDeposits: string;
365
+ intentAmountMin: string;
366
+ intentAmountMax: string;
367
+ acceptingIntents: boolean;
368
+ status: DepositStatus$1;
369
+ outstandingIntentAmount: string;
370
+ totalAmountTaken: string;
371
+ totalWithdrawn: string;
372
+ successRateBps?: number;
373
+ totalIntents: number;
374
+ signaledIntents: number;
375
+ fulfilledIntents: number;
376
+ prunedIntents: number;
377
+ blockNumber: string;
378
+ timestamp: string;
379
+ txHash: string;
380
+ updatedAt: string;
381
+ }
382
+ interface DepositPaymentMethodEntity {
383
+ id: string;
384
+ chainId: number;
385
+ depositIdOnContract: string;
386
+ depositId: string;
387
+ paymentMethodHash: string;
388
+ verifierAddress: string;
389
+ intentGatingService: string;
390
+ payeeDetailsHash: string;
391
+ active: boolean;
392
+ }
393
+ interface MethodCurrencyEntity {
394
+ id: string;
395
+ chainId: number;
396
+ depositIdOnContract: string;
397
+ depositId: string;
398
+ paymentMethodHash: string;
399
+ currencyCode: string;
400
+ minConversionRate: string;
401
+ }
402
+ type IntentStatus = 'SIGNALED' | 'FULFILLED' | 'PRUNED' | 'MANUALLY_RELEASED';
403
+ interface IntentEntity {
404
+ id: string;
405
+ intentHash: string;
406
+ depositId: string;
407
+ orchestratorAddress: string;
408
+ verifier: string;
409
+ owner: string;
410
+ toAddress: string;
411
+ amount: string;
412
+ fiatCurrency: string;
413
+ conversionRate: string;
414
+ status: IntentStatus;
415
+ isExpired: boolean;
416
+ signalTimestamp: string;
417
+ expiryTime?: string;
418
+ fulfillTimestamp?: string | null;
419
+ pruneTimestamp?: string | null;
420
+ updatedAt?: string | null;
421
+ signalTxHash: string;
422
+ fulfillTxHash?: string | null;
423
+ pruneTxHash?: string | null;
424
+ paymentMethodHash?: string | null;
425
+ paymentAmount?: string | null;
426
+ paymentCurrency?: string | null;
427
+ paymentTimestamp?: string | null;
428
+ paymentId?: string | null;
429
+ releasedAmount?: string | null;
430
+ takerAmountNetFees?: string | null;
431
+ }
432
+ interface DepositWithRelations extends DepositEntity {
433
+ paymentMethods?: DepositPaymentMethodEntity[];
434
+ currencies?: MethodCurrencyEntity[];
435
+ intents?: IntentEntity[];
436
+ }
437
+ interface IntentFulfilledEntity {
438
+ intentHash: string;
439
+ isManualRelease: boolean;
440
+ fundsTransferredTo?: string | null;
441
+ }
442
+
443
+ type DepositOrderField = 'remainingDeposits' | 'outstandingIntentAmount' | 'totalAmountTaken' | 'totalWithdrawn' | 'updatedAt' | 'timestamp';
444
+ type OrderDirection = 'asc' | 'desc';
445
+ type DepositFilter = Partial<{
446
+ status: 'ACTIVE' | 'CLOSED';
447
+ depositor: string;
448
+ chainId: number;
449
+ escrowAddress: string;
450
+ escrowAddresses: string[];
451
+ minLiquidity: string;
452
+ acceptingIntents: boolean;
453
+ }>;
454
+ type PaginationOptions = Partial<{
455
+ limit: number;
456
+ offset: number;
457
+ orderBy: DepositOrderField;
458
+ orderDirection: OrderDirection;
459
+ }>;
460
+ declare class IndexerDepositService {
461
+ private client;
462
+ constructor(client: IndexerClient);
463
+ private buildDepositWhere;
464
+ private buildOrderBy;
465
+ private fetchRelations;
466
+ private fetchIntents;
467
+ private attachRelations;
468
+ fetchDeposits(filter?: DepositFilter, pagination?: PaginationOptions): Promise<DepositEntity[]>;
469
+ fetchDepositsWithRelations(filter?: DepositFilter, pagination?: PaginationOptions, options?: {
470
+ includeIntents?: boolean;
471
+ intentStatuses?: IntentStatus[];
472
+ }): Promise<DepositWithRelations[]>;
473
+ fetchDepositsByIds(ids: string[]): Promise<DepositEntity[]>;
474
+ fetchDepositsByIdsWithRelations(ids: string[], options?: {
475
+ includeIntents?: boolean;
476
+ intentStatuses?: IntentStatus[];
477
+ }): Promise<DepositWithRelations[]>;
478
+ fetchIntentsForDeposits(depositIds: string[], statuses?: IntentStatus[]): Promise<IntentEntity[]>;
479
+ fetchIntentsByOwner(owner: string, statuses?: IntentStatus[]): Promise<IntentEntity[]>;
480
+ fetchDepositWithRelations(id: string, options?: {
481
+ includeIntents?: boolean;
482
+ intentStatuses?: IntentStatus[];
483
+ }): Promise<DepositWithRelations | null>;
484
+ fetchExpiredIntents(params: {
485
+ now: bigint | string;
486
+ depositIds: string[];
487
+ limit?: number;
488
+ }): Promise<IntentEntity[]>;
489
+ fetchFulfilledIntentEvents(intentHashes: string[]): Promise<IntentFulfilledEntity[]>;
490
+ resolvePayeeHash(params: {
491
+ escrowAddress?: string | null;
492
+ depositId?: string | number | bigint | null;
493
+ paymentMethodHash?: string | null;
494
+ }): Promise<string | null>;
495
+ fetchDepositsByPayeeHash(payeeHash: string, options?: {
496
+ paymentMethodHash?: string;
497
+ limit?: number;
498
+ includeIntents?: boolean;
499
+ intentStatuses?: IntentStatus[];
500
+ }): Promise<DepositWithRelations[]>;
501
+ }
502
+
503
+ type FulfillmentRecord = {
504
+ id: string;
505
+ intentHash: string;
506
+ amount: string;
507
+ isManualRelease: boolean;
508
+ fundsTransferredTo: string | null;
509
+ };
510
+ type PaymentVerifiedRecord = {
511
+ id: string;
512
+ intentHash: string;
513
+ method: string;
514
+ currency: string;
515
+ amount: string;
516
+ timestamp: string;
517
+ paymentId: string | null;
518
+ payeeId: string | null;
519
+ };
520
+ type FulfillmentAndPaymentResponse = {
521
+ Orchestrator_V21_IntentFulfilled: FulfillmentRecord[];
522
+ UnifiedVerifier_V21_PaymentVerified: PaymentVerifiedRecord[];
523
+ };
524
+ declare function fetchFulfillmentAndPayment(client: IndexerClient, intentHash: string): Promise<FulfillmentAndPaymentResponse>;
525
+
526
+ /**
527
+ * Timeout configuration for different operation types
528
+ */
529
+ type TimeoutConfig = {
530
+ /** API call timeout in milliseconds (default: 30000) */
531
+ api?: number;
532
+ /** Transaction timeout in milliseconds (default: 60000) */
533
+ transaction?: number;
534
+ };
535
+ type Zkp2pClientOptions = {
536
+ walletClient: WalletClient;
537
+ apiKey: string;
538
+ chainId: number;
539
+ environment?: 'production' | 'staging';
540
+ baseApiUrl?: string;
541
+ witnessUrl?: string;
542
+ rpcUrl?: string;
543
+ /** Optional bearer token for hybrid auth */
544
+ authorizationToken?: string;
545
+ /** Optional timeout configuration */
546
+ timeouts?: TimeoutConfig;
547
+ };
548
+ /**
549
+ * Callback function for transaction actions
550
+ * @param params - Transaction callback parameters
551
+ * @param params.hash - Transaction hash
552
+ * @param params.data - Optional additional data from the transaction
553
+ */
554
+ type ActionCallback = (params: {
555
+ hash: Hash;
556
+ data?: unknown;
557
+ }) => void;
558
+ /**
559
+ * Safe transaction overrides including ERC-8021 referrers.
560
+ * Referrer codes are prepended before the Base builder code (bc_nbn6qkni).
561
+ */
562
+ type TxOverrides = {
563
+ gas?: bigint;
564
+ gasPrice?: bigint;
565
+ maxFeePerGas?: bigint;
566
+ maxPriorityFeePerGas?: bigint;
567
+ nonce?: number;
568
+ value?: bigint;
569
+ accessList?: AccessList;
570
+ authorizationList?: AuthorizationList;
571
+ /**
572
+ * ERC-8021 referrer code(s) to prepend before the Base builder code.
573
+ * Accepts a single code or multiple (e.g., ['zkp2p-bot', 'merchant-id']).
574
+ */
575
+ referrer?: string | string[];
576
+ };
577
+ /**
578
+ * Parameters for fulfilling an intent with payment attestation
579
+ */
580
+ type FulfillIntentParams = {
581
+ /** Hash of the intent to fulfill */
582
+ intentHash: Hash;
583
+ /** Attestation proof - object or stringified JSON from attestation service */
584
+ proof: Record<string, unknown> | string;
585
+ /** Optional attestation timestamp buffer override in milliseconds */
586
+ timestampBufferMs?: number | string;
587
+ /** Override the attestation service base URL */
588
+ attestationServiceUrl?: string;
589
+ /** Override the verifying contract (defaults to UnifiedPaymentVerifier) */
590
+ verifyingContract?: Address;
591
+ /** Optional hook payload passed to orchestrator */
592
+ postIntentHookData?: `0x${string}`;
593
+ /** Optional viem transaction overrides */
594
+ txOverrides?: TxOverrides;
595
+ /** Optional lifecycle callbacks */
596
+ callbacks?: {
597
+ onAttestationStart?: () => void;
598
+ onTxSent?: (hash: Hash) => void;
599
+ onTxMined?: (hash: Hash) => void;
600
+ };
601
+ };
602
+ /**
603
+ * Parameters for releasing funds back to the payer
604
+ */
605
+ type ReleaseFundsToPayerParams = {
606
+ /** Hash of the intent to release funds for */
607
+ intentHash: Hash;
608
+ /** Callback when transaction is successfully sent */
609
+ onSuccess?: ActionCallback;
610
+ /** Callback when an error occurs */
611
+ onError?: (error: Error) => void;
612
+ /** Callback when transaction is mined */
613
+ onMined?: ActionCallback;
614
+ };
615
+ /**
616
+ * Parameters for signaling an intent to use a deposit
617
+ */
618
+ type SignalIntentParams = {
619
+ /** Payment processor name (e.g., 'wise', 'revolut') */
620
+ processorName: string;
621
+ /** ID of the deposit to use */
622
+ depositId: string;
623
+ /** Amount of tokens to transfer */
624
+ tokenAmount: string;
625
+ /** Payee details for the payment */
626
+ payeeDetails: string;
627
+ /** Recipient blockchain address */
628
+ toAddress: string;
629
+ /** Currency type for the payment */
630
+ currency: CurrencyType;
631
+ /** Callback when transaction is successfully sent */
632
+ onSuccess?: ActionCallback;
633
+ /** Callback when an error occurs */
634
+ onError?: (error: Error) => void;
635
+ /** Callback when transaction is mined */
636
+ onMined?: ActionCallback;
637
+ };
638
+ /**
639
+ * Request structure for posting deposit details
640
+ */
641
+ type PostDepositDetailsRequest = {
642
+ /** Deposit data key-value pairs */
643
+ depositData: {
644
+ [key: string]: string;
645
+ };
646
+ /** Payment processor name */
647
+ processorName: string;
648
+ };
649
+ /**
650
+ * Response from posting deposit details
651
+ */
652
+ type PostDepositDetailsResponse = {
653
+ /** Whether the request was successful */
654
+ success: boolean;
655
+ message: string;
656
+ responseObject: {
657
+ id: number;
658
+ processorName: string;
659
+ depositData: {
660
+ [key: string]: string;
661
+ };
662
+ hashedOnchainId: string;
663
+ createdAt: string;
664
+ };
665
+ statusCode: number;
666
+ };
667
+ /**
668
+ * Alias types for clarity when registering payee details (makers/create)
669
+ */
670
+ type RegisterPayeeDetailsRequest = PostDepositDetailsRequest;
671
+ type RegisterPayeeDetailsResponse = PostDepositDetailsResponse;
672
+ type QuoteRequest = {
673
+ paymentPlatforms: string[];
674
+ fiatCurrency: string;
675
+ user: string;
676
+ recipient: string;
677
+ destinationChainId: number;
678
+ destinationToken: string;
679
+ referrer?: string;
680
+ useMultihop?: boolean;
681
+ quotesToReturn?: number;
682
+ amount: string;
683
+ isExactFiat?: boolean;
684
+ /** Optional filter: limit quotes to these escrow contracts */
685
+ escrowAddresses?: string[];
686
+ /** Enable nearby quote discovery when exact match unavailable */
687
+ includeNearbyQuotes?: boolean;
688
+ /** Max % deviation to search for nearby quotes (e.g., 10 = ±10%) */
689
+ nearbySearchRange?: number;
690
+ /** Max suggestions per direction (1-10, default: 3) */
691
+ nearbyQuotesCount?: number;
692
+ };
693
+ type FiatResponse = {
694
+ currencyCode: string;
695
+ currencyName: string;
696
+ currencySymbol: string;
697
+ countryCode: string;
698
+ };
699
+ type TokenResponse = {
700
+ token: string;
701
+ decimals: number;
702
+ name: string;
703
+ symbol: string;
704
+ chainId: number;
705
+ };
706
+ /**
707
+ * Intent details within a quote response
708
+ */
709
+ type QuoteIntentResponse = {
710
+ /** Deposit ID */
711
+ depositId: string;
712
+ /** Payment processor name */
713
+ processorName: string;
714
+ /** Amount to transfer */
715
+ amount: string;
716
+ /** Recipient address */
717
+ toAddress: string;
718
+ /** Payee details */
719
+ payeeDetails: string;
720
+ /** Processor-specific intent data */
721
+ processorIntentData: Record<string, unknown>;
722
+ /** Fiat currency code */
723
+ fiatCurrencyCode: string;
724
+ /** Chain ID */
725
+ chainId: string;
726
+ };
727
+ type QuoteSingleResponse = {
728
+ fiatAmount: string;
729
+ fiatAmountFormatted: string;
730
+ tokenAmount: string;
731
+ tokenAmountFormatted: string;
732
+ paymentMethod: string;
733
+ payeeAddress: string;
734
+ conversionRate: string;
735
+ intent: QuoteIntentResponse;
736
+ payeeData?: Record<string, string>;
737
+ };
738
+ type QuoteFeesResponse = {
739
+ zkp2pFee: string;
740
+ zkp2pFeeFormatted: string;
741
+ swapFee: string;
742
+ swapFeeFormatted: string;
743
+ };
744
+ /**
745
+ * A nearby quote suggestion returned when no exact match is available.
746
+ * Fields vary based on whether request was exact-token or exact-fiat mode.
747
+ */
748
+ type NearbyQuote = {
749
+ /** For exact-token mode: suggested token amount */
750
+ suggestedTokenAmount?: string;
751
+ /** For exact-token mode: formatted suggested token amount */
752
+ suggestedTokenAmountFormatted?: string;
753
+ /** For exact-token mode: percentage difference from requested (e.g., "-5.0%" or "+10.0%") */
754
+ tokenPercentDifference?: string;
755
+ /** For exact-fiat mode: suggested fiat amount */
756
+ suggestedFiatAmount?: string;
757
+ /** For exact-fiat mode: formatted suggested fiat amount */
758
+ suggestedFiatAmountFormatted?: string;
759
+ /** For exact-fiat mode: percentage difference from requested */
760
+ fiatPercentDifference?: string;
761
+ /** The full quote at this suggested amount */
762
+ quote: QuoteSingleResponse;
763
+ };
764
+ /**
765
+ * Nearby quote suggestions when no exact match is available.
766
+ * Only present in response when includeNearbyQuotes=true and no exact quotes found.
767
+ */
768
+ type NearbySuggestions = {
769
+ /** Quotes at amounts below the requested amount (sorted by closest first) */
770
+ below: NearbyQuote[];
771
+ /** Quotes at amounts above the requested amount (sorted by closest first) */
772
+ above: NearbyQuote[];
773
+ };
774
+ type QuoteResponseObject = {
775
+ fiat: FiatResponse;
776
+ token: TokenResponse;
777
+ quotes: QuoteSingleResponse[];
778
+ fees: QuoteFeesResponse;
779
+ /** Nearby suggestions when no exact quotes available (only present with includeNearbyQuotes=true) */
780
+ nearbySuggestions?: NearbySuggestions;
781
+ };
782
+ type QuoteResponse = {
783
+ message: string;
784
+ success: boolean;
785
+ responseObject: QuoteResponseObject;
786
+ statusCode: number;
787
+ };
788
+ /**
789
+ * Request to fetch payee details
790
+ * Prefer `processorName`; `platform` kept for backward compatibility.
791
+ */
792
+ type GetPayeeDetailsRequest = {
793
+ hashedOnchainId: string;
794
+ processorName: string;
795
+ };
796
+ type GetPayeeDetailsResponse = {
797
+ success: boolean;
798
+ message: string;
799
+ responseObject: {
800
+ id: number;
801
+ processorName: string;
802
+ depositData: {
803
+ [key: string]: string;
804
+ };
805
+ hashedOnchainId: string;
806
+ createdAt: string;
807
+ };
808
+ statusCode: number;
809
+ };
810
+ type ValidatePayeeDetailsRequest = {
811
+ processorName: string;
812
+ depositData: {
813
+ [key: string]: string;
814
+ };
815
+ };
816
+ type ValidatePayeeDetailsResponse = {
817
+ success: boolean;
818
+ message: string;
819
+ responseObject: {
820
+ isValid: boolean;
821
+ errors?: string[];
822
+ };
823
+ statusCode: number;
824
+ };
825
+ type OnchainCurrency = {
826
+ code: `0x${string}`;
827
+ conversionRate: bigint;
828
+ };
829
+ type DepositVerifierData = {
830
+ intentGatingService: `0x${string}`;
831
+ payeeDetails: string;
832
+ data: `0x${string}`;
833
+ };
834
+ type Range = {
835
+ min: bigint;
836
+ max: bigint;
837
+ };
838
+ type CreateDepositConversionRate = {
839
+ currency: CurrencyType;
840
+ conversionRate: string;
841
+ };
842
+ type CreateDepositParams = {
843
+ token: Address;
844
+ amount: bigint;
845
+ intentAmountRange: Range;
846
+ conversionRates: CreateDepositConversionRate[][];
847
+ processorNames: string[];
848
+ depositData: {
849
+ [key: string]: string;
850
+ }[];
851
+ onSuccess?: ActionCallback;
852
+ onError?: (error: Error) => void;
853
+ onMined?: ActionCallback;
854
+ };
855
+ type WithdrawDepositParams = {
856
+ depositId: string | number | bigint;
857
+ onSuccess?: ActionCallback;
858
+ onError?: (error: Error) => void;
859
+ onMined?: ActionCallback;
860
+ };
861
+ type CancelIntentParams = {
862
+ intentHash: Hash;
863
+ onSuccess?: ActionCallback;
864
+ onError?: (error: Error) => void;
865
+ onMined?: ActionCallback;
866
+ };
867
+ type DepositStatus = 'ACTIVE' | 'WITHDRAWN' | 'CLOSED';
868
+ type ApiIntentStatus = 'SIGNALED' | 'FULFILLED' | 'PRUNED' | 'MANUALLY_RELEASED';
869
+ type Intent = {
870
+ id: number;
871
+ intentHash: string;
872
+ depositId: string;
873
+ verifier: string;
874
+ owner: string;
875
+ toAddress: string;
876
+ amount: string;
877
+ fiatCurrency: string;
878
+ conversionRate: string;
879
+ sustainabilityFee: string | null;
880
+ verifierFee: string | null;
881
+ status: ApiIntentStatus;
882
+ signalTxHash: string;
883
+ signalTimestamp: Date;
884
+ fulfillTxHash: string | null;
885
+ fulfillTimestamp: Date | null;
886
+ pruneTxHash: string | null;
887
+ prunedTimestamp: Date | null;
888
+ createdAt: Date;
889
+ updatedAt: Date;
890
+ };
891
+ type GetOwnerIntentsRequest = {
892
+ ownerAddress: string;
893
+ status?: ApiIntentStatus | ApiIntentStatus[];
894
+ };
895
+ type GetOwnerIntentsResponse = {
896
+ success: boolean;
897
+ message: string;
898
+ responseObject: Intent[];
899
+ statusCode: number;
900
+ };
901
+ type GetIntentsByDepositRequest = {
902
+ depositId: string;
903
+ status?: ApiIntentStatus | ApiIntentStatus[];
904
+ };
905
+ type GetIntentsByDepositResponse = {
906
+ success: boolean;
907
+ message: string;
908
+ responseObject: Intent[];
909
+ statusCode: number;
910
+ };
911
+ type GetIntentByHashRequest = {
912
+ intentHash: string;
913
+ };
914
+ type GetIntentByHashResponse = {
915
+ success: boolean;
916
+ message: string;
917
+ responseObject: Intent;
918
+ statusCode: number;
919
+ };
920
+ type DepositVerifierCurrency = {
921
+ id?: number;
922
+ depositVerifierId?: number;
923
+ currencyCode: string;
924
+ conversionRate: string;
925
+ createdAt?: Date;
926
+ updatedAt?: Date;
927
+ };
928
+ type DepositVerifier = {
929
+ id?: number;
930
+ depositId: number;
931
+ verifier: string;
932
+ intentGatingService: string;
933
+ payeeDetailsHash: string;
934
+ data: string;
935
+ createdAt?: Date;
936
+ updatedAt?: Date;
937
+ currencies: DepositVerifierCurrency[];
938
+ };
939
+ type ApiDeposit = {
940
+ id: number;
941
+ depositor: string;
942
+ token: string;
943
+ amount: string;
944
+ remainingDeposits: string;
945
+ intentAmountMin: string;
946
+ intentAmountMax: string;
947
+ acceptingIntents: boolean;
948
+ outstandingIntentAmount: string;
949
+ availableLiquidity: string;
950
+ status: 'ACTIVE' | 'WITHDRAWN' | 'CLOSED';
951
+ totalIntents: number;
952
+ signaledIntents: number;
953
+ fulfilledIntents: number;
954
+ prunedIntents: number;
955
+ createdAt?: Date;
956
+ updatedAt?: Date;
957
+ verifiers: DepositVerifier[];
958
+ };
959
+ type GetOwnerDepositsRequest = {
960
+ ownerAddress: string;
961
+ /** Optional status filter: 'ACTIVE' | 'WITHDRAWN' | 'CLOSED' */
962
+ status?: DepositStatus;
963
+ };
964
+ type GetOwnerDepositsResponse = {
965
+ success: boolean;
966
+ message: string;
967
+ responseObject: ApiDeposit[];
968
+ statusCode: number;
969
+ };
970
+ type GetDepositByIdRequest = {
971
+ depositId: string;
972
+ };
973
+ type GetDepositByIdResponse = {
974
+ success: boolean;
975
+ message: string;
976
+ responseObject: ApiDeposit;
977
+ statusCode: number;
978
+ };
979
+ type OrderStats = {
980
+ id: number;
981
+ totalIntents: number;
982
+ signaledIntents: number;
983
+ fulfilledIntents: number;
984
+ prunedIntents: number;
985
+ };
986
+ type DepositIntentStatistics = OrderStats;
987
+ type TakerTierStats = {
988
+ lifetimeSignaledCount: number;
989
+ lifetimeFulfilledCount: number;
990
+ lifetimeManualReleaseCount: number;
991
+ lifetimePruneCount: number;
992
+ totalCancelledVolume: string;
993
+ totalFulfilledVolume: string;
994
+ lockScore: string;
995
+ lockScoreDiluted: string;
996
+ firstSeenAt: string;
997
+ lastIntentAt: string;
998
+ updatedAt: string;
999
+ };
1000
+ type TakerTierLevel = 'PEASANT' | 'PEER' | 'PLUS' | 'PRO' | 'PLATINUM' | 'PEER_PRESIDENT';
1001
+ type PlatformRiskLevel = 'LOW' | 'MEDIUM_HIGH' | 'HIGH' | 'HIGHEST';
1002
+ type PlatformLimit = {
1003
+ paymentMethodHash: string;
1004
+ platformName: string;
1005
+ riskLevel: PlatformRiskLevel;
1006
+ capMultiplier: number;
1007
+ effectiveCap: string;
1008
+ effectiveCapDisplay: string;
1009
+ hasCooldown: boolean;
1010
+ cooldownHours: number;
1011
+ isLocked: boolean;
1012
+ minTierRequired: TakerTierLevel | null;
1013
+ };
1014
+ type TakerTier = {
1015
+ owner: string;
1016
+ chainId: number;
1017
+ tier: TakerTierLevel;
1018
+ perIntentCapBaseUnits: string;
1019
+ perIntentCapDisplay: string;
1020
+ lastUpdated: string;
1021
+ source: 'computed' | 'fallback';
1022
+ stats: TakerTierStats | null;
1023
+ cooldownHours: number;
1024
+ cooldownSeconds: number;
1025
+ cooldownActive: boolean;
1026
+ cooldownRemainingSeconds: number;
1027
+ nextIntentAvailableAt: string | null;
1028
+ platformLimits?: PlatformLimit[];
1029
+ };
1030
+ type GetTakerTierRequest = {
1031
+ owner: string;
1032
+ chainId: number;
1033
+ };
1034
+ type GetTakerTierResponse = {
1035
+ success: boolean;
1036
+ message: string;
1037
+ responseObject: TakerTier;
1038
+ statusCode?: number;
1039
+ };
1040
+
1041
+ declare const PAYMENT_PLATFORMS: readonly ["wise", "venmo", "revolut", "cashapp", "mercadopago", "zelle", "paypal", "monzo"];
1042
+ type PaymentPlatformType = typeof PAYMENT_PLATFORMS[number];
1043
+
1044
+ /**
1045
+ * Configuration options for creating a Zkp2pClient instance.
1046
+ *
1047
+ * @example
1048
+ * ```typescript
1049
+ * const options: Zkp2pNextOptions = {
1050
+ * walletClient,
1051
+ * chainId: 8453, // Base mainnet
1052
+ * runtimeEnv: 'production',
1053
+ * apiKey: 'your-api-key',
1054
+ * };
1055
+ * ```
1056
+ */
1057
+ type Zkp2pNextOptions = {
1058
+ /** viem WalletClient instance with an account for signing transactions */
1059
+ walletClient: WalletClient;
1060
+ /** Chain ID (8453 for Base mainnet, 84532 for Base Sepolia) */
1061
+ chainId: number;
1062
+ /** Optional RPC URL override (defaults to wallet's chain RPC, then https://mainnet.base.org for Base or https://sepolia.base.org for Base Sepolia) */
1063
+ rpcUrl?: string;
1064
+ /** Runtime environment: 'production' or 'staging' (defaults to 'production') */
1065
+ runtimeEnv?: RuntimeEnv;
1066
+ /** Optional indexer URL override */
1067
+ indexerUrl?: string;
1068
+ /** Base API URL for ZKP2P services (defaults to https://api.zkp2p.xyz) */
1069
+ baseApiUrl?: string;
1070
+ /** API key for authenticated endpoints (required for createDeposit, signalIntent) */
1071
+ apiKey?: string;
1072
+ /** Optional bearer token for hybrid authentication */
1073
+ authorizationToken?: string;
1074
+ /** Timeout configuration */
1075
+ timeouts?: {
1076
+ /** API call timeout in milliseconds (default: 15000) */
1077
+ api?: number;
1078
+ };
1079
+ };
1080
+ /**
1081
+ * SDK client for ZKP2P liquidity providers (offramp peers).
1082
+ *
1083
+ * This SDK is designed for **liquidity providers** who want to:
1084
+ * - Create and manage USDC deposits that accept fiat payments
1085
+ * - Configure payment methods, currencies, and conversion rates
1086
+ * - Monitor deposit utilization and manage liquidity
1087
+ *
1088
+ * ## Core Functionality (Deposit Management)
1089
+ *
1090
+ * The primary use case is managing deposits as a liquidity provider:
1091
+ *
1092
+ * | Method | Description |
1093
+ * |--------|-------------|
1094
+ * | `createDeposit()` | Create a new USDC deposit |
1095
+ * | `addFunds()` / `removeFunds()` | Adjust deposit balance |
1096
+ * | `withdrawDeposit()` | Fully withdraw a deposit |
1097
+ * | `setAcceptingIntents()` | Enable/disable new intents |
1098
+ * | `setIntentRange()` | Set min/max intent amounts |
1099
+ * | `setCurrencyMinRate()` | Update conversion rates |
1100
+ * | `addPaymentMethods()` | Add payment platforms |
1101
+ * | `getDeposits()` | Query your deposits |
1102
+ *
1103
+ * ## Supporting Functionality
1104
+ *
1105
+ * These methods support the broader ZKP2P ecosystem but are not the
1106
+ * primary focus of this SDK:
1107
+ *
1108
+ * - **Intent Operations**: `signalIntent()`, `fulfillIntent()`, `cancelIntent()`
1109
+ * (typically used by takers/buyers, not liquidity providers)
1110
+ * - **Quote API**: `getQuote()` (used by frontends to find available liquidity)
1111
+ *
1112
+ * @example Creating a Deposit (Primary Use Case)
1113
+ * ```typescript
1114
+ * import { createWalletClient, http } from 'viem';
1115
+ * import { base } from 'viem/chains';
1116
+ * import { privateKeyToAccount } from 'viem/accounts';
1117
+ * import { Zkp2pClient } from '@zkp2p/client-sdk';
1118
+ *
1119
+ * const walletClient = createWalletClient({
1120
+ * account: privateKeyToAccount('0x...'),
1121
+ * chain: base,
1122
+ * transport: http(),
1123
+ * });
1124
+ *
1125
+ * const client = new OfframpClient({
1126
+ * walletClient,
1127
+ * chainId: base.id,
1128
+ * apiKey: 'your-api-key',
1129
+ * });
1130
+ *
1131
+ * // Create a 1000 USDC deposit accepting Wise payments
1132
+ * const { hash } = await client.createDeposit({
1133
+ * token: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', // USDC
1134
+ * amount: 1000_000000n,
1135
+ * intentAmountRange: { min: 10_000000n, max: 500_000000n },
1136
+ * processorNames: ['wise'],
1137
+ * depositData: [{ email: 'you@example.com' }],
1138
+ * conversionRates: [[
1139
+ * { currency: 'USD', conversionRate: '1020000000000000000' },
1140
+ * { currency: 'EUR', conversionRate: '1100000000000000000' },
1141
+ * ]],
1142
+ * });
1143
+ *
1144
+ * // Monitor your deposits
1145
+ * const deposits = await client.getDeposits({ owner: walletClient.account.address });
1146
+ * ```
1147
+ */
1148
+ declare class Zkp2pClient {
1149
+ /** The viem WalletClient used for signing transactions */
1150
+ readonly walletClient: WalletClient;
1151
+ /** The viem PublicClient used for reading contract state */
1152
+ readonly publicClient: PublicClient;
1153
+ /** The chain ID this client is configured for */
1154
+ readonly chainId: number;
1155
+ /** Runtime environment ('production' or 'staging') */
1156
+ readonly runtimeEnv: RuntimeEnv;
1157
+ /** Escrow contract address */
1158
+ readonly escrowAddress: Address;
1159
+ /** Escrow contract ABI */
1160
+ readonly escrowAbi: Abi;
1161
+ /** Orchestrator contract address (handles intent signaling/fulfillment) */
1162
+ readonly orchestratorAddress?: Address;
1163
+ /** Orchestrator contract ABI */
1164
+ readonly orchestratorAbi?: Abi;
1165
+ /** UnifiedPaymentVerifier contract address */
1166
+ readonly unifiedPaymentVerifier?: Address;
1167
+ /** ProtocolViewer contract address (for batch reads) */
1168
+ readonly protocolViewerAddress?: Address;
1169
+ /** ProtocolViewer contract ABI */
1170
+ readonly protocolViewerAbi?: Abi;
1171
+ /** Base API URL for ZKP2P services */
1172
+ readonly baseApiUrl?: string;
1173
+ /** API key for authenticated endpoints */
1174
+ readonly apiKey?: string;
1175
+ /** Bearer token for hybrid authentication */
1176
+ readonly authorizationToken?: string;
1177
+ /** API timeout in milliseconds */
1178
+ readonly apiTimeoutMs: number;
1179
+ private _usdcAddress?;
1180
+ private readonly _indexerClient;
1181
+ private readonly _indexerService;
1182
+ /**
1183
+ * Creates a new Zkp2pClient instance.
1184
+ *
1185
+ * @param opts - Configuration options
1186
+ * @throws Error if walletClient is missing an account
1187
+ */
1188
+ constructor(opts: Zkp2pNextOptions);
1189
+ private isValidHexAddress;
1190
+ /**
1191
+ * Simulate a contract call (validation only) and send with ERC-8021 attribution.
1192
+ * Referrer codes are stripped from overrides for simulation and appended to calldata.
1193
+ */
1194
+ private simulateAndSendWithAttribution;
1195
+ /**
1196
+ * Fetches all deposits owned by the connected wallet from on-chain.
1197
+ *
1198
+ * This is the primary method for liquidity providers to query their deposits.
1199
+ * Uses ProtocolViewer for instant on-chain reads (no indexer lag).
1200
+ *
1201
+ * @returns Array of deposit views with payment methods and currencies
1202
+ *
1203
+ * @example
1204
+ * ```typescript
1205
+ * const deposits = await client.getDeposits();
1206
+ * for (const d of deposits) {
1207
+ * console.log(`Deposit ${d.depositId}: ${d.availableLiquidity} available`);
1208
+ * }
1209
+ * ```
1210
+ */
1211
+ getDeposits(): Promise<PV_DepositView[]>;
1212
+ /**
1213
+ * Fetches all deposits owned by a specific address from on-chain.
1214
+ *
1215
+ * Uses ProtocolViewer for instant on-chain reads.
1216
+ *
1217
+ * @param owner - The owner's Ethereum address
1218
+ * @returns Array of deposit views with payment methods and currencies
1219
+ *
1220
+ * @example
1221
+ * ```typescript
1222
+ * const deposits = await client.getAccountDeposits('0x...');
1223
+ * ```
1224
+ */
1225
+ getAccountDeposits(owner: Address): Promise<PV_DepositView[]>;
1226
+ /**
1227
+ * Fetches a single deposit by its numeric ID from on-chain.
1228
+ *
1229
+ * Uses ProtocolViewer for instant on-chain reads.
1230
+ *
1231
+ * @param depositId - The deposit ID (numeric)
1232
+ * @returns Deposit view with payment methods, currencies, and intent hashes
1233
+ *
1234
+ * @example
1235
+ * ```typescript
1236
+ * const deposit = await client.getDeposit(42n);
1237
+ * console.log(`Available: ${deposit.availableLiquidity}`);
1238
+ * console.log(`Payment methods: ${deposit.paymentMethods.length}`);
1239
+ * ```
1240
+ */
1241
+ getDeposit(depositId: bigint | number | string): Promise<PV_DepositView>;
1242
+ /**
1243
+ * Fetches multiple deposits by their IDs from on-chain in a batch.
1244
+ *
1245
+ * @param depositIds - Array of deposit IDs
1246
+ * @returns Array of deposit views
1247
+ */
1248
+ getDepositsById(depositIds: Array<bigint | number | string>): Promise<PV_DepositView[]>;
1249
+ /**
1250
+ * Fetches all intents created by the connected wallet from on-chain.
1251
+ *
1252
+ * Uses ProtocolViewer for instant on-chain reads.
1253
+ *
1254
+ * @returns Array of intent views with deposit context
1255
+ *
1256
+ * @example
1257
+ * ```typescript
1258
+ * const intents = await client.getIntents();
1259
+ * for (const i of intents) {
1260
+ * console.log(`Intent ${i.intentHash}: ${i.intent.amount} tokens`);
1261
+ * }
1262
+ * ```
1263
+ */
1264
+ getIntents(): Promise<PV_IntentView[]>;
1265
+ /**
1266
+ * Fetches all intents created by a specific address from on-chain.
1267
+ *
1268
+ * @param owner - The owner's Ethereum address
1269
+ * @returns Array of intent views with deposit context
1270
+ */
1271
+ getAccountIntents(owner: Address): Promise<PV_IntentView[]>;
1272
+ /**
1273
+ * Fetches a single intent by its hash from on-chain.
1274
+ *
1275
+ * @param intentHash - The intent hash (0x-prefixed, 32 bytes)
1276
+ * @returns Intent view with deposit context
1277
+ */
1278
+ getIntent(intentHash: `0x${string}`): Promise<PV_IntentView>;
1279
+ /**
1280
+ * Resolves the payee details hash for a deposit's payment method from on-chain.
1281
+ *
1282
+ * @param depositId - The deposit ID
1283
+ * @param paymentMethodHash - The payment method hash
1284
+ * @returns The payee details hash, or null if not found
1285
+ */
1286
+ resolvePayeeHash(depositId: bigint | number | string, paymentMethodHash: string): Promise<string | null>;
1287
+ /**
1288
+ * Access to the indexer for advanced queries.
1289
+ *
1290
+ * Use this for:
1291
+ * - Historical data (totalAmountTaken, totalWithdrawn)
1292
+ * - Filtered queries across all deposits (not just by owner)
1293
+ * - Pagination with ordering
1294
+ * - Fulfillment/verification records
1295
+ *
1296
+ * @example
1297
+ * ```typescript
1298
+ * // Query deposits with filters and pagination
1299
+ * const deposits = await client.indexer.getDeposits(
1300
+ * { status: 'ACTIVE', minLiquidity: '1000000' },
1301
+ * { limit: 50, orderBy: 'remainingDeposits', orderDirection: 'desc' }
1302
+ * );
1303
+ *
1304
+ * // Get historical fulfillment data
1305
+ * const fulfillments = await client.indexer.getFulfilledIntentEvents(['0x...']);
1306
+ * ```
1307
+ */
1308
+ get indexer(): {
1309
+ /** Raw GraphQL client for custom queries */
1310
+ client: IndexerClient;
1311
+ /**
1312
+ * Fetches deposits from the indexer with optional filtering and pagination.
1313
+ * Use for advanced queries across all deposits, not just by owner.
1314
+ */
1315
+ getDeposits: (filter?: DepositFilter, pagination?: PaginationOptions) => Promise<DepositEntity[]>;
1316
+ /**
1317
+ * Fetches deposits with their related payment methods and optionally intents.
1318
+ */
1319
+ getDepositsWithRelations: (filter?: DepositFilter, pagination?: PaginationOptions, options?: {
1320
+ includeIntents?: boolean;
1321
+ intentStatuses?: IntentStatus[];
1322
+ }) => Promise<DepositWithRelations[]>;
1323
+ /**
1324
+ * Fetches a single deposit by its composite ID with all related data.
1325
+ * @param id - Composite ID format: "chainId_escrowAddress_depositId"
1326
+ */
1327
+ getDepositById: (id: string, options?: {
1328
+ includeIntents?: boolean;
1329
+ intentStatuses?: IntentStatus[];
1330
+ }) => Promise<DepositWithRelations | null>;
1331
+ /**
1332
+ * Fetches intents for multiple deposits.
1333
+ */
1334
+ getIntentsForDeposits: (depositIds: string[], statuses?: IntentStatus[]) => Promise<IntentEntity[]>;
1335
+ /**
1336
+ * Fetches all intents created by a specific owner address.
1337
+ */
1338
+ getOwnerIntents: (owner: string, statuses?: IntentStatus[]) => Promise<IntentEntity[]>;
1339
+ /**
1340
+ * Fetches intents that have expired.
1341
+ */
1342
+ getExpiredIntents: (params: {
1343
+ now: bigint | string;
1344
+ depositIds: string[];
1345
+ limit?: number;
1346
+ }) => Promise<IntentEntity[]>;
1347
+ /**
1348
+ * Fetches fulfillment events for completed intents.
1349
+ */
1350
+ getFulfilledIntentEvents: (intentHashes: string[]) => Promise<IntentFulfilledEntity[]>;
1351
+ /**
1352
+ * Fetches both the fulfillment record and payment verification for an intent.
1353
+ */
1354
+ getFulfillmentAndPayment: (intentHash: string) => Promise<FulfillmentAndPaymentResponse>;
1355
+ /**
1356
+ * Fetches deposits that match a specific payee details hash.
1357
+ */
1358
+ getDepositsByPayeeHash: (payeeHash: string, options?: {
1359
+ paymentMethodHash?: string;
1360
+ limit?: number;
1361
+ includeIntents?: boolean;
1362
+ intentStatuses?: IntentStatus[];
1363
+ }) => Promise<DepositWithRelations[]>;
1364
+ };
1365
+ /**
1366
+ * Ensures ERC20 token allowance is sufficient for the Escrow contract.
1367
+ *
1368
+ * If the current allowance is less than the requested amount, this method
1369
+ * will submit an approval transaction. Use `maxApprove: true` for unlimited
1370
+ * approval to avoid repeated approval transactions.
1371
+ *
1372
+ * @param params.token - ERC20 token address to approve
1373
+ * @param params.amount - Minimum required allowance amount
1374
+ * @param params.spender - Spender address (defaults to Escrow contract)
1375
+ * @param params.maxApprove - If true, approves MaxUint256 instead of exact amount
1376
+ * @param params.txOverrides - Optional viem transaction overrides
1377
+ * @returns Object with `hadAllowance` (true if no approval needed) and optional `hash`
1378
+ *
1379
+ * @example
1380
+ * ```typescript
1381
+ * // Ensure allowance for 1000 USDC
1382
+ * const { hadAllowance, hash } = await client.ensureAllowance({
1383
+ * token: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
1384
+ * amount: 1000_000000n,
1385
+ * maxApprove: true,
1386
+ * });
1387
+ *
1388
+ * if (!hadAllowance) {
1389
+ * console.log('Approval tx:', hash);
1390
+ * }
1391
+ * ```
1392
+ */
1393
+ ensureAllowance(params: {
1394
+ token: Address;
1395
+ amount: bigint;
1396
+ spender?: Address;
1397
+ maxApprove?: boolean;
1398
+ txOverrides?: TxOverrides;
1399
+ }): Promise<{
1400
+ hadAllowance: boolean;
1401
+ hash?: Hash;
1402
+ }>;
1403
+ /**
1404
+ * Creates a new USDC deposit in the Escrow contract.
1405
+ *
1406
+ * This is the primary method for liquidity providers to add funds to the protocol.
1407
+ * The deposit can accept intents from multiple payment platforms with different
1408
+ * conversion rates per currency.
1409
+ *
1410
+ * **Important**: Requires `apiKey` or `authorizationToken` to be set.
1411
+ * Call `ensureAllowance()` first to approve USDC spending.
1412
+ *
1413
+ * @param params.token - Token address (USDC)
1414
+ * @param params.amount - Total deposit amount in token units (6 decimals for USDC)
1415
+ * @param params.intentAmountRange - Min/max amount per intent
1416
+ * @param params.processorNames - Payment platforms to accept (e.g., ['wise', 'revolut'])
1417
+ * @param params.depositData - Payee details per processor (e.g., [{ email: '...' }])
1418
+ * @param params.conversionRates - Conversion rates per processor, grouped by currency
1419
+ * @param params.delegate - Optional delegate address that can manage the deposit
1420
+ * @param params.intentGuardian - Optional guardian for intent approval
1421
+ * @param params.retainOnEmpty - Keep deposit active when balance reaches zero
1422
+ * @param params.txOverrides - Optional viem transaction overrides
1423
+ * @returns The deposit details posted to API and the transaction hash
1424
+ *
1425
+ * @throws Error if apiKey/authorizationToken is missing
1426
+ * @throws Error if processorNames, depositData, and conversionRates lengths don't match
1427
+ * @throws Error if a currency is not supported by the specified processor
1428
+ *
1429
+ * @example
1430
+ * ```typescript
1431
+ * // Create a 1000 USDC deposit accepting Wise payments in USD and EUR
1432
+ * const { hash } = await client.createDeposit({
1433
+ * token: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
1434
+ * amount: 1000_000000n,
1435
+ * intentAmountRange: { min: 10_000000n, max: 500_000000n },
1436
+ * processorNames: ['wise'],
1437
+ * depositData: [{ email: 'you@example.com' }],
1438
+ * conversionRates: [[
1439
+ * { currency: 'USD', conversionRate: '1020000000000000000' }, // 1.02
1440
+ * { currency: 'EUR', conversionRate: '1100000000000000000' }, // 1.10
1441
+ * ]],
1442
+ * });
1443
+ * ```
1444
+ */
1445
+ createDeposit(params: {
1446
+ token: Address;
1447
+ amount: bigint;
1448
+ intentAmountRange: {
1449
+ min: bigint;
1450
+ max: bigint;
1451
+ };
1452
+ processorNames: string[];
1453
+ depositData: {
1454
+ [key: string]: string;
1455
+ }[];
1456
+ conversionRates: {
1457
+ currency: string;
1458
+ conversionRate: string;
1459
+ }[][];
1460
+ delegate?: Address;
1461
+ intentGuardian?: Address;
1462
+ retainOnEmpty?: boolean;
1463
+ txOverrides?: TxOverrides;
1464
+ }): Promise<{
1465
+ depositDetails: PostDepositDetailsRequest[];
1466
+ hash: Hash;
1467
+ }>;
1468
+ /**
1469
+ * Enables or disables a deposit from accepting new intents.
1470
+ *
1471
+ * @param params.depositId - The deposit ID
1472
+ * @param params.accepting - Whether to accept new intents
1473
+ * @param params.txOverrides - Optional viem transaction overrides
1474
+ * @returns Transaction hash
1475
+ */
1476
+ setAcceptingIntents(params: {
1477
+ depositId: bigint;
1478
+ accepting: boolean;
1479
+ txOverrides?: TxOverrides;
1480
+ }): Promise<Hash>;
1481
+ /**
1482
+ * Updates the min/max intent amount range for a deposit.
1483
+ *
1484
+ * @param params.depositId - The deposit ID
1485
+ * @param params.min - Minimum intent amount
1486
+ * @param params.max - Maximum intent amount
1487
+ * @param params.txOverrides - Optional viem transaction overrides
1488
+ * @returns Transaction hash
1489
+ */
1490
+ setIntentRange(params: {
1491
+ depositId: bigint;
1492
+ min: bigint;
1493
+ max: bigint;
1494
+ txOverrides?: TxOverrides;
1495
+ }): Promise<Hash>;
1496
+ /**
1497
+ * Updates the minimum conversion rate for a specific currency on a payment method.
1498
+ *
1499
+ * @param params.depositId - The deposit ID
1500
+ * @param params.paymentMethod - Payment method hash (bytes32)
1501
+ * @param params.fiatCurrency - Fiat currency hash (bytes32)
1502
+ * @param params.minConversionRate - New minimum conversion rate (18 decimals)
1503
+ * @param params.txOverrides - Optional viem transaction overrides
1504
+ * @returns Transaction hash
1505
+ */
1506
+ setCurrencyMinRate(params: {
1507
+ depositId: bigint;
1508
+ paymentMethod: `0x${string}`;
1509
+ fiatCurrency: `0x${string}`;
1510
+ minConversionRate: bigint;
1511
+ txOverrides?: TxOverrides;
1512
+ }): Promise<Hash>;
1513
+ /**
1514
+ * Adds additional funds to an existing deposit.
1515
+ * Requires prior approval of the token amount.
1516
+ *
1517
+ * @param params.depositId - The deposit ID to add funds to
1518
+ * @param params.amount - Amount to add (in token units)
1519
+ * @param params.txOverrides - Optional viem transaction overrides
1520
+ * @returns Transaction hash
1521
+ */
1522
+ addFunds(params: {
1523
+ depositId: bigint;
1524
+ amount: bigint;
1525
+ txOverrides?: TxOverrides;
1526
+ }): Promise<Hash>;
1527
+ /**
1528
+ * Removes funds from a deposit (partial withdrawal).
1529
+ * Can only withdraw available (non-locked) funds.
1530
+ *
1531
+ * @param params.depositId - The deposit ID
1532
+ * @param params.amount - Amount to remove (in token units)
1533
+ * @param params.txOverrides - Optional viem transaction overrides
1534
+ * @returns Transaction hash
1535
+ */
1536
+ removeFunds(params: {
1537
+ depositId: bigint;
1538
+ amount: bigint;
1539
+ txOverrides?: TxOverrides;
1540
+ }): Promise<Hash>;
1541
+ /**
1542
+ * Fully withdraws a deposit, returning all available funds to the owner.
1543
+ * The deposit must have no active intents.
1544
+ *
1545
+ * @param params.depositId - The deposit ID to withdraw
1546
+ * @param params.txOverrides - Optional viem transaction overrides
1547
+ * @returns Transaction hash
1548
+ */
1549
+ withdrawDeposit(params: {
1550
+ depositId: bigint;
1551
+ txOverrides?: TxOverrides;
1552
+ }): Promise<Hash>;
1553
+ /**
1554
+ * Sets whether a deposit should remain active when its balance reaches zero.
1555
+ *
1556
+ * @param params.depositId - The deposit ID
1557
+ * @param params.retain - If true, deposit stays active when empty
1558
+ * @param params.txOverrides - Optional viem transaction overrides
1559
+ * @returns Transaction hash
1560
+ */
1561
+ setRetainOnEmpty(params: {
1562
+ depositId: bigint;
1563
+ retain: boolean;
1564
+ txOverrides?: TxOverrides;
1565
+ }): Promise<Hash>;
1566
+ /**
1567
+ * Assigns a delegate address that can manage the deposit on behalf of the owner.
1568
+ *
1569
+ * @param params.depositId - The deposit ID
1570
+ * @param params.delegate - Address to delegate management to
1571
+ * @param params.txOverrides - Optional viem transaction overrides
1572
+ * @returns Transaction hash
1573
+ */
1574
+ setDelegate(params: {
1575
+ depositId: bigint;
1576
+ delegate: Address;
1577
+ txOverrides?: TxOverrides;
1578
+ }): Promise<Hash>;
1579
+ /**
1580
+ * Removes the delegate from a deposit.
1581
+ *
1582
+ * @param params.depositId - The deposit ID
1583
+ * @param params.txOverrides - Optional viem transaction overrides
1584
+ * @returns Transaction hash
1585
+ */
1586
+ removeDelegate(params: {
1587
+ depositId: bigint;
1588
+ txOverrides?: TxOverrides;
1589
+ }): Promise<Hash>;
1590
+ /**
1591
+ * Adds new payment methods to an existing deposit.
1592
+ *
1593
+ * @param params.depositId - The deposit ID
1594
+ * @param params.paymentMethods - Array of payment method hashes to add
1595
+ * @param params.paymentMethodData - Corresponding payment method configuration
1596
+ * @param params.txOverrides - Optional viem transaction overrides
1597
+ * @returns Transaction hash
1598
+ */
1599
+ addPaymentMethods(params: {
1600
+ depositId: bigint;
1601
+ paymentMethods: `0x${string}`[];
1602
+ paymentMethodData: {
1603
+ intentGatingService: Address;
1604
+ payeeDetails: string;
1605
+ data: `0x${string}`;
1606
+ }[];
1607
+ txOverrides?: TxOverrides;
1608
+ }): Promise<Hash>;
1609
+ /**
1610
+ * Activates or deactivates a payment method on a deposit.
1611
+ *
1612
+ * @param params.depositId - The deposit ID
1613
+ * @param params.paymentMethod - Payment method hash to modify
1614
+ * @param params.isActive - Whether the payment method should accept intents
1615
+ * @param params.txOverrides - Optional viem transaction overrides
1616
+ * @returns Transaction hash
1617
+ */
1618
+ setPaymentMethodActive(params: {
1619
+ depositId: bigint;
1620
+ paymentMethod: `0x${string}`;
1621
+ isActive: boolean;
1622
+ txOverrides?: TxOverrides;
1623
+ }): Promise<Hash>;
1624
+ /**
1625
+ * Deactivates a payment method on a deposit (convenience alias for setPaymentMethodActive).
1626
+ *
1627
+ * @param params.depositId - The deposit ID
1628
+ * @param params.paymentMethod - Payment method hash to deactivate
1629
+ * @param params.txOverrides - Optional viem transaction overrides
1630
+ * @returns Transaction hash
1631
+ */
1632
+ removePaymentMethod(params: {
1633
+ depositId: bigint;
1634
+ paymentMethod: `0x${string}`;
1635
+ txOverrides?: TxOverrides;
1636
+ }): Promise<Hash>;
1637
+ /**
1638
+ * Adds new currencies to a payment method on a deposit.
1639
+ *
1640
+ * @param params.depositId - The deposit ID
1641
+ * @param params.paymentMethod - Payment method hash to add currencies to
1642
+ * @param params.currencies - Array of currency configurations with code and min rate
1643
+ * @param params.txOverrides - Optional viem transaction overrides
1644
+ * @returns Transaction hash
1645
+ */
1646
+ addCurrencies(params: {
1647
+ depositId: bigint;
1648
+ paymentMethod: `0x${string}`;
1649
+ currencies: {
1650
+ code: `0x${string}`;
1651
+ minConversionRate: bigint;
1652
+ }[];
1653
+ txOverrides?: TxOverrides;
1654
+ }): Promise<Hash>;
1655
+ /**
1656
+ * Deactivates a currency for a payment method on a deposit.
1657
+ *
1658
+ * @param params.depositId - The deposit ID
1659
+ * @param params.paymentMethod - Payment method hash
1660
+ * @param params.currencyCode - Currency code hash to deactivate
1661
+ * @param params.txOverrides - Optional viem transaction overrides
1662
+ * @returns Transaction hash
1663
+ */
1664
+ deactivateCurrency(params: {
1665
+ depositId: bigint;
1666
+ paymentMethod: `0x${string}`;
1667
+ currencyCode: `0x${string}`;
1668
+ txOverrides?: TxOverrides;
1669
+ }): Promise<Hash>;
1670
+ /**
1671
+ * Removes (deactivates) a currency from a payment method.
1672
+ * Alias for deactivateCurrency.
1673
+ *
1674
+ * @param params.depositId - The deposit ID
1675
+ * @param params.paymentMethod - Payment method hash
1676
+ * @param params.currencyCode - Currency code hash to remove
1677
+ * @param params.txOverrides - Optional viem transaction overrides
1678
+ * @returns Transaction hash
1679
+ */
1680
+ removeCurrency(params: {
1681
+ depositId: bigint;
1682
+ paymentMethod: `0x${string}`;
1683
+ currencyCode: `0x${string}`;
1684
+ txOverrides?: TxOverrides;
1685
+ }): Promise<Hash>;
1686
+ /**
1687
+ * Removes expired intents from a deposit, freeing up locked funds.
1688
+ * Can be called by anyone (permissionless cleanup).
1689
+ *
1690
+ * @param params.depositId - The deposit ID to prune
1691
+ * @param params.txOverrides - Optional viem transaction overrides
1692
+ * @returns Transaction hash
1693
+ */
1694
+ pruneExpiredIntents(params: {
1695
+ depositId: bigint;
1696
+ txOverrides?: TxOverrides;
1697
+ }): Promise<Hash>;
1698
+ /**
1699
+ * **Supporting Method** - Signals intent to use a deposit.
1700
+ *
1701
+ * > **Note**: This method is typically used by takers/buyers who want to
1702
+ * > purchase crypto by paying fiat. Liquidity providers generally don't
1703
+ * > need to call this method directly.
1704
+ *
1705
+ * This reserves funds from a deposit and creates an intent that must be
1706
+ * fulfilled (via `fulfillIntent`) or will expire. The taker commits to
1707
+ * sending fiat payment to the deposit's payee.
1708
+ *
1709
+ * If `gatingServiceSignature` is not provided, the SDK will automatically
1710
+ * fetch one from the API (requires `apiKey` or `authorizationToken`).
1711
+ *
1712
+ * @param params.depositId - The deposit to use
1713
+ * @param params.amount - Amount of tokens to claim (in token units)
1714
+ * @param params.toAddress - Address to receive the tokens when fulfilled
1715
+ * @param params.processorName - Payment platform (e.g., 'wise', 'revolut')
1716
+ * @param params.payeeDetails - Hashed payee details (from deposit)
1717
+ * @param params.fiatCurrencyCode - Fiat currency code (e.g., 'USD', 'EUR')
1718
+ * @param params.conversionRate - Agreed conversion rate (18 decimals)
1719
+ * @param params.referrer - Optional referrer address for fee sharing
1720
+ * @param params.referrerFee - Optional referrer fee amount
1721
+ * @param params.postIntentHook - Optional hook contract to call after signaling
1722
+ * @param params.data - Optional data to pass to the hook
1723
+ * @param params.gatingServiceSignature - Pre-obtained signature (if not auto-fetching)
1724
+ * @param params.signatureExpiration - Signature expiration timestamp
1725
+ * @param params.txOverrides - Optional viem transaction overrides
1726
+ * @returns Transaction hash
1727
+ *
1728
+ * @example
1729
+ * ```typescript
1730
+ * const hash = await client.signalIntent({
1731
+ * depositId: 42n,
1732
+ * amount: 100_000000n, // 100 USDC
1733
+ * toAddress: '0x...',
1734
+ * processorName: 'wise',
1735
+ * payeeDetails: '0x...',
1736
+ * fiatCurrencyCode: 'USD',
1737
+ * conversionRate: 1_020000000000000000n, // 1.02
1738
+ * });
1739
+ * ```
1740
+ */
1741
+ signalIntent(params: {
1742
+ depositId: bigint | string;
1743
+ amount: bigint | string;
1744
+ toAddress: Address;
1745
+ processorName: string;
1746
+ payeeDetails: string;
1747
+ fiatCurrencyCode: string;
1748
+ conversionRate: bigint | string;
1749
+ referrer?: Address;
1750
+ referrerFee?: bigint | string;
1751
+ postIntentHook?: Address;
1752
+ data?: `0x${string}`;
1753
+ gatingServiceSignature?: `0x${string}`;
1754
+ signatureExpiration?: bigint | string;
1755
+ txOverrides?: TxOverrides;
1756
+ }): Promise<Hash>;
1757
+ /**
1758
+ * **Supporting Method** - Cancels a signaled intent before fulfillment.
1759
+ *
1760
+ * Only the intent owner can cancel. Releases reserved funds back to the deposit.
1761
+ *
1762
+ * @param params.intentHash - The intent hash to cancel (0x-prefixed, 32 bytes)
1763
+ * @param params.txOverrides - Optional viem transaction overrides
1764
+ * @returns Transaction hash
1765
+ */
1766
+ cancelIntent(params: {
1767
+ intentHash: `0x${string}`;
1768
+ txOverrides?: TxOverrides;
1769
+ }): Promise<Hash>;
1770
+ /**
1771
+ * **Supporting Method** - Releases funds back to the deposit owner.
1772
+ *
1773
+ * Called by the deposit owner when they want to reject an intent
1774
+ * (e.g., payment verification failed or intent expired).
1775
+ *
1776
+ * @param params.intentHash - The intent hash (0x-prefixed, 32 bytes)
1777
+ * @param params.txOverrides - Optional viem transaction overrides
1778
+ * @returns Transaction hash
1779
+ */
1780
+ releaseFundsToPayer(params: {
1781
+ intentHash: `0x${string}`;
1782
+ txOverrides?: TxOverrides;
1783
+ }): Promise<Hash>;
1784
+ /**
1785
+ * **Supporting Method** - Fulfills an intent by submitting a payment proof.
1786
+ *
1787
+ * > **Note**: This method is typically used by takers/buyers after they've
1788
+ * > sent fiat payment. Liquidity providers generally don't call this directly.
1789
+ *
1790
+ * This is the final step in the off-ramp flow. After the taker has sent
1791
+ * fiat payment, they generate a proof (via the browser extension) and
1792
+ * submit it here. The SDK handles attestation service calls automatically.
1793
+ *
1794
+ * **Flow:**
1795
+ * 1. Intent parameters are derived from the indexer/ProtocolViewer
1796
+ * 2. Proof is sent to the attestation service for verification
1797
+ * 3. Attestation response is encoded and submitted on-chain
1798
+ * 4. Funds are released to the intent's `toAddress`
1799
+ *
1800
+ * @param params.intentHash - The intent hash to fulfill (0x-prefixed, 32 bytes)
1801
+ * @param params.proof - Payment proof from Reclaim (object or JSON string)
1802
+ * @param params.timestampBufferMs - Allowed timestamp variance (default: 300000ms)
1803
+ * @param params.attestationServiceUrl - Override attestation service URL
1804
+ * @param params.verifyingContract - Override verifier contract address
1805
+ * @param params.postIntentHookData - Data to pass to post-intent hook
1806
+ * @param params.txOverrides - Optional viem transaction overrides
1807
+ * @param params.callbacks - Lifecycle callbacks for UI updates
1808
+ * @returns Transaction hash
1809
+ */
1810
+ fulfillIntent(params: {
1811
+ intentHash: `0x${string}`;
1812
+ proof: Record<string, unknown> | string;
1813
+ timestampBufferMs?: string;
1814
+ attestationServiceUrl?: string;
1815
+ verifyingContract?: Address;
1816
+ postIntentHookData?: `0x${string}`;
1817
+ txOverrides?: TxOverrides;
1818
+ callbacks?: {
1819
+ onAttestationStart?: () => void;
1820
+ onTxSent?: (hash: Hash) => void;
1821
+ onTxMined?: (hash: Hash) => void;
1822
+ };
1823
+ }): Promise<Hash>;
1824
+ private defaultAttestationService;
1825
+ /**
1826
+ * **Supporting Method** - Fetches quotes for available liquidity.
1827
+ *
1828
+ * > **Note**: This method is typically used by frontend applications to
1829
+ * > display available off-ramp options to users. Liquidity providers can
1830
+ * > use it to see how their deposits appear to takers.
1831
+ *
1832
+ * Returns available quotes from liquidity providers matching the request
1833
+ * criteria. When authenticated, the API returns payee details in each quote.
1834
+ *
1835
+ * @param req - Quote request parameters
1836
+ * @param req.paymentPlatforms - Payment platforms to search (e.g., ['wise', 'revolut'])
1837
+ * @param req.fiatCurrency - Target fiat currency code (e.g., 'USD')
1838
+ * @param req.user - User's address
1839
+ * @param req.recipient - Token recipient address
1840
+ * @param req.destinationChainId - Chain ID for token delivery
1841
+ * @param req.destinationToken - Token address to receive
1842
+ * @param req.amount - Amount (in fiat if isExactFiat, else in tokens)
1843
+ * @param req.isExactFiat - If true, amount is in fiat; quotes return token amounts
1844
+ * @param req.escrowAddresses - Optional filter for specific escrow contracts
1845
+ * @param opts - Optional overrides for API URL and timeout
1846
+ * @returns Quote response with available options
1847
+ *
1848
+ * @example
1849
+ * ```typescript
1850
+ * const quote = await client.getQuote({
1851
+ * paymentPlatforms: ['wise'],
1852
+ * fiatCurrency: 'EUR',
1853
+ * user: '0x...',
1854
+ * recipient: '0x...',
1855
+ * destinationChainId: 8453,
1856
+ * destinationToken: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
1857
+ * amount: '100',
1858
+ * isExactFiat: true,
1859
+ * });
1860
+ *
1861
+ * for (const q of quote.responseObject.quotes) {
1862
+ * console.log(`${q.tokenAmountFormatted} USDC for ${q.fiatAmountFormatted}`);
1863
+ * }
1864
+ * ```
1865
+ */
1866
+ getQuote(req: QuoteRequest, opts?: {
1867
+ baseApiUrl?: string;
1868
+ timeoutMs?: number;
1869
+ }): Promise<QuoteResponse>;
1870
+ /**
1871
+ * **Supporting Method** - Fetches taker tier information for an address.
1872
+ *
1873
+ * > **Note**: Requires `apiKey` or `authorizationToken` to be set.
1874
+ *
1875
+ * @param req - Taker tier request parameters
1876
+ * @param req.owner - Taker address
1877
+ * @param req.chainId - Chain ID
1878
+ * @param opts - Optional overrides for API URL and timeout
1879
+ * @returns Taker tier response
1880
+ */
1881
+ getTakerTier(req: GetTakerTierRequest, opts?: {
1882
+ baseApiUrl?: string;
1883
+ timeoutMs?: number;
1884
+ }): Promise<GetTakerTierResponse>;
1885
+ private requireProtocolViewer;
1886
+ /**
1887
+ * Fetches a deposit directly from on-chain ProtocolViewer contract.
1888
+ * Falls back to Escrow.getDeposit if ProtocolViewer is unavailable.
1889
+ *
1890
+ * @param depositId - The deposit ID (string or bigint)
1891
+ * @returns Parsed deposit view with all payment methods and currencies
1892
+ */
1893
+ getPvDepositById(depositId: string | bigint): Promise<PV_DepositView>;
1894
+ /**
1895
+ * Fetches multiple deposits by ID from on-chain in a batch call.
1896
+ *
1897
+ * @param ids - Array of deposit IDs
1898
+ * @returns Array of parsed deposit views
1899
+ */
1900
+ getPvDepositsFromIds(ids: Array<string | bigint>): Promise<any[]>;
1901
+ /**
1902
+ * Fetches all deposits owned by an address from on-chain.
1903
+ *
1904
+ * @param owner - The owner address
1905
+ * @returns Array of parsed deposit views
1906
+ */
1907
+ getPvAccountDeposits(owner: Address): Promise<PV_DepositView[]>;
1908
+ /**
1909
+ * Fetches all intents created by an address from on-chain.
1910
+ * Requires ProtocolViewer to be available.
1911
+ *
1912
+ * @param owner - The owner address
1913
+ * @returns Array of parsed intent views
1914
+ */
1915
+ getPvAccountIntents(owner: Address): Promise<PV_IntentView[]>;
1916
+ /**
1917
+ * Fetches a single intent by hash from on-chain.
1918
+ *
1919
+ * @param intentHash - The intent hash (0x-prefixed, 32 bytes)
1920
+ * @returns Parsed intent view with deposit context
1921
+ */
1922
+ getPvIntent(intentHash: `0x${string}`): Promise<PV_IntentView>;
1923
+ /**
1924
+ * Returns the USDC token address for the current network (if known).
1925
+ *
1926
+ * @returns USDC address or undefined if not configured
1927
+ */
1928
+ getUsdcAddress(): Address | undefined;
1929
+ /**
1930
+ * Returns all deployed contract addresses for the current network/environment.
1931
+ *
1932
+ * @returns Object with escrow, orchestrator, protocolViewer, verifier, and USDC addresses
1933
+ */
1934
+ getDeployedAddresses(): {
1935
+ escrow: Address;
1936
+ orchestrator?: Address;
1937
+ protocolViewer?: Address;
1938
+ unifiedPaymentVerifier?: Address;
1939
+ usdc?: Address;
1940
+ };
1941
+ /**
1942
+ * Resolves all parameters needed to fulfill an intent.
1943
+ *
1944
+ * Attempts to fetch from ProtocolViewer first (on-chain source of truth),
1945
+ * then falls back to the indexer. This is called internally by `fulfillIntent`
1946
+ * but exposed for advanced use cases.
1947
+ *
1948
+ * @param intentHash - The intent hash to resolve
1949
+ * @returns Intent parameters needed for fulfillment
1950
+ * @throws Error if intent not found or payee details cannot be resolved
1951
+ */
1952
+ getFulfillIntentInputs(intentHash: `0x${string}`): Promise<{
1953
+ amount: string;
1954
+ fiatCurrency: `0x${string}`;
1955
+ conversionRate: string;
1956
+ payeeDetails: `0x${string}`;
1957
+ intentTimestampMs: string;
1958
+ paymentMethodHash: `0x${string}`;
1959
+ }>;
1960
+ }
1961
+
1962
+ export { type DepositVerifierData as $, type ActionCallback as A, type GetDepositByIdResponse as B, type CreateDepositParams as C, type DepositWithRelations as D, type Intent as E, type FulfillIntentParams as F, type GetPayeeDetailsRequest as G, type ApiIntentStatus as H, type IntentEntity as I, type GetOwnerIntentsRequest as J, type GetOwnerIntentsResponse as K, type GetIntentsByDepositRequest as L, type GetIntentsByDepositResponse as M, type NearbyQuote as N, type GetIntentByHashRequest as O, type PostDepositDetailsRequest as P, type QuoteRequest as Q, type Range as R, type SignalIntentParams as S, type TxOverrides as T, type GetIntentByHashResponse as U, type ValidatePayeeDetailsRequest as V, type WithdrawDepositParams as W, type RegisterPayeeDetailsRequest as X, type RegisterPayeeDetailsResponse as Y, Zkp2pClient as Z, type OnchainCurrency as _, type ValidatePayeeDetailsResponse as a, type OrderStats as a0, type DepositIntentStatistics as a1, type TakerTier as a2, type TakerTierStats as a3, type TakerTierLevel as a4, type PlatformLimit as a5, type PlatformRiskLevel as a6, IndexerClient as a7, defaultIndexerEndpoint as a8, IndexerDepositService as a9, getPaymentMethodsCatalog as aA, getGatingServiceAddress as aB, type RuntimeEnv as aC, parseDepositView as aD, parseIntentView as aE, enrichPvDepositView as aF, enrichPvIntentView as aG, type PV_DepositView as aH, type PV_Deposit as aI, type PV_PaymentMethodData as aJ, type PV_Currency as aK, type PV_IntentView as aL, type PV_Intent as aM, fetchFulfillmentAndPayment as aa, type DepositEntity as ab, type IntentFulfilledEntity as ac, type DepositPaymentMethodEntity as ad, type MethodCurrencyEntity as ae, type IntentStatus as af, type DepositFilter as ag, type PaginationOptions as ah, type DepositOrderField as ai, type OrderDirection as aj, type DeploymentEnv as ak, type FulfillmentRecord as al, type PaymentVerifiedRecord as am, type FulfillmentAndPaymentResponse as an, PAYMENT_PLATFORMS as ao, type PaymentPlatformType as ap, Currency as aq, currencyInfo as ar, getCurrencyInfoFromHash as as, getCurrencyInfoFromCountryCode as at, getCurrencyCodeFromHash as au, isSupportedCurrencyHash as av, mapConversionRatesToOnchainMinRate as aw, type CurrencyType as ax, type CurrencyData as ay, getContracts as az, type PostDepositDetailsResponse as b, type GetPayeeDetailsResponse as c, type GetTakerTierRequest as d, type GetTakerTierResponse as e, type PaymentMethodCatalog as f, type Zkp2pClientOptions as g, type TimeoutConfig as h, type CreateDepositConversionRate as i, type ReleaseFundsToPayerParams as j, type CancelIntentParams as k, type QuoteResponse as l, type QuoteResponseObject as m, type QuoteSingleResponse as n, type QuoteIntentResponse as o, type QuoteFeesResponse as p, type FiatResponse as q, type TokenResponse as r, type NearbySuggestions as s, type ApiDeposit as t, type DepositVerifier as u, type DepositVerifierCurrency as v, type DepositStatus as w, type GetOwnerDepositsRequest as x, type GetOwnerDepositsResponse as y, type GetDepositByIdRequest as z };