@t402/evm 2.0.0

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.
Files changed (63) hide show
  1. package/README.md +183 -0
  2. package/dist/cjs/exact/client/index.d.ts +53 -0
  3. package/dist/cjs/exact/client/index.js +270 -0
  4. package/dist/cjs/exact/client/index.js.map +1 -0
  5. package/dist/cjs/exact/facilitator/index.d.ts +118 -0
  6. package/dist/cjs/exact/facilitator/index.js +735 -0
  7. package/dist/cjs/exact/facilitator/index.js.map +1 -0
  8. package/dist/cjs/exact/server/index.d.ts +36 -0
  9. package/dist/cjs/exact/server/index.js +438 -0
  10. package/dist/cjs/exact/server/index.js.map +1 -0
  11. package/dist/cjs/exact/v1/client/index.d.ts +37 -0
  12. package/dist/cjs/exact/v1/client/index.js +147 -0
  13. package/dist/cjs/exact/v1/client/index.js.map +1 -0
  14. package/dist/cjs/exact/v1/facilitator/index.d.ts +62 -0
  15. package/dist/cjs/exact/v1/facilitator/index.js +401 -0
  16. package/dist/cjs/exact/v1/facilitator/index.js.map +1 -0
  17. package/dist/cjs/index.d.ts +1537 -0
  18. package/dist/cjs/index.js +2368 -0
  19. package/dist/cjs/index.js.map +1 -0
  20. package/dist/cjs/scheme-C6uD7PdY.d.ts +130 -0
  21. package/dist/cjs/scheme-OojTBKAz.d.ts +35 -0
  22. package/dist/cjs/scheme-yqGaK9rK.d.ts +130 -0
  23. package/dist/cjs/signer-BkcAzwYi.d.ts +79 -0
  24. package/dist/cjs/v1/index.d.ts +7 -0
  25. package/dist/cjs/v1/index.js +171 -0
  26. package/dist/cjs/v1/index.js.map +1 -0
  27. package/dist/esm/chunk-ACDQ5QNT.mjs +305 -0
  28. package/dist/esm/chunk-ACDQ5QNT.mjs.map +1 -0
  29. package/dist/esm/chunk-JBWWBRYY.mjs +92 -0
  30. package/dist/esm/chunk-JBWWBRYY.mjs.map +1 -0
  31. package/dist/esm/chunk-LGSG73NJ.mjs +88 -0
  32. package/dist/esm/chunk-LGSG73NJ.mjs.map +1 -0
  33. package/dist/esm/chunk-OEXW2OK2.mjs +251 -0
  34. package/dist/esm/chunk-OEXW2OK2.mjs.map +1 -0
  35. package/dist/esm/chunk-QLXM7BIB.mjs +23 -0
  36. package/dist/esm/chunk-QLXM7BIB.mjs.map +1 -0
  37. package/dist/esm/chunk-XYKAO6KJ.mjs +141 -0
  38. package/dist/esm/chunk-XYKAO6KJ.mjs.map +1 -0
  39. package/dist/esm/exact/client/index.d.mts +53 -0
  40. package/dist/esm/exact/client/index.mjs +36 -0
  41. package/dist/esm/exact/client/index.mjs.map +1 -0
  42. package/dist/esm/exact/facilitator/index.d.mts +118 -0
  43. package/dist/esm/exact/facilitator/index.mjs +324 -0
  44. package/dist/esm/exact/facilitator/index.mjs.map +1 -0
  45. package/dist/esm/exact/server/index.d.mts +36 -0
  46. package/dist/esm/exact/server/index.mjs +218 -0
  47. package/dist/esm/exact/server/index.mjs.map +1 -0
  48. package/dist/esm/exact/v1/client/index.d.mts +37 -0
  49. package/dist/esm/exact/v1/client/index.mjs +8 -0
  50. package/dist/esm/exact/v1/client/index.mjs.map +1 -0
  51. package/dist/esm/exact/v1/facilitator/index.d.mts +62 -0
  52. package/dist/esm/exact/v1/facilitator/index.mjs +8 -0
  53. package/dist/esm/exact/v1/facilitator/index.mjs.map +1 -0
  54. package/dist/esm/index.d.mts +1537 -0
  55. package/dist/esm/index.mjs +1875 -0
  56. package/dist/esm/index.mjs.map +1 -0
  57. package/dist/esm/scheme-D4mOqq9l.d.mts +35 -0
  58. package/dist/esm/scheme-yqGaK9rK.d.mts +130 -0
  59. package/dist/esm/signer-BkcAzwYi.d.mts +79 -0
  60. package/dist/esm/v1/index.d.mts +7 -0
  61. package/dist/esm/v1/index.mjs +13 -0
  62. package/dist/esm/v1/index.mjs.map +1 -0
  63. package/package.json +127 -0
