@pafi-dev/core 0.5.12 → 0.5.14

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 (31) hide show
  1. package/dist/{chunk-2PY5RNVS.cjs → chunk-DX73FB4P.cjs} +11 -11
  2. package/dist/{chunk-2PY5RNVS.cjs.map → chunk-DX73FB4P.cjs.map} +1 -1
  3. package/dist/{chunk-B3PYJGTH.cjs → chunk-JJ2LGENO.cjs} +6 -6
  4. package/dist/chunk-JJ2LGENO.cjs.map +1 -0
  5. package/dist/{chunk-ARZSGP5Y.cjs → chunk-L5UHQQVC.cjs} +6 -6
  6. package/dist/{chunk-ARZSGP5Y.cjs.map → chunk-L5UHQQVC.cjs.map} +1 -1
  7. package/dist/{chunk-WTWG6QXP.js → chunk-TXA4GK5C.js} +2 -2
  8. package/dist/{chunk-MWKJODJE.js → chunk-VG23GIWQ.js} +4 -4
  9. package/dist/{chunk-MWKJODJE.js.map → chunk-VG23GIWQ.js.map} +1 -1
  10. package/dist/{chunk-N5M3BLOV.js → chunk-WAFUL62X.js} +2 -2
  11. package/dist/{chunk-52SZJDFT.cjs → chunk-X2JZFK4C.cjs} +4 -2
  12. package/dist/chunk-X2JZFK4C.cjs.map +1 -0
  13. package/dist/{chunk-S5CCEO4O.js → chunk-Y3HMGOYW.js} +3 -1
  14. package/dist/{chunk-S5CCEO4O.js.map → chunk-Y3HMGOYW.js.map} +1 -1
  15. package/dist/eip712/index.cjs +3 -3
  16. package/dist/eip712/index.js +2 -2
  17. package/dist/index.cjs +31 -29
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +22 -6
  20. package/dist/index.d.ts +22 -6
  21. package/dist/index.js +8 -6
  22. package/dist/index.js.map +1 -1
  23. package/dist/quoting/index.cjs +3 -3
  24. package/dist/quoting/index.js +2 -2
  25. package/dist/swap/index.cjs +3 -3
  26. package/dist/swap/index.js +2 -2
  27. package/package.json +1 -1
  28. package/dist/chunk-52SZJDFT.cjs.map +0 -1
  29. package/dist/chunk-B3PYJGTH.cjs.map +0 -1
  30. /package/dist/{chunk-WTWG6QXP.js.map → chunk-TXA4GK5C.js.map} +0 -0
  31. /package/dist/{chunk-N5M3BLOV.js.map → chunk-WAFUL62X.js.map} +0 -0
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk52SZJDFTcjs = require('./chunk-52SZJDFT.cjs');
5
+ var _chunkX2JZFK4Ccjs = require('./chunk-X2JZFK4C.cjs');
6
6
 
7
7
  // src/eip712/domain.ts
