@pafi-dev/trading 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,10 +17,10 @@ client-side (React, React Native).
|
|
|
17
17
|
- TypeScript >= 5.0
|
|
18
18
|
- `viem` ^2.0.0 and `@pafi-dev/core` ^0.5.17 (peer dependencies)
|
|
19
19
|
|
|
20
|
-
> **Latest:** `0.1.
|
|
21
|
-
> the
|
|
22
|
-
>
|
|
23
|
-
>
|
|
20
|
+
> **Latest:** `0.1.9` — `handleSwap` / `handlePerpDeposit` now
|
|
21
|
+
> auto-quote the operator fee and auto-resolve the PAFI fee recipient.
|
|
22
|
+
> Caller no longer pre-fetches anything from the issuer backend. See
|
|
23
|
+
> [Changelog](#changelog).
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
@@ -341,6 +341,56 @@ It does not depend on `@pafi-dev/issuer`.
|
|
|
341
341
|
|
|
342
342
|
## Changelog
|
|
343
343
|
|
|
344
|
+
### 0.1.9
|
|
345
|
+
|
|
346
|
+
`handleSwap` and `handlePerpDeposit` now **auto-quote the operator fee
|
|
347
|
+
+ auto-resolve the PAFI fee recipient**. Caller no longer needs to
|
|
348
|
+
pre-fetch anything from the issuer backend.
|
|
349
|
+
|
|
350
|
+
**API changes** (additive — passing the old explicit values still works
|
|
351
|
+
as overrides):
|
|
352
|
+
|
|
353
|
+
- `ApiSwapRequest.gasFeePt` — semantics changed:
|
|
354
|
+
- `undefined` (default): handler runs `quoteOperatorFeePt` (Chainlink
|
|
355
|
+
+ V4 subgraph) to compute the PT fee.
|
|
356
|
+
- `0n`: strips the `PT.transfer(...)` from the batch (unsponsored
|
|
357
|
+
fallback).
|
|
358
|
+
- explicit bigint: override (issuer markup / subsidy).
|
|
359
|
+
- `ApiSwapRequest.feeRecipient` — **REMOVED**. Hardcoded to
|
|
360
|
+
`getContractAddresses(chainId).pafiFeeRecipient`. Sponsor-relayer's
|
|
361
|
+
L1 gate would reject any other recipient anyway, so the option was
|
|
362
|
+
removed to keep the API honest.
|
|
363
|
+
- `ApiPerpDepositRequest.gasFeePtRecipient` — **REMOVED** (same
|
|
364
|
+
reason). `pointTokenAddress` still required when fee > 0 (handler
|
|
365
|
+
needs the token to call `transfer` against).
|
|
366
|
+
- `ApiSwapResponse.feeAmountUsed` / `.feeRecipient` — **NEW**. Echo
|
|
367
|
+
what the handler actually embedded so the FE can display it without
|
|
368
|
+
re-quoting.
|
|
369
|
+
- `ApiPerpDepositResponse.feeAmountUsed` / `.feeRecipient` — same.
|
|
370
|
+
|
|
371
|
+
**Migration**:
|
|
372
|
+
|
|
373
|
+
```diff
|
|
374
|
+
- const gasFeePt = await quoteOperatorFeePt({...});
|
|
375
|
+
- const result = await trading.handleSwap({
|
|
376
|
+
- ..., gasFeePt, feeRecipient: PAFI_FEE_RECIPIENT,
|
|
377
|
+
- });
|
|
378
|
+
+ const result = await trading.handleSwap({...});
|
|
379
|
+
+ console.log(`Fee charged: ${result.feeAmountUsed} → ${result.feeRecipient}`);
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Force unsponsored / fallback (no fee transfer):
|
|
383
|
+
|
|
384
|
+
```ts
|
|
385
|
+
const result = await trading.handleSwap({ ..., gasFeePt: 0n });
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Fee policy override (rare):
|
|
389
|
+
|
|
390
|
+
```ts
|
|
391
|
+
const result = await trading.handleSwap({ ..., gasFeePt: customAmount });
|
|
392
|
+
```
|
|
393
|
+
|
|
344
394
|
### 0.1.5
|
|
345
395
|
|
|
346
396
|
`handlePerpDeposit` now defaults to the **PAFI Orderly Relay** path —
|