@pafi-dev/core 0.19.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +100 -8
  2. package/dist/abi/index.cjs +14 -4
  3. package/dist/abi/index.cjs.map +1 -1
  4. package/dist/abi/index.d.cts +3846 -482
  5. package/dist/abi/index.d.ts +3846 -482
  6. package/dist/abi/index.js +15 -5
  7. package/dist/{chunk-KRHGFUDI.cjs → chunk-245YA3CQ.cjs} +87 -20
  8. package/dist/chunk-245YA3CQ.cjs.map +1 -0
  9. package/dist/{chunk-C7VB6WTL.cjs → chunk-2CU7ZH2A.cjs} +490 -497
  10. package/dist/chunk-2CU7ZH2A.cjs.map +1 -0
  11. package/dist/chunk-2DVM77Y2.cjs +5018 -0
  12. package/dist/chunk-2DVM77Y2.cjs.map +1 -0
  13. package/dist/{chunk-UZUDJXKE.cjs → chunk-3ZT7KTN4.cjs} +5 -3
  14. package/dist/chunk-3ZT7KTN4.cjs.map +1 -0
  15. package/dist/{chunk-H3X3FYUU.js → chunk-4VPIPVV5.js} +62 -35
  16. package/dist/chunk-4VPIPVV5.js.map +1 -0
  17. package/dist/{chunk-UCO5DXD6.js → chunk-5Y7MGN56.js} +87 -20
  18. package/dist/chunk-5Y7MGN56.js.map +1 -0
  19. package/dist/chunk-DQKCPH6B.cjs +199 -0
  20. package/dist/chunk-DQKCPH6B.cjs.map +1 -0
  21. package/dist/{chunk-4TNHRZ4X.js → chunk-K4GBOB5V.js} +4 -2
  22. package/dist/chunk-K4GBOB5V.js.map +1 -0
  23. package/dist/{chunk-LF5GIN5P.js → chunk-W2DHHR2N.js} +490 -497
  24. package/dist/chunk-W2DHHR2N.js.map +1 -0
  25. package/dist/chunk-ZQVYWMOG.js +5018 -0
  26. package/dist/chunk-ZQVYWMOG.js.map +1 -0
  27. package/dist/contract/index.cjs +8 -4
  28. package/dist/contract/index.cjs.map +1 -1
  29. package/dist/contract/index.d.cts +53 -27
  30. package/dist/contract/index.d.ts +53 -27
  31. package/dist/contract/index.js +13 -9
  32. package/dist/eip712/index.cjs +3 -3
  33. package/dist/eip712/index.d.cts +7 -1
  34. package/dist/eip712/index.d.ts +7 -1
  35. package/dist/eip712/index.js +2 -2
  36. package/dist/index.cjs +174 -24
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +604 -10
  39. package/dist/index.d.ts +604 -10
  40. package/dist/index.js +174 -24
  41. package/dist/index.js.map +1 -1
  42. package/dist/{types-C17pznGz.d.ts → types-Hn1zUPTt.d.cts} +46 -13
  43. package/dist/{types-C17pznGz.d.cts → types-Hn1zUPTt.d.ts} +46 -13
  44. package/package.json +12 -12
  45. package/dist/chunk-4TNHRZ4X.js.map +0 -1
  46. package/dist/chunk-C7VB6WTL.cjs.map +0 -1
  47. package/dist/chunk-H3X3FYUU.js.map +0 -1
  48. package/dist/chunk-KRHGFUDI.cjs.map +0 -1
  49. package/dist/chunk-LF5GIN5P.js.map +0 -1
  50. package/dist/chunk-TRYGIC2I.cjs +0 -172
  51. package/dist/chunk-TRYGIC2I.cjs.map +0 -1
  52. package/dist/chunk-UCO5DXD6.js.map +0 -1
  53. package/dist/chunk-UZUDJXKE.cjs.map +0 -1
  54. package/dist/chunk-XXLIIWIF.cjs +0 -711
  55. package/dist/chunk-XXLIIWIF.cjs.map +0 -1
  56. package/dist/chunk-ZJXXCG5P.js +0 -711
  57. package/dist/chunk-ZJXXCG5P.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,10 +1,15 @@