8
8
  function buildDomain(config) {
@@ -19,7 +19,7 @@ var _viem = require('viem');
19
19
  function buildMintRequestTypedData(domain, message) {
20
20
  return {
21
21
  domain: buildDomain(domain),
22
- types: _chunk52SZJDFTcjs.mintRequestTypes,
22
+ types: _chunkX2JZFK4Ccjs.mintRequestTypes,
23
23
  primaryType: "MintRequest",
24
24
  message
25
25
  };
@@ -28,7 +28,7 @@ async function signMintRequest(walletClient, domain, message) {
28
28
  const serialized = await walletClient.signTypedData({
29
29
  account: walletClient.account,
30
30
  domain: buildDomain(domain),
31
- types: _chunk52SZJDFTcjs.mintRequestTypes,
31
+ types: _chunkX2JZFK4Ccjs.mintRequestTypes,
32
32
  primaryType: "MintRequest",
33
33
  message
34
34
  });
@@ -43,7 +43,7 @@ async function signMintRequest(walletClient, domain, message) {
43
43
  async function verifyMintRequest(domain, message, signature, expectedMinter) {
44
44
  const recoveredAddress = await _viem.recoverTypedDataAddress.call(void 0, {
45
45
  domain: buildDomain(domain),
46
- types: _chunk52SZJDFTcjs.mintRequestTypes,
46
+ types: _chunkX2JZFK4Ccjs.mintRequestTypes,
47
47
  primaryType: "MintRequest",
48
48
  message,
49
49
  signature
@@ -57,7 +57,7 @@ async function verifyMintRequest(domain, message, signature, expectedMinter) {
57
57
  function buildBurnRequestTypedData(domain, message) {
58
58
  return {
59
59
  domain: buildDomain(domain),
60
- types: _chunk52SZJDFTcjs.burnRequestTypes,
60
+ types: _chunkX2JZFK4Ccjs.burnRequestTypes,
61
61
  primaryType: "BurnRequest",
62
62
  message
63
63
  };
@@ -66,7 +66,7 @@ async function signBurnRequest(walletClient, domain, message) {
66
66
  const serialized = await walletClient.signTypedData({
67
67
  account: walletClient.account,
68
68
  domain: buildDomain(domain),
69
- types: _chunk52SZJDFTcjs.burnRequestTypes,
69
+ types: _chunkX2JZFK4Ccjs.burnRequestTypes,
70
70
  primaryType: "BurnRequest",
71
71
  message
72
72
  });
@@ -81,7 +81,7 @@ async function signBurnRequest(walletClient, domain, message) {
81
81
  async function verifyBurnRequest(domain, message, signature, expectedBurner) {
82
82
  const recoveredAddress = await _viem.recoverTypedDataAddress.call(void 0, {
83
83
  domain: buildDomain(domain),
84
- types: _chunk52SZJDFTcjs.burnRequestTypes,
84
+ types: _chunkX2JZFK4Ccjs.burnRequestTypes,
85
85
  primaryType: "BurnRequest",
86
86
  message,
87
87
  signature
@@ -95,7 +95,7 @@ async function verifyBurnRequest(domain, message, signature, expectedBurner) {
95
95
  function buildReceiverConsentTypedData(domain, message) {
96
96
  return {
97
97
  domain: buildDomain(domain),
98
- types: _chunk52SZJDFTcjs.receiverConsentTypes,
98
+ types: _chunkX2JZFK4Ccjs.receiverConsentTypes,
99
99
  primaryType: "ReceiverConsent",
100
100
  message
101
101
  };
@@ -104,7 +104,7 @@ async function signReceiverConsent(walletClient, domain, message) {
104
104
  const serialized = await walletClient.signTypedData({
105
105
  account: walletClient.account,
106
106
  domain: buildDomain(domain),
107
- types: _chunk52SZJDFTcjs.receiverConsentTypes,
107
+ types: _chunkX2JZFK4Ccjs.receiverConsentTypes,
108
108
  primaryType: "ReceiverConsent",
109
109
  message
110
110
  });
@@ -119,7 +119,7 @@ async function signReceiverConsent(walletClient, domain, message) {
119
119
  async function verifyReceiverConsent(domain, message, signature, expectedReceiver) {
120
120
  const recoveredAddress = await _viem.recoverTypedDataAddress.call(void 0, {
121
121
  domain: buildDomain(domain),
122
- types: _chunk52SZJDFTcjs.receiverConsentTypes,
122
+ types: _chunkX2JZFK4Ccjs.receiverConsentTypes,
123
123
  primaryType: "ReceiverConsent",
124
124
  message,
125
125
  signature
@@ -140,4 +140,4 @@ async function verifyReceiverConsent(domain, message, signature, expectedReceive
140
140
 
141
141
 
142
142
  exports.buildDomain = buildDomain; exports.buildMintRequestTypedData = buildMintRequestTypedData; exports.signMintRequest = signMintRequest; exports.verifyMintRequest = verifyMintRequest; exports.buildBurnRequestTypedData = buildBurnRequestTypedData; exports.signBurnRequest = signBurnRequest; exports.verifyBurnRequest = verifyBurnRequest; exports.buildReceiverConsentTypedData = buildReceiverConsentTypedData; exports.signReceiverConsent = signReceiverConsent; exports.verifyReceiverConsent = verifyReceiverConsent;
143
- //# sourceMappingURL=chunk-2PY5RNVS.cjs.map
143
+ //# sourceMappingURL=chunk-DX73FB4P.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-2PY5RNVS.cjs","../src/eip712/domain.ts","../src/eip712/mintRequest.ts","../src/eip712/burnRequest.ts","../src/eip712/receiverConsent.ts"],"names":["parseSignature","recoverTypedDataAddress","getAddress"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACJO,SAAS,WAAA,CAAY,MAAA,EAAgC;AAC1D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,MAAA,CAAO,IAAA;AAAA,IACb,OAAA,EAAS,GAAA;AAAA,IACT,OAAA,EAAS,MAAA,CAAO,OAAA;AAAA,IAChB,iBAAA,EAAmB,MAAA,CAAO;AAAA,EAC5B,CAAA;AACF;ADMA;AACA;AEhBA,4BAAoE;AAW7D,SAAS,yBAAA,CACd,MAAA,EACA,OAAA,EACA;AACA,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,WAAA,CAAY,MAAM,CAAA;AAAA,IAC1B,KAAA,EAAO,kCAAA;AAAA,IACP,WAAA,EAAa,aAAA;AAAA,IACb;AAAA,EACF,CA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Aa,MAAM,YAAA,CAAa,aAAA,CAAc;AAAA,IAClD,OAAA,EAAS,YAAA,CAAa,OAAA;AAAA,IACtB,MAAA,EAAQ,WAAA,CAAY,MAAM,CAAA;AAAA,IAC1B,KAAA,EAAO,sCAAA;AAAA,IACP,WAAA,EAAa,iBAAA;AAAA,IACb;AAAA,EACF,CAAC,CAAA;AAED,EAAA,MAAM,EAAE,CAAA,EAAG,CAAA,EAAG,EAAE,EAAA,EAAIF,kCAAAA,UAAyB,CAAA;AAE7C,EAAA,OAAO;AAAA,IACL,CAAA,EAAG,MAAA,CAAO,CAAC,CAAA;AAAA,IACX,CAAA;AAAA,IACA,CAAA;AAAA,IACA;AAAA,EACF,CAAA;AACF;AAEA,MAAA,SAAsB,qBAAA,CACpB,MAAA,EACA,OAAA,EACA,SAAA,EACA,gBAAA,EACgC;AAChC,EAAA,MAAM,iBAAA,EAAmB,MAAMC,2CAAAA;AAAwB,IACrD,MAAA,EAAQ,WAAA,CAAY,MAAM,CAAA;AAAA,IAC1B,KAAA,EAAO,sCAAA;AAAA,IACP,WAAA,EAAa,iBAAA;AAAA,IACb,OAAA;AAAA,IACA;AAAA,EACF,CAAC,CAAA;AAED,EAAA,MAAM,QAAA,EAAUC,8BAAAA,gBAA2B,EAAA,IAAMA,8BAAAA,gBAA2B,CAAA;AAE5E,EAAA,OAAO,EAAE,OAAA,EAAS,iBAAiB,CAAA;AACrC;AJkEA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,qgBAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-2PY5RNVS.cjs","sourcesContent":[null,"import type { PointTokenDomainConfig } from \"../types\";\n\nexport function buildDomain(config: PointTokenDomainConfig) {\n return {\n name: config.name,\n version: \"1\" as const,\n chainId: config.chainId,\n verifyingContract: config.verifyingContract,\n };\n}\n","import { getAddress, parseSignature, recoverTypedDataAddress } from \"viem\";\nimport type { Address, Hex, WalletClient } from \"viem\";\nimport { mintRequestTypes } from \"../constants\";\nimport type { EIP712Signature, MintRequest, PointTokenDomainConfig, SignatureVerification } from \"../types\";\nimport { buildDomain } from \"./domain\";\n\n/**\n * Build the EIP-712 typed data object for a MintRequest.\n * Returns the standard `{ domain, types, primaryType, message }` structure\n * that any EIP-712 signer (viem, ethers, Privy, WalletConnect) can consume.\n */\nexport function buildMintRequestTypedData(\n domain: PointTokenDomainConfig,\n message: MintRequest,\n) {\n return {\n domain: buildDomain(domain),\n types: mintRequestTypes,\n primaryType: \"MintRequest\" as const,\n message,\n };\n}\n\nexport async function signMintRequest(\n walletClient: WalletClient,\n domain: PointTokenDomainConfig,\n message: MintRequest,\n): Promise<EIP712Signature> {\n const serialized = await walletClient.signTypedData({\n account: walletClient.account!,\n domain: buildDomain(domain),\n types: mintRequestTypes,\n primaryType: \"MintRequest\",\n message,\n });\n\n const { v, r, s } = parseSignature(serialized);\n\n return {\n v: Number(v),\n r,\n s,\n serialized,\n };\n}\n\nexport async function verifyMintRequest(\n domain: PointTokenDomainConfig,\n message: MintRequest,\n signature: Hex,\n expectedMinter: Address,\n): Promise<SignatureVerification> {\n const recoveredAddress = await recoverTypedDataAddress({\n domain: buildDomain(domain),\n types: mintRequestTypes,\n primaryType: \"MintRequest\",\n message,\n signature,\n });\n\n const isValid = getAddress(recoveredAddress) === getAddress(expectedMinter);\n\n return { isValid, recoveredAddress };\n}\n","import { getAddress, parseSignature, recoverTypedDataAddress } from \"viem\";\nimport type { Address, Hex, WalletClient } from \"viem\";\nimport { burnRequestTypes } from \"../constants\";\nimport type {\n BurnRequest,\n EIP712Signature,\n PointTokenDomainConfig,\n SignatureVerification,\n} from \"../types\";\nimport { buildDomain } from \"./domain\";\n\n/**\n * EIP-712 helpers for `BurnRequest` — consumed by the sig-gated burn\n * path on `PointToken`:\n *\n * burn(address from, uint256 amount, uint256 deadline, bytes burnerSig)\n *\n * Solidity type hash:\n * BurnRequest(address from,uint256 amount,uint256 nonce,uint256 deadline)\n *\n * Issuer backend signs with its burner signer (HSM/KMS). On-chain\n * `msg.sender` must equal `from`, and the recovered signer must be in\n * `burners[]`. Nonce comes from `burnRequestNonces[from]` and is\n * auto-incremented on success.\n */\nexport function buildBurnRequestTypedData(\n domain: PointTokenDomainConfig,\n message: BurnRequest,\n) {\n return {\n domain: buildDomain(domain),\n types: burnRequestTypes,\n primaryType: \"BurnRequest\" as const,\n message,\n };\n}\n\nexport async function signBurnRequest(\n walletClient: WalletClient,\n domain: PointTokenDomainConfig,\n message: BurnRequest,\n): Promise<EIP712Signature> {\n const serialized = await walletClient.signTypedData({\n account: walletClient.account!,\n domain: buildDomain(domain),\n types: burnRequestTypes,\n primaryType: \"BurnRequest\",\n message,\n });\n\n const { v, r, s } = parseSignature(serialized);\n\n return {\n v: Number(v),\n r,\n s,\n serialized,\n };\n}\n\nexport async function verifyBurnRequest(\n domain: PointTokenDomainConfig,\n message: BurnRequest,\n signature: Hex,\n expectedBurner: Address,\n): Promise<SignatureVerification> {\n const recoveredAddress = await recoverTypedDataAddress({\n domain: buildDomain(domain),\n types: burnRequestTypes,\n primaryType: \"BurnRequest\",\n message,\n signature,\n });\n\n const isValid = getAddress(recoveredAddress) === getAddress(expectedBurner);\n\n return { isValid, recoveredAddress };\n}\n","import { getAddress, parseSignature, recoverTypedDataAddress } from \"viem\";\nimport type { Address, Hex, WalletClient } from \"viem\";\nimport { receiverConsentTypes } from \"../constants\";\nimport type { EIP712Signature, PointTokenDomainConfig, ReceiverConsent, SignatureVerification } from \"../types\";\nimport { buildDomain } from \"./domain\";\n\n/**\n * Build the EIP-712 typed data object for a ReceiverConsent.\n * Returns the standard `{ domain, types, primaryType, message }` structure\n * that any EIP-712 signer (viem, ethers, Privy, WalletConnect) can consume.\n */\nexport function buildReceiverConsentTypedData(\n domain: PointTokenDomainConfig,\n message: ReceiverConsent,\n) {\n return {\n domain: buildDomain(domain),\n types: receiverConsentTypes,\n primaryType: \"ReceiverConsent\" as const,\n message,\n };\n}\n\nexport async function signReceiverConsent(\n walletClient: WalletClient,\n domain: PointTokenDomainConfig,\n message: ReceiverConsent,\n): Promise<EIP712Signature> {\n const serialized = await walletClient.signTypedData({\n account: walletClient.account!,\n domain: buildDomain(domain),\n types: receiverConsentTypes,\n primaryType: \"ReceiverConsent\",\n message,\n });\n\n const { v, r, s } = parseSignature(serialized);\n\n return {\n v: Number(v),\n r,\n s,\n serialized,\n };\n}\n\nexport async function verifyReceiverConsent(\n domain: PointTokenDomainConfig,\n message: ReceiverConsent,\n signature: Hex,\n expectedReceiver: Address,\n): Promise<SignatureVerification> {\n const recoveredAddress = await recoverTypedDataAddress({\n domain: buildDomain(domain),\n types: receiverConsentTypes,\n primaryType: \"ReceiverConsent\",\n message,\n signature,\n });\n\n const isValid = getAddress(recoveredAddress) === getAddress(expectedReceiver);\n\n return { isValid, recoveredAddress };\n}\n"]}
1
+ {"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-DX73FB4P.cjs","../src/eip712/domain.ts","../src/eip712/mintRequest.ts","../src/eip712/burnRequest.ts","../src/eip712/receiverConsent.ts"],"names":["parseSignature","recoverTypedDataAddress","getAddress"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACJO,SAAS,WAAA,CAAY,MAAA,EAAgC;AAC1D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,MAAA,CAAO,IAAA;AAAA,IACb,OAAA,EAAS,GAAA;AAAA,IACT,OAAA,EAAS,MAAA,CAAO,OAAA;AAAA,IAChB,iBAAA,EAAmB,MAAA,CAAO;AAAA,EAC5B,CAAA;AACF;ADMA;AACA;AEhBA,4BAAoE;AAW7D,SAAS,yBAAA,CACd,MAAA,EACA,OAAA,EACA;AACA,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,WAAA,CAAY,MAAM,CAAA;AAAA,IAC1B,KAAA,EAAO,kCAAA;AAAA,IACP,WAAA,EAAa,aAAA;AAAA,IACb;AAAA,EACF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,EAAa,MAAM,YAAA,CAAa,aAAA,CAAc;AAAA,IAClD,OAAA,EAAS,YAAA,CAAa,OAAA;AAAA,IACtB,MAAA,EAAQ,WAAA,CAAY,MAAM,CAAA;AAAA,IAC1B,KAAA,EAAO,sCAAA;AAAA,IACP,WAAA,EAAa,iBAAA;AAAA,IACb;AAAA,EACF,CAAC,CAAA;AAED,EAAA,MAAM,EAAE,CAAA,EAAG,CAAA,EAAG,EAAE,EAAA,EAAIF,kCAAAA,UAAyB,CAAA;AAE7C,EAAA,OAAO;AAAA,IACL,CAAA,EAAG,MAAA,CAAO,CAAC,CAAA;AAAA,IACX,CAAA;AAAA,IACA,CAAA;AAAA,IACA;AAAA,EACF,CAAA;AACF;AAEA,MAAA,SAAsB,qBAAA,CACpB,MAAA,EACA,OAAA,EACA,SAAA,EACA,gBAAA,EACgC;AAChC,EAAA,MAAM,iBAAA,EAAmB,MAAMC,2CAAAA;AAAwB,IACrD,MAAA,EAAQ,WAAA,CAAY,MAAM,CAAA;AAAA,IAC1B,KAAA,EAAO,sCAAA;AAAA,IACP,WAAA,EAAa,iBAAA;AAAA,IACb,OAAA;AAAA,IACA;AAAA,EACF,CAAC,CAAA;AAED,EAAA,MAAM,QAAA,EAAUC,8BAAAA,gBAA2B,EAAA,IAAMA,8BAAAA,gBAA2B,CAAA;AAE5E,EAAA,OAAO,EAAE,OAAA,EAAS,iBAAiB,CAAA;AACrC;AJkEA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,qgBAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-DX73FB4P.cjs","sourcesContent":[null,"import type { PointTokenDomainConfig } from \"../types\";\n\nexport function buildDomain(config: PointTokenDomainConfig) {\n return {\n name: config.name,\n version: \"1\" as const,\n chainId: config.chainId,\n verifyingContract: config.verifyingContract,\n };\n}\n","import { getAddress, parseSignature, recoverTypedDataAddress } from \"viem\";\nimport type { Address, Hex, WalletClient } from \"viem\";\nimport { mintRequestTypes } from \"../constants\";\nimport type { EIP712Signature, MintRequest, PointTokenDomainConfig, SignatureVerification } from \"../types\";\nimport { buildDomain } from \"./domain\";\n\n/**\n * Build the EIP-712 typed data object for a MintRequest.\n * Returns the standard `{ domain, types, primaryType, message }` structure\n * that any EIP-712 signer (viem, ethers, Privy, WalletConnect) can consume.\n */\nexport function buildMintRequestTypedData(\n domain: PointTokenDomainConfig,\n message: MintRequest,\n) {\n return {\n domain: buildDomain(domain),\n types: mintRequestTypes,\n primaryType: \"MintRequest\" as const,\n message,\n };\n}\n\nexport async function signMintRequest(\n walletClient: WalletClient,\n domain: PointTokenDomainConfig,\n message: MintRequest,\n): Promise<EIP712Signature> {\n const serialized = await walletClient.signTypedData({\n account: walletClient.account!,\n domain: buildDomain(domain),\n types: mintRequestTypes,\n primaryType: \"MintRequest\",\n message,\n });\n\n const { v, r, s } = parseSignature(serialized);\n\n return {\n v: Number(v),\n r,\n s,\n serialized,\n };\n}\n\nexport async function verifyMintRequest(\n domain: PointTokenDomainConfig,\n message: MintRequest,\n signature: Hex,\n expectedMinter: Address,\n): Promise<SignatureVerification> {\n const recoveredAddress = await recoverTypedDataAddress({\n domain: buildDomain(domain),\n types: mintRequestTypes,\n primaryType: \"MintRequest\",\n message,\n signature,\n });\n\n const isValid = getAddress(recoveredAddress) === getAddress(expectedMinter);\n\n return { isValid, recoveredAddress };\n}\n","import { getAddress, parseSignature, recoverTypedDataAddress } from \"viem\";\nimport type { Address, Hex, WalletClient } from \"viem\";\nimport { burnRequestTypes } from \"../constants\";\nimport type {\n BurnRequest,\n EIP712Signature,\n PointTokenDomainConfig,\n SignatureVerification,\n} from \"../types\";\nimport { buildDomain } from \"./domain\";\n\n/**\n * EIP-712 helpers for `BurnRequest` — consumed by the sig-gated burn\n * path on `PointToken`:\n *\n * burn(address from, uint256 amount, uint256 deadline, bytes burnerSig)\n *\n * Solidity type hash:\n * BurnRequest(address from,uint256 amount,uint256 nonce,uint256 deadline)\n *\n * Issuer backend signs with its burner signer (HSM/KMS). On-chain\n * `msg.sender` must equal `from`, and the recovered signer must be in\n * `burners[]`. Nonce comes from `burnRequestNonces[from]` and is\n * auto-incremented on success.\n */\nexport function buildBurnRequestTypedData(\n domain: PointTokenDomainConfig,\n message: BurnRequest,\n) {\n return {\n domain: buildDomain(domain),\n types: burnRequestTypes,\n primaryType: \"BurnRequest\" as const,\n message,\n };\n}\n\nexport async function signBurnRequest(\n walletClient: WalletClient,\n domain: PointTokenDomainConfig,\n message: BurnRequest,\n): Promise<EIP712Signature> {\n const serialized = await walletClient.signTypedData({\n account: walletClient.account!,\n domain: buildDomain(domain),\n types: burnRequestTypes,\n primaryType: \"BurnRequest\",\n message,\n });\n\n const { v, r, s } = parseSignature(serialized);\n\n return {\n v: Number(v),\n r,\n s,\n serialized,\n };\n}\n\nexport async function verifyBurnRequest(\n domain: PointTokenDomainConfig,\n message: BurnRequest,\n signature: Hex,\n expectedBurner: Address,\n): Promise<SignatureVerification> {\n const recoveredAddress = await recoverTypedDataAddress({\n domain: buildDomain(domain),\n types: burnRequestTypes,\n primaryType: \"BurnRequest\",\n message,\n signature,\n });\n\n const isValid = getAddress(recoveredAddress) === getAddress(expectedBurner);\n\n return { isValid, recoveredAddress };\n}\n","import { getAddress, parseSignature, recoverTypedDataAddress } from \"viem\";\nimport type { Address, Hex, WalletClient } from \"viem\";\nimport { receiverConsentTypes } from \"../constants\";\nimport type { EIP712Signature, PointTokenDomainConfig, ReceiverConsent, SignatureVerification } from \"../types\";\nimport { buildDomain } from \"./domain\";\n\n/**\n * Build the EIP-712 typed data object for a ReceiverConsent.\n * Returns the standard `{ domain, types, primaryType, message }` structure\n * that any EIP-712 signer (viem, ethers, Privy, WalletConnect) can consume.\n */\nexport function buildReceiverConsentTypedData(\n domain: PointTokenDomainConfig,\n message: ReceiverConsent,\n) {\n return {\n domain: buildDomain(domain),\n types: receiverConsentTypes,\n primaryType: \"ReceiverConsent\" as const,\n message,\n };\n}\n\nexport async function signReceiverConsent(\n walletClient: WalletClient,\n domain: PointTokenDomainConfig,\n message: ReceiverConsent,\n): Promise<EIP712Signature> {\n const serialized = await walletClient.signTypedData({\n account: walletClient.account!,\n domain: buildDomain(domain),\n types: receiverConsentTypes,\n primaryType: \"ReceiverConsent\",\n message,\n });\n\n const { v, r, s } = parseSignature(serialized);\n\n return {\n v: Number(v),\n r,\n s,\n serialized,\n };\n}\n\nexport async function verifyReceiverConsent(\n domain: PointTokenDomainConfig,\n message: ReceiverConsent,\n signature: Hex,\n expectedReceiver: Address,\n): Promise<SignatureVerification> {\n const recoveredAddress = await recoverTypedDataAddress({\n domain: buildDomain(domain),\n types: receiverConsentTypes,\n primaryType: \"ReceiverConsent\",\n message,\n signature,\n });\n\n const isValid = getAddress(recoveredAddress) === getAddress(expectedReceiver);\n\n return { isValid, recoveredAddress };\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  var _chunkIPXARZ6Fcjs = require('./chunk-IPXARZ6F.cjs');
6
6
 
7
7
 
8
- var _chunk52SZJDFTcjs = require('./chunk-52SZJDFT.cjs');
8
+ var _chunkX2JZFK4Ccjs = require('./chunk-X2JZFK4C.cjs');
9
9
 
10
10
  // src/swap/approval.ts
11
11
  var _viem = require('viem');
@@ -177,7 +177,7 @@ async function simulateSwap(client, routerAddress, commands, inputs, deadline, f
177
177
  // src/userop/batchExecute.ts
178
178
 
179
179
  var BATCH_EXECUTOR_ABI = _viem.parseAbi.call(void 0, [
180
- "function execute((address target, uint256 value, bytes data)[] calls)"
180
+ "function executeBatch((address target, uint256 value, bytes data)[] calls)"
181
181
  ]);
182
182
  function encodeBatchExecute(operations) {
183
183
  if (operations.length === 0) {
@@ -185,7 +185,7 @@ function encodeBatchExecute(operations) {
185
185
  }
186
186
  return _viem.encodeFunctionData.call(void 0, {
187
187
  abi: BATCH_EXECUTOR_ABI,
188
- functionName: "execute",
188
+ functionName: "executeBatch",
189
189
  args: [
190
190
  operations.map((op) => ({
191
191
  target: op.target,
@@ -315,10 +315,10 @@ function buildSwapWithGasDeduction(params) {
315
315
  const operations = [
316
316
  erc20ApproveOp(
317
317
  params.pointTokenAddress,
318
- _chunk52SZJDFTcjs.PERMIT2_ADDRESS,
318
+ _chunkX2JZFK4Ccjs.PERMIT2_ADDRESS,
319
319
  params.amountIn
320
320
  ),
321
- rawCallOp(_chunk52SZJDFTcjs.PERMIT2_ADDRESS, permit2ApproveData),
321
+ rawCallOp(_chunkX2JZFK4Ccjs.PERMIT2_ADDRESS, permit2ApproveData),
322
322
  rawCallOp(params.universalRouterAddress, swapCallData)
323
323
  ];
324
324
  if (params.gasFeePt > 0n) {
@@ -370,4 +370,4 @@ function buildSwapWithGasDeduction(params) {
370
370
 
371
371
 
372
372
  exports.PafiSDKError = PafiSDKError; exports.ConfigurationError = ConfigurationError; exports.SigningError = SigningError; exports.SimulationError = SimulationError; exports.ApiError = ApiError; exports.checkAllowance = checkAllowance; exports.buildErc20ApprovalCalldata = buildErc20ApprovalCalldata; exports.buildPermit2ApprovalCalldata = buildPermit2ApprovalCalldata; exports.V4_SWAP = V4_SWAP; exports.SWAP_EXACT_IN = SWAP_EXACT_IN; exports.SETTLE_ALL = SETTLE_ALL; exports.TAKE_ALL = TAKE_ALL; exports.buildV4SwapInput = buildV4SwapInput; exports.buildUniversalRouterExecuteArgs = buildUniversalRouterExecuteArgs; exports.buildSwapFromQuote = buildSwapFromQuote; exports.simulateSwap = simulateSwap; exports.BATCH_EXECUTOR_ABI = BATCH_EXECUTOR_ABI; exports.encodeBatchExecute = encodeBatchExecute; exports.decodeBatchExecuteCalls = decodeBatchExecuteCalls; exports.buildPartialUserOperation = buildPartialUserOperation; exports.assembleUserOperation = assembleUserOperation; exports.erc20TransferOp = erc20TransferOp; exports.erc20ApproveOp = erc20ApproveOp; exports.erc20BurnOp = erc20BurnOp; exports.rawCallOp = rawCallOp; exports.buildSwapWithGasDeduction = buildSwapWithGasDeduction;
373
- //# sourceMappingURL=chunk-B3PYJGTH.cjs.map
373
+ //# sourceMappingURL=chunk-JJ2LGENO.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-JJ2LGENO.cjs","../src/swap/approval.ts","../src/swap/universalRouter.ts","../src/errors.ts","../src/swap/simulate.ts","../src/swap/buildSwapWithGasDeduction.ts","../src/userop/batchExecute.ts","../src/userop/buildUserOperation.ts","../src/userop/operations.ts"],"names":["encodeFunctionData","erc20Abi"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACTA,4BAAmC;AAKnC,MAAA,SAAsB,cAAA,CACpB,MAAA,EACA,KAAA,EACA,KAAA,EACA,OAAA,EACiB;AACjB,EAAA,OAAO,MAAA,CAAO,YAAA,CAAa;AAAA,IACzB,OAAA,EAAS,KAAA;AAAA,IACT,GAAA,EAAK,0BAAA;AAAA,IACL,YAAA,EAAc,WAAA;AAAA,IACd,IAAA,EAAM,CAAC,KAAA,EAAO,OAAO;AAAA,EACvB,CAAC,CAAA;AACH;AAKO,SAAS,0BAAA,CACd,OAAA,EACA,MAAA,EACK;AACL,EAAA,OAAO,sCAAA;AAAmB,IACxB,GAAA,EAAK,0BAAA;AAAA,IACL,YAAA,EAAc,SAAA;AAAA,IACd,IAAA,EAAM,CAAC,OAAA,EAAS,MAAM;AAAA,EACxB,CAAC,CAAA;AACH;AAKO,SAAS,4BAAA,CACd,KAAA,EACA,OAAA,EACA,MAAA,EACA,UAAA,EACK;AACL,EAAA,OAAO,sCAAA;AAAmB,IACxB,GAAA,EAAK,4BAAA;AAAA,IACL,YAAA,EAAc,SAAA;AAAA,IACd,IAAA,EAAM,CAAC,KAAA,EAAO,OAAA,EAAS,MAAA,EAAQ,UAAU;AAAA,EAC3C,CAAC,CAAA;AACH;ADdA;AACA;AElCA;AAUO,IAAM,QAAA,EAAU,EAAA;AAIhB,IAAM,cAAA,EAAgB,CAAA;AACtB,IAAM,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;AACG,IAAA;AACD,IAAA;AACkB,IAAA;AAClB,MAAA;AACS,MAAA;AACD,MAAA;AACd,IAAA;AACH,EAAA;AACF;AAWa;AACkB,EAAA;AAC/B;AR8LwD;AACA;AK7KhC;AACK,EAAA;AACT,IAAA;AAClB,EAAA;AAC8B,EAAA;AAClB,IAAA;AACR,MAAA;AACF,IAAA;AACF,EAAA;AAC0B,EAAA;AACd,IAAA;AACR,MAAA;AACF,IAAA;AACF,EAAA;AACkC,EAAA;AACtB,IAAA;AACR,MAAA;AACF,IAAA;AACF,EAAA;AAE6B,EAAA;AACpB,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACT,EAAA;AAE6C,EAAA;AACtC,IAAA;AACS,IAAA;AAC0B,IAAA;AACzC,EAAA;AAE+B,EAAA;AACvB,IAAA;AACA,IAAA;AACA,IAAA;AACe,IAAA;AACxB,EAAA;AAEgC,EAAA;AAC9B,IAAA;AACS,MAAA;AACP,MAAA;AACO,MAAA;AACT,IAAA;AAC6C,IAAA;AACJ,IAAA;AAC3C,EAAA;AAE0B,EAAA;AACb,IAAA;AACT,MAAA;AACS,QAAA;AACA,QAAA;AACA,QAAA;AACT,MAAA;AACF,IAAA;AACF,EAAA;AAEiC,EAAA;AAChB,IAAA;AACD,IAAA;AACd,IAAA;AACW,IAAA;AACuC,MAAA;AAE5B,MAAA;AACkB,MAAA;AACxC,IAAA;AACD,EAAA;AACH;ALwKwD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-JJ2LGENO.cjs","sourcesContent":[null,"import { encodeFunctionData } from \"viem\";\nimport type { Address, Hex, PublicClient } from \"viem\";\nimport { erc20Abi } from \"../abi/erc20\";\nimport { permit2Abi } from \"../abi/permit2\";\n\nexport async function checkAllowance(\n client: PublicClient,\n token: Address,\n owner: Address,\n spender: Address,\n): Promise<bigint> {\n return client.readContract({\n address: token,\n abi: erc20Abi,\n functionName: \"allowance\",\n args: [owner, spender],\n });\n}\n\n/**\n * Encode an ERC-20 approve(spender, amount) call.\n */\nexport function buildErc20ApprovalCalldata(\n spender: Address,\n amount: bigint,\n): Hex {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount],\n });\n}\n\n/**\n * Encode a Permit2 approve(token, spender, amount, expiration) call.\n */\nexport function buildPermit2ApprovalCalldata(\n token: Address,\n spender: Address,\n amount: bigint,\n expiration: number,\n): Hex {\n return encodeFunctionData({\n abi: permit2Abi,\n functionName: \"approve\",\n args: [token, spender, amount, expiration],\n });\n}\n","import { encodeAbiParameters, encodePacked } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport type { PathKey, QuoteResult } from \"../types\";\n\n// -------------------------------------------------------------------------\n// V4 UniversalRouter command / action constants\n// Reference: https://github.com/Uniswap/v4-periphery/blob/main/src/libraries/Actions.sol\n// -------------------------------------------------------------------------\n\n/** UniversalRouter command byte for V4 swap */\nexport const V4_SWAP = 0x10 as const;\n\n/** V4 actions */\nexport const SWAP_EXACT_IN_SINGLE = 0x06 as const;\nexport const SWAP_EXACT_IN = 0x07 as const;\nexport const SETTLE_ALL = 0x0c as const;\nexport const TAKE_ALL = 0x0f as const;\n\n// -------------------------------------------------------------------------\n// ABI type strings matching Uniswap's V4Planner encoding\n// Reference: https://github.com/Uniswap/sdks/blob/main/sdks/v4-sdk/src/utils/v4Planner.ts\n//\n// IMPORTANT: PathKey.fee is uint256 in the V4 Router ABI (not uint24).\n// -------------------------------------------------------------------------\n\n// PathKey components for V4 Router ABI encoding.\n// IMPORTANT: fee is uint256 in the V4 Router (not uint24 as in PoolKey).\n// Reference: https://github.com/Uniswap/sdks/blob/main/sdks/v4-sdk/src/utils/v4Planner.ts\nconst PATH_KEY_ABI_COMPONENTS = [\n { name: \"intermediateCurrency\", type: \"address\" },\n { name: \"fee\", type: \"uint256\" },\n { name: \"tickSpacing\", type: \"int24\" },\n { name: \"hooks\", type: \"address\" },\n { name: \"hookData\", type: \"bytes\" },\n] as const;\n\nconst EXACT_INPUT_PARAMS_ABI = [\n { name: \"currencyIn\", type: \"address\" },\n {\n name: \"path\",\n type: \"tuple[]\",\n components: PATH_KEY_ABI_COMPONENTS,\n },\n { name: \"amountIn\", type: \"uint128\" },\n { name: \"amountOutMinimum\", type: \"uint128\" },\n] as const;\n\n/**\n * Build the calldata inputs[0] (the V4_SWAP command payload) for\n * UniversalRouter.execute.\n *\n * Actions encoded: SWAP_EXACT_IN → SETTLE_ALL → TAKE_ALL\n *\n * Encoding matches the Uniswap V4 SDK's V4Planner — each action's params\n * are individually ABI-encoded, then wrapped together with the action bytes.\n */\nexport function buildV4SwapInput(\n currencyIn: Address,\n path: PathKey[],\n amountIn: bigint,\n minAmountOut: bigint,\n outputCurrency: Address,\n): Hex {\n const actions = encodePacked(\n [\"uint8\", \"uint8\", \"uint8\"],\n [SWAP_EXACT_IN, SETTLE_ALL, TAKE_ALL],\n );\n\n // Param 0: ExactInputParams — encoded as a single tuple so the CalldataDecoder\n // can locate it via a single offset pointer. fee is uint256 per V4 Router spec.\n const swapParam = encodeAbiParameters(\n [{ name: \"swap\", type: \"tuple\", components: EXACT_INPUT_PARAMS_ABI }],\n [\n {\n currencyIn,\n path: path.map((p) => ({\n intermediateCurrency: p.intermediateCurrency,\n fee: BigInt(p.fee),\n tickSpacing: p.tickSpacing,\n hooks: p.hooks,\n hookData: p.hookData,\n })),\n amountIn,\n amountOutMinimum: minAmountOut,\n },\n ],\n );\n\n // Param 1: SETTLE_ALL { currency, maxAmount }\n const settleParam = encodeAbiParameters(\n [\n { name: \"currency\", type: \"address\" },\n { name: \"maxAmount\", type: \"uint256\" },\n ],\n [currencyIn, amountIn],\n );\n\n // Param 2: TAKE_ALL { currency, minAmount }\n const takeParam = encodeAbiParameters(\n [\n { name: \"currency\", type: \"address\" },\n { name: \"minAmount\", type: \"uint256\" },\n ],\n [outputCurrency, minAmountOut],\n );\n\n return encodeAbiParameters(\n [\n { name: \"actions\", type: \"bytes\" },\n { name: \"params\", type: \"bytes[]\" },\n ],\n [actions, [swapParam, settleParam, takeParam]],\n );\n}\n\n/**\n * Build the full commands + inputs args for UniversalRouter.execute.\n */\nexport function buildUniversalRouterExecuteArgs(\n currencyIn: Address,\n path: PathKey[],\n amountIn: bigint,\n minAmountOut: bigint,\n outputCurrency: Address,\n): { commands: Hex; inputs: Hex[] } {\n const commands = encodePacked([\"uint8\"], [V4_SWAP]);\n const inputs: Hex[] = [\n buildV4SwapInput(currencyIn, path, amountIn, minAmountOut, outputCurrency),\n ];\n return { commands, inputs };\n}\n\n/**\n * Build UniversalRouter execute args from a quote result.\n *\n * Takes the output of `findBestQuote` / `quoteBestRoute` and produces\n * ready-to-use `{ commands, inputs }` for `UniversalRouter.execute`.\n *\n * @param quote - Quote result containing the path\n * @param currencyIn - Input token address\n * @param currencyOut - Output token address\n * @param amountIn - Exact input amount (same value passed to the quoter)\n * @param minAmountOut - Minimum acceptable output (caller applies slippage)\n *\n * @deprecated Since v1.4 — the Issuer App no longer handles swaps.\n * For the new PT→USDT batch call on PAFI Web (Scenario 4 with\n * EIP-7702 gas deduction), use `buildSwapWithGasDeduction()` (v1.5).\n * This helper is kept for legacy v0.2.x consumers; will be removed in v2.0.\n */\nexport function buildSwapFromQuote(params: {\n quote: QuoteResult;\n currencyIn: Address;\n currencyOut: Address;\n amountIn: bigint;\n minAmountOut: bigint;\n}): { commands: Hex; inputs: Hex[] } {\n return buildUniversalRouterExecuteArgs(\n params.currencyIn,\n params.quote.path,\n params.amountIn,\n params.minAmountOut,\n params.currencyOut,\n );\n}\n","export class PafiSDKError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"PafiSDKError\";\n }\n}\n\nexport class ConfigurationError extends PafiSDKError {\n constructor(message: string) {\n super(message);\n this.name = \"ConfigurationError\";\n }\n}\n\nexport class SigningError extends PafiSDKError {\n constructor(message: string) {\n super(message);\n this.name = \"SigningError\";\n }\n}\n\nexport class SimulationError extends PafiSDKError {\n constructor(\n public operation: string,\n public reason: string,\n ) {\n super(`Simulation failed for ${operation}: ${reason}`);\n this.name = \"SimulationError\";\n }\n}\n\nexport class ApiError extends PafiSDKError {\n constructor(\n message: string,\n public status?: number,\n ) {\n super(message);\n this.name = \"ApiError\";\n }\n}\n","import type { Address, Hex, PublicClient } from \"viem\";\nimport { universalRouterAbi } from \"../abi/universalRouter\";\nimport { SimulationError } from \"../errors\";\n\nexport interface SwapSimulationResult {\n success: boolean;\n gasEstimate: bigint;\n}\n\n/**\n * Simulate a UniversalRouter.execute swap call via eth_call (no gas spent).\n *\n * Runs the full V4 swap flow — token transfer via Permit2, swap via\n * PoolManager, output settlement — without submitting a transaction.\n * If the simulation reverts, throws a `SimulationError` with the reason.\n *\n * @param client - viem PublicClient\n * @param routerAddress - UniversalRouter contract address\n * @param commands - Packed command bytes (from buildSwapFromQuote)\n * @param inputs - Encoded inputs per command (from buildSwapFromQuote)\n * @param deadline - Unix timestamp after which the tx expires\n * @param from - Address that will execute the swap\n */\nexport async function simulateSwap(\n client: PublicClient,\n routerAddress: Address,\n commands: Hex,\n inputs: Hex[],\n deadline: bigint,\n from: Address,\n): Promise<SwapSimulationResult> {\n try {\n const gasEstimate = await client.estimateContractGas({\n address: routerAddress,\n abi: universalRouterAbi,\n functionName: \"execute\",\n args: [commands, inputs, deadline],\n account: from,\n });\n\n return { success: true, gasEstimate };\n } catch (error: unknown) {\n const message =\n error instanceof Error ? error.message : \"Unknown simulation error\";\n throw new SimulationError(\"swap\", message);\n }\n}\n","import { encodeFunctionData } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport { universalRouterAbi } from \"../abi/universalRouter\";\nimport type { PathKey } from \"../types\";\nimport { buildPartialUserOperation } from \"../userop/buildUserOperation\";\nimport type { PartialUserOperation } from \"../userop/types\";\nimport {\n erc20ApproveOp,\n erc20TransferOp,\n rawCallOp,\n} from \"../userop/operations\";\nimport type { Operation } from \"../userop/types\";\nimport { buildUniversalRouterExecuteArgs } from \"./universalRouter\";\nimport { buildPermit2ApprovalCalldata } from \"./approval\";\nimport { PERMIT2_ADDRESS } from \"../constants\";\n\n/**\n * v1.5 — Scenario 4: Swap PT → USDT on PAFI Web with gas fee\n * deducted in PT from the user's balance.\n *\n * Builds an unsigned `PartialUserOperation` that packages up to four\n * inner calls into a single `BatchExecutor.execute(calls[])`:\n *\n * 1. `PT.approve(Permit2, amountIn)` — grant Permit2 ERC-20 allowance\n * 2. `Permit2.approve(PT, router, amountIn, deadline)` — authorize\n * the UniversalRouter to pull PT via Permit2\n * 3. `UniversalRouter.execute(commands, inputs, deadline)` — V4 swap\n * PT → USDT; user receives ≥ `minAmountOut` USDT\n * 4. `PT.transfer(feeRecipient, gasFeePt)` — pay the operator back\n * for sponsoring the gas, in PT (omitted when `gasFeePt` is 0)\n *\n * The user's wallet must hold `amountIn + gasFeePt` PT before the\n * UserOp runs. All inner calls execute atomically via EIP-7702\n * delegation (`msg.sender = user`), so a reverting swap unwinds\n * the approvals and fee transfer too.\n *\n * ## Fee model\n *\n * The gas fee is a separate `transfer` after the swap — it does NOT\n * come out of the USDT output, because that output goes straight to\n * the user's wallet with no intermediate hook.\n *\n * If the FE wants \"user receives exactly X USDT after gas\":\n * 1. Quote PT→USDT for candidate `amountIn` values\n * 2. Pick an `amountIn` where `minAmountOut ≈ X`\n * 3. Separately compute `gasFeePt` from the operator's rate\n * 4. Ensure user's PT balance ≥ `amountIn + gasFeePt`\n *\n * ## Order of operations\n *\n * Fee transfer is last so a reverting swap also refunds the fee\n * (atomic batch revert semantics).\n */\nexport interface BuildSwapWithGasDeductionParams {\n /** User's EOA (with EIP-7702 delegation to BatchExecutor). */\n userAddress: Address;\n /** ERC-4337 account nonce — fetched from EntryPoint by the caller. */\n aaNonce: bigint;\n\n /** PT token address being swapped. */\n pointTokenAddress: Address;\n /** Destination currency (typically USDT). */\n outputTokenAddress: Address;\n /** UniversalRouter contract address (chain-specific). */\n universalRouterAddress: Address;\n\n /** PT units to swap. User's balance must be ≥ `amountIn + gasFeePt`. */\n amountIn: bigint;\n /**\n * Minimum USDT to accept out of the swap. Caller applies slippage\n * (typically ~0.5-1%) against a fresh quote. Sub-minimum swap reverts.\n */\n minAmountOut: bigint;\n\n /** V4 pool path for the swap. Single-hop = 1 PathKey. */\n swapPath: PathKey[];\n /** Unix seconds. After this, the router rejects the swap. */\n deadline: bigint;\n\n /** PT amount transferred to `feeRecipient` as gas fee recovery. */\n gasFeePt: bigint;\n /** Where the gas fee lands — typically the operator or fee collector. */\n feeRecipient: Address;\n\n /** Override ERC-4337 gas estimates. Defaults are conservative; tune down for cheaper UserOps. */\n gasLimits?: {\n callGasLimit?: bigint;\n verificationGasLimit?: bigint;\n preVerificationGas?: bigint;\n };\n}\n\n/**\n * Build an unsigned UserOp for Scenario 4. Returns a\n * `PartialUserOperation` — caller attaches paymaster sponsorship (via\n * `POST /api/paymaster/sponsor`), adds the user's UserOp-hash\n * signature, and submits to the Bundler.\n *\n * @throws when `amountIn` or `gasFeePt` is not positive, or when\n * `swapPath` is empty (at least one PathKey required).\n */\nexport function buildSwapWithGasDeduction(\n params: BuildSwapWithGasDeductionParams,\n): PartialUserOperation {\n if (params.amountIn <= 0n) {\n throw new Error(\"buildSwapWithGasDeduction: amountIn must be positive\");\n }\n if (params.minAmountOut < 0n) {\n throw new Error(\n \"buildSwapWithGasDeduction: minAmountOut must be non-negative\",\n );\n }\n if (params.gasFeePt < 0n) {\n throw new Error(\n \"buildSwapWithGasDeduction: gasFeePt must be non-negative\",\n );\n }\n if (params.swapPath.length === 0) {\n throw new Error(\n \"buildSwapWithGasDeduction: swapPath must contain at least one PathKey\",\n );\n }\n\n const { commands, inputs } = buildUniversalRouterExecuteArgs(\n params.pointTokenAddress,\n params.swapPath,\n params.amountIn,\n params.minAmountOut,\n params.outputTokenAddress,\n );\n\n const swapCallData: Hex = encodeFunctionData({\n abi: universalRouterAbi,\n functionName: \"execute\",\n args: [commands, inputs, params.deadline],\n });\n\n const permit2ApproveData: Hex = buildPermit2ApprovalCalldata(\n params.pointTokenAddress,\n params.universalRouterAddress,\n params.amountIn,\n Number(params.deadline),\n );\n\n const operations: Operation[] = [\n erc20ApproveOp(\n params.pointTokenAddress,\n PERMIT2_ADDRESS,\n params.amountIn,\n ),\n rawCallOp(PERMIT2_ADDRESS, permit2ApproveData),\n rawCallOp(params.universalRouterAddress, swapCallData),\n ];\n\n if (params.gasFeePt > 0n) {\n operations.push(\n erc20TransferOp(\n params.pointTokenAddress,\n params.feeRecipient,\n params.gasFeePt,\n ),\n );\n }\n\n return buildPartialUserOperation({\n sender: params.userAddress,\n nonce: params.aaNonce,\n operations,\n gasLimits: {\n callGasLimit: params.gasLimits?.callGasLimit ?? 700_000n,\n verificationGasLimit:\n params.gasLimits?.verificationGasLimit ?? 150_000n,\n preVerificationGas: params.gasLimits?.preVerificationGas ?? 50_000n,\n },\n });\n}\n","import { decodeFunctionData, encodeFunctionData, parseAbi } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport type { Operation } from \"./types\";\n\n/**\n * Standard BatchExecutor ABI — a contract that takes an array of calls\n * and invokes each one in sequence, reverting all if any fail.\n *\n * Function name is `executeBatch` (selector `0x34fcd5be`) to match\n * Pimlico's `Simple7702Account` and Coinbase Smart Wallet v2 — both\n * EIP-7702 delegate impls expose `executeBatch(Call[])`, not `execute`.\n * The shorter `execute(Call[])` (selector `0x3f707e6b`) only exists on\n * legacy/standalone batch executor contracts; calling it on a 7702\n * delegated EOA falls through to the fallback function and reverts\n * with \"account: not from EntryPoint\" (AA23).\n */\nexport const BATCH_EXECUTOR_ABI = parseAbi([\n \"function executeBatch((address target, uint256 value, bytes data)[] calls)\",\n]);\n\n/**\n * Encode a batch of operations into calldata for `BatchExecutor.execute()`.\n * The resulting calldata goes into `UserOperation.callData`.\n *\n * When the EOA has an EIP-7702 delegation to a BatchExecutor, calling\n * this calldata against the EOA runs all operations with\n * `msg.sender = EOA` for each inner call.\n *\n * @param operations batch of calls, in execution order\n * @returns calldata bytes for `execute((address,uint256,bytes)[])`\n */\nexport function encodeBatchExecute(operations: Operation[]): Hex {\n if (operations.length === 0) {\n throw new Error(\"encodeBatchExecute: operations array must not be empty\");\n }\n return encodeFunctionData({\n abi: BATCH_EXECUTOR_ABI,\n functionName: \"executeBatch\",\n args: [\n operations.map((op) => ({\n target: op.target,\n value: op.value,\n data: op.data,\n })),\n ],\n });\n}\n\n/**\n * Decode `BatchExecutor.execute(calls[])` callData back into individual\n * `{ to, data, value }` objects.\n *\n * Used by issuer backends to convert a `PartialUserOperation.callData`\n * into the `calls[]` array returned to web/FE clients (which submit via\n * `permissionless.sendTransaction({ calls })`).\n */\nexport function decodeBatchExecuteCalls(\n callData: Hex,\n): Array<{ to: string; data: string; value: string }> {\n const { args } = decodeFunctionData({\n abi: BATCH_EXECUTOR_ABI,\n data: callData,\n });\n return (\n args[0] as ReadonlyArray<{ target: Address; value: bigint; data: Hex }>\n ).map((c) => ({\n to: c.target,\n data: c.data,\n value: c.value.toString(),\n }));\n}\n","import type { Address } from \"viem\";\nimport type { Operation, PartialUserOperation, UserOperation } from \"./types\";\nimport { encodeBatchExecute } from \"./batchExecute\";\n\n/**\n * Default gas limits — rough upper bounds for a 2-op batch on Base.\n * Bundler re-estimates before submission, so these are only used when\n * the caller doesn't supply their own.\n */\nconst DEFAULT_CALL_GAS_LIMIT = 500_000n;\nconst DEFAULT_VERIFICATION_GAS_LIMIT = 150_000n;\nconst DEFAULT_PRE_VERIFICATION_GAS = 50_000n;\n\nexport interface BuildPartialUserOpParams {\n /** User's EOA (with EIP-7702 delegation). */\n sender: Address;\n /** Batch of operations — encoded into callData via `encodeBatchExecute`. */\n operations: Operation[];\n /** EntryPoint nonce for this sender. Caller fetches from the EntryPoint contract. */\n nonce: bigint;\n /** Optional gas overrides; bundler re-estimates before submission. */\n gasLimits?: {\n callGasLimit?: bigint;\n verificationGasLimit?: bigint;\n preVerificationGas?: bigint;\n };\n /** Optional fee overrides; bundler usually fills these. */\n feeOverrides?: {\n maxFeePerGas?: bigint;\n maxPriorityFeePerGas?: bigint;\n };\n}\n\n/**\n * Build a partial ERC-4337 UserOperation from a batch of operations.\n * Paymaster fields and signature are populated later:\n * 1. Call `PafiBackendClient.requestSponsorship()` → get paymaster fields\n * 2. Compute userOpHash and have the user sign it (via Privy)\n * 3. Attach `signature` → submit to bundler\n *\n * This function is a pure struct builder — no network calls.\n */\nexport function buildPartialUserOperation(\n params: BuildPartialUserOpParams,\n): PartialUserOperation {\n return {\n sender: params.sender,\n nonce: params.nonce,\n callData: encodeBatchExecute(params.operations),\n callGasLimit: params.gasLimits?.callGasLimit ?? DEFAULT_CALL_GAS_LIMIT,\n verificationGasLimit:\n params.gasLimits?.verificationGasLimit ??\n DEFAULT_VERIFICATION_GAS_LIMIT,\n preVerificationGas:\n params.gasLimits?.preVerificationGas ?? DEFAULT_PRE_VERIFICATION_GAS,\n maxFeePerGas: params.feeOverrides?.maxFeePerGas ?? 0n,\n maxPriorityFeePerGas: params.feeOverrides?.maxPriorityFeePerGas ?? 0n,\n };\n}\n\n/**\n * Assemble a full UserOperation once paymaster fields + signature are\n * known. Used after `PafiBackendClient.requestSponsorship()` and user\n * signing complete.\n */\nexport function assembleUserOperation(\n partial: PartialUserOperation,\n paymaster: {\n paymaster: Address;\n paymasterData: `0x${string}`;\n paymasterVerificationGasLimit: bigint;\n paymasterPostOpGasLimit: bigint;\n },\n signature: `0x${string}`,\n): UserOperation {\n return {\n ...partial,\n paymaster: paymaster.paymaster,\n paymasterData: paymaster.paymasterData,\n paymasterVerificationGasLimit: paymaster.paymasterVerificationGasLimit,\n paymasterPostOpGasLimit: paymaster.paymasterPostOpGasLimit,\n signature,\n };\n}\n","import { encodeFunctionData, erc20Abi, parseAbi } from \"viem\";\nimport type { Address } from \"viem\";\nimport type { Operation } from \"./types\";\n\n/**\n * ERC20Burnable extension — `burn(uint256 amount)` burns from msg.sender.\n * The EOA (via EIP-7702 delegation) is the `msg.sender` when a batch\n * runs — so this burns the user's balance without any role check.\n */\nconst ERC20_BURNABLE_ABI = parseAbi([\"function burn(uint256 amount)\"]);\n\n/**\n * Build an ERC-20 `transfer(to, amount)` operation. Used inside a batch\n * to move fee tokens from the user to the fee recipient atomically with\n * the main action.\n */\nexport function erc20TransferOp(\n token: Address,\n to: Address,\n amount: bigint,\n): Operation {\n return {\n target: token,\n value: 0n,\n data: encodeFunctionData({\n abi: erc20Abi,\n functionName: \"transfer\",\n args: [to, amount],\n }),\n };\n}\n\n/**\n * Build an ERC-20 `approve(spender, amount)` operation. Used inside a\n * batch before a swap / deposit call so the AMM / protocol can pull\n * tokens from the user.\n */\nexport function erc20ApproveOp(\n token: Address,\n spender: Address,\n amount: bigint,\n): Operation {\n return {\n target: token,\n value: 0n,\n data: encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount],\n }),\n };\n}\n\n/**\n * Build an ERC-20 `burn(amount)` operation (OpenZeppelin ERC20Burnable\n * extension). Burns from `msg.sender`, which — via EIP-7702 — is the\n * user's EOA.\n *\n * Requires the PointToken contract to expose a public `burn(uint256)`\n * without a role check. See\n * [SDK_V1.4_TASKS.md §11 — PointToken.burn callable via batch].\n */\nexport function erc20BurnOp(token: Address, amount: bigint): Operation {\n return {\n target: token,\n value: 0n,\n data: encodeFunctionData({\n abi: ERC20_BURNABLE_ABI,\n functionName: \"burn\",\n args: [amount],\n }),\n };\n}\n\n/**\n * Build a raw call operation with caller-supplied calldata. Useful for\n * non-ERC-20 contracts (PoolManager.swap, PerpDEX.deposit, Relayer.mint)\n * where the encoding is specific to that protocol.\n */\nexport function rawCallOp(\n target: Address,\n data: `0x${string}`,\n value: bigint = 0n,\n): Operation {\n return { target, value, data };\n}\n"]}
@@ -5,13 +5,13 @@ var _chunkCL3QSI4Ocjs = require('./chunk-CL3QSI4O.cjs');
5
5
 
6
6
 
7
7
 
8
- var _chunk52SZJDFTcjs = require('./chunk-52SZJDFT.cjs');
8
+ var _chunkX2JZFK4Ccjs = require('./chunk-X2JZFK4C.cjs');
9
9
 
10
10
  // src/quoting/routes.ts
11
11
  var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
12
12
  function combineRoutes(chainId, pointTokenAddress) {
13
- const commonPools = _nullishCoalesce(_chunk52SZJDFTcjs.COMMON_POOLS[chainId], () => ( []));
14
- const pointPools = _nullishCoalesce(_optionalChain([_chunk52SZJDFTcjs.POINT_TOKEN_POOLS, 'access', _ => _[chainId], 'optionalAccess', _2 => _2[pointTokenAddress]]), () => ( []));
13
+ const commonPools = _nullishCoalesce(_chunkX2JZFK4Ccjs.COMMON_POOLS[chainId], () => ( []));
14
+ const pointPools = _nullishCoalesce(_optionalChain([_chunkX2JZFK4Ccjs.POINT_TOKEN_POOLS, 'access', _ => _[chainId], 'optionalAccess', _2 => _2[pointTokenAddress]]), () => ( []));
15
15
  return [...pointPools, ...commonPools];
16
16
  }
17
17
  function buildAllPaths(pools, tokenIn, tokenOut, maxHops = 3) {
@@ -112,11 +112,11 @@ async function quoteBestRoute(client, quoterAddress, exactCurrency, routes, exac
112
112
  return { bestRoute, allRoutes };
113
113
  }
114
114
  async function findBestQuote(client, chainId, tokenIn, tokenOut, exactAmount, pools = [], quoterAddress, maxHops = 3) {
115
- const quoter = _nullishCoalesce(quoterAddress, () => ( _chunk52SZJDFTcjs.V4_QUOTER_ADDRESSES[chainId]));
115
+ const quoter = _nullishCoalesce(quoterAddress, () => ( _chunkX2JZFK4Ccjs.V4_QUOTER_ADDRESSES[chainId]));
116
116
  if (!quoter) {
117
117
  throw new Error(`No V4 Quoter address configured for chain ${chainId}`);
118
118
  }
119
- const commonPools = _nullishCoalesce(_chunk52SZJDFTcjs.COMMON_POOLS[chainId], () => ( []));
119
+ const commonPools = _nullishCoalesce(_chunkX2JZFK4Ccjs.COMMON_POOLS[chainId], () => ( []));
120
120
  const allPools = [...pools, ...commonPools];
121
121
  const paths = buildAllPaths(allPools, tokenIn, tokenOut, maxHops);
122
122
  if (paths.length === 0) {
@@ -133,4 +133,4 @@ async function findBestQuote(client, chainId, tokenIn, tokenOut, exactAmount, po
133
133
 
134
134
 
135
135
  exports.combineRoutes = combineRoutes; exports.buildAllPaths = buildAllPaths; exports.quoteExactInput = quoteExactInput; exports.quoteExactInputSingle = quoteExactInputSingle; exports.quoteBestRoute = quoteBestRoute; exports.findBestQuote = findBestQuote;
136
- //# sourceMappingURL=chunk-ARZSGP5Y.cjs.map
136
+ //# sourceMappingURL=chunk-L5UHQQVC.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-ARZSGP5Y.cjs","../src/quoting/routes.ts","../src/quoting/quote.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,IAAM,aAAA,EAAe,4CAAA;AAMd,SAAS,aAAA,CACd,OAAA,EACA,iBAAA,EACW;AACX,EAAA,MAAM,YAAA,mBAAc,8BAAA,CAAa,OAAO,CAAA,UAAK,CAAC,GAAA;AAC9C,EAAA,MAAM,WAAA,mCAAa,mCAAA,mBAAkB,OAAO,CAAA,4BAAA,CAAI,iBAAiB,GAAA,UAAK,CAAC,GAAA;AACvE,EAAA,OAAO,CAAC,GAAG,UAAA,EAAY,GAAG,WAAW,CAAA;AACvC;AAcO,SAAS,aAAA,CACd,KAAA,EACA,OAAA,EACA,QAAA,EACA,QAAA,EAAU,CAAA,EACG;AACb,EAAA,MAAM,QAAA,EAAuB,CAAC,CAAA;AAE9B,EAAA,SAAS,GAAA,CACP,YAAA,EACA,WAAA,EACA,eAAA,EACA;AACA,IAAA,GAAA,CAAI,WAAA,CAAY,OAAA,EAAS,OAAA,EAAS,MAAA;AAGlC,IAAA,GAAA,CACE,WAAA,CAAY,OAAA,EAAS,EAAA,GACrB,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AAA,EAAM,OAAA,EAAA,GACxC,OAAA,CAAQ,UAAA,EAAY,IAAA,CAAK,UAAA,EAAY,QAAA,EAAU;AAAA,EACjD,CAAA;AAEA,EAAA,OAAO,EAAE,SAAA,EAAW,UAAU,CAAA;AAChC;AAkBA,MAAA,SAAsB,aAAA,CACpB,MAAA,EACA,OAAA,EACA,OAAA,EACA,QAAA,EACA,WAAA,EACA,MAAA,EAAmB,CAAC,CAAA,EACpB,aAAA,EACA,QAAA,EAAU,CAAA,EACU;AACpB,EAAA,MAAM,OAAA,mBAAS,aAAA,UAAiB,qCAAA,CAAoB,OAAO,GAAA;AAC3D,EAAA,GAAA,CAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,0CAAA,EAA6C,OAAO,CAAA,CAAA;AACtE,EAAA;AAE8C,EAAA;AACJ,EAAA;AACsB,EAAA;AAExC,EAAA;AACyC,IAAA;AACjE,EAAA;AAEiE,EAAA;AACnE;AFjByE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-ARZSGP5Y.cjs","sourcesContent":[null,"import type { Address } from \"viem\";\nimport type { PathKey, PoolKey } from \"../types\";\nimport { COMMON_POOLS, POINT_TOKEN_POOLS } from \"../constants\";\n\nconst ZERO_ADDRESS = \"0x0000000000000000000000000000000000000000\" as Address;\n\n/**\n * Combine point-token-specific pools and common pools for a given chain.\n * Point token pools are listed first so callers can prioritise them.\n */\nexport function combineRoutes(\n chainId: number,\n pointTokenAddress: Address,\n): PoolKey[] {\n const commonPools = COMMON_POOLS[chainId] ?? [];\n const pointPools = POINT_TOKEN_POOLS[chainId]?.[pointTokenAddress] ?? [];\n return [...pointPools, ...commonPools];\n}\n\n/**\n * Build all possible swap paths from `tokenIn` to `tokenOut` using the given\n * pools. Returns an array of PathKey[] routes (each up to `maxHops` hops).\n *\n * Supports both direct single-hop routes and multi-hop routes through\n * intermediate tokens. Each pool is used at most once per path.\n *\n * @param pools - Available pools to route through\n * @param tokenIn - Input token address\n * @param tokenOut - Desired output token address\n * @param maxHops - Maximum number of hops (default 3)\n */\nexport function buildAllPaths(\n pools: PoolKey[],\n tokenIn: Address,\n tokenOut: Address,\n maxHops = 3,\n): PathKey[][] {\n const results: PathKey[][] = [];\n\n function dfs(\n currentToken: Address,\n currentPath: PathKey[],\n usedPoolIndices: Set<number>,\n ) {\n if (currentPath.length > maxHops) return;\n\n // Check if we've reached the destination\n if (\n currentPath.length > 0 &&\n currentToken.toLowerCase() === tokenOut.toLowerCase()\n ) {\n results.push([...currentPath]);\n return;\n }\n\n for (let i = 0; i < pools.length; i++) {\n if (usedPoolIndices.has(i)) continue;\n\n const pool = pools[i]!;\n const c0 = pool.currency0.toLowerCase();\n const c1 = pool.currency1.toLowerCase();\n const curr = currentToken.toLowerCase();\n\n let nextToken: Address | null = null;\n if (curr === c0) {\n nextToken = pool.currency1 as Address;\n } else if (curr === c1) {\n nextToken = pool.currency0 as Address;\n }\n\n if (!nextToken) continue;\n\n const hop: PathKey = {\n intermediateCurrency: nextToken,\n fee: pool.fee,\n tickSpacing: pool.tickSpacing,\n hooks: pool.hooks ?? ZERO_ADDRESS,\n hookData: \"0x\",\n };\n\n usedPoolIndices.add(i);\n currentPath.push(hop);\n dfs(nextToken, currentPath, usedPoolIndices);\n currentPath.pop();\n usedPoolIndices.delete(i);\n }\n }\n\n dfs(tokenIn, [], new Set());\n return results;\n}\n","import type { Address, PublicClient } from \"viem\";\nimport type { BestQuote, PathKey, PoolKey, QuoteResult } from \"../types\";\nimport { v4QuoterAbi } from \"../abi/v4Quoter\";\nimport { buildAllPaths } from \"./routes\";\nimport { COMMON_POOLS, V4_QUOTER_ADDRESSES } from \"../constants\";\n\n/**\n * Quote exact-input for a multi-hop path.\n */\nexport async function quoteExactInput(\n client: PublicClient,\n quoterAddress: Address,\n exactCurrency: Address,\n path: PathKey[],\n exactAmount: bigint,\n): Promise<QuoteResult> {\n const [amountOut, gasEstimate] = await client.readContract({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: \"quoteExactInput\",\n args: [{ exactCurrency, path, exactAmount: BigInt(exactAmount) as unknown as number }],\n }) as [bigint, bigint];\n\n return { amountOut, gasEstimate, path };\n}\n\n/**\n * Quote exact-input for a single-hop swap, given an explicit PoolKey and direction.\n */\nexport async function quoteExactInputSingle(\n client: PublicClient,\n quoterAddress: Address,\n poolKey: PoolKey,\n zeroForOne: boolean,\n exactAmount: bigint,\n hookData: `0x${string}`,\n): Promise<{ amountOut: bigint; gasEstimate: bigint }> {\n const [amountOut, gasEstimate] = await client.readContract({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: \"quoteExactInputSingle\",\n args: [\n {\n poolKey,\n zeroForOne,\n exactAmount: BigInt(exactAmount) as unknown as number,\n hookData,\n },\n ],\n }) as [bigint, bigint];\n\n return { amountOut, gasEstimate };\n}\n\n/**\n * Try multiple PathKey[] routes and return the best quote plus all results.\n * Routes that fail (e.g. pool does not exist) are silently skipped.\n *\n * Uses viem multicall to batch all quotes into a single RPC call for speed.\n */\nexport async function quoteBestRoute(\n client: PublicClient,\n quoterAddress: Address,\n exactCurrency: Address,\n routes: PathKey[][],\n exactAmount: bigint,\n): Promise<BestQuote> {\n const results = await client.multicall({\n contracts: routes.map((path) => ({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: \"quoteExactInput\" as const,\n args: [\n {\n exactCurrency,\n path,\n exactAmount: BigInt(exactAmount) as unknown as number,\n },\n ],\n })),\n allowFailure: true,\n });\n\n const allRoutes: QuoteResult[] = [];\n for (let i = 0; i < results.length; i++) {\n const r = results[i]!;\n if (r.status === \"success\") {\n const [amountOut, gasEstimate] = r.result as unknown as [bigint, bigint];\n allRoutes.push({ amountOut, gasEstimate, path: routes[i]! });\n }\n }\n\n if (allRoutes.length === 0) {\n throw new Error(\"No valid routes found\");\n }\n\n const bestRoute = allRoutes.reduce((best, current) =>\n current.amountOut > best.amountOut ? current : best,\n );\n\n return { bestRoute, allRoutes };\n}\n\n/**\n * Find and quote the best swap route from `tokenIn` to `tokenOut`.\n *\n * Combines the caller's `pools` with `COMMON_POOLS[chainId]`, builds all\n * possible paths (up to `maxHops`), then quotes them all via a single\n * multicall and returns the best result.\n *\n * @param client - viem PublicClient\n * @param chainId - Chain ID (used to look up COMMON_POOLS and V4_QUOTER_ADDRESSES)\n * @param tokenIn - Input token address\n * @param tokenOut - Desired output token address\n * @param exactAmount - Exact input amount\n * @param pools - Additional pools to consider (e.g. point-token-specific)\n * @param quoterAddress - Override the default V4 Quoter address for this chain\n * @param maxHops - Maximum number of hops per path (default 3)\n */\nexport async function findBestQuote(\n client: PublicClient,\n chainId: number,\n tokenIn: Address,\n tokenOut: Address,\n exactAmount: bigint,\n pools: PoolKey[] = [],\n quoterAddress?: Address,\n maxHops = 3,\n): Promise<BestQuote> {\n const quoter = quoterAddress ?? V4_QUOTER_ADDRESSES[chainId];\n if (!quoter) {\n throw new Error(`No V4 Quoter address configured for chain ${chainId}`);\n }\n\n const commonPools = COMMON_POOLS[chainId] ?? [];\n const allPools = [...pools, ...commonPools];\n const paths = buildAllPaths(allPools, tokenIn, tokenOut, maxHops);\n\n if (paths.length === 0) {\n throw new Error(`No paths found from ${tokenIn} to ${tokenOut}`);\n }\n\n return quoteBestRoute(client, quoter, tokenIn, paths, exactAmount);\n}\n"]}
1
+ {"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-L5UHQQVC.cjs","../src/quoting/routes.ts","../src/quoting/quote.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,IAAM,aAAA,EAAe,4CAAA;AAMd,SAAS,aAAA,CACd,OAAA,EACA,iBAAA,EACW;AACX,EAAA,MAAM,YAAA,mBAAc,8BAAA,CAAa,OAAO,CAAA,UAAK,CAAC,GAAA;AAC9C,EAA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CAAA;AACnB,IAAA,GAAA,CAAI,CAAA,CAAE,OAAA,IAAW,SAAA,EAAW;AAC1B,MAAA,MAAM,CAAC,SAAA,EAAW,WAAW,EAAA,EAAI,CAAA,CAAE,MAAA;AACnC,MAAA,SAAA,CAAU,IAAA,CAAK,EAAE,SAAA,EAAW,WAAA,EAAa,IAAA,EAAM,MAAA,CAAO,CAAC,EAAG,CAAC,CAAA;AAAA,IAC7D;AAAA,EACF;AAEA,EAAA,GAAA,CAAI,SAAA,CAAU,OAAA,IAAW,CAAA,EAAG;AAC1B,IAAA,MAAM,IAAI,KAAA,CAAM,uBAAuB,CAAA;AAAA,EACzC;AAEA,EAAA,MAAM,UAAA,EAAY,SAAA,CAAU,MAAA;AAAA,IAAO,CAAC,IAAA,EAAM,OAAA,EAAA,GACxC,OAAA,CAAQ,UAAA,EAAY,IAAA,CAAK,UAAA,EAAY,QAAA,EAAU;AAAA,EACjD,CAAA;AAEA,EAAA,OAAO,EAAE,SAAA,EAAW,UAAU,CAAA;AAChC;AAkBA,MAAA,SAAsB,aAAA,CACpB,MAAA,EACA,OAAA,EACA,OAAA,EACA,QAAA,EACA,WAAA,EACA,MAAA,EAAmB,CAAC,CAAA,EACpB,aAAA,EACA,QAAA,EAAU,CAAA,EACU;AACpB,EAAA,MAAM,OAAA,mBAAS,aAAA,UAAiB,qCAAA,CAAoB,OAAO,GAAA;AAC3D,EAAA,GAAA,CAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,0CAAA,EAA6C,OAAO,CAAA,CAAA;AACtE,EAAA;AAE8C,EAAA;AACJ,EAAA;AACsB,EAAA;AAExC,EAAA;AACyC,IAAA;AACjE,EAAA;AAEiE,EAAA;AACnE;AFjByE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/chunk-L5UHQQVC.cjs","sourcesContent":[null,"import type { Address } from \"viem\";\nimport type { PathKey, PoolKey } from \"../types\";\nimport { COMMON_POOLS, POINT_TOKEN_POOLS } from \"../constants\";\n\nconst ZERO_ADDRESS = \"0x0000000000000000000000000000000000000000\" as Address;\n\n/**\n * Combine point-token-specific pools and common pools for a given chain.\n * Point token pools are listed first so callers can prioritise them.\n */\nexport function combineRoutes(\n chainId: number,\n pointTokenAddress: Address,\n): PoolKey[] {\n const commonPools = COMMON_POOLS[chainId] ?? [];\n const pointPools = POINT_TOKEN_POOLS[chainId]?.[pointTokenAddress] ?? [];\n return [...pointPools, ...commonPools];\n}\n\n/**\n * Build all possible swap paths from `tokenIn` to `tokenOut` using the given\n * pools. Returns an array of PathKey[] routes (each up to `maxHops` hops).\n *\n * Supports both direct single-hop routes and multi-hop routes through\n * intermediate tokens. Each pool is used at most once per path.\n *\n * @param pools - Available pools to route through\n * @param tokenIn - Input token address\n * @param tokenOut - Desired output token address\n * @param maxHops - Maximum number of hops (default 3)\n */\nexport function buildAllPaths(\n pools: PoolKey[],\n tokenIn: Address,\n tokenOut: Address,\n maxHops = 3,\n): PathKey[][] {\n const results: PathKey[][] = [];\n\n function dfs(\n currentToken: Address,\n currentPath: PathKey[],\n usedPoolIndices: Set<number>,\n ) {\n if (currentPath.length > maxHops) return;\n\n // Check if we've reached the destination\n if (\n currentPath.length > 0 &&\n currentToken.toLowerCase() === tokenOut.toLowerCase()\n ) {\n results.push([...currentPath]);\n return;\n }\n\n for (let i = 0; i < pools.length; i++) {\n if (usedPoolIndices.has(i)) continue;\n\n const pool = pools[i]!;\n const c0 = pool.currency0.toLowerCase();\n const c1 = pool.currency1.toLowerCase();\n const curr = currentToken.toLowerCase();\n\n let nextToken: Address | null = null;\n if (curr === c0) {\n nextToken = pool.currency1 as Address;\n } else if (curr === c1) {\n nextToken = pool.currency0 as Address;\n }\n\n if (!nextToken) continue;\n\n const hop: PathKey = {\n intermediateCurrency: nextToken,\n fee: pool.fee,\n tickSpacing: pool.tickSpacing,\n hooks: pool.hooks ?? ZERO_ADDRESS,\n hookData: \"0x\",\n };\n\n usedPoolIndices.add(i);\n currentPath.push(hop);\n dfs(nextToken, currentPath, usedPoolIndices);\n currentPath.pop();\n usedPoolIndices.delete(i);\n }\n }\n\n dfs(tokenIn, [], new Set());\n return results;\n}\n","import type { Address, PublicClient } from \"viem\";\nimport type { BestQuote, PathKey, PoolKey, QuoteResult } from \"../types\";\nimport { v4QuoterAbi } from \"../abi/v4Quoter\";\nimport { buildAllPaths } from \"./routes\";\nimport { COMMON_POOLS, V4_QUOTER_ADDRESSES } from \"../constants\";\n\n/**\n * Quote exact-input for a multi-hop path.\n */\nexport async function quoteExactInput(\n client: PublicClient,\n quoterAddress: Address,\n exactCurrency: Address,\n path: PathKey[],\n exactAmount: bigint,\n): Promise<QuoteResult> {\n const [amountOut, gasEstimate] = await client.readContract({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: \"quoteExactInput\",\n args: [{ exactCurrency, path, exactAmount: BigInt(exactAmount) as unknown as number }],\n }) as [bigint, bigint];\n\n return { amountOut, gasEstimate, path };\n}\n\n/**\n * Quote exact-input for a single-hop swap, given an explicit PoolKey and direction.\n */\nexport async function quoteExactInputSingle(\n client: PublicClient,\n quoterAddress: Address,\n poolKey: PoolKey,\n zeroForOne: boolean,\n exactAmount: bigint,\n hookData: `0x${string}`,\n): Promise<{ amountOut: bigint; gasEstimate: bigint }> {\n const [amountOut, gasEstimate] = await client.readContract({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: \"quoteExactInputSingle\",\n args: [\n {\n poolKey,\n zeroForOne,\n exactAmount: BigInt(exactAmount) as unknown as number,\n hookData,\n },\n ],\n }) as [bigint, bigint];\n\n return { amountOut, gasEstimate };\n}\n\n/**\n * Try multiple PathKey[] routes and return the best quote plus all results.\n * Routes that fail (e.g. pool does not exist) are silently skipped.\n *\n * Uses viem multicall to batch all quotes into a single RPC call for speed.\n */\nexport async function quoteBestRoute(\n client: PublicClient,\n quoterAddress: Address,\n exactCurrency: Address,\n routes: PathKey[][],\n exactAmount: bigint,\n): Promise<BestQuote> {\n const results = await client.multicall({\n contracts: routes.map((path) => ({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: \"quoteExactInput\" as const,\n args: [\n {\n exactCurrency,\n path,\n exactAmount: BigInt(exactAmount) as unknown as number,\n },\n ],\n })),\n allowFailure: true,\n });\n\n const allRoutes: QuoteResult[] = [];\n for (let i = 0; i < results.length; i++) {\n const r = results[i]!;\n if (r.status === \"success\") {\n const [amountOut, gasEstimate] = r.result as unknown as [bigint, bigint];\n allRoutes.push({ amountOut, gasEstimate, path: routes[i]! });\n }\n }\n\n if (allRoutes.length === 0) {\n throw new Error(\"No valid routes found\");\n }\n\n const bestRoute = allRoutes.reduce((best, current) =>\n current.amountOut > best.amountOut ? current : best,\n );\n\n return { bestRoute, allRoutes };\n}\n\n/**\n * Find and quote the best swap route from `tokenIn` to `tokenOut`.\n *\n * Combines the caller's `pools` with `COMMON_POOLS[chainId]`, builds all\n * possible paths (up to `maxHops`), then quotes them all via a single\n * multicall and returns the best result.\n *\n * @param client - viem PublicClient\n * @param chainId - Chain ID (used to look up COMMON_POOLS and V4_QUOTER_ADDRESSES)\n * @param tokenIn - Input token address\n * @param tokenOut - Desired output token address\n * @param exactAmount - Exact input amount\n * @param pools - Additional pools to consider (e.g. point-token-specific)\n * @param quoterAddress - Override the default V4 Quoter address for this chain\n * @param maxHops - Maximum number of hops per path (default 3)\n */\nexport async function findBestQuote(\n client: PublicClient,\n chainId: number,\n tokenIn: Address,\n tokenOut: Address,\n exactAmount: bigint,\n pools: PoolKey[] = [],\n quoterAddress?: Address,\n maxHops = 3,\n): Promise<BestQuote> {\n const quoter = quoterAddress ?? V4_QUOTER_ADDRESSES[chainId];\n if (!quoter) {\n throw new Error(`No V4 Quoter address configured for chain ${chainId}`);\n }\n\n const commonPools = COMMON_POOLS[chainId] ?? [];\n const allPools = [...pools, ...commonPools];\n const paths = buildAllPaths(allPools, tokenIn, tokenOut, maxHops);\n\n if (paths.length === 0) {\n throw new Error(`No paths found from ${tokenIn} to ${tokenOut}`);\n }\n\n return quoteBestRoute(client, quoter, tokenIn, paths, exactAmount);\n}\n"]}
@@ -2,7 +2,7 @@ import {
2
2
  burnRequestTypes,
3
3
  mintRequestTypes,
4
4
  receiverConsentTypes
5
- } from "./chunk-S5CCEO4O.js";
5
+ } from "./chunk-Y3HMGOYW.js";
6
6
 
7
7
  // src/eip712/domain.ts
8
8
  function buildDomain(config) {
@@ -140,4 +140,4 @@ export {
140
140
  signReceiverConsent,
141
141
  verifyReceiverConsent
142
142
  };
143
- //# sourceMappingURL=chunk-WTWG6QXP.js.map
143
+ //# sourceMappingURL=chunk-TXA4GK5C.js.map
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-2PIXFXA2.js";
6
6
  import {
7
7
  PERMIT2_ADDRESS
8
- } from "./chunk-S5CCEO4O.js";
8
+ } from "./chunk-Y3HMGOYW.js";
9
9
 
10
10
  // src/swap/approval.ts
11
11
  import { encodeFunctionData } from "viem";
@@ -177,7 +177,7 @@ import { encodeFunctionData as encodeFunctionData4 } from "viem";
177
177
  // src/userop/batchExecute.ts
178
178
  import { decodeFunctionData, encodeFunctionData as encodeFunctionData2, parseAbi } from "viem";
179
179
  var BATCH_EXECUTOR_ABI = parseAbi([
180
- "function execute((address target, uint256 value, bytes data)[] calls)"
180
+ "function executeBatch((address target, uint256 value, bytes data)[] calls)"
181
181
  ]);
182
182
  function encodeBatchExecute(operations) {
183
183
  if (operations.length === 0) {
@@ -185,7 +185,7 @@ function encodeBatchExecute(operations) {
185
185
  }
186
186
  return encodeFunctionData2({
187
187
  abi: BATCH_EXECUTOR_ABI,
188
- functionName: "execute",
188
+ functionName: "executeBatch",
189
189
  args: [
190
190
  operations.map((op) => ({
191
191
  target: op.target,
@@ -370,4 +370,4 @@ export {
370
370
  rawCallOp,
371
371
  buildSwapWithGasDeduction
372
372
  };
373
- //# sourceMappingURL=chunk-MWKJODJE.js.map
373
+ //# sourceMappingURL=chunk-VG23GIWQ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/swap/approval.ts","../src/swap/universalRouter.ts","../src/errors.ts","../src/swap/simulate.ts","../src/swap/buildSwapWithGasDeduction.ts","../src/userop/batchExecute.ts","../src/userop/buildUserOperation.ts","../src/userop/operations.ts"],"sourcesContent":["import { encodeFunctionData } from \"viem\";\nimport type { Address, Hex, PublicClient } from \"viem\";\nimport { erc20Abi } from \"../abi/erc20\";\nimport { permit2Abi } from \"../abi/permit2\";\n\nexport async function checkAllowance(\n client: PublicClient,\n token: Address,\n owner: Address,\n spender: Address,\n): Promise<bigint> {\n return client.readContract({\n address: token,\n abi: erc20Abi,\n functionName: \"allowance\",\n args: [owner, spender],\n });\n}\n\n/**\n * Encode an ERC-20 approve(spender, amount) call.\n */\nexport function buildErc20ApprovalCalldata(\n spender: Address,\n amount: bigint,\n): Hex {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount],\n });\n}\n\n/**\n * Encode a Permit2 approve(token, spender, amount, expiration) call.\n */\nexport function buildPermit2ApprovalCalldata(\n token: Address,\n spender: Address,\n amount: bigint,\n expiration: number,\n): Hex {\n return encodeFunctionData({\n abi: permit2Abi,\n functionName: \"approve\",\n args: [token, spender, amount, expiration],\n });\n}\n","import { encodeAbiParameters, encodePacked } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport type { PathKey, QuoteResult } from \"../types\";\n\n// -------------------------------------------------------------------------\n// V4 UniversalRouter command / action constants\n// Reference: https://github.com/Uniswap/v4-periphery/blob/main/src/libraries/Actions.sol\n// -------------------------------------------------------------------------\n\n/** UniversalRouter command byte for V4 swap */\nexport const V4_SWAP = 0x10 as const;\n\n/** V4 actions */\nexport const SWAP_EXACT_IN_SINGLE = 0x06 as const;\nexport const SWAP_EXACT_IN = 0x07 as const;\nexport const SETTLE_ALL = 0x0c as const;\nexport const TAKE_ALL = 0x0f as const;\n\n// -------------------------------------------------------------------------\n// ABI type strings matching Uniswap's V4Planner encoding\n// Reference: https://github.com/Uniswap/sdks/blob/main/sdks/v4-sdk/src/utils/v4Planner.ts\n//\n// IMPORTANT: PathKey.fee is uint256 in the V4 Router ABI (not uint24).\n// -------------------------------------------------------------------------\n\n// PathKey components for V4 Router ABI encoding.\n// IMPORTANT: fee is uint256 in the V4 Router (not uint24 as in PoolKey).\n// Reference: https://github.com/Uniswap/sdks/blob/main/sdks/v4-sdk/src/utils/v4Planner.ts\nconst PATH_KEY_ABI_COMPONENTS = [\n { name: \"intermediateCurrency\", type: \"address\" },\n { name: \"fee\", type: \"uint256\" },\n { name: \"tickSpacing\", type: \"int24\" },\n { name: \"hooks\", type: \"address\" },\n { name: \"hookData\", type: \"bytes\" },\n] as const;\n\nconst EXACT_INPUT_PARAMS_ABI = [\n { name: \"currencyIn\", type: \"address\" },\n {\n name: \"path\",\n type: \"tuple[]\",\n components: PATH_KEY_ABI_COMPONENTS,\n },\n { name: \"amountIn\", type: \"uint128\" },\n { name: \"amountOutMinimum\", type: \"uint128\" },\n] as const;\n\n/**\n * Build the calldata inputs[0] (the V4_SWAP command payload) for\n * UniversalRouter.execute.\n *\n * Actions encoded: SWAP_EXACT_IN → SETTLE_ALL → TAKE_ALL\n *\n * Encoding matches the Uniswap V4 SDK's V4Planner — each action's params\n * are individually ABI-encoded, then wrapped together with the action bytes.\n */\nexport function buildV4SwapInput(\n currencyIn: Address,\n path: PathKey[],\n amountIn: bigint,\n minAmountOut: bigint,\n outputCurrency: Address,\n): Hex {\n const actions = encodePacked(\n [\"uint8\", \"uint8\", \"uint8\"],\n [SWAP_EXACT_IN, SETTLE_ALL, TAKE_ALL],\n );\n\n // Param 0: ExactInputParams — encoded as a single tuple so the CalldataDecoder\n // can locate it via a single offset pointer. fee is uint256 per V4 Router spec.\n const swapParam = encodeAbiParameters(\n [{ name: \"swap\", type: \"tuple\", components: EXACT_INPUT_PARAMS_ABI }],\n [\n {\n currencyIn,\n path: path.map((p) => ({\n intermediateCurrency: p.intermediateCurrency,\n fee: BigInt(p.fee),\n tickSpacing: p.tickSpacing,\n hooks: p.hooks,\n hookData: p.hookData,\n })),\n amountIn,\n amountOutMinimum: minAmountOut,\n },\n ],\n );\n\n // Param 1: SETTLE_ALL { currency, maxAmount }\n const settleParam = encodeAbiParameters(\n [\n { name: \"currency\", type: \"address\" },\n { name: \"maxAmount\", type: \"uint256\" },\n ],\n [currencyIn, amountIn],\n );\n\n // Param 2: TAKE_ALL { currency, minAmount }\n const takeParam = encodeAbiParameters(\n [\n { name: \"currency\", type: \"address\" },\n { name: \"minAmount\", type: \"uint256\" },\n ],\n [outputCurrency, minAmountOut],\n );\n\n return encodeAbiParameters(\n [\n { name: \"actions\", type: \"bytes\" },\n { name: \"params\", type: \"bytes[]\" },\n ],\n [actions, [swapParam, settleParam, takeParam]],\n );\n}\n\n/**\n * Build the full commands + inputs args for UniversalRouter.execute.\n */\nexport function buildUniversalRouterExecuteArgs(\n currencyIn: Address,\n path: PathKey[],\n amountIn: bigint,\n minAmountOut: bigint,\n outputCurrency: Address,\n): { commands: Hex; inputs: Hex[] } {\n const commands = encodePacked([\"uint8\"], [V4_SWAP]);\n const inputs: Hex[] = [\n buildV4SwapInput(currencyIn, path, amountIn, minAmountOut, outputCurrency),\n ];\n return { commands, inputs };\n}\n\n/**\n * Build UniversalRouter execute args from a quote result.\n *\n * Takes the output of `findBestQuote` / `quoteBestRoute` and produces\n * ready-to-use `{ commands, inputs }` for `UniversalRouter.execute`.\n *\n * @param quote - Quote result containing the path\n * @param currencyIn - Input token address\n * @param currencyOut - Output token address\n * @param amountIn - Exact input amount (same value passed to the quoter)\n * @param minAmountOut - Minimum acceptable output (caller applies slippage)\n *\n * @deprecated Since v1.4 — the Issuer App no longer handles swaps.\n * For the new PT→USDT batch call on PAFI Web (Scenario 4 with\n * EIP-7702 gas deduction), use `buildSwapWithGasDeduction()` (v1.5).\n * This helper is kept for legacy v0.2.x consumers; will be removed in v2.0.\n */\nexport function buildSwapFromQuote(params: {\n quote: QuoteResult;\n currencyIn: Address;\n currencyOut: Address;\n amountIn: bigint;\n minAmountOut: bigint;\n}): { commands: Hex; inputs: Hex[] } {\n return buildUniversalRouterExecuteArgs(\n params.currencyIn,\n params.quote.path,\n params.amountIn,\n params.minAmountOut,\n params.currencyOut,\n );\n}\n","export class PafiSDKError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"PafiSDKError\";\n }\n}\n\nexport class ConfigurationError extends PafiSDKError {\n constructor(message: string) {\n super(message);\n this.name = \"ConfigurationError\";\n }\n}\n\nexport class SigningError extends PafiSDKError {\n constructor(message: string) {\n super(message);\n this.name = \"SigningError\";\n }\n}\n\nexport class SimulationError extends PafiSDKError {\n constructor(\n public operation: string,\n public reason: string,\n ) {\n super(`Simulation failed for ${operation}: ${reason}`);\n this.name = \"SimulationError\";\n }\n}\n\nexport class ApiError extends PafiSDKError {\n constructor(\n message: string,\n public status?: number,\n ) {\n super(message);\n this.name = \"ApiError\";\n }\n}\n","import type { Address, Hex, PublicClient } from \"viem\";\nimport { universalRouterAbi } from \"../abi/universalRouter\";\nimport { SimulationError } from \"../errors\";\n\nexport interface SwapSimulationResult {\n success: boolean;\n gasEstimate: bigint;\n}\n\n/**\n * Simulate a UniversalRouter.execute swap call via eth_call (no gas spent).\n *\n * Runs the full V4 swap flow — token transfer via Permit2, swap via\n * PoolManager, output settlement — without submitting a transaction.\n * If the simulation reverts, throws a `SimulationError` with the reason.\n *\n * @param client - viem PublicClient\n * @param routerAddress - UniversalRouter contract address\n * @param commands - Packed command bytes (from buildSwapFromQuote)\n * @param inputs - Encoded inputs per command (from buildSwapFromQuote)\n * @param deadline - Unix timestamp after which the tx expires\n * @param from - Address that will execute the swap\n */\nexport async function simulateSwap(\n client: PublicClient,\n routerAddress: Address,\n commands: Hex,\n inputs: Hex[],\n deadline: bigint,\n from: Address,\n): Promise<SwapSimulationResult> {\n try {\n const gasEstimate = await client.estimateContractGas({\n address: routerAddress,\n abi: universalRouterAbi,\n functionName: \"execute\",\n args: [commands, inputs, deadline],\n account: from,\n });\n\n return { success: true, gasEstimate };\n } catch (error: unknown) {\n const message =\n error instanceof Error ? error.message : \"Unknown simulation error\";\n throw new SimulationError(\"swap\", message);\n }\n}\n","import { encodeFunctionData } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport { universalRouterAbi } from \"../abi/universalRouter\";\nimport type { PathKey } from \"../types\";\nimport { buildPartialUserOperation } from \"../userop/buildUserOperation\";\nimport type { PartialUserOperation } from \"../userop/types\";\nimport {\n erc20ApproveOp,\n erc20TransferOp,\n rawCallOp,\n} from \"../userop/operations\";\nimport type { Operation } from \"../userop/types\";\nimport { buildUniversalRouterExecuteArgs } from \"./universalRouter\";\nimport { buildPermit2ApprovalCalldata } from \"./approval\";\nimport { PERMIT2_ADDRESS } from \"../constants\";\n\n/**\n * v1.5 — Scenario 4: Swap PT → USDT on PAFI Web with gas fee\n * deducted in PT from the user's balance.\n *\n * Builds an unsigned `PartialUserOperation` that packages up to four\n * inner calls into a single `BatchExecutor.execute(calls[])`:\n *\n * 1. `PT.approve(Permit2, amountIn)` — grant Permit2 ERC-20 allowance\n * 2. `Permit2.approve(PT, router, amountIn, deadline)` — authorize\n * the UniversalRouter to pull PT via Permit2\n * 3. `UniversalRouter.execute(commands, inputs, deadline)` — V4 swap\n * PT → USDT; user receives ≥ `minAmountOut` USDT\n * 4. `PT.transfer(feeRecipient, gasFeePt)` — pay the operator back\n * for sponsoring the gas, in PT (omitted when `gasFeePt` is 0)\n *\n * The user's wallet must hold `amountIn + gasFeePt` PT before the\n * UserOp runs. All inner calls execute atomically via EIP-7702\n * delegation (`msg.sender = user`), so a reverting swap unwinds\n * the approvals and fee transfer too.\n *\n * ## Fee model\n *\n * The gas fee is a separate `transfer` after the swap — it does NOT\n * come out of the USDT output, because that output goes straight to\n * the user's wallet with no intermediate hook.\n *\n * If the FE wants \"user receives exactly X USDT after gas\":\n * 1. Quote PT→USDT for candidate `amountIn` values\n * 2. Pick an `amountIn` where `minAmountOut ≈ X`\n * 3. Separately compute `gasFeePt` from the operator's rate\n * 4. Ensure user's PT balance ≥ `amountIn + gasFeePt`\n *\n * ## Order of operations\n *\n * Fee transfer is last so a reverting swap also refunds the fee\n * (atomic batch revert semantics).\n */\nexport interface BuildSwapWithGasDeductionParams {\n /** User's EOA (with EIP-7702 delegation to BatchExecutor). */\n userAddress: Address;\n /** ERC-4337 account nonce — fetched from EntryPoint by the caller. */\n aaNonce: bigint;\n\n /** PT token address being swapped. */\n pointTokenAddress: Address;\n /** Destination currency (typically USDT). */\n outputTokenAddress: Address;\n /** UniversalRouter contract address (chain-specific). */\n universalRouterAddress: Address;\n\n /** PT units to swap. User's balance must be ≥ `amountIn + gasFeePt`. */\n amountIn: bigint;\n /**\n * Minimum USDT to accept out of the swap. Caller applies slippage\n * (typically ~0.5-1%) against a fresh quote. Sub-minimum swap reverts.\n */\n minAmountOut: bigint;\n\n /** V4 pool path for the swap. Single-hop = 1 PathKey. */\n swapPath: PathKey[];\n /** Unix seconds. After this, the router rejects the swap. */\n deadline: bigint;\n\n /** PT amount transferred to `feeRecipient` as gas fee recovery. */\n gasFeePt: bigint;\n /** Where the gas fee lands — typically the operator or fee collector. */\n feeRecipient: Address;\n\n /** Override ERC-4337 gas estimates. Defaults are conservative; tune down for cheaper UserOps. */\n gasLimits?: {\n callGasLimit?: bigint;\n verificationGasLimit?: bigint;\n preVerificationGas?: bigint;\n };\n}\n\n/**\n * Build an unsigned UserOp for Scenario 4. Returns a\n * `PartialUserOperation` — caller attaches paymaster sponsorship (via\n * `POST /api/paymaster/sponsor`), adds the user's UserOp-hash\n * signature, and submits to the Bundler.\n *\n * @throws when `amountIn` or `gasFeePt` is not positive, or when\n * `swapPath` is empty (at least one PathKey required).\n */\nexport function buildSwapWithGasDeduction(\n params: BuildSwapWithGasDeductionParams,\n): PartialUserOperation {\n if (params.amountIn <= 0n) {\n throw new Error(\"buildSwapWithGasDeduction: amountIn must be positive\");\n }\n if (params.minAmountOut < 0n) {\n throw new Error(\n \"buildSwapWithGasDeduction: minAmountOut must be non-negative\",\n );\n }\n if (params.gasFeePt < 0n) {\n throw new Error(\n \"buildSwapWithGasDeduction: gasFeePt must be non-negative\",\n );\n }\n if (params.swapPath.length === 0) {\n throw new Error(\n \"buildSwapWithGasDeduction: swapPath must contain at least one PathKey\",\n );\n }\n\n const { commands, inputs } = buildUniversalRouterExecuteArgs(\n params.pointTokenAddress,\n params.swapPath,\n params.amountIn,\n params.minAmountOut,\n params.outputTokenAddress,\n );\n\n const swapCallData: Hex = encodeFunctionData({\n abi: universalRouterAbi,\n functionName: \"execute\",\n args: [commands, inputs, params.deadline],\n });\n\n const permit2ApproveData: Hex = buildPermit2ApprovalCalldata(\n params.pointTokenAddress,\n params.universalRouterAddress,\n params.amountIn,\n Number(params.deadline),\n );\n\n const operations: Operation[] = [\n erc20ApproveOp(\n params.pointTokenAddress,\n PERMIT2_ADDRESS,\n params.amountIn,\n ),\n rawCallOp(PERMIT2_ADDRESS, permit2ApproveData),\n rawCallOp(params.universalRouterAddress, swapCallData),\n ];\n\n if (params.gasFeePt > 0n) {\n operations.push(\n erc20TransferOp(\n params.pointTokenAddress,\n params.feeRecipient,\n params.gasFeePt,\n ),\n );\n }\n\n return buildPartialUserOperation({\n sender: params.userAddress,\n nonce: params.aaNonce,\n operations,\n gasLimits: {\n callGasLimit: params.gasLimits?.callGasLimit ?? 700_000n,\n verificationGasLimit:\n params.gasLimits?.verificationGasLimit ?? 150_000n,\n preVerificationGas: params.gasLimits?.preVerificationGas ?? 50_000n,\n },\n });\n}\n","import { decodeFunctionData, encodeFunctionData, parseAbi } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport type { Operation } from \"./types\";\n\n/**\n * Standard BatchExecutor ABI — a contract that takes an array of calls\n * and invokes each one in sequence, reverting all if any fail.\n *\n * Compatible with OpenZeppelin `Account.execute(Call[])`, Biconomy\n * `executeBatch`, Safe `MultiSend`, and most EIP-7702 delegation\n * targets. The exact deployed address is supplied by the infra team\n * (see [V1.4_V1.5_READINESS.md B2]).\n */\nexport const BATCH_EXECUTOR_ABI = parseAbi([\n \"function execute((address target, uint256 value, bytes data)[] calls)\",\n]);\n\n/**\n * Encode a batch of operations into calldata for `BatchExecutor.execute()`.\n * The resulting calldata goes into `UserOperation.callData`.\n *\n * When the EOA has an EIP-7702 delegation to a BatchExecutor, calling\n * this calldata against the EOA runs all operations with\n * `msg.sender = EOA` for each inner call.\n *\n * @param operations batch of calls, in execution order\n * @returns calldata bytes for `execute((address,uint256,bytes)[])`\n */\nexport function encodeBatchExecute(operations: Operation[]): Hex {\n if (operations.length === 0) {\n throw new Error(\"encodeBatchExecute: operations array must not be empty\");\n }\n return encodeFunctionData({\n abi: BATCH_EXECUTOR_ABI,\n functionName: \"execute\",\n args: [\n operations.map((op) => ({\n target: op.target,\n value: op.value,\n data: op.data,\n })),\n ],\n });\n}\n\n/**\n * Decode `BatchExecutor.execute(calls[])` callData back into individual\n * `{ to, data, value }` objects.\n *\n * Used by issuer backends to convert a `PartialUserOperation.callData`\n * into the `calls[]` array returned to web/FE clients (which submit via\n * `permissionless.sendTransaction({ calls })`).\n */\nexport function decodeBatchExecuteCalls(\n callData: Hex,\n): Array<{ to: string; data: string; value: string }> {\n const { args } = decodeFunctionData({\n abi: BATCH_EXECUTOR_ABI,\n data: callData,\n });\n return (\n args[0] as ReadonlyArray<{ target: Address; value: bigint; data: Hex }>\n ).map((c) => ({\n to: c.target,\n data: c.data,\n value: c.value.toString(),\n }));\n}\n","import type { Address } from \"viem\";\nimport type { Operation, PartialUserOperation, UserOperation } from \"./types\";\nimport { encodeBatchExecute } from \"./batchExecute\";\n\n/**\n * Default gas limits — rough upper bounds for a 2-op batch on Base.\n * Bundler re-estimates before submission, so these are only used when\n * the caller doesn't supply their own.\n */\nconst DEFAULT_CALL_GAS_LIMIT = 500_000n;\nconst DEFAULT_VERIFICATION_GAS_LIMIT = 150_000n;\nconst DEFAULT_PRE_VERIFICATION_GAS = 50_000n;\n\nexport interface BuildPartialUserOpParams {\n /** User's EOA (with EIP-7702 delegation). */\n sender: Address;\n /** Batch of operations — encoded into callData via `encodeBatchExecute`. */\n operations: Operation[];\n /** EntryPoint nonce for this sender. Caller fetches from the EntryPoint contract. */\n nonce: bigint;\n /** Optional gas overrides; bundler re-estimates before submission. */\n gasLimits?: {\n callGasLimit?: bigint;\n verificationGasLimit?: bigint;\n preVerificationGas?: bigint;\n };\n /** Optional fee overrides; bundler usually fills these. */\n feeOverrides?: {\n maxFeePerGas?: bigint;\n maxPriorityFeePerGas?: bigint;\n };\n}\n\n/**\n * Build a partial ERC-4337 UserOperation from a batch of operations.\n * Paymaster fields and signature are populated later:\n * 1. Call `PafiBackendClient.requestSponsorship()` → get paymaster fields\n * 2. Compute userOpHash and have the user sign it (via Privy)\n * 3. Attach `signature` → submit to bundler\n *\n * This function is a pure struct builder — no network calls.\n */\nexport function buildPartialUserOperation(\n params: BuildPartialUserOpParams,\n): PartialUserOperation {\n return {\n sender: params.sender,\n nonce: params.nonce,\n callData: encodeBatchExecute(params.operations),\n callGasLimit: params.gasLimits?.callGasLimit ?? DEFAULT_CALL_GAS_LIMIT,\n verificationGasLimit:\n params.gasLimits?.verificationGasLimit ??\n DEFAULT_VERIFICATION_GAS_LIMIT,\n preVerificationGas:\n params.gasLimits?.preVerificationGas ?? DEFAULT_PRE_VERIFICATION_GAS,\n maxFeePerGas: params.feeOverrides?.maxFeePerGas ?? 0n,\n maxPriorityFeePerGas: params.feeOverrides?.maxPriorityFeePerGas ?? 0n,\n };\n}\n\n/**\n * Assemble a full UserOperation once paymaster fields + signature are\n * known. Used after `PafiBackendClient.requestSponsorship()` and user\n * signing complete.\n */\nexport function assembleUserOperation(\n partial: PartialUserOperation,\n paymaster: {\n paymaster: Address;\n paymasterData: `0x${string}`;\n paymasterVerificationGasLimit: bigint;\n paymasterPostOpGasLimit: bigint;\n },\n signature: `0x${string}`,\n): UserOperation {\n return {\n ...partial,\n paymaster: paymaster.paymaster,\n paymasterData: paymaster.paymasterData,\n paymasterVerificationGasLimit: paymaster.paymasterVerificationGasLimit,\n paymasterPostOpGasLimit: paymaster.paymasterPostOpGasLimit,\n signature,\n };\n}\n","import { encodeFunctionData, erc20Abi, parseAbi } from \"viem\";\nimport type { Address } from \"viem\";\nimport type { Operation } from \"./types\";\n\n/**\n * ERC20Burnable extension — `burn(uint256 amount)` burns from msg.sender.\n * The EOA (via EIP-7702 delegation) is the `msg.sender` when a batch\n * runs — so this burns the user's balance without any role check.\n */\nconst ERC20_BURNABLE_ABI = parseAbi([\"function burn(uint256 amount)\"]);\n\n/**\n * Build an ERC-20 `transfer(to, amount)` operation. Used inside a batch\n * to move fee tokens from the user to the fee recipient atomically with\n * the main action.\n */\nexport function erc20TransferOp(\n token: Address,\n to: Address,\n amount: bigint,\n): Operation {\n return {\n target: token,\n value: 0n,\n data: encodeFunctionData({\n abi: erc20Abi,\n functionName: \"transfer\",\n args: [to, amount],\n }),\n };\n}\n\n/**\n * Build an ERC-20 `approve(spender, amount)` operation. Used inside a\n * batch before a swap / deposit call so the AMM / protocol can pull\n * tokens from the user.\n */\nexport function erc20ApproveOp(\n token: Address,\n spender: Address,\n amount: bigint,\n): Operation {\n return {\n target: token,\n value: 0n,\n data: encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount],\n }),\n };\n}\n\n/**\n * Build an ERC-20 `burn(amount)` operation (OpenZeppelin ERC20Burnable\n * extension). Burns from `msg.sender`, which — via EIP-7702 — is the\n * user's EOA.\n *\n * Requires the PointToken contract to expose a public `burn(uint256)`\n * without a role check. See\n * [SDK_V1.4_TASKS.md §11 — PointToken.burn callable via batch].\n */\nexport function erc20BurnOp(token: Address, amount: bigint): Operation {\n return {\n target: token,\n value: 0n,\n data: encodeFunctionData({\n abi: ERC20_BURNABLE_ABI,\n functionName: \"burn\",\n args: [amount],\n }),\n };\n}\n\n/**\n * Build a raw call operation with caller-supplied calldata. Useful for\n * non-ERC-20 contracts (PoolManager.swap, PerpDEX.deposit, Relayer.mint)\n * where the encoding is specific to that protocol.\n */\nexport function rawCallOp(\n target: Address,\n data: `0x${string}`,\n value: bigint = 0n,\n): Operation {\n return { target, value, data };\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,0BAA0B;AAKnC,eAAsB,eACpB,QACA,OACA,OACA,SACiB;AACjB,SAAO,OAAO,aAAa;AAAA,IACzB,SAAS;AAAA,IACT,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,OAAO,OAAO;AAAA,EACvB,CAAC;AACH;AAKO,SAAS,2BACd,SACA,QACK;AACL,SAAO,mBAAmB;AAAA,IACxB,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,SAAS,MAAM;AAAA,EACxB,CAAC;AACH;AAKO,SAAS,6BACd,OACA,SACA,QACA,YACK;AACL,SAAO,mBAAmB;AAAA,IACxB,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,OAAO,SAAS,QAAQ,UAAU;AAAA,EAC3C,CAAC;AACH;;;AC/CA,SAAS,qBAAqB,oBAAoB;AAU3C,IAAM,UAAU;AAIhB,IAAM,gBAAgB;AACtB,IAAM,aAAa;AACnB,IAAM,WAAW;AAYxB,IAAM,0BAA0B;AAAA,EAC9B,EAAE,MAAM,wBAAwB,MAAM,UAAU;AAAA,EAChD,EAAE,MAAM,OAAO,MAAM,UAAU;AAAA,EAC/B,EAAE,MAAM,eAAe,MAAM,QAAQ;AAAA,EACrC,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,EACjC,EAAE,MAAM,YAAY,MAAM,QAAQ;AACpC;AAEA,IAAM,yBAAyB;AAAA,EAC7B,EAAE,MAAM,cAAc,MAAM,UAAU;AAAA,EACtC;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,YAAY;AAAA,EACd;AAAA,EACA,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,EACpC,EAAE,MAAM,oBAAoB,MAAM,UAAU;AAC9C;AAWO,SAAS,i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AAE,UAAU,OAAO,IAAI;AAAA,IAC3B,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAEA,QAAM,eAAoBG,oBAAmB;AAAA,IAC3C,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,UAAU,QAAQ,OAAO,QAAQ;AAAA,EAC1C,CAAC;AAED,QAAM,qBAA0B;AAAA,IAC9B,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO,OAAO,QAAQ;AAAA,EACxB;AAEA,QAAM,aAA0B;AAAA,IAC9B;AAAA,MACE,OAAO;AAAA,MACP;AAAA,MACA,OAAO;AAAA,IACT;AAAA,IACA,UAAU,iBAAiB,kBAAkB;AAAA,IAC7C,UAAU,OAAO,wBAAwB,YAAY;AAAA,EACvD;AAEA,MAAI,OAAO,WAAW,IAAI;AACxB,eAAW;AAAA,MACT;AAAA,QACE,OAAO;AAAA,QACP,OAAO;AAAA,QACP,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAEA,SAAO,0BAA0B;AAAA,IAC/B,QAAQ,OAAO;AAAA,IACf,OAAO,OAAO;AAAA,IACd;AAAA,IACA,WAAW;AAAA,MACT,cAAc,OAAO,WAAW,gBAAgB;AAAA,MAChD,sBACE,OAAO,WAAW,wBAAwB;AAAA,MAC5C,oBAAoB,OAAO,WAAW,sBAAsB;AAAA,IAC9D;AAAA,EACF,CAAC;AACH;","names":["encodeFunctionData","encodeFunctionData","encodeFunctionData","erc20Abi","parseAbi","encodeFunctionData"]}
1
+ {"version":3,"sources":["../src/swap/approval.ts","../src/swap/universalRouter.ts","../src/errors.ts","../src/swap/simulate.ts","../src/swap/buildSwapWithGasDeduction.ts","../src/userop/batchExecute.ts","../src/userop/buildUserOperation.ts","../src/userop/operations.ts"],"sourcesContent":["import { encodeFunctionData } from \"viem\";\nimport type { Address, Hex, PublicClient } from \"viem\";\nimport { erc20Abi } from \"../abi/erc20\";\nimport { permit2Abi } from \"../abi/permit2\";\n\nexport async function checkAllowance(\n client: PublicClient,\n token: Address,\n owner: Address,\n spender: Address,\n): Promise<bigint> {\n return client.readContract({\n address: token,\n abi: erc20Abi,\n functionName: \"allowance\",\n args: [owner, spender],\n });\n}\n\n/**\n * Encode an ERC-20 approve(spender, amount) call.\n */\nexport function buildErc20ApprovalCalldata(\n spender: Address,\n amount: bigint,\n): Hex {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount],\n });\n}\n\n/**\n * Encode a Permit2 approve(token, spender, amount, expiration) call.\n */\nexport function buildPermit2ApprovalCalldata(\n token: Address,\n spender: Address,\n amount: bigint,\n expiration: number,\n): Hex {\n return encodeFunctionData({\n abi: permit2Abi,\n functionName: \"approve\",\n args: [token, spender, amount, expiration],\n });\n}\n","import { encodeAbiParameters, encodePacked } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport type { PathKey, QuoteResult } from \"../types\";\n\n// -------------------------------------------------------------------------\n// V4 UniversalRouter command / action constants\n// Reference: https://github.com/Uniswap/v4-periphery/blob/main/src/libraries/Actions.sol\n// -------------------------------------------------------------------------\n\n/** UniversalRouter command byte for V4 swap */\nexport const V4_SWAP = 0x10 as const;\n\n/** V4 actions */\nexport const SWAP_EXACT_IN_SINGLE = 0x06 as const;\nexport const SWAP_EXACT_IN = 0x07 as const;\nexport const SETTLE_ALL = 0x0c as const;\nexport const TAKE_ALL = 0x0f as const;\n\n// -------------------------------------------------------------------------\n// ABI type strings matching Uniswap's V4Planner encoding\n// Reference: https://github.com/Uniswap/sdks/blob/main/sdks/v4-sdk/src/utils/v4Planner.ts\n//\n// IMPORTANT: PathKey.fee is uint256 in the V4 Router ABI (not uint24).\n// -------------------------------------------------------------------------\n\n// PathKey components for V4 Router ABI encoding.\n// IMPORTANT: fee is uint256 in the V4 Router (not uint24 as in PoolKey).\n// Reference: https://github.com/Uniswap/sdks/blob/main/sdks/v4-sdk/src/utils/v4Planner.ts\nconst PATH_KEY_ABI_COMPONENTS = [\n { name: \"intermediateCurrency\", type: \"address\" },\n { name: \"fee\", type: \"uint256\" },\n { name: \"tickSpacing\", type: \"int24\" },\n { name: \"hooks\", type: \"address\" },\n { name: \"hookData\", type: \"bytes\" },\n] as const;\n\nconst EXACT_INPUT_PARAMS_ABI = [\n { name: \"currencyIn\", type: \"address\" },\n {\n name: \"path\",\n type: \"tuple[]\",\n components: PATH_KEY_ABI_COMPONENTS,\n },\n { name: \"amountIn\", type: \"uint128\" },\n { name: \"amountOutMinimum\", type: \"uint128\" },\n] as const;\n\n/**\n * Build the calldata inputs[0] (the V4_SWAP command payload) for\n * UniversalRouter.execute.\n *\n * Actions encoded: SWAP_EXACT_IN → SETTLE_ALL → TAKE_ALL\n *\n * Encoding matches the Uniswap V4 SDK's V4Planner — each action's params\n * are individually ABI-encoded, then wrapped together with the action bytes.\n */\nexport function buildV4SwapInput(\n currencyIn: Address,\n path: PathKey[],\n amountIn: bigint,\n minAmountOut: bigint,\n outputCurrency: Address,\n): Hex {\n const actions = encodePacked(\n [\"uint8\", \"uint8\", \"uint8\"],\n [SWAP_EXACT_IN, SETTLE_ALL, TAKE_ALL],\n );\n\n // Param 0: ExactInputParams — encoded as a single tuple so the CalldataDecoder\n // can locate it via a single offset pointer. fee is uint256 per V4 Router spec.\n const swapParam = encodeAbiParameters(\n [{ name: \"swap\", type: \"tuple\", components: EXACT_INPUT_PARAMS_ABI }],\n [\n {\n currencyIn,\n path: path.map((p) => ({\n intermediateCurrency: p.intermediateCurrency,\n fee: BigInt(p.fee),\n tickSpacing: p.tickSpacing,\n hooks: p.hooks,\n hookData: p.hookData,\n })),\n amountIn,\n amountOutMinimum: minAmountOut,\n },\n ],\n );\n\n // Param 1: SETTLE_ALL { currency, maxAmount }\n const settleParam = encodeAbiParameters(\n [\n { name: \"currency\", type: \"address\" },\n { name: \"maxAmount\", type: \"uint256\" },\n ],\n [currencyIn, amountIn],\n );\n\n // Param 2: TAKE_ALL { currency, minAmount }\n const takeParam = encodeAbiParameters(\n [\n { name: \"currency\", type: \"address\" },\n { name: \"minAmount\", type: \"uint256\" },\n ],\n [outputCurrency, minAmountOut],\n );\n\n return encodeAbiParameters(\n [\n { name: \"actions\", type: \"bytes\" },\n { name: \"params\", type: \"bytes[]\" },\n ],\n [actions, [swapParam, settleParam, takeParam]],\n );\n}\n\n/**\n * Build the full commands + inputs args for UniversalRouter.execute.\n */\nexport function buildUniversalRouterExecuteArgs(\n currencyIn: Address,\n path: PathKey[],\n amountIn: bigint,\n minAmountOut: bigint,\n outputCurrency: Address,\n): { commands: Hex; inputs: Hex[] } {\n const commands = encodePacked([\"uint8\"], [V4_SWAP]);\n const inputs: Hex[] = [\n buildV4SwapInput(currencyIn, path, amountIn, minAmountOut, outputCurrency),\n ];\n return { commands, inputs };\n}\n\n/**\n * Build UniversalRouter execute args from a quote result.\n *\n * Takes the output of `findBestQuote` / `quoteBestRoute` and produces\n * ready-to-use `{ commands, inputs }` for `UniversalRouter.execute`.\n *\n * @param quote - Quote result containing the path\n * @param currencyIn - Input token address\n * @param currencyOut - Output token address\n * @param amountIn - Exact input amount (same value passed to the quoter)\n * @param minAmountOut - Minimum acceptable output (caller applies slippage)\n *\n * @deprecated Since v1.4 — the Issuer App no longer handles swaps.\n * For the new PT→USDT batch call on PAFI Web (Scenario 4 with\n * EIP-7702 gas deduction), use `buildSwapWithGasDeduction()` (v1.5).\n * This helper is kept for legacy v0.2.x consumers; will be removed in v2.0.\n */\nexport function buildSwapFromQuote(params: {\n quote: QuoteResult;\n currencyIn: Address;\n currencyOut: Address;\n amountIn: bigint;\n minAmountOut: bigint;\n}): { commands: Hex; inputs: Hex[] } {\n return buildUniversalRouterExecuteArgs(\n params.currencyIn,\n params.quote.path,\n params.amountIn,\n params.minAmountOut,\n params.currencyOut,\n );\n}\n","export class PafiSDKError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"PafiSDKError\";\n }\n}\n\nexport class ConfigurationError extends PafiSDKError {\n constructor(message: string) {\n super(message);\n this.name = \"ConfigurationError\";\n }\n}\n\nexport class SigningError extends PafiSDKError {\n constructor(message: string) {\n super(message);\n this.name = \"SigningError\";\n }\n}\n\nexport class SimulationError extends PafiSDKError {\n constructor(\n public operation: string,\n public reason: string,\n ) {\n super(`Simulation failed for ${operation}: ${reason}`);\n this.name = \"SimulationError\";\n }\n}\n\nexport class ApiError extends PafiSDKError {\n constructor(\n message: string,\n public status?: number,\n ) {\n super(message);\n this.name = \"ApiError\";\n }\n}\n","import type { Address, Hex, PublicClient } from \"viem\";\nimport { universalRouterAbi } from \"../abi/universalRouter\";\nimport { SimulationError } from \"../errors\";\n\nexport interface SwapSimulationResult {\n success: boolean;\n gasEstimate: bigint;\n}\n\n/**\n * Simulate a UniversalRouter.execute swap call via eth_call (no gas spent).\n *\n * Runs the full V4 swap flow — token transfer via Permit2, swap via\n * PoolManager, output settlement — without submitting a transaction.\n * If the simulation reverts, throws a `SimulationError` with the reason.\n *\n * @param client - viem PublicClient\n * @param routerAddress - UniversalRouter contract address\n * @param commands - Packed command bytes (from buildSwapFromQuote)\n * @param inputs - Encoded inputs per command (from buildSwapFromQuote)\n * @param deadline - Unix timestamp after which the tx expires\n * @param from - Address that will execute the swap\n */\nexport async function simulateSwap(\n client: PublicClient,\n routerAddress: Address,\n commands: Hex,\n inputs: Hex[],\n deadline: bigint,\n from: Address,\n): Promise<SwapSimulationResult> {\n try {\n const gasEstimate = await client.estimateContractGas({\n address: routerAddress,\n abi: universalRouterAbi,\n functionName: \"execute\",\n args: [commands, inputs, deadline],\n account: from,\n });\n\n return { success: true, gasEstimate };\n } catch (error: unknown) {\n const message =\n error instanceof Error ? error.message : \"Unknown simulation error\";\n throw new SimulationError(\"swap\", message);\n }\n}\n","import { encodeFunctionData } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport { universalRouterAbi } from \"../abi/universalRouter\";\nimport type { PathKey } from \"../types\";\nimport { buildPartialUserOperation } from \"../userop/buildUserOperation\";\nimport type { PartialUserOperation } from \"../userop/types\";\nimport {\n erc20ApproveOp,\n erc20TransferOp,\n rawCallOp,\n} from \"../userop/operations\";\nimport type { Operation } from \"../userop/types\";\nimport { buildUniversalRouterExecuteArgs } from \"./universalRouter\";\nimport { buildPermit2ApprovalCalldata } from \"./approval\";\nimport { PERMIT2_ADDRESS } from \"../constants\";\n\n/**\n * v1.5 — Scenario 4: Swap PT → USDT on PAFI Web with gas fee\n * deducted in PT from the user's balance.\n *\n * Builds an unsigned `PartialUserOperation` that packages up to four\n * inner calls into a single `BatchExecutor.execute(calls[])`:\n *\n * 1. `PT.approve(Permit2, amountIn)` — grant Permit2 ERC-20 allowance\n * 2. `Permit2.approve(PT, router, amountIn, deadline)` — authorize\n * the UniversalRouter to pull PT via Permit2\n * 3. `UniversalRouter.execute(commands, inputs, deadline)` — V4 swap\n * PT → USDT; user receives ≥ `minAmountOut` USDT\n * 4. `PT.transfer(feeRecipient, gasFeePt)` — pay the operator back\n * for sponsoring the gas, in PT (omitted when `gasFeePt` is 0)\n *\n * The user's wallet must hold `amountIn + gasFeePt` PT before the\n * UserOp runs. All inner calls execute atomically via EIP-7702\n * delegation (`msg.sender = user`), so a reverting swap unwinds\n * the approvals and fee transfer too.\n *\n * ## Fee model\n *\n * The gas fee is a separate `transfer` after the swap — it does NOT\n * come out of the USDT output, because that output goes straight to\n * the user's wallet with no intermediate hook.\n *\n * If the FE wants \"user receives exactly X USDT after gas\":\n * 1. Quote PT→USDT for candidate `amountIn` values\n * 2. Pick an `amountIn` where `minAmountOut ≈ X`\n * 3. Separately compute `gasFeePt` from the operator's rate\n * 4. Ensure user's PT balance ≥ `amountIn + gasFeePt`\n *\n * ## Order of operations\n *\n * Fee transfer is last so a reverting swap also refunds the fee\n * (atomic batch revert semantics).\n */\nexport interface BuildSwapWithGasDeductionParams {\n /** User's EOA (with EIP-7702 delegation to BatchExecutor). */\n userAddress: Address;\n /** ERC-4337 account nonce — fetched from EntryPoint by the caller. */\n aaNonce: bigint;\n\n /** PT token address being swapped. */\n pointTokenAddress: Address;\n /** Destination currency (typically USDT). */\n outputTokenAddress: Address;\n /** UniversalRouter contract address (chain-specific). */\n universalRouterAddress: Address;\n\n /** PT units to swap. User's balance must be ≥ `amountIn + gasFeePt`. */\n amountIn: bigint;\n /**\n * Minimum USDT to accept out of the swap. Caller applies slippage\n * (typically ~0.5-1%) against a fresh quote. Sub-minimum swap reverts.\n */\n minAmountOut: bigint;\n\n /** V4 pool path for the swap. Single-hop = 1 PathKey. */\n swapPath: PathKey[];\n /** Unix seconds. After this, the router rejects the swap. */\n deadline: bigint;\n\n /** PT amount transferred to `feeRecipient` as gas fee recovery. */\n gasFeePt: bigint;\n /** Where the gas fee lands — typically the operator or fee collector. */\n feeRecipient: Address;\n\n /** Override ERC-4337 gas estimates. Defaults are conservative; tune down for cheaper UserOps. */\n gasLimits?: {\n callGasLimit?: bigint;\n verificationGasLimit?: bigint;\n preVerificationGas?: bigint;\n };\n}\n\n/**\n * Build an unsigned UserOp for Scenario 4. Returns a\n * `PartialUserOperation` — caller attaches paymaster sponsorship (via\n * `POST /api/paymaster/sponsor`), adds the user's UserOp-hash\n * signature, and submits to the Bundler.\n *\n * @throws when `amountIn` or `gasFeePt` is not positive, or when\n * `swapPath` is empty (at least one PathKey required).\n */\nexport function buildSwapWithGasDeduction(\n params: BuildSwapWithGasDeductionParams,\n): PartialUserOperation {\n if (params.amountIn <= 0n) {\n throw new Error(\"buildSwapWithGasDeduction: amountIn must be positive\");\n }\n if (params.minAmountOut < 0n) {\n throw new Error(\n \"buildSwapWithGasDeduction: minAmountOut must be non-negative\",\n );\n }\n if (params.gasFeePt < 0n) {\n throw new Error(\n \"buildSwapWithGasDeduction: gasFeePt must be non-negative\",\n );\n }\n if (params.swapPath.length === 0) {\n throw new Error(\n \"buildSwapWithGasDeduction: swapPath must contain at least one PathKey\",\n );\n }\n\n const { commands, inputs } = buildUniversalRouterExecuteArgs(\n params.pointTokenAddress,\n params.swapPath,\n params.amountIn,\n params.minAmountOut,\n params.outputTokenAddress,\n );\n\n const swapCallData: Hex = encodeFunctionData({\n abi: universalRouterAbi,\n functionName: \"execute\",\n args: [commands, inputs, params.deadline],\n });\n\n const permit2ApproveData: Hex = buildPermit2ApprovalCalldata(\n params.pointTokenAddress,\n params.universalRouterAddress,\n params.amountIn,\n Number(params.deadline),\n );\n\n const operations: Operation[] = [\n erc20ApproveOp(\n params.pointTokenAddress,\n PERMIT2_ADDRESS,\n params.amountIn,\n ),\n rawCallOp(PERMIT2_ADDRESS, permit2ApproveData),\n rawCallOp(params.universalRouterAddress, swapCallData),\n ];\n\n if (params.gasFeePt > 0n) {\n operations.push(\n erc20TransferOp(\n params.pointTokenAddress,\n params.feeRecipient,\n params.gasFeePt,\n ),\n );\n }\n\n return buildPartialUserOperation({\n sender: params.userAddress,\n nonce: params.aaNonce,\n operations,\n gasLimits: {\n callGasLimit: params.gasLimits?.callGasLimit ?? 700_000n,\n verificationGasLimit:\n params.gasLimits?.verificationGasLimit ?? 150_000n,\n preVerificationGas: params.gasLimits?.preVerificationGas ?? 50_000n,\n },\n });\n}\n","import { decodeFunctionData, encodeFunctionData, parseAbi } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport type { Operation } from \"./types\";\n\n/**\n * Standard BatchExecutor ABI — a contract that takes an array of calls\n * and invokes each one in sequence, reverting all if any fail.\n *\n * Function name is `executeBatch` (selector `0x34fcd5be`) to match\n * Pimlico's `Simple7702Account` and Coinbase Smart Wallet v2 — both\n * EIP-7702 delegate impls expose `executeBatch(Call[])`, not `execute`.\n * The shorter `execute(Call[])` (selector `0x3f707e6b`) only exists on\n * legacy/standalone batch executor contracts; calling it on a 7702\n * delegated EOA falls through to the fallback function and reverts\n * with \"account: not from EntryPoint\" (AA23).\n */\nexport const BATCH_EXECUTOR_ABI = parseAbi([\n \"function executeBatch((address target, uint256 value, bytes data)[] calls)\",\n]);\n\n/**\n * Encode a batch of operations into calldata for `BatchExecutor.execute()`.\n * The resulting calldata goes into `UserOperation.callData`.\n *\n * When the EOA has an EIP-7702 delegation to a BatchExecutor, calling\n * this calldata against the EOA runs all operations with\n * `msg.sender = EOA` for each inner call.\n *\n * @param operations batch of calls, in execution order\n * @returns calldata bytes for `execute((address,uint256,bytes)[])`\n */\nexport function encodeBatchExecute(operations: Operation[]): Hex {\n if (operations.length === 0) {\n throw new Error(\"encodeBatchExecute: operations array must not be empty\");\n }\n return encodeFunctionData({\n abi: BATCH_EXECUTOR_ABI,\n functionName: \"executeBatch\",\n args: [\n operations.map((op) => ({\n target: op.target,\n value: op.value,\n data: op.data,\n })),\n ],\n });\n}\n\n/**\n * Decode `BatchExecutor.execute(calls[])` callData back into individual\n * `{ to, data, value }` objects.\n *\n * Used by issuer backends to convert a `PartialUserOperation.callData`\n * into the `calls[]` array returned to web/FE clients (which submit via\n * `permissionless.sendTransaction({ calls })`).\n */\nexport function decodeBatchExecuteCalls(\n callData: Hex,\n): Array<{ to: string; data: string; value: string }> {\n const { args } = decodeFunctionData({\n abi: BATCH_EXECUTOR_ABI,\n data: callData,\n });\n return (\n args[0] as ReadonlyArray<{ target: Address; value: bigint; data: Hex }>\n ).map((c) => ({\n to: c.target,\n data: c.data,\n value: c.value.toString(),\n }));\n}\n","import type { Address } from \"viem\";\nimport type { Operation, PartialUserOperation, UserOperation } from \"./types\";\nimport { encodeBatchExecute } from \"./batchExecute\";\n\n/**\n * Default gas limits — rough upper bounds for a 2-op batch on Base.\n * Bundler re-estimates before submission, so these are only used when\n * the caller doesn't supply their own.\n */\nconst DEFAULT_CALL_GAS_LIMIT = 500_000n;\nconst DEFAULT_VERIFICATION_GAS_LIMIT = 150_000n;\nconst DEFAULT_PRE_VERIFICATION_GAS = 50_000n;\n\nexport interface BuildPartialUserOpParams {\n /** User's EOA (with EIP-7702 delegation). */\n sender: Address;\n /** Batch of operations — encoded into callData via `encodeBatchExecute`. */\n operations: Operation[];\n /** EntryPoint nonce for this sender. Caller fetches from the EntryPoint contract. */\n nonce: bigint;\n /** Optional gas overrides; bundler re-estimates before submission. */\n gasLimits?: {\n callGasLimit?: bigint;\n verificationGasLimit?: bigint;\n preVerificationGas?: bigint;\n };\n /** Optional fee overrides; bundler usually fills these. */\n feeOverrides?: {\n maxFeePerGas?: bigint;\n maxPriorityFeePerGas?: bigint;\n };\n}\n\n/**\n * Build a partial ERC-4337 UserOperation from a batch of operations.\n * Paymaster fields and signature are populated later:\n * 1. Call `PafiBackendClient.requestSponsorship()` → get paymaster fields\n * 2. Compute userOpHash and have the user sign it (via Privy)\n * 3. Attach `signature` → submit to bundler\n *\n * This function is a pure struct builder — no network calls.\n */\nexport function buildPartialUserOperation(\n params: BuildPartialUserOpParams,\n): PartialUserOperation {\n return {\n sender: params.sender,\n nonce: params.nonce,\n callData: encodeBatchExecute(params.operations),\n callGasLimit: params.gasLimits?.callGasLimit ?? DEFAULT_CALL_GAS_LIMIT,\n verificationGasLimit:\n params.gasLimits?.verificationGasLimit ??\n DEFAULT_VERIFICATION_GAS_LIMIT,\n preVerificationGas:\n params.gasLimits?.preVerificationGas ?? DEFAULT_PRE_VERIFICATION_GAS,\n maxFeePerGas: params.feeOverrides?.maxFeePerGas ?? 0n,\n maxPriorityFeePerGas: params.feeOverrides?.maxPriorityFeePerGas ?? 0n,\n };\n}\n\n/**\n * Assemble a full UserOperation once paymaster fields + signature are\n * known. Used after `PafiBackendClient.requestSponsorship()` and user\n * signing complete.\n */\nexport function assembleUserOperation(\n partial: PartialUserOperation,\n paymaster: {\n paymaster: Address;\n paymasterData: `0x${string}`;\n paymasterVerificationGasLimit: bigint;\n paymasterPostOpGasLimit: bigint;\n },\n signature: `0x${string}`,\n): UserOperation {\n return {\n ...partial,\n paymaster: paymaster.paymaster,\n paymasterData: paymaster.paymasterData,\n paymasterVerificationGasLimit: paymaster.paymasterVerificationGasLimit,\n paymasterPostOpGasLimit: paymaster.paymasterPostOpGasLimit,\n signature,\n };\n}\n","import { encodeFunctionData, erc20Abi, parseAbi } from \"viem\";\nimport type { Address } from \"viem\";\nimport type { Operation } from \"./types\";\n\n/**\n * ERC20Burnable extension — `burn(uint256 amount)` burns from msg.sender.\n * The EOA (via EIP-7702 delegation) is the `msg.sender` when a batch\n * runs — so this burns the user's balance without any role check.\n */\nconst ERC20_BURNABLE_ABI = parseAbi([\"function burn(uint256 amount)\"]);\n\n/**\n * Build an ERC-20 `transfer(to, amount)` operation. Used inside a batch\n * to move fee tokens from the user to the fee recipient atomically with\n * the main action.\n */\nexport function erc20TransferOp(\n token: Address,\n to: Address,\n amount: bigint,\n): Operation {\n return {\n target: token,\n value: 0n,\n data: encodeFunctionData({\n abi: erc20Abi,\n functionName: \"transfer\",\n args: [to, amount],\n }),\n };\n}\n\n/**\n * Build an ERC-20 `approve(spender, amount)` operation. Used inside a\n * batch before a swap / deposit call so the AMM / protocol can pull\n * tokens from the user.\n */\nexport function erc20ApproveOp(\n token: Address,\n spender: Address,\n amount: bigint,\n): Operation {\n return {\n target: token,\n value: 0n,\n data: encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount],\n }),\n };\n}\n\n/**\n * Build an ERC-20 `burn(amount)` operation (OpenZeppelin ERC20Burnable\n * extension). Burns from `msg.sender`, which — via EIP-7702 — is the\n * user's EOA.\n *\n * Requires the PointToken contract to expose a public `burn(uint256)`\n * without a role check. See\n * [SDK_V1.4_TASKS.md §11 — PointToken.burn callable via batch].\n */\nexport function erc20BurnOp(token: Address, amount: bigint): Operation {\n return {\n target: token,\n value: 0n,\n data: encodeFunctionData({\n abi: ERC20_BURNABLE_ABI,\n functionName: \"burn\",\n args: [amount],\n }),\n };\n}\n\n/**\n * Build a raw call operation with caller-supplied calldata. Useful for\n * non-ERC-20 contracts (PoolManager.swap, PerpDEX.deposit, Relayer.mint)\n * where the encoding is specific to that protocol.\n */\nexport function rawCallOp(\n target: Address,\n data: `0x${string}`,\n value: bigint = 0n,\n): Operation {\n return { target, value, data };\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,0BA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AAA,IAC3C,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,UAAU,QAAQ,OAAO,QAAQ;AAAA,EAC1C,CAAC;AAED,QAAM,qBAA0B;AAAA,IAC9B,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO,OAAO,QAAQ;AAAA,EACxB;AAEA,QAAM,aAA0B;AAAA,IAC9B;AAAA,MACE,OAAO;AAAA,MACP;AAAA,MACA,OAAO;AAAA,IACT;AAAA,IACA,UAAU,iBAAiB,kBAAkB;AAAA,IAC7C,UAAU,OAAO,wBAAwB,YAAY;AAAA,EACvD;AAEA,MAAI,OAAO,WAAW,IAAI;AACxB,eAAW;AAAA,MACT;AAAA,QACE,OAAO;AAAA,QACP,OAAO;AAAA,QACP,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAEA,SAAO,0BAA0B;AAAA,IAC/B,QAAQ,OAAO;AAAA,IACf,OAAO,OAAO;AAAA,IACd;AAAA,IACA,WAAW;AAAA,MACT,cAAc,OAAO,WAAW,gBAAgB;AAAA,MAChD,sBACE,OAAO,WAAW,wBAAwB;AAAA,MAC5C,oBAAoB,OAAO,WAAW,sBAAsB;AAAA,IAC9D;AAAA,EACF,CAAC;AACH;","names":["encodeFunctionData","encodeFunctionData","encodeFunctionData","erc20Abi","parseAbi","encodeFunctionData"]}
@@ -5,7 +5,7 @@ import {
5
5
  COMMON_POOLS,
6
6
  POINT_TOKEN_POOLS,
7
7
  V4_QUOTER_ADDRESSES
8
- } from "./chunk-S5CCEO4O.js";
8
+ } from "./chunk-Y3HMGOYW.js";
9
9
 
10
10
  // src/quoting/routes.ts
11
11
  var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
@@ -133,4 +133,4 @@ export {
133
133
  quoteBestRoute,
134
134
  findBestQuote
135
135
  };
136
- //# sourceMappingURL=chunk-N5M3BLOV.js.map
136
+ //# sourceMappingURL=chunk-WAFUL62X.js.map
@@ -67,6 +67,7 @@ var POINT_TOKEN_POOLS = {
67
67
  // chainId → pointTokenAddress → PoolKey[]
68
68
  };
69
69
  var ENTRY_POINT_V07 = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
70
+ var ENTRY_POINT_V08 = "0x4337084d9e255ff0702461cf8895ce9e3b5ff108";
70
71
  var PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
71
72
 
72
73
 
@@ -81,5 +82,6 @@ var PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
81
82
 
82
83
 
83
84
 
84
- exports.mintRequestTypes = mintRequestTypes; exports.burnRequestTypes = burnRequestTypes; exports.receiverConsentTypes = receiverConsentTypes; exports.SUPPORTED_CHAINS = SUPPORTED_CHAINS; exports.V4_QUOTER_ADDRESSES = V4_QUOTER_ADDRESSES; exports.UNIVERSAL_ROUTER_ADDRESSES = UNIVERSAL_ROUTER_ADDRESSES; exports.COMMON_TOKENS = COMMON_TOKENS; exports.COMMON_POOLS = COMMON_POOLS; exports.POINT_TOKEN_POOLS = POINT_TOKEN_POOLS; exports.ENTRY_POINT_V07 = ENTRY_POINT_V07; exports.PERMIT2_ADDRESS = PERMIT2_ADDRESS;
85
- //# sourceMappingURL=chunk-52SZJDFT.cjs.map
85
+
86
+ exports.mintRequestTypes = mintRequestTypes; exports.burnRequestTypes = burnRequestTypes; exports.receiverConsentTypes = receiverConsentTypes; exports.SUPPORTED_CHAINS = SUPPORTED_CHAINS; exports.V4_QUOTER_ADDRESSES = V4_QUOTER_ADDRESSES; exports.UNIVERSAL_ROUTER_ADDRESSES = UNIVERSAL_ROUTER_ADDRESSES; exports.COMMON_TOKENS = COMMON_TOKENS; exports.COMMON_POOLS = COMMON_POOLS; exports.POINT_TOKEN_POOLS = POINT_TOKEN_POOLS; exports.ENTRY_POINT_V07 = ENTRY_POINT_V07; exports.ENTRY_POINT_V08 = ENTRY_POINT_V08; exports.PERMIT2_ADDRESS = PERMIT2_ADDRESS;
87
+ //# sourceMappingURL=chunk-X2JZFK4C.cjs.map