@pafi-dev/core 0.1.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 (104) hide show
  1. package/README.md +1157 -0
  2. package/dist/abi/index.cjs +31 -0
  3. package/dist/abi/index.cjs.map +1 -0
  4. package/dist/abi/index.d.cts +2479 -0
  5. package/dist/abi/index.d.ts +2479 -0
  6. package/dist/abi/index.js +31 -0
  7. package/dist/abi/index.js.map +1 -0
  8. package/dist/auth/index.cjs +11 -0
  9. package/dist/auth/index.cjs.map +1 -0
  10. package/dist/auth/index.d.cts +60 -0
  11. package/dist/auth/index.d.ts +60 -0
  12. package/dist/auth/index.js +11 -0
  13. package/dist/auth/index.js.map +1 -0
  14. package/dist/chunk-27V32VNM.cjs +370 -0
  15. package/dist/chunk-27V32VNM.cjs.map +1 -0
  16. package/dist/chunk-2PIXFXA2.js +135 -0
  17. package/dist/chunk-2PIXFXA2.js.map +1 -0
  18. package/dist/chunk-37BBGXTS.js +149 -0
  19. package/dist/chunk-37BBGXTS.js.map +1 -0
  20. package/dist/chunk-4QOWQQCH.cjs +99 -0
  21. package/dist/chunk-4QOWQQCH.cjs.map +1 -0
  22. package/dist/chunk-4RYBJLF3.js +370 -0
  23. package/dist/chunk-4RYBJLF3.js.map +1 -0
  24. package/dist/chunk-5QJZT7VB.cjs +46 -0
  25. package/dist/chunk-5QJZT7VB.cjs.map +1 -0
  26. package/dist/chunk-5YH4D7QF.js +467 -0
  27. package/dist/chunk-5YH4D7QF.js.map +1 -0
  28. package/dist/chunk-BNTVOKYT.cjs +101 -0
  29. package/dist/chunk-BNTVOKYT.cjs.map +1 -0
  30. package/dist/chunk-C4ZDYG4D.js +101 -0
  31. package/dist/chunk-C4ZDYG4D.js.map +1 -0
  32. package/dist/chunk-CAE2BVKI.cjs +136 -0
  33. package/dist/chunk-CAE2BVKI.cjs.map +1 -0
  34. package/dist/chunk-CL3QSI4O.cjs +65 -0
  35. package/dist/chunk-CL3QSI4O.cjs.map +1 -0
  36. package/dist/chunk-CWP4PFOP.cjs +72 -0
  37. package/dist/chunk-CWP4PFOP.cjs.map +1 -0
  38. package/dist/chunk-DSCUHT3F.js +99 -0
  39. package/dist/chunk-DSCUHT3F.js.map +1 -0
  40. package/dist/chunk-FGKLDKJK.cjs +467 -0
  41. package/dist/chunk-FGKLDKJK.cjs.map +1 -0
  42. package/dist/chunk-FIKTQR7H.js +136 -0
  43. package/dist/chunk-FIKTQR7H.js.map +1 -0
  44. package/dist/chunk-FXNG4G22.js +2041 -0
  45. package/dist/chunk-FXNG4G22.js.map +1 -0
  46. package/dist/chunk-GWLEEXM4.cjs +163 -0
  47. package/dist/chunk-GWLEEXM4.cjs.map +1 -0
  48. package/dist/chunk-IPXARZ6F.cjs +135 -0
  49. package/dist/chunk-IPXARZ6F.cjs.map +1 -0
  50. package/dist/chunk-KFWZRL7I.js +65 -0
  51. package/dist/chunk-KFWZRL7I.js.map +1 -0
  52. package/dist/chunk-KW6M5FXY.js +129 -0
  53. package/dist/chunk-KW6M5FXY.js.map +1 -0
  54. package/dist/chunk-MEREIEE4.cjs +129 -0
  55. package/dist/chunk-MEREIEE4.cjs.map +1 -0
  56. package/dist/chunk-O4SMTUOY.js +163 -0
  57. package/dist/chunk-O4SMTUOY.js.map +1 -0
  58. package/dist/chunk-O7LQKCBT.cjs +149 -0
  59. package/dist/chunk-O7LQKCBT.cjs.map +1 -0
  60. package/dist/chunk-P56TUGTS.js +46 -0
  61. package/dist/chunk-P56TUGTS.js.map +1 -0
  62. package/dist/chunk-R4L66ZR5.js +72 -0
  63. package/dist/chunk-R4L66ZR5.js.map +1 -0
  64. package/dist/chunk-S2XRFFP3.cjs +2041 -0
  65. package/dist/chunk-S2XRFFP3.cjs.map +1 -0
  66. package/dist/contract/index.cjs +27 -0
  67. package/dist/contract/index.cjs.map +1 -0
  68. package/dist/contract/index.d.cts +18 -0
  69. package/dist/contract/index.d.ts +18 -0
  70. package/dist/contract/index.js +27 -0
  71. package/dist/contract/index.js.map +1 -0
  72. package/dist/eip712/index.cjs +20 -0
  73. package/dist/eip712/index.cjs.map +1 -0
  74. package/dist/eip712/index.d.cts +83 -0
  75. package/dist/eip712/index.d.ts +83 -0
  76. package/dist/eip712/index.js +20 -0
  77. package/dist/eip712/index.js.map +1 -0
  78. package/dist/index.cjs +412 -0
  79. package/dist/index.cjs.map +1 -0
  80. package/dist/index.d.cts +239 -0
  81. package/dist/index.d.ts +239 -0
  82. package/dist/index.js +412 -0
  83. package/dist/index.js.map +1 -0
  84. package/dist/quoting/index.cjs +19 -0
  85. package/dist/quoting/index.cjs.map +1 -0
  86. package/dist/quoting/index.d.cts +59 -0
  87. package/dist/quoting/index.d.ts +59 -0
  88. package/dist/quoting/index.js +19 -0
  89. package/dist/quoting/index.js.map +1 -0
  90. package/dist/relay/index.cjs +19 -0
  91. package/dist/relay/index.cjs.map +1 -0
  92. package/dist/relay/index.d.cts +62 -0
  93. package/dist/relay/index.d.ts +62 -0
  94. package/dist/relay/index.js +19 -0
  95. package/dist/relay/index.js.map +1 -0
  96. package/dist/swap/index.cjs +29 -0
  97. package/dist/swap/index.cjs.map +1 -0
  98. package/dist/swap/index.d.cts +79 -0
  99. package/dist/swap/index.d.ts +79 -0
  100. package/dist/swap/index.js +29 -0
  101. package/dist/swap/index.js.map +1 -0
  102. package/dist/types-CkRJzrZr.d.cts +98 -0
  103. package/dist/types-CkRJzrZr.d.ts +98 -0
  104. package/package.json +114 -0