1
1
  import {
2
2
  erc20Abi,
3
3
  permit2Abi,
4
+ pointModuleCoreAbi,
4
5
  pointTokenFactoryAbi,
6
+ settlementVaultAbi,
7
+ tokenRegistryAbi,
5
8
  universalRouterAbi,
6
- v3QuoterV2Abi
7
- } from "./chunk-ZJXXCG5P.js";
9
+ v3QuoterV2Abi,
10
+ vaultFactoryAbi,
11
+ vaultRegistryAbi
12
+ } from "./chunk-ZQVYWMOG.js";
8
13
  import {
9
14
  SPONSOR_AUTH_DOMAIN_ANCHOR_BASE_MAINNET,
10
15
  SPONSOR_AUTH_DOMAIN_NAME,
@@ -22,26 +27,29 @@ import {
22
27
  verifySponsorAuth
23
28
  } from "./chunk-4EGXLYMM.js";
24
29
  import {
30
+ Source,
31
+ computeEquityCap,
25
32
  getBurnRequestNonce,
26
33
  getIssuer,
27
34
  getIssuer2,
28
35
  getMintFeeBps,
29
36
  getMintFeeRecipients,
30
37
  getMintRequestNonce,
38
+ getOracleRegistries,
31
39
  getPointTokenBalance,
32
- getPointTokenIssuer,
33
- getTokenCap,
34
40
  getTokenName,
35
41
  isActiveIssuer,
36
42
  isMinter,
37
43
  issuerRegistryGetIssuerFlatAbi,
38
- verifyMintCap
39
- } from "./chunk-H3X3FYUU.js";
44
+ verifyEquityMint,
45
+ verifyIssuerOperative,
46
+ verifyMint
47
+ } from "./chunk-4VPIPVV5.js";
40
48
  import {
41
49
  issuerRegistryAbi,
42
50
  mintFeeWrapperAbi,
43
51
  mintingOracleAbi
44
- } from "./chunk-LF5GIN5P.js";
52
+ } from "./chunk-W2DHHR2N.js";
45
53
  import {
46
54
  COMMON_POOLS,
47
55
  COMMON_TOKENS,
@@ -66,10 +74,10 @@ import {
66
74
  signMintRequest,
67
75
  verifyBurnRequest,
68
76
  verifyMintRequest
69
- } from "./chunk-4TNHRZ4X.js";
77
+ } from "./chunk-K4GBOB5V.js";
70
78
  import {
71
79
  pointTokenAbi
72
- } from "./chunk-UCO5DXD6.js";
80
+ } from "./chunk-5Y7MGN56.js";
73
81
  import "./chunk-DGUM43GV.js";
74
82
 
75
83
  // src/index.ts
