@pafi-dev/core 0.3.0-beta.1 → 0.3.0-beta.10

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 (85) hide show
  1. package/dist/abi/index.cjs +2 -6
  2. package/dist/abi/index.cjs.map +1 -1
  3. package/dist/abi/index.d.cts +1 -286
  4. package/dist/abi/index.d.ts +1 -286
  5. package/dist/abi/index.js +1 -5
  6. package/dist/{chunk-R4L66ZR5.js → chunk-73CQTNLB.js} +10 -1
  7. package/dist/chunk-73CQTNLB.js.map +1 -0
  8. package/dist/{chunk-5YH4D7QF.js → chunk-7UBO7DY5.js} +1 -1
  9. package/dist/{chunk-FGKLDKJK.cjs → chunk-ALCWYDVG.cjs} +1 -1
  10. package/dist/{chunk-FGKLDKJK.cjs.map → chunk-ALCWYDVG.cjs.map} +1 -1
  11. package/dist/{chunk-X3I5XWAR.cjs → chunk-CQCSQPWG.cjs} +2 -15
  12. package/dist/chunk-CQCSQPWG.cjs.map +1 -0
  13. package/dist/{chunk-CWP4PFOP.cjs → chunk-DMW67WBU.cjs} +11 -2
  14. package/dist/chunk-DMW67WBU.cjs.map +1 -0
  15. package/dist/{chunk-C4ZDYG4D.js → chunk-DUY7Z2AI.js} +48 -6
  16. package/dist/chunk-DUY7Z2AI.js.map +1 -0
  17. package/dist/{chunk-CXFUP2YK.cjs → chunk-EDR5SFJN.cjs} +46 -6
  18. package/dist/chunk-EDR5SFJN.cjs.map +1 -0
  19. package/dist/{chunk-FIKTQR7H.js → chunk-I2P3TIP7.js} +2 -2
  20. package/dist/{chunk-BNTVOKYT.cjs → chunk-KJKDLD7N.cjs} +51 -9
  21. package/dist/chunk-KJKDLD7N.cjs.map +1 -0
  22. package/dist/{chunk-VQSRCMMK.js → chunk-QGO6X6LG.js} +2 -15
  23. package/dist/chunk-QGO6X6LG.js.map +1 -0
  24. package/dist/{chunk-IK4UK7KT.js → chunk-W23EJNYG.js} +44 -4
  25. package/dist/chunk-W23EJNYG.js.map +1 -0
  26. package/dist/{chunk-CAE2BVKI.cjs → chunk-Z2V525IS.cjs} +6 -6
  27. package/dist/{chunk-CAE2BVKI.cjs.map → chunk-Z2V525IS.cjs.map} +1 -1
  28. package/dist/contract/index.cjs +2 -5
  29. package/dist/contract/index.cjs.map +1 -1
  30. package/dist/contract/index.d.cts +2 -4
  31. package/dist/contract/index.d.ts +2 -4
  32. package/dist/contract/index.js +1 -4
  33. package/dist/eip712/index.cjs +9 -3
  34. package/dist/eip712/index.cjs.map +1 -1
  35. package/dist/eip712/index.d.cts +44 -2
  36. package/dist/eip712/index.d.ts +44 -2
  37. package/dist/eip712/index.js +8 -2
  38. package/dist/{index-CNALKsH1.d.ts → index-B06IJlHe.d.ts} +1 -1
  39. package/dist/{index-BpUYHGu3.d.cts → index-B7pGBych.d.cts} +1 -1
  40. package/dist/index.cjs +363 -248
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +813 -426
  43. package/dist/index.d.ts +813 -426
  44. package/dist/index.js +375 -260
  45. package/dist/index.js.map +1 -1
  46. package/dist/quoting/index.cjs +3 -3
  47. package/dist/quoting/index.d.cts +1 -1
  48. package/dist/quoting/index.d.ts +1 -1
  49. package/dist/quoting/index.js +2 -2
  50. package/dist/swap/index.cjs +2 -3
  51. package/dist/swap/index.cjs.map +1 -1
  52. package/dist/swap/index.d.cts +2 -2
  53. package/dist/swap/index.d.ts +2 -2
  54. package/dist/swap/index.js +1 -2
  55. package/dist/{types-BDOnH5Le.d.cts → types-b5_Tokjl.d.cts} +8 -17
  56. package/dist/{types-BDOnH5Le.d.ts → types-b5_Tokjl.d.ts} +8 -17
  57. package/package.json +1 -1
  58. package/dist/chunk-27V32VNM.cjs +0 -370
  59. package/dist/chunk-27V32VNM.cjs.map +0 -1
  60. package/dist/chunk-4RYBJLF3.js +0 -370
  61. package/dist/chunk-4RYBJLF3.js.map +0 -1
  62. package/dist/chunk-5QJZT7VB.cjs +0 -46
  63. package/dist/chunk-5QJZT7VB.cjs.map +0 -1
  64. package/dist/chunk-BNTVOKYT.cjs.map +0 -1
  65. package/dist/chunk-C4ZDYG4D.js.map +0 -1
  66. package/dist/chunk-CWP4PFOP.cjs.map +0 -1
  67. package/dist/chunk-CXFUP2YK.cjs.map +0 -1
  68. package/dist/chunk-IK4UK7KT.js.map +0 -1
  69. package/dist/chunk-L74CZAVQ.cjs +0 -99
  70. package/dist/chunk-L74CZAVQ.cjs.map +0 -1
  71. package/dist/chunk-P56TUGTS.js +0 -46
  72. package/dist/chunk-P56TUGTS.js.map +0 -1
  73. package/dist/chunk-R4L66ZR5.js.map +0 -1
  74. package/dist/chunk-VQSRCMMK.js.map +0 -1
  75. package/dist/chunk-X3I5XWAR.cjs.map +0 -1
  76. package/dist/chunk-X4IXUTTD.js +0 -99
  77. package/dist/chunk-X4IXUTTD.js.map +0 -1
  78. package/dist/relay/index.cjs +0 -19
  79. package/dist/relay/index.cjs.map +0 -1
  80. package/dist/relay/index.d.cts +0 -75
  81. package/dist/relay/index.d.ts +0 -75
  82. package/dist/relay/index.js +0 -19
  83. package/dist/relay/index.js.map +0 -1
  84. /package/dist/{chunk-5YH4D7QF.js.map → chunk-7UBO7DY5.js.map} +0 -0
  85. /package/dist/{chunk-FIKTQR7H.js.map → chunk-I2P3TIP7.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pointTokenFactoryAbi
3
- } from "./chunk-5YH4D7QF.js";
3
+ } from "./chunk-7UBO7DY5.js";
4
4
  import {
5
5
  createLoginMessage,
6
6
  parseLoginMessage,
@@ -14,25 +14,27 @@ import {
14
14
  getPointTokenIssuer,
15
15
  getReceiverConsentNonce,
16
16
  getTokenName,
17
- getUsdt,
18
17
  isActiveIssuer,
19
18
  isMinter,
20
19
  verifyMintCap
21
- } from "./chunk-VQSRCMMK.js";
20
+ } from "./chunk-QGO6X6LG.js";
22
21
  import {
23
22
  issuerRegistryAbi,
24
23
  mintingOracleAbi,
25
24
  pointTokenAbi
26
25
  } from "./chunk-FXNG4G22.js";