package/dist/index.js ADDED
@@ -0,0 +1,412 @@
1
+ import {
2
+ pointTokenFactoryAbi
3
+ } from "./chunk-5YH4D7QF.js";
4
+ import {
5
+ createLoginMessage,
6
+ parseLoginMessage,
7
+ verifyLoginMessage
8
+ } from "./chunk-O4SMTUOY.js";
9
+ import {
10
+ getIssuer,
11
+ getIssuer2,
12
+ getMintRequestNonce,
13
+ getPointTokenIssuer,
14
+ getReceiverConsentNonce,
15
+ getTokenName,
16
+ getUsdt,
17
+ isActiveIssuer,
18
+ isMinter,
19
+ verifyMintCap
20
+ } from "./chunk-KW6M5FXY.js";
21
+ import {
22
+ issuerRegistryAbi,
23
+ mintingOracleAbi,
24
+ pointTokenAbi
25
+ } from "./chunk-FXNG4G22.js";
26
+ import {
27
+ buildDomain,
28
+ buildMintRequestTypedData,
29
+ buildReceiverConsentTypedData,
30
+ signMintRequest,
31
+ signReceiverConsent,
32
+ verifyMintRequest,
33
+ verifyReceiverConsent
34
+ } from "./chunk-C4ZDYG4D.js";
35
+ import {
36
+ buildAllPaths,
37
+ combineRoutes,
38
+ findBestQuote,
39
+ quoteBestRoute,
40
+ quoteExactInput,
41
+ quoteExactInputSingle
42
+ } from "./chunk-FIKTQR7H.js";
43
+ import {
44
+ v4QuoterAbi
45
+ } from "./chunk-KFWZRL7I.js";
46
+ import {
47
+ COMMON_POOLS,
48
+ COMMON_TOKENS,
49
+ POINT_TOKEN_POOLS,
50
+ SUPPORTED_CHAINS,
51
+ UNIVERSAL_ROUTER_ADDRESSES,
52
+ V4_QUOTER_ADDRESSES,
53
+ mintRequestTypes,
54
+ receiverConsentTypes
55
+ } from "./chunk-R4L66ZR5.js";
56
+ import {
57
+ SETTLE_ALL,
58
+ SWAP_EXACT_IN,
59
+ TAKE_ALL,
60
+ V4_SWAP,
61
+ buildErc20ApprovalCalldata,
62
+ buildPermit2ApprovalCalldata,
63
+ buildSwapFromQuote,
64
+ buildUniversalRouterExecuteArgs,
65
+ buildV4SwapInput,
66
+ checkAllowance,
67
+ simulateSwap
68
+ } from "./chunk-37BBGXTS.js";
69
+ import {
70
+ erc20Abi,
71
+ permit2Abi,
72
+ universalRouterAbi
73
+ } from "./chunk-2PIXFXA2.js";
74
+ import {
75
+ buildRelaySwapParams,
76
+ decodeExtData,
77
+ decodeMintAndSwap,
78
+ encodeExtData,
79
+ encodeMintAndSwap,
80
+ simulateMintAndSwap
81
+ } from "./chunk-DSCUHT3F.js";
82
+ import {
83
+ relayAbi
84
+ } from "./chunk-4RYBJLF3.js";
85
+ import {
86
+ ApiError,
87
+ ConfigurationError,
88
+ PafiSDKError,
89
+ SigningError,
90
+ SimulationError
91
+ } from "./chunk-P56TUGTS.js";
92
+
93
+ // src/index.ts
94
+ import { createPublicClient, http } from "viem";
95
+ var PafiSDK = class {
96
+ _pointTokenAddress;
97
+ _relayContractAddress;
98
+ _signer;
99
+ _provider;
100
+ _chainId;
101
+ constructor(config) {
102
+ this._pointTokenAddress = config.pointTokenAddress;
103
+ this._relayContractAddress = config.relayContractAddress;
104
+ this._signer = config.signer;
105
+ this._chainId = config.chainId;
106
+ if (config.provider) {
107
+ this._provider = config.provider;
108
+ } else if (config.rpcUrl) {
109
+ this._provider = createPublicClient({
110
+ transport: http(config.rpcUrl)
111
+ });
112
+ }
113
+ }
114
+ // -------------------------------------------------------------------------
115
+ // Setters
116
+ // -------------------------------------------------------------------------
117
+ setPointTokenAddress(address) {
118
+ this._pointTokenAddress = address;
119
+ }
120
+ setRelayContractAddress(address) {
121
+ this._relayContractAddress = address;
122
+ }
123
+ setSigner(signer) {
124
+ this._signer = signer;
125
+ }
126
+ setProvider(provider) {
127
+ this._provider = provider;
128
+ }
129
+ // -------------------------------------------------------------------------
130
+ // Private guards
131
+ // -------------------------------------------------------------------------
132
+ requirePointToken() {
133
+ if (!this._pointTokenAddress) {
134
+ throw new ConfigurationError("pointTokenAddress not set");
135
+ }
136
+ return this._pointTokenAddress;
137
+ }
138
+ requireProvider() {
139
+ if (!this._provider) {
140
+ throw new ConfigurationError("provider not set");
141
+ }
142
+ return this._provider;
143
+ }
144
+ requireSigner() {
145
+ if (!this._signer) {
146
+ throw new ConfigurationError("signer not set");
147
+ }
148
+ return this._signer;
149
+ }
150
+ requireChainId() {
151
+ if (this._chainId === void 0) {
152
+ throw new ConfigurationError("chainId not set");
153
+ }
154
+ return this._chainId;
155
+ }
156
+ // -------------------------------------------------------------------------
157
+ // Domain
158
+ // -------------------------------------------------------------------------
159
+ async getDomain() {
160
+ const provider = this.requireProvider();
161
+ const pointToken = this.requirePointToken();
162
+ const chainId = this.requireChainId();
163
+ const name = await getTokenName(provider, pointToken);
164
+ return { name, verifyingContract: pointToken, chainId };
165
+ }
166
+ // -------------------------------------------------------------------------
167
+ // EIP-712 — delegates to pure functions
168
+ // -------------------------------------------------------------------------
169
+ /**
170
+ * Build the EIP-712 typed data for a MintRequest.
171
+ * Pass the result to any external signer (Privy, WalletConnect, etc.).
172
+ */
173
+ async buildMintRequestTypedData(message) {
174
+ const domain = await this.getDomain();
175
+ return buildMintRequestTypedData(domain, message);
176
+ }
177
+ /**
178
+ * Build the EIP-712 typed data for a ReceiverConsent.
179
+ * Pass the result to any external signer (Privy, WalletConnect, etc.).
180
+ */
181
+ async buildReceiverConsentTypedData(message) {
182
+ const domain = await this.getDomain();
183
+ return buildReceiverConsentTypedData(domain, message);
184
+ }
185
+ async signMintRequest(message) {
186
+ const domain = await this.getDomain();
187
+ return signMintRequest(this.requireSigner(), domain, message);
188
+ }
189
+ async verifyMintRequest(message, signature, expectedMinter) {
190
+ const domain = await this.getDomain();
191
+ return verifyMintRequest(domain, message, signature, expectedMinter);
192
+ }
193
+ async signReceiverConsent(message) {
194
+ const domain = await this.getDomain();
195
+ return signReceiverConsent(this.requireSigner(), domain, message);
196
+ }
197
+ async verifyReceiverConsent(message, signature, expectedReceiver) {
198
+ const domain = await this.getDomain();
199
+ return verifyReceiverConsent(domain, message, signature, expectedReceiver);
200
+ }
201
+ // -------------------------------------------------------------------------
202
+ // Contract reads
203
+ // -------------------------------------------------------------------------
204
+ async getMintRequestNonce(receiver) {
205
+ return getMintRequestNonce(
206
+ this.requireProvider(),
207
+ this.requirePointToken(),
208
+ receiver
209
+ );
210
+ }
211
+ async getReceiverConsentNonce(receiver) {
212
+ return getReceiverConsentNonce(
213
+ this.requireProvider(),
214
+ this.requirePointToken(),
215
+ receiver
216
+ );
217
+ }
218
+ // -------------------------------------------------------------------------
219
+ // Relay calldata — delegates to pure functions
220
+ // -------------------------------------------------------------------------
221
+ encodeMintAndSwap(mint, swap) {
222
+ return encodeMintAndSwap(mint, swap);
223
+ }
224
+ decodeMintAndSwap(calldata) {
225
+ return decodeMintAndSwap(calldata);
226
+ }
227
+ // -------------------------------------------------------------------------
228
+ // Quoting — delegates to pure functions
229
+ // -------------------------------------------------------------------------
230
+ /**
231
+ * Find the best swap route from `tokenIn` to `tokenOut`.
232
+ * Merges `pools` with COMMON_POOLS for the configured chain, builds all
233
+ * paths, and quotes via a single multicall RPC call.
234
+ */
235
+ async findBestQuote(tokenIn, tokenOut, exactAmount, pools = [], quoterAddress, maxHops) {
236
+ return findBestQuote(
237
+ this.requireProvider(),
238
+ this.requireChainId(),
239
+ tokenIn,
240
+ tokenOut,
241
+ exactAmount,
242
+ pools,
243
+ quoterAddress,
244
+ maxHops
245
+ );
246
+ }
247
+ // -------------------------------------------------------------------------
248
+ // Swap building — delegates to pure functions
249
+ // -------------------------------------------------------------------------
250
+ /**
251
+ * Build UniversalRouter execute args from a quote result.
252
+ * The caller provides `minAmountOut` after applying their own slippage.
253
+ */
254
+ buildSwapFromQuote(params) {
255
+ return buildSwapFromQuote(params);
256
+ }
257
+ /**
258
+ * Build Relay SwapParams + extData from a quote result.
259
+ * Returns ready-to-use args for `Relay.mintAndSwap`.
260
+ */
261
+ buildRelaySwapParams(params) {
262
+ return buildRelaySwapParams(params);
263
+ }
264
+ /**
265
+ * Encode extData for ReceiverConsent and MintParams.
266
+ * extData = abi.encode(minAmountOut, feeInUsdt)
267
+ */
268
+ encodeExtData(minAmountOut, feeInUsdt) {
269
+ return encodeExtData(minAmountOut, feeInUsdt);
270
+ }
271
+ // -------------------------------------------------------------------------
272
+ // Simulation — dry-run via eth_call (no gas spent)
273
+ // -------------------------------------------------------------------------
274
+ /**
275
+ * Simulate a Relay.mintAndSwap call. Catches reverts (bad signatures,
276
+ * expired deadlines, insufficient mint cap, pool errors) before submitting.
277
+ *
278
+ * @param relayAddress - Relay contract address
279
+ * @param mint - MintParams with real signatures
280
+ * @param swap - SwapParams (path + deadline)
281
+ * @param from - Relayer address that will submit the tx
282
+ */
283
+ async simulateMintAndSwap(relayAddress, mint, swap, from) {
284
+ return simulateMintAndSwap(
285
+ this.requireProvider(),
286
+ relayAddress,
287
+ mint,
288
+ swap,
289
+ from
290
+ );
291
+ }
292
+ /**
293
+ * Simulate a UniversalRouter.execute swap call. Catches reverts (bad
294
+ * approvals, insufficient balance, pool errors) before submitting.
295
+ *
296
+ * @param routerAddress - UniversalRouter contract address
297
+ * @param commands - Packed command bytes (from buildSwapFromQuote)
298
+ * @param inputs - Encoded inputs (from buildSwapFromQuote)
299
+ * @param deadline - Unix timestamp
300
+ * @param from - Address that will execute the swap
301
+ */
302
+ async simulateSwap(routerAddress, commands, inputs, deadline, from) {
303
+ return simulateSwap(
304
+ this.requireProvider(),
305
+ routerAddress,
306
+ commands,
307
+ inputs,
308
+ deadline,
309
+ from
310
+ );
311
+ }
312
+ // -------------------------------------------------------------------------
313
+ // Auth — EIP-4361 login helpers (offline, stateless)
314
+ //
315
+ // These are convenience wrappers around the pure functions in
316
+ // `./auth/loginMessage.ts`. They do NOT hit the network — the caller is
317
+ // responsible for fetching the nonce, POSTing the signed message, and
318
+ // storing the JWT returned by the issuer backend.
319
+ // -------------------------------------------------------------------------
320
+ /**
321
+ * Build an EIP-4361 login message for the current signer + chain. The
322
+ * caller supplies the issuer-specific fields (domain, nonce, uri); the SDK
323
+ * fills in the wallet address and chain id from its own config.
324
+ */
325
+ async createLoginMessage(params) {
326
+ const signer = this.requireSigner();
327
+ const chainId = this.requireChainId();
328
+ const account = signer.account;
329
+ if (!account) {
330
+ throw new ConfigurationError("signer has no account attached");
331
+ }
332
+ return createLoginMessage({ ...params, address: account.address, chainId });
333
+ }
334
+ /** Sign a login message string with the current signer (personal_sign) */
335
+ async signLoginMessage(message) {
336
+ const signer = this.requireSigner();
337
+ const account = signer.account;
338
+ if (!account) {
339
+ throw new ConfigurationError("signer has no account attached");
340
+ }
341
+ return signer.signMessage({ account, message });
342
+ }
343
+ };
344
+ export {
345
+ ApiError,
346
+ COMMON_POOLS,
347
+ COMMON_TOKENS,
348
+ ConfigurationError,
349
+ POINT_TOKEN_POOLS,
350
+ PafiSDK,
351
+ PafiSDKError,
352
+ SETTLE_ALL,
353
+ SUPPORTED_CHAINS,
354
+ SWAP_EXACT_IN,
355
+ SigningError,
356
+ SimulationError,
357
+ TAKE_ALL,
358
+ UNIVERSAL_ROUTER_ADDRESSES,
359
+ V4_QUOTER_ADDRESSES,
360
+ V4_SWAP,
361
+ buildAllPaths,
362
+ buildDomain,
363
+ buildErc20ApprovalCalldata,
364
+ buildMintRequestTypedData,
365
+ buildPermit2ApprovalCalldata,
366
+ buildReceiverConsentTypedData,
367
+ buildRelaySwapParams,
368
+ buildSwapFromQuote,
369
+ buildUniversalRouterExecuteArgs,
370
+ buildV4SwapInput,
371
+ checkAllowance,
372
+ combineRoutes,
373
+ createLoginMessage,
374
+ decodeExtData,
375
+ decodeMintAndSwap,
376
+ encodeExtData,
377
+ encodeMintAndSwap,
378
+ erc20Abi,
379
+ findBestQuote,
380
+ getIssuer2 as getIssuer,
381
+ getMintRequestNonce,
382
+ getPointTokenIssuer,
383
+ getIssuer as getPointTokenIssuerAddress,
384
+ getReceiverConsentNonce,
385
+ getTokenName,
386
+ getUsdt,
387
+ isActiveIssuer,
388
+ isMinter,
389
+ issuerRegistryAbi,
390
+ mintRequestTypes,
391
+ mintingOracleAbi,
392
+ parseLoginMessage,
393
+ permit2Abi,
394
+ pointTokenAbi,
395
+ pointTokenFactoryAbi,
396
+ quoteBestRoute,
397
+ quoteExactInput,
398
+ quoteExactInputSingle,
399
+ receiverConsentTypes,
400
+ relayAbi,
401
+ signMintRequest,
402
+ signReceiverConsent,
403
+ simulateMintAndSwap,
404
+ simulateSwap,
405
+ universalRouterAbi,
406
+ v4QuoterAbi,
407
+ verifyLoginMessage,
408
+ verifyMintCap,
409
+ verifyMintRequest,
410
+ verifyReceiverConsent
411
+ };
412
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createPublicClient, http } from \"viem\";\nimport type { Address, Hex, PublicClient, WalletClient } from \"viem\";\n\n// -------------------------------------------------------------------------\n// Re-export all sub-modules\n// -------------------------------------------------------------------------\nexport * from \"./types\";\nexport * from \"./constants\";\nexport * from \"./errors\";\nexport * from \"./abi/index\";\nexport * from \"./eip712/index\";\nexport * from \"./relay/index\";\nexport * from \"./contract/index\";\nexport * from \"./quoting/index\";\nexport * from \"./swap/index\";\nexport * from \"./auth/index\";\n\n// -------------------------------------------------------------------------\n// Internal imports for PafiSDK class\n// -------------------------------------------------------------------------\nimport { buildMintRequestTypedData, signMintRequest, verifyMintRequest } from \"./eip712/mintRequest\";\nimport {\n buildReceiverConsentTypedData,\n signReceiverConsent,\n verifyReceiverConsent,\n} from \"./eip712/receiverConsent\";\nimport {\n getMintRequestNonce,\n getReceiverConsentNonce,\n getTokenName,\n} from \"./contract/pointToken\";\nimport {\n encodeMintAndSwap,\n decodeMintAndSwap,\n encodeExtData,\n buildRelaySwapParams,\n} from \"./relay/calldata\";\nimport { findBestQuote } from \"./quoting/quote\";\nimport {\n buildSwapFromQuote,\n buildUniversalRouterExecuteArgs,\n} from \"./swap/universalRouter\";\nimport { simulateMintAndSwap } from \"./relay/simulate\";\nimport { simulateSwap } from \"./swap/simulate\";\nimport type { SimulationResult } from \"./relay/simulate\";\nimport type { SwapSimulationResult } from \"./swap/simulate\";\nimport { createLoginMessage } from \"./auth/loginMessage\";\nimport type { LoginMessageParams } from \"./auth/types\";\nimport { ConfigurationError } from \"./errors\";\nimport type {\n BestQuote,\n EIP712Signature,\n MintParams,\n MintRequest,\n PafiSDKConfig,\n PathKey,\n PointTokenDomainConfig,\n PoolKey,\n QuoteResult,\n ReceiverConsent,\n SignatureVerification,\n SwapParams,\n} from \"./types\";\n\n// -------------------------------------------------------------------------\n// PafiSDK — convenience class wrapping all contract + crypto primitives.\n//\n// This class is HTTP-client-free on purpose. It covers signing, verifying,\n// contract reads, and calldata encoding — the things that need a signer\n// or a provider but no HTTP layer. The issuer backend defines its own HTTP\n// contract via `@pafi/issuer`; frontends build `fetch()` calls against\n// those types directly.\n// -------------------------------------------------------------------------\n\nexport class PafiSDK {\n private _pointTokenAddress?: Address;\n private _relayContractAddress?: Address;\n private _signer?: WalletClient;\n private _provider?: PublicClient;\n private _chainId?: number;\n\n constructor(config: PafiSDKConfig) {\n this._pointTokenAddress = config.pointTokenAddress;\n this._relayContractAddress = config.relayContractAddress;\n this._signer = config.signer;\n this._chainId = config.chainId;\n\n if (config.provider) {\n this._provider = config.provider;\n } else if (config.rpcUrl) {\n this._provider = createPublicClient({\n transport: http(config.rpcUrl),\n });\n }\n }\n\n // -------------------------------------------------------------------------\n // Setters\n // -------------------------------------------------------------------------\n\n setPointTokenAddress(address: Address): void {\n this._pointTokenAddress = address;\n }\n\n setRelayContractAddress(address: Address): void {\n this._relayContractAddress = address;\n }\n\n setSigner(signer: WalletClient): void {\n this._signer = signer;\n }\n\n setProvider(provider: PublicClient): void {\n this._provider = provider;\n }\n\n // -------------------------------------------------------------------------\n // Private guards\n // -------------------------------------------------------------------------\n\n private requirePointToken(): Address {\n if (!this._pointTokenAddress) {\n throw new ConfigurationError(\"pointTokenAddress not set\");\n }\n return this._pointTokenAddress;\n }\n\n private requireProvider(): PublicClient {\n if (!this._provider) {\n throw new ConfigurationError(\"provider not set\");\n }\n return this._provider;\n }\n\n private requireSigner(): WalletClient {\n if (!this._signer) {\n throw new ConfigurationError(\"signer not set\");\n }\n return this._signer;\n }\n\n private requireChainId(): number {\n if (this._chainId === undefined) {\n throw new ConfigurationError(\"chainId not set\");\n }\n return this._chainId;\n }\n\n // -------------------------------------------------------------------------\n // Domain\n // -------------------------------------------------------------------------\n\n async getDomain(): Promise<PointTokenDomainConfig> {\n const provider = this.requireProvider();\n const pointToken = this.requirePointToken();\n const chainId = this.requireChainId();\n const name = await getTokenName(provider, pointToken);\n return { name, verifyingContract: pointToken, chainId };\n }\n\n // -------------------------------------------------------------------------\n // EIP-712 — delegates to pure functions\n // -------------------------------------------------------------------------\n\n /**\n * Build the EIP-712 typed data for a MintRequest.\n * Pass the result to any external signer (Privy, WalletConnect, etc.).\n */\n async buildMintRequestTypedData(message: MintRequest) {\n const domain = await this.getDomain();\n return buildMintRequestTypedData(domain, message);\n }\n\n /**\n * Build the EIP-712 typed data for a ReceiverConsent.\n * Pass the result to any external signer (Privy, WalletConnect, etc.).\n */\n async buildReceiverConsentTypedData(message: ReceiverConsent) {\n const domain = await this.getDomain();\n return buildReceiverConsentTypedData(domain, message);\n }\n\n async signMintRequest(message: MintRequest): Promise<EIP712Signature> {\n const domain = await this.getDomain();\n return signMintRequest(this.requireSigner(), domain, message);\n }\n\n async verifyMintRequest(\n message: MintRequest,\n signature: Hex,\n expectedMinter: Address,\n ): Promise<SignatureVerification> {\n const domain = await this.getDomain();\n return verifyMintRequest(domain, message, signature, expectedMinter);\n }\n\n async signReceiverConsent(\n message: ReceiverConsent,\n ): Promise<EIP712Signature> {\n const domain = await this.getDomain();\n return signReceiverConsent(this.requireSigner(), domain, message);\n }\n\n async verifyReceiverConsent(\n message: ReceiverConsent,\n signature: Hex,\n expectedReceiver: Address,\n ): Promise<SignatureVerification> {\n const domain = await this.getDomain();\n return verifyReceiverConsent(domain, message, signature, expectedReceiver);\n }\n\n // -------------------------------------------------------------------------\n // Contract reads\n // -------------------------------------------------------------------------\n\n async getMintRequestNonce(receiver: Address): Promise<bigint> {\n return getMintRequestNonce(\n this.requireProvider(),\n this.requirePointToken(),\n receiver,\n );\n }\n\n async getReceiverConsentNonce(receiver: Address): Promise<bigint> {\n return getReceiverConsentNonce(\n this.requireProvider(),\n this.requirePointToken(),\n receiver,\n );\n }\n\n // -------------------------------------------------------------------------\n // Relay calldata — delegates to pure functions\n // -------------------------------------------------------------------------\n\n encodeMintAndSwap(mint: MintParams, swap: SwapParams): Hex {\n return encodeMintAndSwap(mint, swap);\n }\n\n decodeMintAndSwap(calldata: Hex): { mint: MintParams; swap: SwapParams } {\n return decodeMintAndSwap(calldata);\n }\n\n // -------------------------------------------------------------------------\n // Quoting — delegates to pure functions\n // -------------------------------------------------------------------------\n\n /**\n * Find the best swap route from `tokenIn` to `tokenOut`.\n * Merges `pools` with COMMON_POOLS for the configured chain, builds all\n * paths, and quotes via a single multicall RPC call.\n */\n async findBestQuote(\n tokenIn: Address,\n tokenOut: Address,\n exactAmount: bigint,\n pools: PoolKey[] = [],\n quoterAddress?: Address,\n maxHops?: number,\n ): Promise<BestQuote> {\n return findBestQuote(\n this.requireProvider(),\n this.requireChainId(),\n tokenIn,\n tokenOut,\n exactAmount,\n pools,\n quoterAddress,\n maxHops,\n );\n }\n\n // -------------------------------------------------------------------------\n // Swap building — delegates to pure functions\n // -------------------------------------------------------------------------\n\n /**\n * Build UniversalRouter execute args from a quote result.\n * The caller provides `minAmountOut` after applying their own slippage.\n */\n buildSwapFromQuote(params: {\n quote: QuoteResult;\n currencyIn: Address;\n currencyOut: Address;\n amountIn: bigint;\n minAmountOut: bigint;\n }): { commands: Hex; inputs: Hex[] } {\n return buildSwapFromQuote(params);\n }\n\n /**\n * Build Relay SwapParams + extData from a quote result.\n * Returns ready-to-use args for `Relay.mintAndSwap`.\n */\n buildRelaySwapParams(params: {\n quote: { path: PathKey[] };\n minAmountOut: bigint;\n feeInUsdt: bigint;\n deadline: bigint;\n }): { swapParams: SwapParams; extData: Hex } {\n return buildRelaySwapParams(params);\n }\n\n /**\n * Encode extData for ReceiverConsent and MintParams.\n * extData = abi.encode(minAmountOut, feeInUsdt)\n */\n encodeExtData(minAmountOut: bigint, feeInUsdt: bigint): Hex {\n return encodeExtData(minAmountOut, feeInUsdt);\n }\n\n // -------------------------------------------------------------------------\n // Simulation — dry-run via eth_call (no gas spent)\n // -------------------------------------------------------------------------\n\n /**\n * Simulate a Relay.mintAndSwap call. Catches reverts (bad signatures,\n * expired deadlines, insufficient mint cap, pool errors) before submitting.\n *\n * @param relayAddress - Relay contract address\n * @param mint - MintParams with real signatures\n * @param swap - SwapParams (path + deadline)\n * @param from - Relayer address that will submit the tx\n */\n async simulateMintAndSwap(\n relayAddress: Address,\n mint: MintParams,\n swap: SwapParams,\n from: Address,\n ): Promise<SimulationResult> {\n return simulateMintAndSwap(\n this.requireProvider(),\n relayAddress,\n mint,\n swap,\n from,\n );\n }\n\n /**\n * Simulate a UniversalRouter.execute swap call. Catches reverts (bad\n * approvals, insufficient balance, pool errors) before submitting.\n *\n * @param routerAddress - UniversalRouter contract address\n * @param commands - Packed command bytes (from buildSwapFromQuote)\n * @param inputs - Encoded inputs (from buildSwapFromQuote)\n * @param deadline - Unix timestamp\n * @param from - Address that will execute the swap\n */\n async simulateSwap(\n routerAddress: Address,\n commands: Hex,\n inputs: Hex[],\n deadline: bigint,\n from: Address,\n ): Promise<SwapSimulationResult> {\n return simulateSwap(\n this.requireProvider(),\n routerAddress,\n commands,\n inputs,\n deadline,\n from,\n );\n }\n\n // -------------------------------------------------------------------------\n // Auth — EIP-4361 login helpers (offline, stateless)\n //\n // These are convenience wrappers around the pure functions in\n // `./auth/loginMessage.ts`. They do NOT hit the network — the caller is\n // responsible for fetching the nonce, POSTing the signed message, and\n // storing the JWT returned by the issuer backend.\n // -------------------------------------------------------------------------\n\n /**\n * Build an EIP-4361 login message for the current signer + chain. The\n * caller supplies the issuer-specific fields (domain, nonce, uri); the SDK\n * fills in the wallet address and chain id from its own config.\n */\n async createLoginMessage(\n params: Omit<LoginMessageParams, \"address\" | \"chainId\">,\n ): Promise<string> {\n const signer = this.requireSigner();\n const chainId = this.requireChainId();\n const account = signer.account;\n if (!account) {\n throw new ConfigurationError(\"signer has no account attached\");\n }\n return createLoginMessage({ ...params, address: account.address, chainId });\n }\n\n /** Sign a login message string with the current signer (personal_sign) */\n async signLoginMessage(message: string): Promise<Hex> {\n const signer = this.requireSigner();\n const account = signer.account;\n if (!account) {\n throw new ConfigurationError(\"signer has no account attached\");\n }\n return signer.signMessage({ account, message });\n }\n}\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;AAAA;AAAA,EAYA,MAAM,aACJ,eACA,UACA,QACA,UACA,MAC+B;AAC/B,WAAO;AAAA,MACL,KAAK,gBAAgB;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,MAAM,mBACJ,QACiB;AACjB,UAAM,SAAS,KAAK,cAAc;AAClC,UAAM,UAAU,KAAK,eAAe;AACpC,UAAM,UAAU,OAAO;AACvB,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,mBAAmB,gCAAgC;AAAA,IAC/D;AACA,WAAO,mBAAmB,EAAE,GAAG,QAAQ,SAAS,QAAQ,SAAS,QAAQ,CAAC;AAAA,EAC5E;AAAA;AAAA,EAGA,MAAM,iBAAiB,SAA+B;AACpD,UAAM,SAAS,KAAK,cAAc;AAClC,UAAM,UAAU,OAAO;AACvB,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,mBAAmB,gCAAgC;AAAA,IAC/D;AACA,WAAO,OAAO,YAAY,EAAE,SAAS,QAAQ,CAAC;AAAA,EAChD;AACF;","names":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+ var _chunkCAE2BVKIcjs = require('../chunk-CAE2BVKI.cjs');
9
+ require('../chunk-CL3QSI4O.cjs');
10
+ require('../chunk-CWP4PFOP.cjs');
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ exports.buildAllPaths = _chunkCAE2BVKIcjs.buildAllPaths; exports.combineRoutes = _chunkCAE2BVKIcjs.combineRoutes; exports.findBestQuote = _chunkCAE2BVKIcjs.findBestQuote; exports.quoteBestRoute = _chunkCAE2BVKIcjs.quoteBestRoute; exports.quoteExactInput = _chunkCAE2BVKIcjs.quoteExactInput; exports.quoteExactInputSingle = _chunkCAE2BVKIcjs.quoteExactInputSingle;
19
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/quoting/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,2WAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/quoting/index.cjs"}
@@ -0,0 +1,59 @@
1
+ import { Address, PublicClient } from 'viem';
2
+ import { P as PoolKey, e as PathKey, B as BestQuote, Q as QuoteResult } from '../types-CkRJzrZr.cjs';
3
+
4
+ /**
5
+ * Combine point-token-specific pools and common pools for a given chain.
6
+ * Point token pools are listed first so callers can prioritise them.
7
+ */
8
+ declare function combineRoutes(chainId: number, pointTokenAddress: Address): PoolKey[];
9
+ /**
10
+ * Build all possible swap paths from `tokenIn` to `tokenOut` using the given
11
+ * pools. Returns an array of PathKey[] routes (each up to `maxHops` hops).
12
+ *
13
+ * Supports both direct single-hop routes and multi-hop routes through
14
+ * intermediate tokens. Each pool is used at most once per path.
15
+ *
16
+ * @param pools - Available pools to route through
17
+ * @param tokenIn - Input token address
18
+ * @param tokenOut - Desired output token address
19
+ * @param maxHops - Maximum number of hops (default 3)
20
+ */
21
+ declare function buildAllPaths(pools: PoolKey[], tokenIn: Address, tokenOut: Address, maxHops?: number): PathKey[][];
22
+
23
+ /**
24
+ * Quote exact-input for a multi-hop path.
25
+ */
26
+ declare function quoteExactInput(client: PublicClient, quoterAddress: Address, exactCurrency: Address, path: PathKey[], exactAmount: bigint): Promise<QuoteResult>;
27
+ /**
28
+ * Quote exact-input for a single-hop swap, given an explicit PoolKey and direction.
29
+ */
30
+ declare function quoteExactInputSingle(client: PublicClient, quoterAddress: Address, poolKey: PoolKey, zeroForOne: boolean, exactAmount: bigint, hookData: `0x${string}`): Promise<{
31
+ amountOut: bigint;
32
+ gasEstimate: bigint;
33
+ }>;
34
+ /**
35
+ * Try multiple PathKey[] routes and return the best quote plus all results.
36
+ * Routes that fail (e.g. pool does not exist) are silently skipped.
37
+ *
38
+ * Uses viem multicall to batch all quotes into a single RPC call for speed.
39
+ */
40
+ declare function quoteBestRoute(client: PublicClient, quoterAddress: Address, exactCurrency: Address, routes: PathKey[][], exactAmount: bigint): Promise<BestQuote>;
41
+ /**
42
+ * Find and quote the best swap route from `tokenIn` to `tokenOut`.
43
+ *
44
+ * Combines the caller's `pools` with `COMMON_POOLS[chainId]`, builds all
45
+ * possible paths (up to `maxHops`), then quotes them all via a single
46
+ * multicall and returns the best result.
47
+ *
48
+ * @param client - viem PublicClient
49
+ * @param chainId - Chain ID (used to look up COMMON_POOLS and V4_QUOTER_ADDRESSES)
50
+ * @param tokenIn - Input token address
51
+ * @param tokenOut - Desired output token address
52
+ * @param exactAmount - Exact input amount
53
+ * @param pools - Additional pools to consider (e.g. point-token-specific)
54
+ * @param quoterAddress - Override the default V4 Quoter address for this chain
55
+ * @param maxHops - Maximum number of hops per path (default 3)
56
+ */
57
+ declare function findBestQuote(client: PublicClient, chainId: number, tokenIn: Address, tokenOut: Address, exactAmount: bigint, pools?: PoolKey[], quoterAddress?: Address, maxHops?: number): Promise<BestQuote>;
58
+
59
+ export { buildAllPaths, combineRoutes, findBestQuote, quoteBestRoute, quoteExactInput, quoteExactInputSingle };
@@ -0,0 +1,59 @@
1
+ import { Address, PublicClient } from 'viem';
2
+ import { P as PoolKey, e as PathKey, B as BestQuote, Q as QuoteResult } from '../types-CkRJzrZr.js';
3
+
4
+ /**
5
+ * Combine point-token-specific pools and common pools for a given chain.
6
+ * Point token pools are listed first so callers can prioritise them.
7
+ */
8
+ declare function combineRoutes(chainId: number, pointTokenAddress: Address): PoolKey[];
9
+ /**
10
+ * Build all possible swap paths from `tokenIn` to `tokenOut` using the given
11
+ * pools. Returns an array of PathKey[] routes (each up to `maxHops` hops).
12
+ *
13
+ * Supports both direct single-hop routes and multi-hop routes through
14
+ * intermediate tokens. Each pool is used at most once per path.
15
+ *
16
+ * @param pools - Available pools to route through
17
+ * @param tokenIn - Input token address
18
+ * @param tokenOut - Desired output token address
19
+ * @param maxHops - Maximum number of hops (default 3)
20
+ */
21
+ declare function buildAllPaths(pools: PoolKey[], tokenIn: Address, tokenOut: Address, maxHops?: number): PathKey[][];
22
+
23
+ /**
24
+ * Quote exact-input for a multi-hop path.
25
+ */
26
+ declare function quoteExactInput(client: PublicClient, quoterAddress: Address, exactCurrency: Address, path: PathKey[], exactAmount: bigint): Promise<QuoteResult>;
27
+ /**
28
+ * Quote exact-input for a single-hop swap, given an explicit PoolKey and direction.
29
+ */
30
+ declare function quoteExactInputSingle(client: PublicClient, quoterAddress: Address, poolKey: PoolKey, zeroForOne: boolean, exactAmount: bigint, hookData: `0x${string}`): Promise<{
31
+ amountOut: bigint;
32
+ gasEstimate: bigint;
33
+ }>;
34
+ /**
35
+ * Try multiple PathKey[] routes and return the best quote plus all results.
36
+ * Routes that fail (e.g. pool does not exist) are silently skipped.
37
+ *
38
+ * Uses viem multicall to batch all quotes into a single RPC call for speed.
39
+ */
40
+ declare function quoteBestRoute(client: PublicClient, quoterAddress: Address, exactCurrency: Address, routes: PathKey[][], exactAmount: bigint): Promise<BestQuote>;
41
+ /**
42
+ * Find and quote the best swap route from `tokenIn` to `tokenOut`.
43
+ *
44
+ * Combines the caller's `pools` with `COMMON_POOLS[chainId]`, builds all
45
+ * possible paths (up to `maxHops`), then quotes them all via a single
46
+ * multicall and returns the best result.
47
+ *
48
+ * @param client - viem PublicClient
49
+ * @param chainId - Chain ID (used to look up COMMON_POOLS and V4_QUOTER_ADDRESSES)
50
+ * @param tokenIn - Input token address
51
+ * @param tokenOut - Desired output token address
52
+ * @param exactAmount - Exact input amount
53
+ * @param pools - Additional pools to consider (e.g. point-token-specific)
54
+ * @param quoterAddress - Override the default V4 Quoter address for this chain
55
+ * @param maxHops - Maximum number of hops per path (default 3)
56
+ */
57
+ declare function findBestQuote(client: PublicClient, chainId: number, tokenIn: Address, tokenOut: Address, exactAmount: bigint, pools?: PoolKey[], quoterAddress?: Address, maxHops?: number): Promise<BestQuote>;
58
+
59
+ export { buildAllPaths, combineRoutes, findBestQuote, quoteBestRoute, quoteExactInput, quoteExactInputSingle };
@@ -0,0 +1,19 @@
1
+ import {
2
+ buildAllPaths,
3
+ combineRoutes,
4
+ findBestQuote,
5
+ quoteBestRoute,
6
+ quoteExactInput,
7
+ quoteExactInputSingle
8
+ } from "../chunk-FIKTQR7H.js";
9
+ import "../chunk-KFWZRL7I.js";
10
+ import "../chunk-R4L66ZR5.js";
11
+ export {
12
+ buildAllPaths,
13
+ combineRoutes,
14
+ findBestQuote,
15
+ quoteBestRoute,
16
+ quoteExactInput,
17
+ quoteExactInputSingle
18
+ };
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+ var _chunk4QOWQQCHcjs = require('../chunk-4QOWQQCH.cjs');
9
+ require('../chunk-27V32VNM.cjs');
10
+ require('../chunk-5QJZT7VB.cjs');
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ exports.buildRelaySwapParams = _chunk4QOWQQCHcjs.buildRelaySwapParams; exports.decodeExtData = _chunk4QOWQQCHcjs.decodeExtData; exports.decodeMintAndSwap = _chunk4QOWQQCHcjs.decodeMintAndSwap; exports.encodeExtData = _chunk4QOWQQCHcjs.encodeExtData; exports.encodeMintAndSwap = _chunk4QOWQQCHcjs.encodeMintAndSwap; exports.simulateMintAndSwap = _chunk4QOWQQCHcjs.simulateMintAndSwap;
19
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/relay/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,+XAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/relay/index.cjs"}