@pafi-dev/trading 0.9.0 → 0.10.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.
- package/README.md +12 -9
- package/dist/index.cjs +2063 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1330 -2
- package/dist/index.d.ts +1330 -2
- package/dist/index.js +2053 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ import { getContractAddresses } from "@pafi-dev/core";
|
|
|
57
57
|
|
|
58
58
|
const provider = createPublicClient({ transport: http("https://mainnet.base.org") });
|
|
59
59
|
const trading = new TradingHandlers({ provider, chainId: 8453 });
|
|
60
|
-
const { usdt } = getContractAddresses(8453);
|
|
60
|
+
const { usdt, usdc } = getContractAddresses(8453); // usdc is optional, used by perp-deposit fee path
|
|
61
61
|
|
|
62
62
|
// Pool discovery — loop call when both sides are PT (PT0 → PT1 multi-hop).
|
|
63
63
|
const pools = await fetchPafiPools(8453, POINT_TOKEN);
|
|
@@ -92,11 +92,13 @@ const swap = await trading.handleSwap(userAddress, {
|
|
|
92
92
|
|
|
93
93
|
## Direction matrix
|
|
94
94
|
|
|
95
|
-
| Direction | Use case |
|
|
96
|
-
| --- | --- | --- | --- |
|
|
97
|
-
| `PT → USDT` | Cashout | 1 |
|
|
98
|
-
| `USDT → PT` | Buy PT | 1 |
|
|
99
|
-
| `PT0 → PT1` | Multi-token swap | 2 (via USDT) |
|
|
95
|
+
| Direction | Use case | Hops | Operator fee token |
|
|
96
|
+
| --- | --- | --- | --- |
|
|
97
|
+
| `PT → USDT` | Cashout | 1 | USDT (output) |
|
|
98
|
+
| `USDT → PT` | Buy PT | 1 | PT (output) |
|
|
99
|
+
| `PT0 → PT1` | Multi-token swap | 2 (via USDT) | output PT |
|
|
100
|
+
|
|
101
|
+
Pool fee depends on which V3 tier the pool was created at (typically 0.05% or 0.3% — `COMMON_POOLS` carries both). `findBestQuote` picks the route with the best amountOut across all tiers.
|
|
100
102
|
|
|
101
103
|
**Cross-issuer OK** for PT0 → PT1 (e.g. TPT ↔ LTR if both issuers ship
|
|
102
104
|
V3 pools with USDT). The router auto-routes through `USDT`.
|
|
@@ -204,7 +206,6 @@ import {
|
|
|
204
206
|
buildUniversalRouterExecuteArgsExactOut,
|
|
205
207
|
buildV3SwapInputExactIn,
|
|
206
208
|
buildV3SwapInputExactOut,
|
|
207
|
-
buildSwapFromQuote,
|
|
208
209
|
buildPermit2ApprovalCalldata,
|
|
209
210
|
buildErc20ApprovalCalldata,
|
|
210
211
|
checkAllowance,
|
|
@@ -217,6 +218,8 @@ import {
|
|
|
217
218
|
Use these to build custom direction-agnostic swap flows or pre-flight
|
|
218
219
|
simulations.
|
|
219
220
|
|
|
221
|
+
> `buildSwapFromQuote` is also re-exported but `@deprecated` — pass `bestRoute.path` from `findBestQuote(...)` directly into `buildUniversalRouterExecuteArgs(...)` instead. Will be removed in a future minor.
|
|
222
|
+
|
|
220
223
|
---
|
|
221
224
|
|
|
222
225
|
## Direct path — no AA, no bundler, no sponsor-relayer
|
|
@@ -358,7 +361,7 @@ Methods:
|
|
|
358
361
|
- `findBestQuoteExactOut(...)`
|
|
359
362
|
- `quoteBestRoute`, `quoteBestRouteExactOut`, `quoteExactInput`, `quoteExactInputSingle`, `quoteExactOutput`, `quoteExactOutputSingle`
|
|
360
363
|
- `buildSwapUserOp(params)` / `buildSwapUserOpExactOut(params)` — direction-agnostic UserOp builder
|
|
361
|
-
- `buildUniversalRouterExecuteArgs`, `buildUniversalRouterExecuteArgsExactOut`, `buildV3SwapInputExactIn`, `buildV3SwapInputExactOut
|
|
364
|
+
- `buildUniversalRouterExecuteArgs`, `buildUniversalRouterExecuteArgsExactOut`, `buildV3SwapInputExactIn`, `buildV3SwapInputExactOut` (and the `@deprecated` `buildSwapFromQuote` alias)
|
|
362
365
|
- `buildPermit2ApprovalCalldata`, `buildErc20ApprovalCalldata`, `checkAllowance`
|
|
363
366
|
- `simulateSwap` — `eth_call` dry-run
|
|
364
367
|
- `fetchPafiPools(chainId, pointTokenAddress, subgraphUrl?)` — re-exported from core
|
|
@@ -369,7 +372,7 @@ Methods:
|
|
|
369
372
|
|
|
370
373
|
## References
|
|
371
374
|
|
|
372
|
-
- Fee math: [
|
|
375
|
+
- Fee math: see [`@pafi-dev/core` README — Operator fee quoter](../core/README.md#operator-fee-quoter)
|
|
373
376
|
- Architecture: [`ARCHITECTURE.md`](../../ARCHITECTURE.md) at SDK root
|
|
374
377
|
|
|
375
378
|
## License
|