27
26
  import {
27
+ buildBurnRequestTypedData,
28
28
  buildDomain,
29
29
  buildMintRequestTypedData,
30
30
  buildReceiverConsentTypedData,
31
+ signBurnRequest,
31
32
  signMintRequest,
32
33
  signReceiverConsent,
34
+ verifyBurnRequest,
33
35
  verifyMintRequest,
34
36
  verifyReceiverConsent
35
- } from "./chunk-C4ZDYG4D.js";
37
+ } from "./chunk-DUY7Z2AI.js";
36
38
  import {
37
39
  buildAllPaths,
38
40
  combineRoutes,
@@ -40,7 +42,7 @@ import {
40
42
  quoteBestRoute,
41
43
  quoteExactInput,
42
44
  quoteExactInputSingle
43
- } from "./chunk-FIKTQR7H.js";
45
+ } from "./chunk-I2P3TIP7.js";
44
46
  import {
45
47
  v4QuoterAbi
46
48
  } from "./chunk-KFWZRL7I.js";
@@ -51,24 +53,19 @@ import {
51
53
  SUPPORTED_CHAINS,
52
54
  UNIVERSAL_ROUTER_ADDRESSES,
53
55
  V4_QUOTER_ADDRESSES,
56
+ burnRequestTypes,
54
57
  mintRequestTypes,
55
58
  receiverConsentTypes
56
- } from "./chunk-R4L66ZR5.js";
57
- import {
58
- buildRelaySwapParams,
59
- decodeExtData,
60
- decodeMintAndSwap,
61
- encodeExtData,
62
- encodeMintAndSwap,
63
- simulateMintAndSwap
64
- } from "./chunk-X4IXUTTD.js";
65
- import {
66
- relayAbi
67
- } from "./chunk-4RYBJLF3.js";
59
+ } from "./chunk-73CQTNLB.js";
68
60
  import {
61
+ ApiError,
69
62
  BATCH_EXECUTOR_ABI,
63
+ ConfigurationError,
64
+ PafiSDKError,
70
65
  SETTLE_ALL,
71
66
  SWAP_EXACT_IN,
67
+ SigningError,
68
+ SimulationError,
72
69
  TAKE_ALL,
73
70
  V4_SWAP,
74
71
  assembleUserOperation,
@@ -86,23 +83,156 @@ import {
86
83
  erc20TransferOp,
87
84
  rawCallOp,
88
85
  simulateSwap
89
- } from "./chunk-IK4UK7KT.js";
86
+ } from "./chunk-W23EJNYG.js";
90
87
  import {
91
88
  erc20Abi,
92
89
  permit2Abi,
93
90
  universalRouterAbi
94
91
  } from "./chunk-2PIXFXA2.js";
95
- import {
96
- ApiError,
97
- ConfigurationError,
98
- PafiSDKError,
99
- SigningError,
100
- SimulationError
101
- } from "./chunk-P56TUGTS.js";
102
92
 
103
93
  // src/index.ts
104
94
  import { createPublicClient, http } from "viem";
105
95
 