@@ -865,14 +873,18 @@ function buildEip7702Authorization(params) {
865
873
  // src/contracts/real/addresses.ts
866
874
  var PLACEHOLDER_DEAD = (suffix) => `0x000000000000000000000000000000000000${suffix.toLowerCase().padStart(4, "0")}`;
867
875
  var CONTRACT_ADDRESSES = {
868
- // Base mainnet — live deployment
876
+ // ──────────────────────────────────────────────────────────────────
877
+ // Base mainnet (8453) — V2 dual-bucket deploy 2026-06-12
878
+ //
879
+ // Replaces the v1.6 single-bucket deploy (2026-05-07). Periphery
880
+ // addresses (batchExecutor / chainlinkEthUsd / orderlyRelay /
881
+ // universalRouter / permit2 / pafiFeeRecipient) are inherited from
882
+ // v1.6 — they were not redeployed for V2. PointToken impl + factory
883
+ // were rotated as part of the dual-bucket schema change.
884
+ // ──────────────────────────────────────────────────────────────────
869
885
  8453: {
886
+ // ── Periphery (inherited from v1.6, unchanged) ────────────────
870
887
  batchExecutor: "0xe6Cae83BdE06E4c305530e199D7217f42808555B",
871
- usdt: "0x3F7e71B150e97316Bb9f363A32c19CcD36ac2382",
872
- usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
873
- issuerRegistry: "0xAB1d1e117c41636f30bb10194Fe6B774B6Da9E01",
874
- mintingOracle: "0x2f4cf8C5F8b41efC970c5b46a5d905CeA1f871a0",
875
- mintFeeWrapper: "0xD324EE2e3220B23d1b1BfbB85f5bC1EF2E917B93",
876
888
  chainlinkEthUsd: "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70",
877
889
  orderlyRelay: "0xDA082DAce1522c185aeB5A713FcA6fa6B6E99e7f",
878
890
  pafiFeeRecipient: "0xa3F71eadEd101513a0151007590020dCFD7C495e",
@@ -886,7 +898,22 @@ var CONTRACT_ADDRESSES = {
886
898
  // Permit2, so swaps signed against the canonical Permit2 fail
887
899
  // signature verification. Keep in sync with `PERMIT2_ADDRESS`
888
900
  // top-level export.
889
- permit2: "0xEB450d21ae68D3303Cf5775A54Cc84EE7c3fC8eC"
901
+ permit2: "0xEB450d21ae68D3303Cf5775A54Cc84EE7c3fC8eC",
902
+ // ── Stablecoins ───────────────────────────────────────────────
903
+ // USDT inherited from v1.6 (MockUSDT — no new V2 USDT deploy).
904
+ usdt: "0x3F7e71B150e97316Bb9f363A32c19CcD36ac2382",
905
+ // V2 USDC — PAFI ecosystem USDC (custom deploy, NOT canonical Base
906
+ // USDC `0x833589fC...`). Paired with the USDC/USD Chainlink feed below.
907
+ usdc: "0xf0Fa9eB05fd3a373d3c54775Ff0ed55Dc9cc2D3E",
908
+ chainlinkUsdcUsd: "0xEE86BfD4E2B3A1e71a1b45f750791D67e735e4a7",
909
+ // ── V2 core registries (replaces v1.6) ────────────────────────
910
+ issuerRegistry: "0x3e82647b0f716f80e65d311354E2C4F0DcFd6997",
911
+ mintingOracle: "0x19F5Ea31D42E957F66B672c83293588f190f9fEB",
912
+ mintFeeWrapper: "0x72B8FB182A72741d2F85Bd78B5cAAC8b98c5A493",
913
+ tokenRegistry: "0x7092b329a5c9a823EE0b629D391330D29E109d97",
914
+ vaultRegistry: "0x8D97352cEaA6d6C1Ee2ddFd327F1487357650712",
915
+ vaultFactory: "0xDaD6b27Be7d89A6776b85D0672e0B645318DE63b",
916
+ pointModuleCore: "0x3995fE8ED9dc563C2d7268fCA86d08cc1A2C1c9c"
890
917
  },
891
918
  // Base Sepolia — not in active use; placeholders kept so the map
892
919
  // compiles for tooling that enumerates chains.
@@ -900,15 +927,31 @@ var CONTRACT_ADDRESSES = {
900
927
  orderlyRelay: PLACEHOLDER_DEAD("de03"),
901
928
  pafiFeeRecipient: PLACEHOLDER_DEAD("de04"),
902
929
  universalRouter: PLACEHOLDER_DEAD("de05"),
903
- permit2: PLACEHOLDER_DEAD("de06")
930
+ permit2: PLACEHOLDER_DEAD("de06"),
931
+ tokenRegistry: PLACEHOLDER_DEAD("de07"),
932
+ vaultRegistry: PLACEHOLDER_DEAD("de08"),
933
+ vaultFactory: PLACEHOLDER_DEAD("de09"),
934
+ pointModuleCore: PLACEHOLDER_DEAD("de0a")
904
935
  }
905
936
  };
906
937
  var POINT_TOKEN_FACTORY_ADDRESSES = {
907
- 8453: "0xA08274458b43E7D6F4ff61ddFe8A9852c6531085",
938
+ // V2 dual-bucket factory (2026-06-12). Replaces v1.6 factory
939
+ // `0xA08274458b43E7D6F4ff61ddFe8A9852c6531085`.
940
+ 8453: "0x34f9F84841A77A19040686396b8B64522A2da4c8",
908
941
  84532: PLACEHOLDER_DEAD("dead")
909
942
  };
910
943
  var POINT_TOKEN_IMPL_ADDRESSES = {
911
- 8453: "0xc41c3F8A0380c7760Ee1209d6d19C4b81dE994e4",
944
+ // V2 dual-bucket impl (2026-06-12). Replaces v1.6 impl
945
+ // `0xc41c3F8A0380c7760Ee1209d6d19C4b81dE994e4` (single-bucket).
946
+ 8453: "0x067d2d82F7cfbAf9bBA1f493167cC6043eD5d7dd",
947
+ 84532: PLACEHOLDER_DEAD("dead")
948
+ };
949
+ var POINT_TOKEN_BEACON_ADDRESSES = {
950
+ 8453: "0xdC479E294FD12658FDC68B9400c2073De291acf3",
951
+ 84532: PLACEHOLDER_DEAD("dead")
952
+ };
953
+ var VAULT_BEACON_ADDRESSES = {
954
+ 8453: "0x4E583d64bfcCD86dFf1f68b792D5a1Cd169f22eB",
912
955
  84532: PLACEHOLDER_DEAD("dead")
913
956
  };
914
957
  function getContractAddresses(chainId) {
@@ -1005,6 +1048,46 @@ function normalizeHex32(value) {
1005
1048
  return "0x" + stripped.padStart(64, "0");
1006
1049
  }
1007
1050
 
1051
+ // src/delegation/attachDelegationIfNeeded.ts
1052
+ var inFlight = /* @__PURE__ */ new Map();
1053
+ function cacheKey(chainId, account) {
1054
+ return `${chainId}:${account.toLowerCase()}`;
1055
+ }
1056
+ async function attachDelegationIfNeeded(params) {
1057
+ const key = cacheKey(params.chainId, params.account);
1058
+ const existing = inFlight.get(key);
1059
+ if (existing) return existing;
1060
+ const promise = doAttach(params).finally(() => {
1061
+ inFlight.delete(key);
1062
+ });
1063
+ inFlight.set(key, promise);
1064
+ return promise;
1065
+ }
1066
+ async function doAttach(params) {
1067
+ const { rpc, account, expectedDelegate, chainId, signAuthorization } = params;
1068
+ if (await isDelegatedTo(rpc, account, expectedDelegate)) {
1069
+ return void 0;
1070
+ }
1071
+ const nonce = await rpc.getTransactionCount({ address: account });
1072
+ const rawAuth = await signAuthorization({
1073
+ contractAddress: expectedDelegate,
1074
+ chainId,
1075
+ nonce
1076
+ });
1077
+ const authorization = {
1078
+ chainId: toHexQuantity(rawAuth.chainId),
1079
+ address: rawAuth.contractAddress ?? rawAuth.address ?? expectedDelegate,
1080
+ nonce: toHexQuantity(BigInt(rawAuth.nonce)),
1081
+ r: rawAuth.r,
1082
+ s: rawAuth.s,
1083
+ yParity: typeof rawAuth.yParity === "string" ? rawAuth.yParity.startsWith("0x") ? rawAuth.yParity : `0x${rawAuth.yParity}` : `0x${rawAuth.yParity}`
1084
+ };
1085
+ return { authorization };
1086
+ }
1087
+ function toHexQuantity(n) {
1088
+ return `0x${BigInt(n).toString(16)}`;
1089
+ }
1090
+
1008
1091
  // src/transport/proxyTransport.ts
1009
1092
  import { http } from "viem";
1010
1093
  function createPafiProxyTransport(params) {
@@ -1064,7 +1147,7 @@ import { parseAbi as parseAbi3 } from "viem";
1064
1147
 
1065
1148
  // src/subgraph/pools.ts
1066
1149
  import { isAddress } from "viem";
1067
- var PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v4";
1150
+ var PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v1";
1068
1151
  var POOL_QUERY = `
1069
1152
  query GetPoolForPointToken($id: ID!) {
1070
1153
  pafiToken(id: $id) {
@@ -1356,6 +1439,60 @@ function parseBigDecimalTo18(s) {
1356
1439
  return BigInt(whole + padded);
1357
1440
  }
1358
1441
 
1442
+ // src/contracts/real/pointToken.ts
1443
+ import { parseAbi as parseAbi4 } from "viem";
1444
+ var POINT_TOKEN_MINT_SIG_ABI = parseAbi4([
1445
+ "function mint(address user, uint256 amount, uint8 source, uint256 deadline, bytes minterSig) external"
1446
+ ]);
1447
+ var POINT_TOKEN_BURN_SIG_ABI = parseAbi4([
1448
+ "function burn(address from, uint256 amount, uint8 source, uint256 deadline, bytes burnerSig) external"
1449
+ ]);
1450
+ var POINT_TOKEN_ABI = parseAbi4([
1451
+ // --- Mint paths (V2 dual-bucket: +uint8 source) ---
1452
+ "function mint(address to, uint256 amount, uint8 source) external",
1453
+ "function mint(address user, uint256 amount, uint8 source, uint256 deadline, bytes minterSig) external",
1454
+ // --- Burn paths (V2 dual-bucket: +uint8 source) ---
1455
+ "function burn(address from, uint256 amount, uint8 source) external",
1456
+ "function burn(address from, uint256 amount, uint8 source, uint256 deadline, bytes burnerSig) external",
1457
+ // --- V2 per-bucket supply views ---
1458
+ "function equitySupply() external view returns (uint256)",
1459
+ "function vaultSupply() external view returns (uint256)",
1460
+ // --- Authorization reads ---
1461
+ "function minters(address account) external view returns (bool)",
1462
+ "function burners(address account) external view returns (bool)",
1463
+ // --- Authorization writes (owner-only; used by provisioning scripts) ---
1464
+ "function addMinter(address minter) external",
1465
+ "function removeMinter(address minter) external",
1466
+ "function addBurner(address burner) external",
1467
+ "function removeBurner(address burner) external",
1468
+ // --- Nonces (sig-gated paths) ---
1469
+ "function mintRequestNonces(address receiver) external view returns (uint256)",
1470
+ "function burnRequestNonces(address from) external view returns (uint256)",
1471
+ // --- Oracle ---
1472
+ "function mintingOracle() external view returns (address)",
1473
+ "function setMintingOracle(address _mintingOracle) external",
1474
+ // --- Issuer ---
1475
+ "function issuer() external view returns (address)",
1476
+ // --- Standard ERC-20 reads ---
1477
+ "function balanceOf(address account) external view returns (uint256)",
1478
+ "function totalSupply() external view returns (uint256)",
1479
+ "function name() external view returns (string)",
1480
+ "function symbol() external view returns (string)",
1481
+ "function decimals() external view returns (uint8)",
1482
+ // --- EIP-712 domain (for off-chain sig verification) ---
1483
+ "function DOMAIN_SEPARATOR() external view returns (bytes32)",
1484
+ "function eip712Domain() external view returns (bytes1 fields, string name, string version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] extensions)",
1485
+ // --- Events ---
1486
+ // PointIndexer filters Transfer(from=0x0) for mints
1487
+ // BurnIndexer filters Transfer(to=0x0) for burns
1488
+ "event Transfer(address indexed from, address indexed to, uint256 value)",
1489
+ "event MinterAdded(address indexed minter)",
1490
+ "event MinterRemoved(address indexed minter)",
1491
+ "event BurnerAdded(address indexed burner)",
1492
+ "event BurnerRemoved(address indexed burner)",
1493
+ "event MintingOracleUpdated(address indexed mintingOracle)"
1494
+ ]);
1495
+
1359
1496
  // src/contracts/real/batchExecutor.ts
1360
1497
  var BATCH_EXECUTOR_ADDRESS_BASE_MAINNET = getContractAddresses(8453).batchExecutor;
1361
1498
  var BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA = getContractAddresses(84532).batchExecutor;
@@ -1669,9 +1806,12 @@ export {
1669
1806
  PAFI_SERVICE_URLS,
1670
1807
  PAFI_SUBGRAPH_URL,
1671
1808
  PERMIT2_ADDRESS,
1672
- pointTokenAbi as POINT_TOKEN_ABI,
1809
+ POINT_TOKEN_ABI,
1810
+ POINT_TOKEN_BEACON_ADDRESSES,
1811
+ POINT_TOKEN_BURN_SIG_ABI,
1673
1812
  POINT_TOKEN_FACTORY_ADDRESSES,
1674
1813
  POINT_TOKEN_IMPL_ADDRESSES,
1814
+ POINT_TOKEN_MINT_SIG_ABI,
1675
1815
  POINT_TOKEN_POOLS,
1676
1816
  PafiSDK,
1677
1817
  PafiSdkError,
@@ -1685,15 +1825,18 @@ export {
1685
1825
  SUPPORTED_CHAINS,
1686
1826
  SigningError,
1687
1827
  SimulationError,
1828
+ Source,
1688
1829
  TOKEN_HASHES,
1689
1830
  UNIVERSAL_ROUTER_ADDRESSES,
1690
1831
  V3_FACTORY_ADDRESSES,
1691
1832
  V3_POOL_INIT_CODE_HASH,
1692
1833
  V3_SWAP_ROUTER_ADDRESSES,
1834
+ VAULT_BEACON_ADDRESSES,
1693
1835
  ValidationError,
1694
1836
  ZERO_VALUE,
1695
1837
  assembleUserOperation,
1696
1838
  assertDomainMatchesContract,
1839
+ attachDelegationIfNeeded,
1697
1840
  buildAndSignSponsorAuth,
1698
1841
  buildBurnRequestTypedData,
1699
1842
  buildDelegationUserOp,
@@ -1713,6 +1856,7 @@ export {
1713
1856
  computeAccountId,
1714
1857
  computeAuthorizationHash,
1715
1858
  computeCallDataHash,
1859
+ computeEquityCap,
1716
1860
  computeUserOpHash,
1717
1861
  computeV3PoolAddress,
1718
1862
  createLoginMessage,
@@ -1738,13 +1882,12 @@ export {
1738
1882
  getMintFeeBps,
1739
1883
  getMintFeeRecipients,
1740
1884
  getMintRequestNonce,
1885
+ getOracleRegistries,
1741
1886
  getPafiServiceUrls,
1742
1887
  getPafiWebModalAdapter,
1743
1888
  getPointTokenBalance,
1744
- getPointTokenIssuer,
1745
1889
  getIssuer as getPointTokenIssuerAddress,
1746
1890
  getSponsorAuthDomainAnchor,
1747
- getTokenCap,
1748
1891
  getTokenName,
1749
1892
  isActiveIssuer,
1750
1893
  isDelegatedTo,
@@ -1761,6 +1904,7 @@ export {
1761
1904
  parseEip7702DelegatedAddress,
1762
1905
  parseLoginMessage,
1763
1906
  permit2Abi,
1907
+ pointModuleCoreAbi,
1764
1908
  pointTokenAbi,
1765
1909
  pointTokenFactoryAbi,
1766
1910
  quoteOperatorFeeForTransfer,
@@ -1770,15 +1914,21 @@ export {
1770
1914
  sendWithPaymasterFallback,
1771
1915
  serializeUserOpToJsonRpc,
1772
1916
  setPafiWebModalAdapter,
1917
+ settlementVaultAbi,
1773
1918
  signBurnRequest,
1774
1919
  signMintRequest,
1775
1920
  signSponsorAuth,
1776
1921
  splitAuthorizationSig,
1922
+ tokenRegistryAbi,
1777
1923
  universalRouterAbi,
1778
1924
  v3QuoterV2Abi,
1925
+ vaultFactoryAbi,
1926
+ vaultRegistryAbi,
1779
1927
  verifyBurnRequest,
1928
+ verifyEquityMint,
1929
+ verifyIssuerOperative,
1780
1930
  verifyLoginMessage,
1781
- verifyMintCap,
1931
+ verifyMint,
1782
1932
  verifyMintRequest,
1783
1933
  verifySponsorAuth,
1784
1934
  webPopupAdapter