@pafi-dev/core 0.19.0 → 0.20.1

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 +46 -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 +132 -23
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +508 -9
  39. package/dist/index.d.ts +508 -9
  40. package/dist/index.js +132 -23
  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 +1 -1
  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/README.md CHANGED
@@ -140,7 +140,35 @@ to recipients. User receives `gross × (1 - bps/10000)` net.
140
140
 
141
141
  ## Operator fee quoter
142
142
 
143
- Two helpers for FE direct usage (no backend round-trip):
143
+ Two execution paths depending on whether your caller has access to a
144
+ bundler-driven estimator (recommended) or needs a self-contained quote.
145
+
146
+ ### Recommended: bundler-driven via `FeeManager` (issuer SDK)
147
+
148
+ For issuer backends (`@pafi-dev/issuer`) and trading helpers
149
+ (`@pafi-dev/trading`), the `FeeManager` class is wired with a
150
+ `BundlerEstimatorClient` (typically `createPafiEstimatorClient(...)`)
151
+ that hits PAFI sponsor-relayer's `POST /v1/estimate-gas-fee`. Server-side
152
+ that endpoint calls Pimlico's `eth_estimateUserOperationGas`, caches by
153
+ `(scenario, contract codehash, paymaster)` in Redis (5 min TTL), applies
154
+ PAFI's 110% premium, and returns gas units. SDK FeeManager then converts
155
+ to PT/USDT via the helpers below with `premiumBps: 10_000` (no
156
+ double-pad). This is the path used by every `/claim/prepare` and
157
+ `/redeem/prepare` flow.
158
+
159
+ Same Redis key is read by sponsor-relayer's `FeeValidator` when verifying
160
+ the submitted UserOp — so the issuer's quote and PAFI's expected fee
161
+ match exactly (no formula drift; only ±5% slack for ETH-price movement
162
+ between quote-time and submit-time).
163
+
164
+ ### Self-contained: direct helpers (FE / fallback path)
165
+
166
+ When no backend round-trip is possible (FE direct `swapDirect`, or a
167
+ caller without `BundlerEstimatorClient` wired), use these helpers
168
+ directly. They run the same math but with **hardcoded** `SCENARIO_GAS_UNITS`
169
+ (per-scenario table) and default `premiumBps: 12_000` (legacy 120%
170
+ self-contained margin — higher than bundler-driven because there's no
171
+ PAFI-side premium to layer on).
144
172
 
145
173
  ```ts
146
174
  import { quoteOperatorFeeUsdt, quoteOperatorFeePt } from "@pafi-dev/core";
@@ -150,7 +178,7 @@ const gasFeeUsdt = await quoteOperatorFeeUsdt({
150
178
  provider, chainId: 8453, scenario: "mint",
151
179
  });
152
180
 
153
- // PT-denominated (used by mint/burn flows). Adds V3 subgraph call.
181
+ // PT-denominated. Adds V3 subgraph call for ptPerUsdt.
154
182
  const gasFeePt = await quoteOperatorFeePt({
155
183
  provider, chainId: 8453, scenario: "mint",
156
184
  pointTokenAddress: POINT_TOKEN,
@@ -158,12 +186,21 @@ const gasFeePt = await quoteOperatorFeePt({
158
186
  });
159
187
  ```
160
188
 
161
- Both return `bigint` raw units. Fallback prices (`0.1 USDT/PT` default,
162
- 3000 USD/ETH default) used when oracles unreachable + `allowStaleFallback`
163
- is true. Sponsor-relayer's `FeeValidator` runs the same math server-side
164
- with a 5% tolerance window.
189
+ Both return `bigint` raw units. Fallback prices (`0.1 USDT/PT`,
190
+ `3000 USD/ETH`) used when oracles unreachable + `allowStaleFallback: true`.
165
191
 
166
- Fee math (raw bigint, no scaling shortcuts):
192
+ ### Scenario table
193
+
194
+ | Scenario | `gasUnits` | Notes |
195
+ |---|---|---|
196
+ | `mint` | 500_000n | Standard mint with wrapper |
197
+ | `burn` | 500_000n | Standard burn |
198
+ | `swap` | 700_000n | Single hop; multi-hop adds headroom inside the premium |
199
+ | `perp-deposit` | 800_000n | Heavier — Orderly Vault interaction |
200
+ | `delegate` | 200_000n | EIP-7702 no-op (gratis-sponsored as one-time onboarding) |
201
+ | `erc20-transfer` | 200_000n | Tiny 2-call batch; bypasses bundler estimator (round-trip > savings) |
202
+
203
+ ### Fee math (raw bigint, no scaling shortcuts)
167
204
 