96
+ // src/perp/buildPerpDepositWithGasDeduction.ts
97
+ import { encodeFunctionData } from "viem";
98
+
99
+ // src/contracts/real/orderlyVault.ts
100
+ import { keccak256, encodePacked, encodeAbiParameters } from "viem";
101
+ var ORDERLY_VAULT_BASE_MAINNET = "0xDe5cE5DD048596e46Ff671b13317aCC3C5B59b01";
102
+ var ORDERLY_VAULT_ADDRESSES = {
103
+ 8453: ORDERLY_VAULT_BASE_MAINNET
104
+ };
105
+ var BROKER_HASHES = {
106
+ /** Default partner broker on Base — most commonly whitelisted. */
107
+ woofi_pro: keccak256(encodePacked(["string"], ["woofi_pro"])),
108
+ /** Orderly's own white-label broker. */
109
+ orderly: keccak256(encodePacked(["string"], ["orderly"])),
110
+ /** LogX. */
111
+ logx: keccak256(encodePacked(["string"], ["logx"]))
112
+ };
113
+ var TOKEN_HASHES = {
114
+ USDC: keccak256(encodePacked(["string"], ["USDC"]))
115
+ };
116
+ function computeAccountId(user, brokerHash) {
117
+ return keccak256(
118
+ encodeAbiParameters(
119
+ [
120
+ { type: "address" },
121
+ { type: "bytes32" }
122
+ ],
123
+ [user, brokerHash]
124
+ )
125
+ );
126
+ }
127
+ var ORDERLY_VAULT_ABI = [
128
+ // Deposit USDC into Orderly perp account. Emits LayerZero message
129
+ // to the Orderly chain. `msg.value` MUST equal `getDepositFee(...)`.
130
+ {
131
+ type: "function",
132
+ name: "deposit",
133
+ stateMutability: "payable",
134
+ inputs: [
135
+ {
136
+ name: "data",
137
+ type: "tuple",
138
+ components: [
139
+ { name: "accountId", type: "bytes32" },
140
+ { name: "brokerHash", type: "bytes32" },
141
+ { name: "tokenHash", type: "bytes32" },
142
+ { name: "tokenAmount", type: "uint128" }
143
+ ]
144
+ }
145
+ ],
146
+ outputs: []
147
+ },
148
+ // Quote the LayerZero fee for a deposit message. Pass the same
149
+ // VaultDepositFE struct you intend to send.
150
+ {
151
+ type: "function",
152
+ name: "getDepositFee",
153
+ stateMutability: "view",
154
+ inputs: [
155
+ { name: "user", type: "address" },
156
+ {
157
+ name: "data",
158
+ type: "tuple",
159
+ components: [
160
+ { name: "accountId", type: "bytes32" },
161
+ { name: "brokerHash", type: "bytes32" },
162
+ { name: "tokenHash", type: "bytes32" },
163
+ { name: "tokenAmount", type: "uint128" }
164
+ ]
165
+ }
166
+ ],
167
+ outputs: [{ name: "", type: "uint256" }]
168
+ },
169
+ // Pre-flight check — is this brokerId whitelisted on this Vault?
170
+ {
171
+ type: "function",
172
+ name: "getAllowedBroker",
173
+ stateMutability: "view",
174
+ inputs: [{ name: "brokerHash", type: "bytes32" }],
175
+ outputs: [{ name: "", type: "bool" }]
176
+ },
177
+ // Pre-flight check — what ERC-20 address does this token symbol
178
+ // resolve to on this Vault?
179
+ {
180
+ type: "function",
181
+ name: "getAllowedToken",
182
+ stateMutability: "view",
183
+ inputs: [{ name: "tokenHash", type: "bytes32" }],
184
+ outputs: [{ name: "", type: "address" }]
185
+ }
186
+ ];
187
+
188
+ // src/perp/buildPerpDepositWithGasDeduction.ts
189
+ function buildPerpDepositWithGasDeduction(params) {
190
+ if (params.amount <= 0n) {
191
+ throw new Error("buildPerpDepositWithGasDeduction: amount must be positive");
192
+ }
193
+ if (params.layerZeroFee < 0n) {
194
+ throw new Error(
195
+ "buildPerpDepositWithGasDeduction: layerZeroFee cannot be negative"
196
+ );
197
+ }
198
+ if (params.depositData.tokenAmount !== params.amount) {
199
+ throw new Error(
200
+ `buildPerpDepositWithGasDeduction: depositData.tokenAmount (${params.depositData.tokenAmount}) must equal amount (${params.amount})`
201
+ );
202
+ }
203
+ const vault = params.vaultAddress ?? ORDERLY_VAULT_ADDRESSES[params.chainId];
204
+ if (!vault) {
205
+ throw new Error(
206
+ `buildPerpDepositWithGasDeduction: no Orderly Vault address for chainId ${params.chainId}`
207
+ );
208
+ }
209
+ const depositCallData = encodeFunctionData({
210
+ abi: ORDERLY_VAULT_ABI,
211
+ functionName: "deposit",
212
+ args: [params.depositData]
213
+ });
214
+ const operations = [
215
+ erc20ApproveOp(params.usdcAddress, vault, params.amount),
216
+ {
217
+ ...rawCallOp(vault, depositCallData),
218
+ // BatchExecutor passes `value` from the inner call along; this
219
+ // becomes the LayerZero fee. The aggregated `msg.value` for the
220
+ // top-level UserOp must equal the sum of inner `value`s.
221
+ value: params.layerZeroFee
222
+ }
223
+ ];
224
+ return buildPartialUserOperation({
225
+ sender: params.userAddress,
226
+ nonce: params.aaNonce,
227
+ operations,
228
+ gasLimits: {
229
+ callGasLimit: params.gasLimits?.callGasLimit ?? 800000n,
230
+ verificationGasLimit: params.gasLimits?.verificationGasLimit ?? 150000n,
231
+ preVerificationGas: params.gasLimits?.preVerificationGas ?? 50000n
232
+ }
233
+ });
234
+ }
235
+
106
236
  // src/userop/types.ts
107
237
  var ENTRY_POINT_V07 = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
108
238
  var ZERO_VALUE = 0n;
@@ -150,186 +280,233 @@ async function checkEthAndBranch(params) {
150
280
  return balance >= required ? "normal" : "paymaster";
151
281
  }
152
282
 
153
- // src/contracts/mocks/relayerV2.mock.ts
283
+ // src/contracts/real/pointToken.ts
154
284
  import { parseAbi } from "viem";