@@ -0,0 +1,1537 @@
1
+ export { E as ExactEvmScheme } from './scheme-OojTBKAz.js';
2
+ export { a as ExactEvmSchemeConfig } from './scheme-yqGaK9rK.js';
3
+ import { SchemeNetworkClient, PaymentRequirements, PaymentPayload, SchemeNetworkServer, MoneyParser, Price, Network, AssetAmount, SchemeNetworkFacilitator, VerifyResponse, SettleResponse } from '@t402/core/types';
4
+ import { C as ClientEvmSigner, F as FacilitatorEvmSigner } from './signer-BkcAzwYi.js';
5
+ export { t as toClientEvmSigner, a as toFacilitatorEvmSigner } from './signer-BkcAzwYi.js';
6
+ import { Address, Hex, PublicClient } from 'viem';
7
+
8
+ /**
9
+ * EVM client implementation for the exact-legacy payment scheme.
10
+ * Used for legacy tokens (like USDT) that don't support EIP-3009.
11
+ *
12
+ * This scheme uses the approve + transferFrom pattern:
13
+ * 1. Client must first approve the facilitator to spend tokens
14
+ * 2. Client signs an authorization message
15
+ * 3. Facilitator verifies the signature and calls transferFrom
16
+ *
17
+ * Note: The client must have already approved the facilitator (spender)
18
+ * for at least the payment amount before creating a payment payload.
19
+ */
20
+ declare class ExactLegacyEvmScheme$2 implements SchemeNetworkClient {
21
+ private readonly signer;
22
+ readonly scheme = "exact-legacy";
23
+ /**
24
+ * Creates a new ExactLegacyEvmScheme instance.
25
+ *
26
+ * @param signer - The EVM signer for client operations
27
+ */
28
+ constructor(signer: ClientEvmSigner);
29
+ /**
30
+ * Creates a payment payload for the exact-legacy scheme.
31
+ *
32
+ * @param t402Version - The t402 protocol version
33
+ * @param paymentRequirements - The payment requirements
34
+ * @returns Promise resolving to a payment payload
35
+ */
36
+ createPaymentPayload(t402Version: number, paymentRequirements: PaymentRequirements): Promise<Pick<PaymentPayload, "t402Version" | "payload">>;
37
+ /**
38
+ * Sign the legacy transfer authorization using EIP-712
39
+ *
40
+ * @param authorization - The authorization to sign
41
+ * @param requirements - The payment requirements
42
+ * @returns Promise resolving to the signature
43
+ */
44
+ private signAuthorization;
45
+ }
46
+
47
+ /**
48
+ * Configuration options for ExactLegacyEvmScheme
49
+ */
50
+ interface ExactLegacyEvmSchemeConfig$1 {
51
+ /** Preferred token symbol. Defaults to "USDT" (legacy USDT) */
52
+ preferredToken?: string;
53
+ }
54
+ /**
55
+ * EVM server implementation for the exact-legacy payment scheme.
56
+ * Supports legacy tokens that use approve + transferFrom pattern.
57
+ */
58
+ declare class ExactLegacyEvmScheme$1 implements SchemeNetworkServer {
59
+ readonly scheme = "exact-legacy";
60
+ private moneyParsers;
61
+ private config;
62
+ constructor(config?: ExactLegacyEvmSchemeConfig$1);
63
+ /**
64
+ * Register a custom money parser in the parser chain.
65
+ */
66
+ registerMoneyParser(parser: MoneyParser): ExactLegacyEvmScheme$1;
67
+ /**
68
+ * Parses a price into an asset amount for legacy tokens.
69
+ */
70
+ parsePrice(price: Price, network: Network): Promise<AssetAmount>;
71
+ /**
72
+ * Build payment requirements for this scheme/network combination.
73
+ * Adds the spender (facilitator) address to the extra field.
74
+ */
75
+ enhancePaymentRequirements(paymentRequirements: PaymentRequirements, supportedKind: {
76
+ t402Version: number;
77
+ scheme: string;
78
+ network: Network;
79
+ extra?: Record<string, unknown>;
80
+ }, extensionKeys: string[]): Promise<PaymentRequirements>;
81
+ /**
82
+ * Parse Money (string | number) to a decimal number.
83
+ */
84
+ private parseMoneyToDecimal;
85
+ /**
86
+ * Default money conversion implementation for legacy tokens.
87
+ */
88
+ private defaultMoneyConversion;
89
+ /**
90
+ * Convert decimal amount to token units
91
+ */
92
+ private convertToTokenAmount;
93
+ /**
94
+ * Get the default legacy token for a network.
95
+ */
96
+ private getDefaultAsset;
97
+ /**
98
+ * Get all supported networks that have legacy tokens
99
+ */
100
+ static getSupportedNetworks(): string[];
101
+ /**
102
+ * Check if a network has legacy token support
103
+ */
104
+ static isNetworkSupported(network: string): boolean;
105
+ }
106
+
107
+ interface ExactLegacyEvmSchemeConfig {
108
+ /**
109
+ * Minimum allowance ratio required (0.0 to 1.0)
110
+ * If the allowance is less than this ratio of the payment amount,
111
+ * verification will fail.
112
+ *
113
+ * @default 1.0 (exact allowance required)
114
+ */
115
+ minAllowanceRatio?: number;
116
+ }
117
+ /**
118
+ * EVM facilitator implementation for the exact-legacy payment scheme.
119
+ * Uses the approve + transferFrom pattern for legacy tokens.
120
+ */
121
+ declare class ExactLegacyEvmScheme implements SchemeNetworkFacilitator {
122
+ private readonly signer;
123
+ readonly scheme = "exact-legacy";
124
+ readonly caipFamily = "eip155:*";
125
+ private readonly config;
126
+ /**
127
+ * Creates a new ExactLegacyEvmScheme instance.
128
+ *
129
+ * @param signer - The EVM signer for facilitator operations
130
+ * @param config - Optional configuration
131
+ */
132
+ constructor(signer: FacilitatorEvmSigner, config?: ExactLegacyEvmSchemeConfig);
133
+ /**
134
+ * Get mechanism-specific extra data for the supported kinds endpoint.
135
+ * For exact-legacy, returns the spender (facilitator) addresses.
136
+ *
137
+ * @param network - The network identifier
138
+ * @returns Extra data including spender addresses
139
+ */
140
+ getExtra(network: string): Record<string, unknown> | undefined;
141
+ /**
142
+ * Get signer addresses used by this facilitator.
143
+ */
144
+ getSigners(network: string): string[];
145
+ /**
146
+ * Verifies a payment payload.
147
+ */
148
+ verify(payload: PaymentPayload, requirements: PaymentRequirements): Promise<VerifyResponse>;
149
+ /**
150
+ * Settles a payment by executing transferFrom.
151
+ */
152
+ settle(payload: PaymentPayload, requirements: PaymentRequirements): Promise<SettleResponse>;
153
+ }
154
+
155
+ /**
156
+ * Token configuration for T402 EVM payments
157
+ *
158
+ * This module provides comprehensive token definitions including:
159
+ * - USDT0 (Tether's new omnichain token with EIP-3009 support)
160
+ * - USDC (USD Coin with EIP-3009 support)
161
+ * - Legacy tokens configuration
162
+ */
163
+
164
+ /**
165
+ * Token type classification for payment scheme selection
166
+ */
167
+ type TokenType = "eip3009" | "legacy";
168
+ /**
169
+ * Token configuration with EIP-712 domain parameters
170
+ */
171
+ interface TokenConfig {
172
+ /** Token contract address */
173
+ address: Address;
174
+ /** Token symbol (e.g., "USDT0", "USDC") */
175
+ symbol: string;
176
+ /** EIP-712 domain name for signing */
177
+ name: string;
178
+ /** EIP-712 domain version for signing */
179
+ version: string;
180
+ /** Number of decimal places */
181
+ decimals: number;
182
+ /** Token type for scheme selection */
183
+ tokenType: TokenType;
184
+ /** Payment priority (lower = higher priority) */
185
+ priority: number;
186
+ }
187
+ /**
188
+ * Network token registry mapping network -> symbol -> config
189
+ */
190
+ type NetworkTokenRegistry = Record<string, Record<string, TokenConfig>>;
191
+ /**
192
+ * USDT0 Contract Addresses by Network
193
+ * Source: https://docs.tether.io/usdt0/integration-guide/deployed-contracts
194
+ *
195
+ * USDT0 is Tether's new omnichain token using LayerZero OFT standard.
196
+ * Key features:
197
+ * - Supports EIP-3009 transferWithAuthorization (gasless transfers)
198
+ * - Supports EIP-2612 permit
199
+ * - Native cross-chain via LayerZero
200
+ */
201
+ declare const USDT0_ADDRESSES: Record<string, Address>;
202
+ /**
203
+ * USDC Contract Addresses by Network
204
+ * Native USDC with EIP-3009 support
205
+ */
206
+ declare const USDC_ADDRESSES: Record<string, Address>;
207
+ /**
208
+ * Traditional USDT Addresses (Legacy - no EIP-3009 support)
209
+ * These require the approve + transferFrom pattern
210
+ */
211
+ declare const USDT_LEGACY_ADDRESSES: Record<string, Address>;
212
+ /**
213
+ * Complete token registry with all supported tokens per network
214
+ */
215
+ declare const TOKEN_REGISTRY: NetworkTokenRegistry;
216
+ /**
217
+ * Token priority for payment method selection
218
+ * Lower number = higher priority
219
+ */
220
+ declare const TOKEN_PRIORITY: Record<string, number>;
221
+ /**
222
+ * Get token configuration for a specific token on a network
223
+ */
224
+ declare function getTokenConfig(network: string, symbol: string): TokenConfig | undefined;
225
+ /**
226
+ * Get all tokens available on a network
227
+ */
228
+ declare function getNetworkTokens(network: string): TokenConfig[];
229
+ /**
230
+ * Get the default/preferred token for a network
231
+ * Prefers USDT0 > USDC > others based on priority
232
+ */
233
+ declare function getDefaultToken(network: string): TokenConfig | undefined;
234
+ /**
235
+ * Get token by contract address on a network
236
+ */
237
+ declare function getTokenByAddress(network: string, address: Address): TokenConfig | undefined;
238
+ /**
239
+ * Check if a token supports EIP-3009 (gasless transfers)
240
+ */
241
+ declare function supportsEIP3009(network: string, symbol: string): boolean;
242
+ /**
243
+ * Get all networks that support a specific token
244
+ */
245
+ declare function getNetworksForToken(symbol: string): string[];
246
+ /**
247
+ * Get USDT0 networks (primary T402 token)
248
+ */
249
+ declare function getUsdt0Networks(): string[];
250
+ /**
251
+ * EIP-712 domain configuration for a token
252
+ */
253
+ declare function getEIP712Domain(network: string, tokenAddress: Address, chainId: number): {
254
+ name: string;
255
+ version: string;
256
+ chainId: number;
257
+ verifyingContract: Address;
258
+ } | undefined;
259
+
260
+ type ExactEIP3009Payload = {
261
+ signature?: `0x${string}`;
262
+ authorization: {
263
+ from: `0x${string}`;
264
+ to: `0x${string}`;
265
+ value: string;
266
+ validAfter: string;
267
+ validBefore: string;
268
+ nonce: `0x${string}`;
269
+ };
270
+ };
271
+ type ExactEvmPayloadV1 = ExactEIP3009Payload;
272
+ type ExactEvmPayloadV2 = ExactEIP3009Payload;
273
+ /**
274
+ * Payload for exact-legacy scheme (approve + transferFrom pattern)
275
+ * Used for legacy USDT and other tokens without EIP-3009 support
276
+ */
277
+ type ExactLegacyPayload = {
278
+ signature?: `0x${string}`;
279
+ authorization: {
280
+ /** Payer address */
281
+ from: `0x${string}`;
282
+ /** Recipient address */
283
+ to: `0x${string}`;
284
+ /** Payment amount in token units */
285
+ value: string;
286
+ /** Unix timestamp after which the authorization is valid */
287
+ validAfter: string;
288
+ /** Unix timestamp before which the authorization is valid */
289
+ validBefore: string;
290
+ /** Unique nonce to prevent replay attacks */
291
+ nonce: `0x${string}`;
292
+ /** Facilitator address that will call transferFrom */
293
+ spender: `0x${string}`;
294
+ };
295
+ };
296
+
297
+ declare const authorizationTypes: {
298
+ readonly TransferWithAuthorization: readonly [{
299
+ readonly name: "from";
300
+ readonly type: "address";
301
+ }, {
302
+ readonly name: "to";
303
+ readonly type: "address";
304
+ }, {
305
+ readonly name: "value";
306
+ readonly type: "uint256";
307
+ }, {
308
+ readonly name: "validAfter";
309
+ readonly type: "uint256";
310
+ }, {
311
+ readonly name: "validBefore";
312
+ readonly type: "uint256";
313
+ }, {
314
+ readonly name: "nonce";
315
+ readonly type: "bytes32";
316
+ }];
317
+ };
318
+ declare const legacyAuthorizationTypes: {
319
+ readonly LegacyTransferAuthorization: readonly [{
320
+ readonly name: "from";
321
+ readonly type: "address";
322
+ }, {
323
+ readonly name: "to";
324
+ readonly type: "address";
325
+ }, {
326
+ readonly name: "value";
327
+ readonly type: "uint256";
328
+ }, {
329
+ readonly name: "validAfter";
330
+ readonly type: "uint256";
331
+ }, {
332
+ readonly name: "validBefore";
333
+ readonly type: "uint256";
334
+ }, {
335
+ readonly name: "nonce";
336
+ readonly type: "bytes32";
337
+ }, {
338
+ readonly name: "spender";
339
+ readonly type: "address";
340
+ }];
341
+ };
342
+ declare const eip3009ABI: readonly [{
343
+ readonly inputs: readonly [{
344
+ readonly name: "from";
345
+ readonly type: "address";
346
+ }, {
347
+ readonly name: "to";
348
+ readonly type: "address";
349
+ }, {
350
+ readonly name: "value";
351
+ readonly type: "uint256";
352
+ }, {
353
+ readonly name: "validAfter";
354
+ readonly type: "uint256";
355
+ }, {
356
+ readonly name: "validBefore";
357
+ readonly type: "uint256";
358
+ }, {
359
+ readonly name: "nonce";
360
+ readonly type: "bytes32";
361
+ }, {
362
+ readonly name: "v";
363
+ readonly type: "uint8";
364
+ }, {
365
+ readonly name: "r";
366
+ readonly type: "bytes32";
367
+ }, {
368
+ readonly name: "s";
369
+ readonly type: "bytes32";
370
+ }];
371
+ readonly name: "transferWithAuthorization";
372
+ readonly outputs: readonly [];
373
+ readonly stateMutability: "nonpayable";
374
+ readonly type: "function";
375
+ }, {
376
+ readonly inputs: readonly [{
377
+ readonly name: "from";
378
+ readonly type: "address";
379
+ }, {
380
+ readonly name: "to";
381
+ readonly type: "address";
382
+ }, {
383
+ readonly name: "value";
384
+ readonly type: "uint256";
385
+ }, {
386
+ readonly name: "validAfter";
387
+ readonly type: "uint256";
388
+ }, {
389
+ readonly name: "validBefore";
390
+ readonly type: "uint256";
391
+ }, {
392
+ readonly name: "nonce";
393
+ readonly type: "bytes32";
394
+ }, {
395
+ readonly name: "signature";
396
+ readonly type: "bytes";
397
+ }];
398
+ readonly name: "transferWithAuthorization";
399
+ readonly outputs: readonly [];
400
+ readonly stateMutability: "nonpayable";
401
+ readonly type: "function";
402
+ }, {
403
+ readonly inputs: readonly [{
404
+ readonly name: "account";
405
+ readonly type: "address";
406
+ }];
407
+ readonly name: "balanceOf";
408
+ readonly outputs: readonly [{
409
+ readonly name: "";
410
+ readonly type: "uint256";
411
+ }];
412
+ readonly stateMutability: "view";
413
+ readonly type: "function";
414
+ }, {
415
+ readonly inputs: readonly [];
416
+ readonly name: "version";
417
+ readonly outputs: readonly [{
418
+ readonly name: "";
419
+ readonly type: "string";
420
+ }];
421
+ readonly stateMutability: "view";
422
+ readonly type: "function";
423
+ }];
424
+ declare const erc20LegacyABI: readonly [{
425
+ readonly inputs: readonly [{
426
+ readonly name: "account";
427
+ readonly type: "address";
428
+ }];
429
+ readonly name: "balanceOf";
430
+ readonly outputs: readonly [{
431
+ readonly name: "";
432
+ readonly type: "uint256";
433
+ }];
434
+ readonly stateMutability: "view";
435
+ readonly type: "function";
436
+ }, {
437
+ readonly inputs: readonly [{
438
+ readonly name: "owner";
439
+ readonly type: "address";
440
+ }, {
441
+ readonly name: "spender";
442
+ readonly type: "address";
443
+ }];
444
+ readonly name: "allowance";
445
+ readonly outputs: readonly [{
446
+ readonly name: "";
447
+ readonly type: "uint256";
448
+ }];
449
+ readonly stateMutability: "view";
450
+ readonly type: "function";
451
+ }, {
452
+ readonly inputs: readonly [{
453
+ readonly name: "spender";
454
+ readonly type: "address";
455
+ }, {
456
+ readonly name: "amount";
457
+ readonly type: "uint256";
458
+ }];
459
+ readonly name: "approve";
460
+ readonly outputs: readonly [{
461
+ readonly name: "";
462
+ readonly type: "bool";
463
+ }];
464
+ readonly stateMutability: "nonpayable";
465
+ readonly type: "function";
466
+ }, {
467
+ readonly inputs: readonly [{
468
+ readonly name: "from";
469
+ readonly type: "address";
470
+ }, {
471
+ readonly name: "to";
472
+ readonly type: "address";
473
+ }, {
474
+ readonly name: "amount";
475
+ readonly type: "uint256";
476
+ }];
477
+ readonly name: "transferFrom";
478
+ readonly outputs: readonly [{
479
+ readonly name: "";
480
+ readonly type: "bool";
481
+ }];
482
+ readonly stateMutability: "nonpayable";
483
+ readonly type: "function";
484
+ }];
485
+
486
+ /**
487
+ * Type definitions for USDT0 cross-chain bridging
488
+ */
489
+
490
+ /**
491
+ * Parameters for quoting a bridge transaction
492
+ */
493
+ interface BridgeQuoteParams {
494
+ /** Source chain name (e.g., "ethereum", "arbitrum") */
495
+ fromChain: string;
496
+ /** Destination chain name */
497
+ toChain: string;
498
+ /** Amount to bridge in token units (6 decimals for USDT0) */
499
+ amount: bigint;
500
+ /** Recipient address on destination chain */
501
+ recipient: Address;
502
+ }
503
+ /**
504
+ * Quote result for a bridge transaction
505
+ */
506
+ interface BridgeQuote {
507
+ /** Native token fee required (in wei) */
508
+ nativeFee: bigint;
509
+ /** Amount that will be sent */
510
+ amountToSend: bigint;
511
+ /** Minimum amount to receive (after fees/slippage) */
512
+ minAmountToReceive: bigint;
513
+ /** Estimated time for bridge completion in seconds */
514
+ estimatedTime: number;
515
+ /** Source chain */
516
+ fromChain: string;
517
+ /** Destination chain */
518
+ toChain: string;
519
+ }
520
+ /**
521
+ * Parameters for executing a bridge transaction
522
+ */
523
+ interface BridgeExecuteParams extends BridgeQuoteParams {
524
+ /** Slippage tolerance as percentage (e.g., 0.5 for 0.5%) */
525
+ slippageTolerance?: number;
526
+ /** Custom gas limit for the destination chain execution */
527
+ dstGasLimit?: bigint;
528
+ /** Refund address for excess fees (defaults to sender) */
529
+ refundAddress?: Address;
530
+ }
531
+ /**
532
+ * Result of a bridge transaction
533
+ */
534
+ interface BridgeResult {
535
+ /** Transaction hash on source chain */
536
+ txHash: `0x${string}`;
537
+ /** LayerZero message GUID */
538
+ messageGuid: `0x${string}`;
539
+ /** Amount sent */
540
+ amountSent: bigint;
541
+ /** Amount to be received on destination */
542
+ amountToReceive: bigint;
543
+ /** Source chain */
544
+ fromChain: string;
545
+ /** Destination chain */
546
+ toChain: string;
547
+ /** Estimated completion time in seconds */
548
+ estimatedTime: number;
549
+ }
550
+ /**
551
+ * Bridge status for tracking cross-chain transfers
552
+ */
553
+ type BridgeStatus = "pending" | "inflight" | "delivered" | "completed" | "failed";
554
+ /**
555
+ * Bridge transaction tracking info
556
+ */
557
+ interface BridgeTransaction {
558
+ /** Source chain transaction hash */
559
+ srcTxHash: `0x${string}`;
560
+ /** LayerZero message GUID */
561
+ messageGuid: `0x${string}`;
562
+ /** Current status */
563
+ status: BridgeStatus;
564
+ /** Source chain */
565
+ fromChain: string;
566
+ /** Destination chain */
567
+ toChain: string;
568
+ /** Amount sent */
569
+ amount: bigint;
570
+ /** Recipient address */
571
+ recipient: Address;
572
+ /** Timestamp when bridge was initiated */
573
+ timestamp: number;
574
+ /** Destination chain transaction hash (when completed) */
575
+ dstTxHash?: `0x${string}`;
576
+ }
577
+ /**
578
+ * Signer interface for bridge operations
579
+ */
580
+ interface BridgeSigner {
581
+ /** Wallet address */
582
+ readonly address: Address;
583
+ /** Read contract state */
584
+ readContract(args: {
585
+ address: Address;
586
+ abi: readonly unknown[];
587
+ functionName: string;
588
+ args?: readonly unknown[];
589
+ }): Promise<unknown>;
590
+ /** Write to contract */
591
+ writeContract(args: {
592
+ address: Address;
593
+ abi: readonly unknown[];
594
+ functionName: string;
595
+ args: readonly unknown[];
596
+ value?: bigint;
597
+ }): Promise<`0x${string}`>;
598
+ /** Wait for transaction receipt */
599
+ waitForTransactionReceipt(args: {
600
+ hash: `0x${string}`;
601
+ }): Promise<{
602
+ status: string;
603
+ }>;
604
+ }
605
+
606
+ /**
607
+ * USDT0 Bridge Client
608
+ *
609
+ * Provides cross-chain USDT0 transfers using LayerZero OFT standard.
610
+ *
611
+ * @example
612
+ * ```typescript
613
+ * import { Usdt0Bridge } from '@t402/evm';
614
+ * import { createWalletClient, http } from 'viem';
615
+ * import { arbitrum } from 'viem/chains';
616
+ *
617
+ * const walletClient = createWalletClient({
618
+ * chain: arbitrum,
619
+ * transport: http(),
620
+ * account: privateKeyToAccount(privateKey),
621
+ * });
622
+ *
623
+ * const bridge = new Usdt0Bridge(walletClient, 'arbitrum');
624
+ *
625
+ * // Get quote
626
+ * const quote = await bridge.quote({
627
+ * fromChain: 'arbitrum',
628
+ * toChain: 'ethereum',
629
+ * amount: 100_000000n, // 100 USDT0
630
+ * recipient: '0x...',
631
+ * });
632
+ *
633
+ * // Execute bridge
634
+ * const result = await bridge.send({
635
+ * fromChain: 'arbitrum',
636
+ * toChain: 'ethereum',
637
+ * amount: 100_000000n,
638
+ * recipient: '0x...',
639
+ * });
640
+ * ```
641
+ */
642
+
643
+ /**
644
+ * USDT0 Bridge Client for LayerZero OFT transfers
645
+ */
646
+ declare class Usdt0Bridge {
647
+ private readonly signer;
648
+ private readonly chain;
649
+ /**
650
+ * Create a new bridge client
651
+ *
652
+ * @param signer - Wallet signer with read/write capabilities
653
+ * @param chain - Source chain name (e.g., "arbitrum", "ethereum")
654
+ */
655
+ constructor(signer: BridgeSigner, chain: string);
656
+ /**
657
+ * Get a quote for bridging USDT0
658
+ *
659
+ * @param params - Bridge parameters
660
+ * @returns Quote with fee and amount information
661
+ */
662
+ quote(params: BridgeQuoteParams): Promise<BridgeQuote>;
663
+ /**
664
+ * Execute a bridge transaction
665
+ *
666
+ * @param params - Bridge execution parameters
667
+ * @returns Bridge result with transaction hash
668
+ */
669
+ send(params: BridgeExecuteParams): Promise<BridgeResult>;
670
+ /**
671
+ * Ensure sufficient token allowance for the OFT contract
672
+ */
673
+ private ensureAllowance;
674
+ /**
675
+ * Build SendParam struct for LayerZero
676
+ */
677
+ private buildSendParam;
678
+ /**
679
+ * Validate bridge parameters
680
+ */
681
+ private validateBridgeParams;
682
+ /**
683
+ * Get all supported destination chains from current chain
684
+ */
685
+ getSupportedDestinations(): string[];
686
+ /**
687
+ * Check if a destination chain is supported
688
+ */
689
+ supportsDestination(toChain: string): boolean;
690
+ }
691
+ /**
692
+ * Create a bridge client for a specific chain
693
+ */
694
+ declare function createUsdt0Bridge(signer: BridgeSigner, chain: string): Usdt0Bridge;
695
+
696
+ /**
697
+ * LayerZero OFT Bridge Constants for USDT0
698
+ *
699
+ * USDT0 uses LayerZero's OFT (Omnichain Fungible Token) standard
700
+ * for cross-chain transfers.
701
+ *
702
+ * @see https://docs.layerzero.network/v2/developers/evm/oft/quickstart
703
+ */
704
+
705
+ /**
706
+ * LayerZero V2 Endpoint IDs (EIDs) for supported chains
707
+ * These are unique identifiers used by LayerZero to route messages
708
+ *
709
+ * @see https://docs.layerzero.network/v2/deployments/deployed-contracts
710
+ */
711
+ declare const LAYERZERO_ENDPOINT_IDS: Record<string, number>;
712
+ /**
713
+ * USDT0 OFT Adapter contract addresses by chain
714
+ * These are the contracts that handle cross-chain transfers
715
+ */
716
+ declare const USDT0_OFT_ADDRESSES: Record<string, Address>;
717
+ /**
718
+ * LayerZero V2 Endpoint contract addresses
719
+ * Same address on all EVM chains
720
+ */
721
+ declare const LAYERZERO_ENDPOINT_V2: Address;
722
+ /**
723
+ * Get LayerZero endpoint ID for a chain
724
+ */
725
+ declare function getEndpointId(chain: string): number | undefined;
726
+ /**
727
+ * Get USDT0 OFT contract address for a chain
728
+ */
729
+ declare function getUsdt0OftAddress(chain: string): Address | undefined;
730
+ /**
731
+ * Check if a chain supports USDT0 bridging
732
+ */
733
+ declare function supportsBridging(chain: string): boolean;
734
+ /**
735
+ * Get all chains that support USDT0 bridging
736
+ */
737
+ declare function getBridgeableChains(): string[];
738
+ /**
739
+ * Convert address to bytes32 format for LayerZero
740
+ * Pads address with leading zeros to 32 bytes
741
+ */
742
+ declare function addressToBytes32(address: Address): `0x${string}`;
743
+ /**
744
+ * Convert bytes32 to address
745
+ */
746
+ declare function bytes32ToAddress(bytes32: `0x${string}`): Address;
747
+
748
+ /**
749
+ * ERC-4337 Account Abstraction Types
750
+ *
751
+ * Type definitions for ERC-4337 v0.7 implementation.
752
+ */
753
+
754
+ /**
755
+ * UserOperation for off-chain representation
756
+ * This is the format used before packing for on-chain submission
757
+ */
758
+ interface UserOperation {
759
+ /** Smart account address */
760
+ sender: Address;
761
+ /** Anti-replay nonce */
762
+ nonce: bigint;
763
+ /** Factory address + init data (for account deployment) or empty */
764
+ initCode: Hex;
765
+ /** Encoded call data for the account's execute function */
766
+ callData: Hex;
767
+ /** Gas limit for account validation */
768
+ verificationGasLimit: bigint;
769
+ /** Gas limit for call execution */
770
+ callGasLimit: bigint;
771
+ /** Gas to pay bundler for overhead */
772
+ preVerificationGas: bigint;
773
+ /** Max priority fee per gas (tip) */
774
+ maxPriorityFeePerGas: bigint;
775
+ /** Max fee per gas */
776
+ maxFeePerGas: bigint;
777
+ /** Paymaster address + data, or empty for self-pay */
778
+ paymasterAndData: Hex;
779
+ /** Signature over the UserOperation hash */
780
+ signature: Hex;
781
+ }
782
+ /**
783
+ * PackedUserOperation for on-chain submission (v0.7)
784
+ * Gas fields are packed into bytes32 for efficiency
785
+ */
786
+ interface PackedUserOperation {
787
+ /** Smart account address */
788
+ sender: Address;
789
+ /** Anti-replay nonce */
790
+ nonce: bigint;
791
+ /** Factory address + init data, or empty */
792
+ initCode: Hex;
793
+ /** Encoded call data */
794
+ callData: Hex;
795
+ /** Packed: verificationGasLimit (16 bytes) + callGasLimit (16 bytes) */
796
+ accountGasLimits: Hex;
797
+ /** Gas for bundler overhead */
798
+ preVerificationGas: bigint;
799
+ /** Packed: maxPriorityFeePerGas (16 bytes) + maxFeePerGas (16 bytes) */
800
+ gasFees: Hex;
801
+ /** Paymaster address + verification gas + postOp gas + data */
802
+ paymasterAndData: Hex;
803
+ /** Authorization signature */
804
+ signature: Hex;
805
+ }
806
+ /**
807
+ * Paymaster data for gas sponsorship
808
+ */
809
+ interface PaymasterData {
810
+ /** Paymaster contract address */
811
+ paymaster: Address;
812
+ /** Gas limit for paymaster validation */
813
+ paymasterVerificationGasLimit: bigint;
814
+ /** Gas limit for paymaster post-operation */
815
+ paymasterPostOpGasLimit: bigint;
816
+ /** Additional paymaster-specific data */
817
+ paymasterData: Hex;
818
+ }
819
+ /**
820
+ * Gas estimation result from bundler
821
+ */
822
+ interface GasEstimate {
823
+ /** Gas for account validation */
824
+ verificationGasLimit: bigint;
825
+ /** Gas for call execution */
826
+ callGasLimit: bigint;
827
+ /** Gas for bundler overhead */
828
+ preVerificationGas: bigint;
829
+ /** Gas for paymaster validation (if applicable) */
830
+ paymasterVerificationGasLimit?: bigint;
831
+ /** Gas for paymaster post-op (if applicable) */
832
+ paymasterPostOpGasLimit?: bigint;
833
+ }
834
+ /**
835
+ * UserOperation receipt from bundler
836
+ */
837
+ interface UserOperationReceipt {
838
+ /** UserOperation hash */
839
+ userOpHash: Hex;
840
+ /** Smart account address */
841
+ sender: Address;
842
+ /** Nonce used */
843
+ nonce: bigint;
844
+ /** Paymaster address (if used) */
845
+ paymaster?: Address;
846
+ /** Actual gas cost */
847
+ actualGasCost: bigint;
848
+ /** Actual gas used */
849
+ actualGasUsed: bigint;
850
+ /** Success status */
851
+ success: boolean;
852
+ /** Revert reason (if failed) */
853
+ reason?: string;
854
+ /** Transaction receipt */
855
+ receipt: {
856
+ transactionHash: Hex;
857
+ blockNumber: bigint;
858
+ blockHash: Hex;
859
+ };
860
+ }
861
+ /**
862
+ * Bundler client configuration
863
+ */
864
+ interface BundlerConfig {
865
+ /** Bundler RPC endpoint URL */
866
+ bundlerUrl: string;
867
+ /** EntryPoint contract address */
868
+ entryPoint?: Address;
869
+ /** Chain ID */
870
+ chainId: number;
871
+ }
872
+ /**
873
+ * Paymaster configuration
874
+ */
875
+ interface PaymasterConfig {
876
+ /** Paymaster contract address */
877
+ address: Address;
878
+ /** Paymaster service URL (for verifying paymasters) */
879
+ url?: string;
880
+ /** Paymaster type */
881
+ type: "verifying" | "token" | "sponsoring";
882
+ /** Additional configuration */
883
+ options?: Record<string, unknown>;
884
+ }
885
+ /**
886
+ * Smart account signer interface
887
+ */
888
+ interface SmartAccountSigner {
889
+ /** Get the smart account address */
890
+ getAddress(): Promise<Address>;
891
+ /** Sign a UserOperation hash */
892
+ signUserOpHash(userOpHash: Hex): Promise<Hex>;
893
+ /** Get the account's init code (for deployment) */
894
+ getInitCode(): Promise<Hex>;
895
+ /** Check if the account is deployed */
896
+ isDeployed(): Promise<boolean>;
897
+ /** Encode a call to the account's execute function */
898
+ encodeExecute(target: Address, value: bigint, data: Hex): Hex;
899
+ /** Encode a batch call to the account's executeBatch function */
900
+ encodeExecuteBatch(targets: Address[], values: bigint[], datas: Hex[]): Hex;
901
+ }
902
+ /**
903
+ * UserOperation builder configuration
904
+ */
905
+ interface UserOpBuilderConfig {
906
+ /** Smart account signer */
907
+ signer: SmartAccountSigner;
908
+ /** Bundler configuration */
909
+ bundler: BundlerConfig;
910
+ /** Optional paymaster configuration */
911
+ paymaster?: PaymasterConfig;
912
+ }
913
+ /**
914
+ * Transaction intent for building UserOperations
915
+ */
916
+ interface TransactionIntent {
917
+ /** Target contract address */
918
+ to: Address;
919
+ /** Value to send (in wei) */
920
+ value?: bigint;
921
+ /** Call data */
922
+ data?: Hex;
923
+ }
924
+ /**
925
+ * Result of submitting a UserOperation
926
+ */
927
+ interface UserOperationResult {
928
+ /** UserOperation hash */
929
+ userOpHash: Hex;
930
+ /** Wait for the operation to be included */
931
+ wait(): Promise<UserOperationReceipt>;
932
+ }
933
+
934
+ /**
935
+ * ERC-4337 Account Abstraction Constants
936
+ *
937
+ * Provides constants for ERC-4337 v0.7 implementation including:
938
+ * - EntryPoint contract addresses
939
+ * - Default gas limits
940
+ * - ABI definitions
941
+ *
942
+ * @see https://eips.ethereum.org/EIPS/eip-4337
943
+ */
944
+
945
+ /**
946
+ * EntryPoint v0.7 contract address (canonical deployment)
947
+ * Deployed on all major EVM chains at the same address
948
+ */
949
+ declare const ENTRYPOINT_V07_ADDRESS: Address;
950
+ /**
951
+ * EntryPoint v0.6 contract address (legacy)
952
+ */
953
+ declare const ENTRYPOINT_V06_ADDRESS: Address;
954
+ /**
955
+ * Default gas limits for UserOperations
956
+ */
957
+ declare const DEFAULT_GAS_LIMITS: {
958
+ /** Gas for account validation */
959
+ readonly verificationGasLimit: 150000n;
960
+ /** Gas for callData execution */
961
+ readonly callGasLimit: 100000n;
962
+ /** Gas paid to bundler for overhead */
963
+ readonly preVerificationGas: 50000n;
964
+ /** Gas for paymaster validation */
965
+ readonly paymasterVerificationGasLimit: 50000n;
966
+ /** Gas for paymaster post-op */
967
+ readonly paymasterPostOpGasLimit: 50000n;
968
+ };
969
+ /**
970
+ * EntryPoint v0.7 ABI (essential functions)
971
+ */
972
+ declare const ENTRYPOINT_V07_ABI: readonly [{
973
+ readonly inputs: readonly [{
974
+ readonly components: readonly [{
975
+ readonly name: "sender";
976
+ readonly type: "address";
977
+ }, {
978
+ readonly name: "nonce";
979
+ readonly type: "uint256";
980
+ }, {
981
+ readonly name: "initCode";
982
+ readonly type: "bytes";
983
+ }, {
984
+ readonly name: "callData";
985
+ readonly type: "bytes";
986
+ }, {
987
+ readonly name: "accountGasLimits";
988
+ readonly type: "bytes32";
989
+ }, {
990
+ readonly name: "preVerificationGas";
991
+ readonly type: "uint256";
992
+ }, {
993
+ readonly name: "gasFees";
994
+ readonly type: "bytes32";
995
+ }, {
996
+ readonly name: "paymasterAndData";
997
+ readonly type: "bytes";
998
+ }, {
999
+ readonly name: "signature";
1000
+ readonly type: "bytes";
1001
+ }];
1002
+ readonly name: "ops";
1003
+ readonly type: "tuple[]";
1004
+ }, {
1005
+ readonly name: "beneficiary";
1006
+ readonly type: "address";
1007
+ }];
1008
+ readonly name: "handleOps";
1009
+ readonly outputs: readonly [];
1010
+ readonly stateMutability: "nonpayable";
1011
+ readonly type: "function";
1012
+ }, {
1013
+ readonly inputs: readonly [{
1014
+ readonly name: "sender";
1015
+ readonly type: "address";
1016
+ }];
1017
+ readonly name: "getNonce";
1018
+ readonly outputs: readonly [{
1019
+ readonly name: "nonce";
1020
+ readonly type: "uint256";
1021
+ }];
1022
+ readonly stateMutability: "view";
1023
+ readonly type: "function";
1024
+ }, {
1025
+ readonly inputs: readonly [{
1026
+ readonly name: "sender";
1027
+ readonly type: "address";
1028
+ }, {
1029
+ readonly name: "key";
1030
+ readonly type: "uint192";
1031
+ }];
1032
+ readonly name: "getNonce";
1033
+ readonly outputs: readonly [{
1034
+ readonly name: "nonce";
1035
+ readonly type: "uint256";
1036
+ }];
1037
+ readonly stateMutability: "view";
1038
+ readonly type: "function";
1039
+ }, {
1040
+ readonly inputs: readonly [{
1041
+ readonly components: readonly [{
1042
+ readonly name: "sender";
1043
+ readonly type: "address";
1044
+ }, {
1045
+ readonly name: "nonce";
1046
+ readonly type: "uint256";
1047
+ }, {
1048
+ readonly name: "initCode";
1049
+ readonly type: "bytes";
1050
+ }, {
1051
+ readonly name: "callData";
1052
+ readonly type: "bytes";
1053
+ }, {
1054
+ readonly name: "accountGasLimits";
1055
+ readonly type: "bytes32";
1056
+ }, {
1057
+ readonly name: "preVerificationGas";
1058
+ readonly type: "uint256";
1059
+ }, {
1060
+ readonly name: "gasFees";
1061
+ readonly type: "bytes32";
1062
+ }, {
1063
+ readonly name: "paymasterAndData";
1064
+ readonly type: "bytes";
1065
+ }, {
1066
+ readonly name: "signature";
1067
+ readonly type: "bytes";
1068
+ }];
1069
+ readonly name: "userOp";
1070
+ readonly type: "tuple";
1071
+ }];
1072
+ readonly name: "getUserOpHash";
1073
+ readonly outputs: readonly [{
1074
+ readonly name: "";
1075
+ readonly type: "bytes32";
1076
+ }];
1077
+ readonly stateMutability: "view";
1078
+ readonly type: "function";
1079
+ }];
1080
+ /**
1081
+ * IAccount interface ABI (smart wallet validation)
1082
+ */
1083
+ declare const ACCOUNT_ABI: readonly [{
1084
+ readonly inputs: readonly [{
1085
+ readonly components: readonly [{
1086
+ readonly name: "sender";
1087
+ readonly type: "address";
1088
+ }, {
1089
+ readonly name: "nonce";
1090
+ readonly type: "uint256";
1091
+ }, {
1092
+ readonly name: "initCode";
1093
+ readonly type: "bytes";
1094
+ }, {
1095
+ readonly name: "callData";
1096
+ readonly type: "bytes";
1097
+ }, {
1098
+ readonly name: "accountGasLimits";
1099
+ readonly type: "bytes32";
1100
+ }, {
1101
+ readonly name: "preVerificationGas";
1102
+ readonly type: "uint256";
1103
+ }, {
1104
+ readonly name: "gasFees";
1105
+ readonly type: "bytes32";
1106
+ }, {
1107
+ readonly name: "paymasterAndData";
1108
+ readonly type: "bytes";
1109
+ }, {
1110
+ readonly name: "signature";
1111
+ readonly type: "bytes";
1112
+ }];
1113
+ readonly name: "userOp";
1114
+ readonly type: "tuple";
1115
+ }, {
1116
+ readonly name: "userOpHash";
1117
+ readonly type: "bytes32";
1118
+ }, {
1119
+ readonly name: "missingAccountFunds";
1120
+ readonly type: "uint256";
1121
+ }];
1122
+ readonly name: "validateUserOp";
1123
+ readonly outputs: readonly [{
1124
+ readonly name: "validationData";
1125
+ readonly type: "uint256";
1126
+ }];
1127
+ readonly stateMutability: "nonpayable";
1128
+ readonly type: "function";
1129
+ }, {
1130
+ readonly inputs: readonly [{
1131
+ readonly name: "dest";
1132
+ readonly type: "address";
1133
+ }, {
1134
+ readonly name: "value";
1135
+ readonly type: "uint256";
1136
+ }, {
1137
+ readonly name: "func";
1138
+ readonly type: "bytes";
1139
+ }];
1140
+ readonly name: "execute";
1141
+ readonly outputs: readonly [];
1142
+ readonly stateMutability: "nonpayable";
1143
+ readonly type: "function";
1144
+ }, {
1145
+ readonly inputs: readonly [{
1146
+ readonly name: "dest";
1147
+ readonly type: "address[]";
1148
+ }, {
1149
+ readonly name: "value";
1150
+ readonly type: "uint256[]";
1151
+ }, {
1152
+ readonly name: "func";
1153
+ readonly type: "bytes[]";
1154
+ }];
1155
+ readonly name: "executeBatch";
1156
+ readonly outputs: readonly [];
1157
+ readonly stateMutability: "nonpayable";
1158
+ readonly type: "function";
1159
+ }];
1160
+ /**
1161
+ * Bundler JSON-RPC method names
1162
+ */
1163
+ declare const BUNDLER_METHODS: {
1164
+ readonly sendUserOperation: "eth_sendUserOperation";
1165
+ readonly estimateUserOperationGas: "eth_estimateUserOperationGas";
1166
+ readonly getUserOperationByHash: "eth_getUserOperationByHash";
1167
+ readonly getUserOperationReceipt: "eth_getUserOperationReceipt";
1168
+ readonly supportedEntryPoints: "eth_supportedEntryPoints";
1169
+ readonly chainId: "eth_chainId";
1170
+ };
1171
+ /**
1172
+ * Common paymaster types
1173
+ */
1174
+ declare enum PaymasterType {
1175
+ /** No paymaster - user pays gas */
1176
+ None = "none",
1177
+ /** Verifying paymaster with off-chain signature */
1178
+ Verifying = "verifying",
1179
+ /** Token paymaster - pay gas with ERC20 */
1180
+ Token = "token",
1181
+ /** Sponsoring paymaster - third party pays */
1182
+ Sponsoring = "sponsoring"
1183
+ }
1184
+ /**
1185
+ * Pack verification and call gas limits into bytes32
1186
+ */
1187
+ declare function packAccountGasLimits(verificationGasLimit: bigint, callGasLimit: bigint): `0x${string}`;
1188
+ /**
1189
+ * Unpack account gas limits from bytes32
1190
+ */
1191
+ declare function unpackAccountGasLimits(packed: `0x${string}`): {
1192
+ verificationGasLimit: bigint;
1193
+ callGasLimit: bigint;
1194
+ };
1195
+ /**
1196
+ * Pack max priority fee and max fee per gas into bytes32
1197
+ */
1198
+ declare function packGasFees(maxPriorityFeePerGas: bigint, maxFeePerGas: bigint): `0x${string}`;
1199
+ /**
1200
+ * Unpack gas fees from bytes32
1201
+ */
1202
+ declare function unpackGasFees(packed: `0x${string}`): {
1203
+ maxPriorityFeePerGas: bigint;
1204
+ maxFeePerGas: bigint;
1205
+ };
1206
+
1207
+ /**
1208
+ * ERC-4337 UserOperation Builder
1209
+ *
1210
+ * Builds UserOperations from transaction intents for ERC-4337 v0.7.
1211
+ * Handles gas estimation, nonce management, and operation packing.
1212
+ */
1213
+
1214
+ /**
1215
+ * Builder configuration
1216
+ */
1217
+ interface UserOpBuilderOptions {
1218
+ /** EntryPoint address (defaults to v0.7) */
1219
+ entryPoint?: Address;
1220
+ /** Default gas multiplier for safety margin */
1221
+ gasMultiplier?: number;
1222
+ }
1223
+ /**
1224
+ * UserOperation Builder for creating and packing operations
1225
+ */
1226
+ declare class UserOpBuilder {
1227
+ private readonly entryPoint;
1228
+ private readonly gasMultiplier;
1229
+ constructor(options?: UserOpBuilderOptions);
1230
+ /**
1231
+ * Build a UserOperation from a transaction intent
1232
+ */
1233
+ buildUserOp(signer: SmartAccountSigner, intent: TransactionIntent, client: PublicClient, gasEstimate?: GasEstimate, paymaster?: PaymasterData): Promise<UserOperation>;
1234
+ /**
1235
+ * Build a batch UserOperation from multiple transaction intents
1236
+ */
1237
+ buildBatchUserOp(signer: SmartAccountSigner, intents: TransactionIntent[], client: PublicClient, gasEstimate?: GasEstimate, paymaster?: PaymasterData): Promise<UserOperation>;
1238
+ /**
1239
+ * Pack a UserOperation for on-chain submission (v0.7 format)
1240
+ */
1241
+ packUserOp(userOp: UserOperation): PackedUserOperation;
1242
+ /**
1243
+ * Compute the UserOperation hash for signing
1244
+ */
1245
+ getUserOpHash(userOp: UserOperation, client: PublicClient, chainId: number): Promise<Hex>;
1246
+ /**
1247
+ * Sign a UserOperation
1248
+ */
1249
+ signUserOp(userOp: UserOperation, signer: SmartAccountSigner, client: PublicClient, chainId: number): Promise<UserOperation>;
1250
+ /**
1251
+ * Get the nonce for an account from EntryPoint
1252
+ */
1253
+ private getNonce;
1254
+ /**
1255
+ * Get current gas prices from the chain
1256
+ */
1257
+ private getGasPrices;
1258
+ /**
1259
+ * Apply gas multiplier for safety margin
1260
+ */
1261
+ private applyMultiplier;
1262
+ /**
1263
+ * Encode paymaster data for the UserOperation
1264
+ */
1265
+ private encodePaymasterData;
1266
+ }
1267
+ /**
1268
+ * Create a UserOpBuilder instance
1269
+ */
1270
+ declare function createUserOpBuilder(options?: UserOpBuilderOptions): UserOpBuilder;
1271
+
1272
+ /**
1273
+ * ERC-4337 Bundler Client
1274
+ *
1275
+ * Client for interacting with ERC-4337 bundlers via JSON-RPC.
1276
+ * Handles UserOperation submission, gas estimation, and receipt polling.
1277
+ */
1278
+
1279
+ /**
1280
+ * Bundler error class
1281
+ */
1282
+ declare class BundlerError extends Error {
1283
+ code?: number | undefined;
1284
+ data?: unknown | undefined;
1285
+ constructor(message: string, code?: number | undefined, data?: unknown | undefined);
1286
+ }
1287
+ /**
1288
+ * Bundler client for submitting UserOperations
1289
+ */
1290
+ declare class BundlerClient {
1291
+ private readonly bundlerUrl;
1292
+ private readonly entryPoint;
1293
+ private readonly chainId;
1294
+ private requestId;
1295
+ constructor(config: BundlerConfig);
1296
+ /**
1297
+ * Send a UserOperation to the bundler
1298
+ */
1299
+ sendUserOperation(userOp: UserOperation): Promise<UserOperationResult>;
1300
+ /**
1301
+ * Estimate gas for a UserOperation
1302
+ */
1303
+ estimateUserOperationGas(userOp: Partial<UserOperation> & {
1304
+ sender: Address;
1305
+ callData: Hex;
1306
+ }): Promise<GasEstimate>;
1307
+ /**
1308
+ * Get UserOperation by hash
1309
+ */
1310
+ getUserOperationByHash(userOpHash: Hex): Promise<{
1311
+ userOperation: PackedUserOperation;
1312
+ entryPoint: Address;
1313
+ } | null>;
1314
+ /**
1315
+ * Get UserOperation receipt
1316
+ */
1317
+ getUserOperationReceipt(userOpHash: Hex): Promise<UserOperationReceipt | null>;
1318
+ /**
1319
+ * Get supported EntryPoints
1320
+ */
1321
+ getSupportedEntryPoints(): Promise<Address[]>;
1322
+ /**
1323
+ * Get chain ID from bundler
1324
+ */
1325
+ getChainId(): Promise<number>;
1326
+ /**
1327
+ * Wait for UserOperation receipt with polling
1328
+ */
1329
+ waitForReceipt(userOpHash: Hex, options?: {
1330
+ timeout?: number;
1331
+ pollingInterval?: number;
1332
+ }): Promise<UserOperationReceipt>;
1333
+ /**
1334
+ * Pack UserOperation for RPC (convert bigints to hex strings)
1335
+ */
1336
+ private packForRpc;
1337
+ /**
1338
+ * Convert bigint to hex string
1339
+ */
1340
+ private toHex;
1341
+ /**
1342
+ * Make a JSON-RPC call to the bundler
1343
+ */
1344
+ private rpcCall;
1345
+ }
1346
+ /**
1347
+ * Create a BundlerClient instance
1348
+ */
1349
+ declare function createBundlerClient(config: BundlerConfig): BundlerClient;
1350
+
1351
+ /**
1352
+ * ERC-4337 Paymaster Client
1353
+ *
1354
+ * Handles paymaster interactions for gas sponsorship.
1355
+ * Supports verifying paymasters (off-chain signature) and
1356
+ * sponsoring paymasters (third-party gas payment).
1357
+ */
1358
+
1359
+ /**
1360
+ * Paymaster service response
1361
+ */
1362
+ interface PaymasterResponse {
1363
+ /** Paymaster address */
1364
+ paymaster: Address;
1365
+ /** Paymaster data to include in UserOp */
1366
+ paymasterData: Hex;
1367
+ /** Gas limits for paymaster operations */
1368
+ paymasterVerificationGasLimit: bigint;
1369
+ paymasterPostOpGasLimit: bigint;
1370
+ }
1371
+ /**
1372
+ * Paymaster sponsor request
1373
+ */
1374
+ interface SponsorRequest {
1375
+ /** UserOperation to sponsor (without paymaster data) */
1376
+ userOp: Partial<UserOperation>;
1377
+ /** Chain ID */
1378
+ chainId: number;
1379
+ /** EntryPoint address */
1380
+ entryPoint: Address;
1381
+ /** Optional context for the paymaster */
1382
+ context?: Record<string, unknown>;
1383
+ }
1384
+ /**
1385
+ * Paymaster client for gas sponsorship
1386
+ */
1387
+ declare class PaymasterClient {
1388
+ private readonly config;
1389
+ constructor(config: PaymasterConfig);
1390
+ /**
1391
+ * Get paymaster data for a UserOperation
1392
+ */
1393
+ getPaymasterData(userOp: Partial<UserOperation>, chainId: number, entryPoint: Address, context?: Record<string, unknown>): Promise<PaymasterData>;
1394
+ /**
1395
+ * Get gas estimates including paymaster gas
1396
+ */
1397
+ estimatePaymasterGas(userOp: Partial<UserOperation>, _chainId: number): Promise<GasEstimate>;
1398
+ /**
1399
+ * Check if the paymaster will sponsor this operation
1400
+ */
1401
+ willSponsor(userOp: Partial<UserOperation>, chainId: number, entryPoint: Address, context?: Record<string, unknown>): Promise<boolean>;
1402
+ /**
1403
+ * Get verifying paymaster data (off-chain signature)
1404
+ */
1405
+ private getVerifyingPaymasterData;
1406
+ /**
1407
+ * Get sponsoring paymaster data (third-party pays)
1408
+ */
1409
+ private getSponsoringPaymasterData;
1410
+ /**
1411
+ * Get token paymaster data (pay gas with ERC20)
1412
+ */
1413
+ private getTokenPaymasterData;
1414
+ /**
1415
+ * Call paymaster service API
1416
+ */
1417
+ private callPaymasterService;
1418
+ /**
1419
+ * Serialize UserOperation for API calls
1420
+ */
1421
+ private serializeUserOp;
1422
+ }
1423
+ /**
1424
+ * Create a PaymasterClient instance
1425
+ */
1426
+ declare function createPaymasterClient(config: PaymasterConfig): PaymasterClient;
1427
+ /**
1428
+ * Encode paymaster data for inclusion in UserOperation
1429
+ */
1430
+ declare function encodePaymasterAndData(data: PaymasterData): Hex;
1431
+ /**
1432
+ * Decode paymaster and data from UserOperation
1433
+ */
1434
+ declare function decodePaymasterAndData(paymasterAndData: Hex): PaymasterData | null;
1435
+
1436
+ /**
1437
+ * ERC-4337 T402 Integration
1438
+ *
1439
+ * Integrates ERC-4337 Account Abstraction with T402 payment protocol.
1440
+ * Enables gasless payment execution via smart accounts and paymasters.
1441
+ */
1442
+
1443
+ /**
1444
+ * T402 payment parameters for ERC-4337
1445
+ */
1446
+ interface GaslessPaymentParams {
1447
+ /** Token contract address */
1448
+ tokenAddress: Address;
1449
+ /** Recipient address (resource server/facilitator) */
1450
+ to: Address;
1451
+ /** Amount to transfer */
1452
+ amount: bigint;
1453
+ /** Optional: Pre-signed authorization (for EIP-3009 tokens) */
1454
+ authorization?: {
1455
+ validAfter: bigint;
1456
+ validBefore: bigint;
1457
+ nonce: Hex;
1458
+ signature: Hex;
1459
+ };
1460
+ }
1461
+ /**
1462
+ * Gasless T402 client configuration
1463
+ */
1464
+ interface GaslessClientConfig {
1465
+ /** Smart account signer */
1466
+ signer: SmartAccountSigner;
1467
+ /** Bundler configuration */
1468
+ bundler: BundlerConfig;
1469
+ /** Optional paymaster for gas sponsorship */
1470
+ paymaster?: PaymasterConfig;
1471
+ /** Chain ID */
1472
+ chainId: number;
1473
+ /** Public client for chain interactions */
1474
+ publicClient: PublicClient;
1475
+ }
1476
+ /**
1477
+ * Gasless T402 client for executing payments via ERC-4337
1478
+ */
1479
+ declare class GaslessT402Client {
1480
+ private readonly signer;
1481
+ private readonly builder;
1482
+ private readonly bundler;
1483
+ private readonly paymaster?;
1484
+ private readonly chainId;
1485
+ private readonly publicClient;
1486
+ constructor(config: GaslessClientConfig);
1487
+ /**
1488
+ * Execute a T402 payment via ERC-4337
1489
+ *
1490
+ * This submits the payment as a UserOperation which can be:
1491
+ * - Sponsored by a paymaster (truly gasless)
1492
+ * - Paid from the smart account's balance
1493
+ */
1494
+ executePayment(params: GaslessPaymentParams): Promise<UserOperationResult>;
1495
+ /**
1496
+ * Execute multiple T402 payments in a single UserOperation
1497
+ */
1498
+ executeBatchPayments(payments: GaslessPaymentParams[]): Promise<UserOperationResult>;
1499
+ /**
1500
+ * Check if a payment can be sponsored (gasless)
1501
+ */
1502
+ canSponsor(params: GaslessPaymentParams): Promise<boolean>;
1503
+ /**
1504
+ * Get the smart account address
1505
+ */
1506
+ getAccountAddress(): Promise<Address>;
1507
+ /**
1508
+ * Check if the smart account is deployed
1509
+ */
1510
+ isAccountDeployed(): Promise<boolean>;
1511
+ /**
1512
+ * Build call data for a simple ERC20 transfer
1513
+ */
1514
+ private buildTransferCallData;
1515
+ /**
1516
+ * Build call data for an authorized transfer (EIP-3009)
1517
+ */
1518
+ private buildAuthorizedTransferCallData;
1519
+ /**
1520
+ * Estimate gas for a single transaction
1521
+ */
1522
+ private estimateGas;
1523
+ /**
1524
+ * Estimate gas for a batch transaction
1525
+ */
1526
+ private estimateBatchGas;
1527
+ /**
1528
+ * Get paymaster data if configured
1529
+ */
1530
+ private getPaymasterData;
1531
+ }
1532
+ /**
1533
+ * Create a GaslessT402Client instance
1534
+ */
1535
+ declare function createGaslessT402Client(config: GaslessClientConfig): GaslessT402Client;
1536
+
1537
+ export { ACCOUNT_ABI, BUNDLER_METHODS, type BridgeExecuteParams, type BridgeQuote, type BridgeQuoteParams, type BridgeResult, type BridgeSigner, type BridgeStatus, type BridgeTransaction, BundlerClient, type BundlerConfig, BundlerError, ClientEvmSigner, DEFAULT_GAS_LIMITS, ENTRYPOINT_V06_ADDRESS, ENTRYPOINT_V07_ABI, ENTRYPOINT_V07_ADDRESS, type ExactEvmPayloadV1, type ExactEvmPayloadV2, ExactLegacyEvmScheme$2 as ExactLegacyEvmClientScheme, ExactLegacyEvmScheme as ExactLegacyEvmFacilitatorScheme, type ExactLegacyEvmSchemeConfig as ExactLegacyEvmFacilitatorSchemeConfig, ExactLegacyEvmScheme$1 as ExactLegacyEvmServerScheme, type ExactLegacyEvmSchemeConfig$1 as ExactLegacyEvmServerSchemeConfig, type ExactLegacyPayload, FacilitatorEvmSigner, type GasEstimate, type GaslessClientConfig, type GaslessPaymentParams, GaslessT402Client, LAYERZERO_ENDPOINT_IDS, LAYERZERO_ENDPOINT_V2, type NetworkTokenRegistry, type PackedUserOperation, PaymasterClient, type PaymasterConfig, type PaymasterData, type PaymasterResponse, PaymasterType, type SmartAccountSigner, type SponsorRequest, TOKEN_PRIORITY, TOKEN_REGISTRY, type TokenConfig, type TokenType, type TransactionIntent, USDC_ADDRESSES, USDT0_ADDRESSES, USDT0_OFT_ADDRESSES, USDT_LEGACY_ADDRESSES, Usdt0Bridge, UserOpBuilder, type UserOpBuilderConfig, type UserOpBuilderOptions, type UserOperation, type UserOperationReceipt, type UserOperationResult, addressToBytes32, authorizationTypes, bytes32ToAddress, createBundlerClient, createGaslessT402Client, createPaymasterClient, createUsdt0Bridge, createUserOpBuilder, decodePaymasterAndData, eip3009ABI, encodePaymasterAndData, erc20LegacyABI, getBridgeableChains, getDefaultToken, getEIP712Domain, getEndpointId, getNetworkTokens, getNetworksForToken, getTokenByAddress, getTokenConfig, getUsdt0Networks, getUsdt0OftAddress, legacyAuthorizationTypes, packAccountGasLimits, packGasFees, supportsBridging, supportsEIP3009, unpackAccountGasLimits, unpackGasFees };