168
205
  ```
169
206
  withPremium = gasUnits × gasPrice × premiumBps / 10000 (wei)
@@ -171,7 +208,8 @@ fee_USDT_6dec = withPremium × ethPrice_8dec / 10^(18+8-6)
171
208
  fee_PT_18dec = withPremium × ethPrice_8dec × ptPerUsdt_18dec / 10^26
172
209
  ```
173
210
 
174
- Where `ptPerUsdt_18dec` comes from the V3 subgraph (`token0Price` / `token1Price`) inverted to PT-per-USDT and scaled to 18 decimals.
211
+ `ptPerUsdt_18dec` comes from the V3 subgraph (`token0Price` /
212
+ `token1Price` inverted to PT-per-USDT, scaled to 18 decimals).
175
213
 
176
214
  ---
177
215
 
@@ -4,15 +4,20 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkXXLIIWIFcjs = require('../chunk-XXLIIWIF.cjs');
8
7
 
9
8
 
10
9
 
11
10
 
12
- var _chunkC7VB6WTLcjs = require('../chunk-C7VB6WTL.cjs');
13
11
 
12
+ var _chunk2DVM77Y2cjs = require('../chunk-2DVM77Y2.cjs');
14
13
 
15
- var _chunkKRHGFUDIcjs = require('../chunk-KRHGFUDI.cjs');
14
+
15
+
16
+
17
+ var _chunk2CU7ZH2Acjs = require('../chunk-2CU7ZH2A.cjs');
18
+
19
+
20
+ var _chunk245YA3CQcjs = require('../chunk-245YA3CQ.cjs');
16
21
  require('../chunk-JEQ2X3Z6.cjs');
17
22
 
18
23
 
@@ -24,5 +29,10 @@ require('../chunk-JEQ2X3Z6.cjs');
24
29
 
25
30
 
26
31
 
27
- exports.erc20Abi = _chunkXXLIIWIFcjs.erc20Abi; exports.issuerRegistryAbi = _chunkC7VB6WTLcjs.issuerRegistryAbi; exports.mintFeeWrapperAbi = _chunkC7VB6WTLcjs.mintFeeWrapperAbi; exports.mintingOracleAbi = _chunkC7VB6WTLcjs.mintingOracleAbi; exports.permit2Abi = _chunkXXLIIWIFcjs.permit2Abi; exports.pointTokenAbi = _chunkKRHGFUDIcjs.pointTokenAbi; exports.pointTokenFactoryAbi = _chunkXXLIIWIFcjs.pointTokenFactoryAbi; exports.universalRouterAbi = _chunkXXLIIWIFcjs.universalRouterAbi; exports.v3QuoterV2Abi = _chunkXXLIIWIFcjs.v3QuoterV2Abi;
32
+
33
+
34
+
35
+
36
+
37
+ exports.erc20Abi = _chunk2DVM77Y2cjs.erc20Abi; exports.issuerRegistryAbi = _chunk2CU7ZH2Acjs.issuerRegistryAbi; exports.mintFeeWrapperAbi = _chunk2CU7ZH2Acjs.mintFeeWrapperAbi; exports.mintingOracleAbi = _chunk2CU7ZH2Acjs.mintingOracleAbi; exports.permit2Abi = _chunk2DVM77Y2cjs.permit2Abi; exports.pointModuleCoreAbi = _chunk2DVM77Y2cjs.pointModuleCoreAbi; exports.pointTokenAbi = _chunk245YA3CQcjs.pointTokenAbi; exports.pointTokenFactoryAbi = _chunk2DVM77Y2cjs.pointTokenFactoryAbi; exports.settlementVaultAbi = _chunk2DVM77Y2cjs.settlementVaultAbi; exports.tokenRegistryAbi = _chunk2DVM77Y2cjs.tokenRegistryAbi; exports.universalRouterAbi = _chunk2DVM77Y2cjs.universalRouterAbi; exports.v3QuoterV2Abi = _chunk2DVM77Y2cjs.v3QuoterV2Abi; exports.vaultFactoryAbi = _chunk2DVM77Y2cjs.vaultFactoryAbi; exports.vaultRegistryAbi = _chunk2DVM77Y2cjs.vaultRegistryAbi;
28
38
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/abi/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,8hBAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/abi/index.cjs"}
1
+ {"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/abi/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,+1BAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/abi/index.cjs"}