155
- var MOCK_RELAYER_V2_ABI = parseAbi([
156
- "function mint((address to, uint256 amount, uint256 feeAmount, address feeRecipient, uint256 nonce, uint256 deadline, bytes extData) request, (uint8 v, bytes32 r, bytes32 s) userSig, (uint8 v, bytes32 r, bytes32 s) issuerSig) external",
157
- // View functions we'll likely want (nonce getter is standard)
158
- "function mintRequestNonce(address user) external view returns (uint256)",
159
- "event Minted(address indexed user, uint256 amount, uint256 feeAmount, address indexed feeRecipient, bytes32 requestHash)"
285
+ var POINT_TOKEN_ABI = parseAbi([
286
+ // --- Mint paths ---
287
+ "function mint(address to, uint256 amount) external",
288
+ "function mint(address to, uint256 amount, uint256 deadline, bytes minterSig) external",
289
+ // --- Burn paths ---
290
+ "function burn(address from, uint256 amount) external",
291
+ "function burn(address from, uint256 amount, uint256 deadline, bytes burnerSig) external",
292
+ // --- Authorization reads ---
293
+ "function minters(address account) external view returns (bool)",
294
+ "function burners(address account) external view returns (bool)",
295
+ // --- Authorization writes (owner-only; used by provisioning scripts) ---
296
+ "function addMinter(address minter) external",
297
+ "function removeMinter(address minter) external",
298
+ "function addBurner(address burner) external",
299
+ "function removeBurner(address burner) external",
300
+ // --- Nonces (sig-gated paths) ---
301
+ "function mintRequestNonces(address receiver) external view returns (uint256)",
302
+ "function burnRequestNonces(address from) external view returns (uint256)",
303
+ // --- Oracle ---
304
+ "function mintingOracle() external view returns (address)",
305
+ "function setMintingOracle(address _mintingOracle) external",
306
+ // --- Issuer ---
307
+ "function issuer() external view returns (address)",
308
+ // --- Standard ERC-20 reads ---
309
+ "function balanceOf(address account) external view returns (uint256)",
310
+ "function totalSupply() external view returns (uint256)",
311
+ "function name() external view returns (string)",
312
+ "function symbol() external view returns (string)",
313
+ "function decimals() external view returns (uint8)",
314
+ // --- EIP-712 domain (for off-chain sig verification) ---
315
+ "function DOMAIN_SEPARATOR() external view returns (bytes32)",
316
+ "function eip712Domain() external view returns (bytes1 fields, string name, string version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] extensions)",
317
+ // --- Events ---
318
+ // PointIndexer filters Transfer(from=0x0) for mints
319
+ // BurnIndexer filters Transfer(to=0x0) for burns
320
+ "event Transfer(address indexed from, address indexed to, uint256 value)",
321
+ "event MinterAdded(address indexed minter)",
322
+ "event MinterRemoved(address indexed minter)",
323
+ "event BurnerAdded(address indexed burner)",
324
+ "event BurnerRemoved(address indexed burner)",
325
+ "event MintingOracleUpdated(address indexed mintingOracle)"
160
326
  ]);
161
- var MOCK_RELAYER_V2_MINT_SELECTOR = "0xMOCKED__";
162
327
 
163
- // src/contracts/mocks/pointTokenV2.mock.ts
164
- import { parseAbi as parseAbi2 } from "viem";
165
- var MOCK_POINT_TOKEN_V2_ABI = parseAbi2([
166
- // Variant A
167
- "function burn(uint256 amount) external",
168
- // Variant B
169
- "function burnWithSig((address user, address pointToken, uint256 amount, uint256 nonce, uint256 deadline) consent, (uint8 v, bytes32 r, bytes32 s) sig) external",
170
- // Standard reads we always need
171
- "function balanceOf(address user) external view returns (uint256)",
172
- "function burnNonce(address user) external view returns (uint256)",
173
- // ERC-20 Transfer event (inherited) — BurnIndexer filters `to = 0x0`
174
- "event Transfer(address indexed from, address indexed to, uint256 value)"
175
- ]);
176
-
177
- // src/contracts/mocks/batchExecutor.mock.ts
178
- var MOCK_BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA = "0x000000000000000000000000000000000000DE01";
179
- var MOCK_BATCH_EXECUTOR_ADDRESS_BASE_MAINNET = "0x000000000000000000000000000000000000DE02";
328
+ // src/contracts/real/batchExecutor.ts
329
+ var BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA = "0x000000000000000000000000000000000000DE01";
330
+ var BATCH_EXECUTOR_ADDRESS_BASE_MAINNET = "0x7702cb554e6bFb442cb743A7dF23154544a7176C";
180
331
 
181
- // src/contracts/mocks/addresses.mock.ts
182
- var MOCK_PLACEHOLDER = (suffix) => `0x000000000000000000000000000000000000${suffix.toLowerCase().padStart(4, "0")}`;
183
- var MOCK_ADDRESSES = {
184
- // Base Sepoliasafe targets for integration tests (MockRelayer
185
- // fixtures deployed by Hardhat will override these at test time)
186
- 84532: {
187
- relayerV2: MOCK_PLACEHOLDER("de10"),
188
- pointToken: MOCK_PLACEHOLDER("de11"),
189
- batchExecutor: MOCK_PLACEHOLDER("de01"),
190
- usdt: MOCK_PLACEHOLDER("de12"),
191
- issuerRegistry: MOCK_PLACEHOLDER("de13"),
192
- mintingOracle: MOCK_PLACEHOLDER("de14")
193
- },
194
- // Base mainnet — intentionally left as placeholder. Do NOT ship to
195
- // prod without swapping.
332
+ // src/contracts/real/addresses.ts
333
+ var PLACEHOLDER_DEAD = (suffix) => `0x000000000000000000000000000000000000${suffix.toLowerCase().padStart(4, "0")}`;
334
+ var CONTRACT_ADDRESSES = {
335
+ // Base mainnetSC-delivered (2026-04-21, 2026-04-22)
336
+ // registry: IssuerRegistry 0xda2D3338CF70F462Ac175F5f2edfa45660CA4f31
337
+ // factory: PointTokenFactory 0x36c0BAb2faBE45EfA6d13001143e43A266Af673B
338
+ // oracle: MintingOracle 0xD85165939C700E51c8a45099316C6482634C2Ab9
339
+ // tokenImpl: PointToken (impl) 0x2e6FB1B0C1A51abb83eC974890126a64eC02E995
340
+ // mockUsdt: MockERC20 0x5d313485Ba59C3bb91e1A9C0C11782F0b83d5dcd
341
+ // POINT: PointToken instance 0x7d25E7156E51F865D522fd3ef257a6B5DD41b97e
342
+ // batchExecutor: Coinbase SW v2 0x7702cb554e6bFb442cb743A7dF23154544a7176C
343
+ // pafiHook: PAFIHook (V4, 10%) 0x870cAF9882d3160602AaC1769C2B264A2d8EC044
196
344
  8453: {
197
- relayerV2: MOCK_PLACEHOLDER("dead"),
198
- pointToken: MOCK_PLACEHOLDER("dead"),
199
- batchExecutor: MOCK_PLACEHOLDER("dead"),
200
- usdt: MOCK_PLACEHOLDER("dead"),
201
- issuerRegistry: MOCK_PLACEHOLDER("dead"),
202
- mintingOracle: MOCK_PLACEHOLDER("dead")
345
+ pointToken: "0x7d25E7156E51F865D522fd3ef257a6B5DD41b97e",
346
+ batchExecutor: "0x7702cb554e6bFb442cb743A7dF23154544a7176C",
347
+ usdt: "0x5d313485Ba59C3bb91e1A9C0C11782F0b83d5dcd",
348
+ issuerRegistry: "0xda2D3338CF70F462Ac175F5f2edfa45660CA4f31",
349
+ mintingOracle: "0xD85165939C700E51c8a45099316C6482634C2Ab9",
350
+ pafiHook: "0x870cAF9882d3160602AaC1769C2B264A2d8EC044"
351
+ },
352
+ // Base Sepolia — not in active use; placeholders kept so the map
353
+ // compiles for tooling that enumerates chains.
354
+ 84532: {
355
+ pointToken: PLACEHOLDER_DEAD("dead"),
356
+ batchExecutor: PLACEHOLDER_DEAD("de01"),
357
+ usdt: PLACEHOLDER_DEAD("dead"),
358
+ issuerRegistry: PLACEHOLDER_DEAD("dead"),
359
+ mintingOracle: PLACEHOLDER_DEAD("dead"),
360
+ pafiHook: PLACEHOLDER_DEAD("dead")
203
361
  }
204
362
  };
205
- function getMockAddresses(chainId) {
206
- const addrs = MOCK_ADDRESSES[chainId];
363
+ var POINT_TOKEN_FACTORY_ADDRESSES = {
364
+ 8453: "0x36c0BAb2faBE45EfA6d13001143e43A266Af673B",
365
+ 84532: PLACEHOLDER_DEAD("dead")
366
+ };
367
+ var POINT_TOKEN_IMPL_ADDRESSES = {
368
+ 8453: "0x2e6FB1B0C1A51abb83eC974890126a64eC02E995",
369
+ 84532: PLACEHOLDER_DEAD("dead")
370
+ };
371
+ function getContractAddresses(chainId) {
372
+ const addrs = CONTRACT_ADDRESSES[chainId];
207
373
  if (!addrs) {
208
374
  throw new Error(
209
- `getMockAddresses: no mock addresses for chainId ${chainId}. Supported: ${Object.keys(MOCK_ADDRESSES).join(", ")}`
375
+ `getContractAddresses: no addresses for chainId ${chainId}. Supported: ${Object.keys(CONTRACT_ADDRESSES).join(", ")}`
210
376
  );
211
377
  }
212
378
  return addrs;
213
379
  }
214
380
 
215
- // src/contracts/mocks/eip712/mintRequestV2.mock.ts
216
- import {
217
- parseSignature,
218
- recoverTypedDataAddress
219
- } from "viem";
220
- var MOCK_MINT_REQUEST_V2_TYPES = {
221
- MintRequest: [
222
- { name: "to", type: "address" },
223
- { name: "amount", type: "uint256" },
224
- { name: "feeAmount", type: "uint256" },
225
- { name: "feeRecipient", type: "address" },
226
- { name: "nonce", type: "uint256" },
227
- { name: "deadline", type: "uint256" },
228
- { name: "extData", type: "bytes" }
229
- ]
230
- };
231
- function buildMockMintRequestV2TypedData(domain, message) {
232
- return {
233
- domain: buildDomain(domain),
234
- types: MOCK_MINT_REQUEST_V2_TYPES,
235
- primaryType: "MintRequest",
236
- message
237
- };
238
- }
239
- async function signMockMintRequestV2(walletClient, domain, message) {
240
- const serialized = await walletClient.signTypedData({
241
- account: walletClient.account,
242
- domain: buildDomain(domain),
243
- types: MOCK_MINT_REQUEST_V2_TYPES,
244
- primaryType: "MintRequest",
245
- message
246
- });
247
- const { v, r, s } = parseSignature(serialized);
248
- return {
249
- v: Number(v),
250
- r,
251
- s,
252
- serialized
381
+ // src/web-handoff/webPopup.ts
382
+ var DEFAULT_WIDTH = 900;
383
+ var DEFAULT_HEIGHT = 700;
384
+ var DEFAULT_NAME = "pafi-web";
385
+ function openWebPopup(url, options = {}) {
386
+ if (typeof window === "undefined" || typeof window.open !== "function") {
387
+ throw new Error(
388
+ "openWebPopup: `window.open` is not available in this runtime. Register a platform adapter via setPafiWebModalAdapter() instead."
389
+ );
390
+ }
391
+ const width = options.width ?? DEFAULT_WIDTH;
392
+ const height = options.height ?? DEFAULT_HEIGHT;
393
+ const name = options.windowName ?? DEFAULT_NAME;
394
+ const screenW = window.screen?.availWidth ?? window.innerWidth;
395
+ const screenH = window.screen?.availHeight ?? window.innerHeight;
396
+ const left = Math.max(0, Math.floor((screenW - width) / 2));
397
+ const top = Math.max(0, Math.floor((screenH - height) / 2));
398
+ const features = [
399
+ `width=${width}`,
400
+ `height=${height}`,
401
+ `left=${left}`,
402
+ `top=${top}`,
403
+ "resizable=yes",
404
+ "scrollbars=yes",
405
+ "noopener=no"
406
+ // we need opener.postMessage to work
407
+ ].join(",");
408
+ const popup = window.open(url, name, features);
409
+ if (!popup) {
410
+ throw new Error(
411
+ "openWebPopup: popup was blocked. Ensure this call runs inside a user gesture (click handler)."
412
+ );
413
+ }
414
+ let closed = false;
415
+ let pollId = null;
416
+ let messageListener = null;
417
+ const dispose = () => {
418
+ if (closed) return;
419
+ closed = true;
420
+ if (pollId !== null) {
421
+ clearInterval(pollId);
422
+ pollId = null;
423
+ }
424
+ if (messageListener) {
425
+ window.removeEventListener("message", messageListener);
426
+ messageListener = null;
427
+ }
428
+ options.onClose?.();
253
429
  };
254
- }
255
- async function verifyMockMintRequestV2(domain, message, signature, expectedSigner) {
256
- const recoveredAddress = await recoverTypedDataAddress({
257
- domain: buildDomain(domain),
258
- types: MOCK_MINT_REQUEST_V2_TYPES,
259
- primaryType: "MintRequest",
260
- message,
261
- signature
262
- });
263
- const isValid = recoveredAddress.toLowerCase() === expectedSigner.toLowerCase();
430
+ pollId = setInterval(() => {
431
+ if (popup.closed) {
432
+ dispose();
433
+ }
434
+ }, 500);
435
+ if (options.onMessage) {
436
+ const allowed = options.allowedOrigins ?? [];
437
+ const onMessage = options.onMessage;
438
+ messageListener = (event) => {
439
+ if (event.source !== popup) return;
440
+ if (!allowed.includes(event.origin)) return;
441
+ onMessage(event.data, event.origin);
442
+ };
443
+ window.addEventListener("message", messageListener);
444
+ }
264
445
  return {
265
- isValid,
266
- recoveredAddress
446
+ get isOpen() {
447
+ return !closed && !popup.closed;
448
+ },
449
+ close() {
450
+ if (closed) return;
451
+ try {
452
+ popup.close();
453
+ } catch {
454
+ }
455
+ dispose();
456
+ },
457
+ focus() {
458
+ if (closed || popup.closed) return;
459
+ try {
460
+ popup.focus();
461
+ } catch {
462
+ }
463
+ },
464
+ postMessage(data) {
465
+ if (closed || popup.closed) return;
466
+ try {
467
+ popup.postMessage(data, "*");
468
+ } catch {
469
+ }
470
+ }
267
471
  };
268
472
  }
269
-
270
- // src/contracts/mocks/eip712/burnConsent.mock.ts
271
- import {
272
- parseSignature as parseSignature2,
273
- recoverTypedDataAddress as recoverTypedDataAddress2
274
- } from "viem";
275
- var MOCK_BURN_CONSENT_TYPES = {
276
- BurnConsent: [
277
- { name: "user", type: "address" },
278
- { name: "pointToken", type: "address" },
279
- { name: "amount", type: "uint256" },
280
- { name: "nonce", type: "uint256" },
281
- { name: "deadline", type: "uint256" }
282
- ]
473
+ var webPopupAdapter = {
474
+ open(url, options) {
475
+ return openWebPopup(url, options);
476
+ }
283
477
  };
284
- function buildMockBurnConsentTypedData(domain, message) {
285
- return {
286
- domain: buildDomain(domain),
287
- types: MOCK_BURN_CONSENT_TYPES,
288
- primaryType: "BurnConsent",
289
- message
290
- };
478
+
479
+ // src/web-handoff/index.ts
480
+ var registeredAdapter = null;
481
+ function setPafiWebModalAdapter(adapter) {
482
+ registeredAdapter = adapter;
291
483
  }
292
- async function signMockBurnConsent(walletClient, domain, message) {
293
- const serialized = await walletClient.signTypedData({
294
- account: walletClient.account,
295
- domain: buildDomain(domain),
296
- types: MOCK_BURN_CONSENT_TYPES,
297
- primaryType: "BurnConsent",
298
- message
299
- });
300
- const { v, r, s } = parseSignature2(serialized);
301
- return {
302
- v: Number(v),
303
- r,
304
- s,
305
- serialized
306
- };
484
+ function getPafiWebModalAdapter() {
485
+ return registeredAdapter;
307
486
  }
308
- async function verifyMockBurnConsent(domain, message, signature, expectedUser) {
309
- const recoveredAddress = await recoverTypedDataAddress2({
310
- domain: buildDomain(domain),
311
- types: MOCK_BURN_CONSENT_TYPES,
312
- primaryType: "BurnConsent",
313
- message,
314
- signature
315
- });
316
- const isValid = recoveredAddress.toLowerCase() === expectedUser.toLowerCase();
317
- return {
318
- isValid,
319
- recoveredAddress
320
- };
487
+ async function openPafiWebModal(url, options = {}) {
488
+ if (!url || typeof url !== "string") {
489
+ throw new Error("openPafiWebModal: `url` is required");
490
+ }
491
+ if (registeredAdapter) {
492
+ return Promise.resolve(registeredAdapter.open(url, options));
493
+ }
494
+ if (typeof window !== "undefined" && typeof window.open === "function") {
495
+ return openWebPopup(url, options);
496
+ }
497
+ throw new Error(
498
+ "openPafiWebModal: no adapter registered and `window.open` is unavailable. Call `setPafiWebModalAdapter()` with a platform-specific adapter (e.g. SFSafariViewController on iOS) during app boot."
499
+ );
321
500
  }
322
501
 
323
502
  // src/index.ts
324
503
  var PafiSDK = class {
325
504
  _pointTokenAddress;
326
- _relayContractAddress;
327
505
  _signer;
328
506
  _provider;
329
507
  _chainId;
330
508
  constructor(config) {
331
509
  this._pointTokenAddress = config.pointTokenAddress;
332
- this._relayContractAddress = config.relayContractAddress;
333
510
  this._signer = config.signer;
334
511
  this._chainId = config.chainId;
335
512
  if (config.provider) {
@@ -346,9 +523,6 @@ var PafiSDK = class {
346
523
  setPointTokenAddress(address) {
347
524
  this._pointTokenAddress = address;
348
525
  }
349
- setRelayContractAddress(address) {
350
- this._relayContractAddress = address;
351
- }
352
526
  setSigner(signer) {
353
527
  this._signer = signer;
354
528
  }
@@ -395,18 +569,10 @@ var PafiSDK = class {
395
569
  // -------------------------------------------------------------------------
396
570
  // EIP-712 — delegates to pure functions
397
571
  // -------------------------------------------------------------------------
398
- /**
399
- * Build the EIP-712 typed data for a MintRequest.
400
- * Pass the result to any external signer (Privy, WalletConnect, etc.).
401
- */
402
572
  async buildMintRequestTypedData(message) {
403
573
  const domain = await this.getDomain();
404
574
  return buildMintRequestTypedData(domain, message);
405
575
  }
406
- /**
407
- * Build the EIP-712 typed data for a ReceiverConsent.
408
- * Pass the result to any external signer (Privy, WalletConnect, etc.).
409
- */
410
576
  async buildReceiverConsentTypedData(message) {
411
577
  const domain = await this.getDomain();
412
578
  return buildReceiverConsentTypedData(domain, message);
@@ -445,15 +611,6 @@ var PafiSDK = class {
445
611
  );
446
612
  }
447
613
  // -------------------------------------------------------------------------
448
- // Relay calldata — delegates to pure functions
449
- // -------------------------------------------------------------------------
450
- encodeMintAndSwap(mint, swap) {
451
- return encodeMintAndSwap(mint, swap);
452
- }
453
- decodeMintAndSwap(calldata) {
454
- return decodeMintAndSwap(calldata);
455
- }
456
- // -------------------------------------------------------------------------
457
614
  // Quoting — delegates to pure functions
458
615
  // -------------------------------------------------------------------------
459
616
  /**
@@ -483,41 +640,9 @@ var PafiSDK = class {
483
640
  buildSwapFromQuote(params) {
484
641
  return buildSwapFromQuote(params);
485
642
  }
486
- /**
487
- * Build Relay SwapParams + extData from a quote result.
488
- * Returns ready-to-use args for `Relay.mintAndSwap`.
489
- */
490
- buildRelaySwapParams(params) {
491
- return buildRelaySwapParams(params);
492
- }
493
- /**
494
- * Encode extData for ReceiverConsent and MintParams.
495
- * extData = abi.encode(minAmountOut, feeInUsdt)
496
- */
497
- encodeExtData(minAmountOut, feeInUsdt) {
498
- return encodeExtData(minAmountOut, feeInUsdt);
499
- }
500
643
  // -------------------------------------------------------------------------
501
644
  // Simulation — dry-run via eth_call (no gas spent)
502
645
  // -------------------------------------------------------------------------
503
- /**
504
- * Simulate a Relay.mintAndSwap call. Catches reverts (bad signatures,
505
- * expired deadlines, insufficient mint cap, pool errors) before submitting.
506
- *
507
- * @param relayAddress - Relay contract address
508
- * @param mint - MintParams with real signatures
509
- * @param swap - SwapParams (path + deadline)
510
- * @param from - Relayer address that will submit the tx
511
- */
512
- async simulateMintAndSwap(relayAddress, mint, swap, from) {
513
- return simulateMintAndSwap(
514
- this.requireProvider(),
515
- relayAddress,
516
- mint,
517
- swap,
518
- from
519
- );
520
- }
521
646
  /**
522
647
  * Simulate a UniversalRouter.execute swap call. Catches reverts (bad
523
648
  * approvals, insufficient balance, pool errors) before submitting.
@@ -540,17 +665,7 @@ var PafiSDK = class {
540
665
  }
541
666
  // -------------------------------------------------------------------------
542
667
  // Auth — EIP-4361 login helpers (offline, stateless)
543
- //
544
- // These are convenience wrappers around the pure functions in
545
- // `./auth/loginMessage.ts`. They do NOT hit the network — the caller is
546
- // responsible for fetching the nonce, POSTing the signed message, and
547
- // storing the JWT returned by the issuer backend.
548
668
  // -------------------------------------------------------------------------
549
- /**
550
- * Build an EIP-4361 login message for the current signer + chain. The
551
- * caller supplies the issuer-specific fields (domain, nonce, uri); the SDK
552
- * fills in the wallet address and chain id from its own config.
553
- */
554
669
  async createLoginMessage(params) {
555
670
  const signer = this.requireSigner();
556
671
  const chainId = this.requireChainId();
@@ -573,27 +688,30 @@ var PafiSDK = class {
573
688
  export {
574
689
  ApiError,
575
690
  BATCH_EXECUTOR_ABI,
576
- MOCK_BATCH_EXECUTOR_ADDRESS_BASE_MAINNET as BATCH_EXECUTOR_ADDRESS_BASE_MAINNET,
577
- MOCK_BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA as BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA,
578
- MOCK_BURN_CONSENT_TYPES as BURN_CONSENT_TYPES,
691
+ BATCH_EXECUTOR_ADDRESS_BASE_MAINNET,
692
+ BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA,
693
+ BROKER_HASHES,
579
694
  COMMON_POOLS,
580
695
  COMMON_TOKENS,
581
- MOCK_ADDRESSES as CONTRACT_ADDRESSES,
696
+ CONTRACT_ADDRESSES,
582
697
  ConfigurationError,
583
698
  ENTRY_POINT_V07,
584
- MOCK_MINT_REQUEST_V2_TYPES as MINT_REQUEST_V2_TYPES,
699
+ ORDERLY_VAULT_ABI,
700
+ ORDERLY_VAULT_ADDRESSES,
701
+ ORDERLY_VAULT_BASE_MAINNET,
702
+ POINT_TOKEN_FACTORY_ADDRESSES,
703
+ POINT_TOKEN_IMPL_ADDRESSES,
585
704
  POINT_TOKEN_POOLS,
586
- MOCK_POINT_TOKEN_V2_ABI as POINT_TOKEN_V2_ABI,
705
+ POINT_TOKEN_ABI as POINT_TOKEN_V2_ABI,
587
706
  PafiSDK,
588
707
  PafiSDKError,
589
- MOCK_RELAYER_V2_ABI as RELAYER_V2_ABI,
590
- MOCK_RELAYER_V2_MINT_SELECTOR as RELAYER_V2_MINT_SELECTOR,
591
708
  SETTLE_ALL,
592
709
  SUPPORTED_CHAINS,
593
710
  SWAP_EXACT_IN,
594
711
  SigningError,
595
712
  SimulationError,
596
713
  TAKE_ALL,
714
+ TOKEN_HASHES,
597
715
  UNIVERSAL_ROUTER_ADDRESSES,
598
716
  V4_QUOTER_ADDRESSES,
599
717
  V4_SWAP,
@@ -601,49 +719,48 @@ export {
601
719
  _resetPaymasterConfigForTests,
602
720
  assembleUserOperation,
603
721
  buildAllPaths,
604
- buildMockBurnConsentTypedData as buildBurnConsentTypedData,
722
+ buildBurnRequestTypedData,
605
723
  buildDomain,
606
724
  buildErc20ApprovalCalldata,
607
725
  buildMintRequestTypedData,
608
- buildMockMintRequestV2TypedData as buildMintRequestV2TypedData,
609
726
  buildPartialUserOperation,
610
727
  buildPermit2ApprovalCalldata,
728
+ buildPerpDepositWithGasDeduction,
611
729
  buildReceiverConsentTypedData,
612
- buildRelaySwapParams,
613
730
  buildSwapFromQuote,
614
731
  buildSwapWithGasDeduction,
615
732
  buildUniversalRouterExecuteArgs,
616
733
  buildV4SwapInput,
734
+ burnRequestTypes,
617
735
  checkAllowance,
618
736
  checkEthAndBranch,
619
737
  combineRoutes,
738
+ computeAccountId,
620
739
  createLoginMessage,
621
- decodeExtData,
622
- decodeMintAndSwap,
623
740
  encodeBatchExecute,
624
- encodeExtData,
625
- encodeMintAndSwap,
626
741
  erc20Abi,
627
742
  erc20ApproveOp,
628
743
  erc20BurnOp,
629
744
  erc20TransferOp,
630
745
  findBestQuote,
631
- getMockAddresses as getContractAddresses,
746
+ getContractAddresses,
632
747
  getIssuer2 as getIssuer,
633
748
  getMintRequestNonce,
749
+ getPafiWebModalAdapter,
634
750
  getPaymasterConfig,
635
751
  getPointTokenBalance,
636
752
  getPointTokenIssuer,
637
753
  getIssuer as getPointTokenIssuerAddress,
638
754
  getReceiverConsentNonce,
639
755
  getTokenName,
640
- getUsdt,
641
756
  isActiveIssuer,
642
757
  isMinter,
643
758
  isPaymasterConfigured,
644
759
  issuerRegistryAbi,
645
760
  mintRequestTypes,
646
761
  mintingOracleAbi,
762
+ openPafiWebModal,
763
+ openWebPopup,
647
764
  parseLoginMessage,
648
765
  permit2Abi,
649
766
  pointTokenAbi,
@@ -653,21 +770,19 @@ export {
653
770
  quoteExactInputSingle,
654
771
  rawCallOp,
655
772
  receiverConsentTypes,
656
- relayAbi,
773
+ setPafiWebModalAdapter,
657
774
  setPaymasterConfig,
658
- signMockBurnConsent as signBurnConsent,
775
+ signBurnRequest,
659
776
  signMintRequest,
660
- signMockMintRequestV2 as signMintRequestV2,
661
777
  signReceiverConsent,
662
- simulateMintAndSwap,
663
778
  simulateSwap,
664
779
  universalRouterAbi,
665
780
  v4QuoterAbi,
666
- verifyMockBurnConsent as verifyBurnConsent,
781
+ verifyBurnRequest,
667
782
  verifyLoginMessage,
668
783
  verifyMintCap,
669
784
  verifyMintRequest,
670
- verifyMockMintRequestV2 as verifyMintRequestV2,
671
- verifyReceiverConsent
785
+ verifyReceiverConsent,
786
+ webPopupAdapter
672
787
  };
673
788
  //# sourceMappingURL=index.js.map