@pafi-dev/issuer 0.5.42 → 0.6.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.
- package/dist/index.cjs +138 -536
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -343
- package/dist/index.d.ts +49 -343
- package/dist/index.js +95 -498
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -507,15 +507,13 @@ declare class RelayService {
|
|
|
507
507
|
*/
|
|
508
508
|
prepareMint(params: PrepareMintParams): Promise<PartialUserOperation>;
|
|
509
509
|
/**
|
|
510
|
-
* Build an unsigned UserOp for Scenario 2 (Burn/Redeem)
|
|
510
|
+
* Build an unsigned UserOp for Scenario 2 (Burn/Redeem) — sig-gated
|
|
511
|
+
* `PointToken.burn(from, amount, deadline, burnerSig)`. Caller
|
|
512
|
+
* provides a pre-signed `BurnRequest` + sig bytes (typically from
|
|
513
|
+
* `PTRedeemHandler`).
|
|
511
514
|
*
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
* usable if the caller (via EIP-7702) is whitelisted as a burner.
|
|
515
|
-
* Rare in v1.4; kept for admin/operator tools.
|
|
516
|
-
* - `mode: 'burnWithSig'` — `PointToken.burn(from, amount, deadline,
|
|
517
|
-
* burnerSig)`. Caller provides a pre-signed `BurnRequest` + sig
|
|
518
|
-
* bytes (typically from `PTRedeemHandler`).
|
|
515
|
+
* Direct burn (no sig) was dropped in v1.4 — every burn now goes
|
|
516
|
+
* through the issuer-signed `BurnRequest` path.
|
|
519
517
|
*/
|
|
520
518
|
prepareBurn(params: PrepareBurnParams): Promise<PartialUserOperation>;
|
|
521
519
|
}
|
|
@@ -562,12 +560,24 @@ interface PrepareMintParams {
|
|
|
562
560
|
verificationGasLimit?: bigint;
|
|
563
561
|
preVerificationGas?: bigint;
|
|
564
562
|
}
|
|
565
|
-
|
|
566
|
-
|
|
563
|
+
/**
|
|
564
|
+
* v1.4 — sig-gated burn only. Direct (no-sig) burn was dropped because
|
|
565
|
+
* every burn now goes through `BurnRequest` EIP-712 signed by the
|
|
566
|
+
* issuer burner. The `mode: 'burnWithSig'` discriminant is preserved
|
|
567
|
+
* for backwards-compat with existing callers but is no longer
|
|
568
|
+
* branched on internally.
|
|
569
|
+
*/
|
|
570
|
+
interface PrepareBurnParams {
|
|
567
571
|
userAddress: Address;
|
|
568
572
|
aaNonce: bigint;
|
|
569
573
|
pointTokenAddress: Address;
|
|
570
574
|
batchExecutorAddress: Address;
|
|
575
|
+
/** Discriminant kept for backwards compat. Always `'burnWithSig'`. */
|
|
576
|
+
mode?: "burnWithSig";
|
|
577
|
+
/** BurnRequest message the issuer burner signer signed. */
|
|
578
|
+
burnRequest: BurnRequest;
|
|
579
|
+
/** Serialized EIP-712 signature (bytes) over `burnRequest`. */
|
|
580
|
+
burnerSignature: Hex;
|
|
571
581
|
/**
|
|
572
582
|
* Optional — application-level PT fee transfer appended after burn.
|
|
573
583
|
* Used for gas reimbursement on the sponsored path. Set both
|
|
@@ -580,17 +590,6 @@ interface PrepareBurnCommonParams {
|
|
|
580
590
|
verificationGasLimit?: bigint;
|
|
581
591
|
preVerificationGas?: bigint;
|
|
582
592
|
}
|
|
583
|
-
interface PrepareBurnDirectParams extends PrepareBurnCommonParams {
|
|
584
|
-
mode: "burn";
|
|
585
|
-
amount: bigint;
|
|
586
|
-
}
|
|
587
|
-
interface PrepareBurnWithSigParams extends PrepareBurnCommonParams {
|
|
588
|
-
mode: "burnWithSig";
|
|
589
|
-
/** BurnRequest message the issuer burner signer signed. */
|
|
590
|
-
burnRequest: BurnRequest;
|
|
591
|
-
/** Serialized EIP-712 signature (bytes) over `burnRequest`. */
|
|
592
|
-
burnerSignature: Hex;
|
|
593
|
-
}
|
|
594
593
|
|
|
595
594
|
interface FeeManagerConfig {
|
|
596
595
|
/** Provider used for gas price reads. */
|
|
@@ -627,7 +626,7 @@ interface FeeManagerConfig {
|
|
|
627
626
|
* (PT for mint/burn, USDT for swap/perp_deposit) — not hardcoded to USDT.
|
|
628
627
|
*
|
|
629
628
|
* **Operator rebalancing is gone.** In v1.4 the operator no longer holds
|
|
630
|
-
* ETH directly — gas is paid by
|
|
629
|
+
* ETH directly — gas is paid by PAFI sponsor-relayer via the paymaster-proxy
|
|
631
630
|
* (see [SPONSORED_PATH_FLOW.md]). The fee collected here is an
|
|
632
631
|
* application-level ERC-20 transfer inside the same UserOp batch, not a
|
|
633
632
|
* reimbursement to a wallet that needs topping up.
|
|
@@ -985,67 +984,6 @@ interface ApiUserResponse {
|
|
|
985
984
|
balance: bigint;
|
|
986
985
|
isMinter: boolean;
|
|
987
986
|
}
|
|
988
|
-
interface ApiRedeemRequest {
|
|
989
|
-
userAddress: Address;
|
|
990
|
-
/** PT amount to burn. */
|
|
991
|
-
amount: bigint;
|
|
992
|
-
/** ERC-4337 account nonce for the user's EOA. */
|
|
993
|
-
aaNonce: bigint;
|
|
994
|
-
}
|
|
995
|
-
interface ApiRedeemResponse {
|
|
996
|
-
/** Pending credit lock id — poll `/user` to track PENDING → CREDITED. */
|
|
997
|
-
lockId: string;
|
|
998
|
-
/** Unsigned UserOp — attach paymaster data + user signature, then submit. */
|
|
999
|
-
userOp: PartialUserOperation;
|
|
1000
|
-
/** Seconds until the pending credit lock expires if the burn doesn't land. */
|
|
1001
|
-
expiresInSeconds: number;
|
|
1002
|
-
/** BurnRequest deadline (unix seconds) — FE can surface a countdown. */
|
|
1003
|
-
signatureDeadline: bigint;
|
|
1004
|
-
}
|
|
1005
|
-
interface ApiTopUpRequest {
|
|
1006
|
-
userAddress: Address;
|
|
1007
|
-
/** Total points the voucher requires off-chain. */
|
|
1008
|
-
requiredAmount: bigint;
|
|
1009
|
-
/** ERC-4337 account nonce for the user's EOA. */
|
|
1010
|
-
aaNonce: bigint;
|
|
1011
|
-
}
|
|
1012
|
-
type ApiTopUpResponse = {
|
|
1013
|
-
/** Off-chain balance already covers the required amount — no burn needed. */
|
|
1014
|
-
action: "NO_TOP_UP_NEEDED";
|
|
1015
|
-
offChainBalance: bigint;
|
|
1016
|
-
} | {
|
|
1017
|
-
/** Combined off-chain + on-chain is still insufficient — cannot fulfill. */
|
|
1018
|
-
action: "INSUFFICIENT_ONCHAIN";
|
|
1019
|
-
offChainBalance: bigint;
|
|
1020
|
-
onChainBalance: bigint;
|
|
1021
|
-
shortfall: bigint;
|
|
1022
|
-
} | {
|
|
1023
|
-
/** Burn of `shortfall` PT initiated — FE submits the returned UserOp. */
|
|
1024
|
-
action: "TOP_UP_STARTED";
|
|
1025
|
-
shortfall: bigint;
|
|
1026
|
-
redeem: ApiRedeemResponse;
|
|
1027
|
-
};
|
|
1028
|
-
interface ApiClaimRequest {
|
|
1029
|
-
chainId: number;
|
|
1030
|
-
pointTokenAddress: Address;
|
|
1031
|
-
/** PT amount to mint. */
|
|
1032
|
-
amount: bigint;
|
|
1033
|
-
/** ERC-4337 account nonce for the user's EOA (from EntryPoint). */
|
|
1034
|
-
aaNonce: bigint;
|
|
1035
|
-
/** Unix seconds — when the MintRequest signature expires. */
|
|
1036
|
-
deadline: bigint;
|
|
1037
|
-
/** Optional operator fee (PT) deducted inside the same UserOp batch. */
|
|
1038
|
-
feeAmount?: bigint;
|
|
1039
|
-
feeRecipient?: Address;
|
|
1040
|
-
}
|
|
1041
|
-
interface ApiClaimResponse {
|
|
1042
|
-
/** Off-chain lock id — poll `/user` to track PENDING → MINTED. */
|
|
1043
|
-
lockId: string;
|
|
1044
|
-
/** Unsigned UserOp — attach paymaster data + user signature, then submit. */
|
|
1045
|
-
userOp: PartialUserOperation;
|
|
1046
|
-
/** Seconds until the off-chain lock expires if the UserOp is not submitted. */
|
|
1047
|
-
expiresInSeconds: number;
|
|
1048
|
-
}
|
|
1049
987
|
type PoolsProvider = (request: ApiPoolsRequest) => Promise<ApiPoolsResponse>;
|
|
1050
988
|
|
|
1051
989
|
interface IssuerApiHandlersConfig {
|
|
@@ -1075,20 +1013,6 @@ interface IssuerApiHandlersConfig {
|
|
|
1075
1013
|
feeManager?: FeeManager;
|
|
1076
1014
|
/** Required by `handlePools`; omit to disable the endpoint. */
|
|
1077
1015
|
poolsProvider?: PoolsProvider;
|
|
1078
|
-
/**
|
|
1079
|
-
* Required by `handleClaim`; omit to disable the endpoint.
|
|
1080
|
-
* Wires policy evaluation + ledger locking + MintRequest signing
|
|
1081
|
-
* into a single atomic handler so callers cannot accidentally skip
|
|
1082
|
-
* the policy check.
|
|
1083
|
-
*/
|
|
1084
|
-
claim?: {
|
|
1085
|
-
policy: IPolicyEngine;
|
|
1086
|
-
relayService: RelayService;
|
|
1087
|
-
issuerSignerWallet: WalletClient;
|
|
1088
|
-
batchExecutorAddress: Address;
|
|
1089
|
-
/** How long to hold the off-chain lock while the UserOp is in flight. Default: 15 min. */
|
|
1090
|
-
lockDurationMs?: number;
|
|
1091
|
-
};
|
|
1092
1016
|
}
|
|
1093
1017
|
/**
|
|
1094
1018
|
* Framework-agnostic HTTP handlers that match the endpoints a `PafiSDK`
|
|
@@ -1115,7 +1039,6 @@ declare class IssuerApiHandlers {
|
|
|
1115
1039
|
private readonly pafiWebUrl?;
|
|
1116
1040
|
private readonly feeManager?;
|
|
1117
1041
|
private readonly poolsProvider?;
|
|
1118
|
-
private readonly claim?;
|
|
1119
1042
|
constructor(config: IssuerApiHandlersConfig);
|
|
1120
1043
|
/** `GET /auth/nonce` */
|
|
1121
1044
|
handleGetNonce(): Promise<ApiNonceResponse>;
|
|
@@ -1147,22 +1070,6 @@ declare class IssuerApiHandlers {
|
|
|
1147
1070
|
* balance.
|
|
1148
1071
|
*/
|
|
1149
1072
|
handleUser(userAddress: Address, request: ApiUserRequest): Promise<ApiUserResponse>;
|
|
1150
|
-
/**
|
|
1151
|
-
* `POST /claim`
|
|
1152
|
-
*
|
|
1153
|
-
* Policy gate + ledger lock + MintRequest signing in a single atomic
|
|
1154
|
-
* step. Returns an unsigned UserOp the frontend attaches paymaster data
|
|
1155
|
-
* to and submits via EIP-7702 + Bundler.
|
|
1156
|
-
*
|
|
1157
|
-
* Order of operations:
|
|
1158
|
-
* 1. Validate request fields.
|
|
1159
|
-
* 2. policy.evaluate() — throws if denied; cannot be bypassed.
|
|
1160
|
-
* 3. ledger.lockForMinting() — reserves the balance.
|
|
1161
|
-
* 4. Read on-chain mintRequestNonce + token name in parallel.
|
|
1162
|
-
* 5. relayService.prepareMint() — sign MintRequest + encode UserOp.
|
|
1163
|
-
* 6. On any error after step 3, release the lock before re-throwing.
|
|
1164
|
-
*/
|
|
1165
|
-
handleClaim(userAddress: Address, request: ApiClaimRequest): Promise<ApiClaimResponse>;
|
|
1166
1073
|
}
|
|
1167
1074
|
|
|
1168
1075
|
/**
|
|
@@ -1171,7 +1078,7 @@ declare class IssuerApiHandlers {
|
|
|
1171
1078
|
* User has on-chain PT, wants to convert back to off-chain points. The
|
|
1172
1079
|
* issuer backend signs a `BurnRequest` with its burner signer, reserves
|
|
1173
1080
|
* an off-chain pending credit, and returns an unsigned UserOp. The FE
|
|
1174
|
-
* submits the UserOp via EIP-7702 +
|
|
1081
|
+
* submits the UserOp via EIP-7702 + PAFI sponsor-relayer. On confirmation,
|
|
1175
1082
|
* `Transfer(user → 0x0)` is emitted; `BurnIndexer` resolves the pending
|
|
1176
1083
|
* credit to a real off-chain credit.
|
|
1177
1084
|
*
|
|
@@ -1333,70 +1240,6 @@ declare class PTRedeemHandler {
|
|
|
1333
1240
|
private _handleAfterNonceLock;
|
|
1334
1241
|
}
|
|
1335
1242
|
|
|
1336
|
-
/**
|
|
1337
|
-
* v1.4 reverse flow — **Variant B**: auto top-up on voucher redemption.
|
|
1338
|
-
*
|
|
1339
|
-
* User tries to redeem a voucher for `requiredAmount` off-chain points
|
|
1340
|
-
* but their off-chain balance is short. If their on-chain PT balance is
|
|
1341
|
-
* enough to cover the shortfall, this handler auto-triggers a burn for
|
|
1342
|
-
* exactly the shortfall amount so the voucher can proceed.
|
|
1343
|
-
*
|
|
1344
|
-
* Required off-chain: 500
|
|
1345
|
-
* Available off-chain: 300
|
|
1346
|
-
* Shortfall: 200
|
|
1347
|
-
* On-chain PT: 250 ← enough, top-up fires
|
|
1348
|
-
* → burn 200 PT, credit 200 off-chain, voucher proceeds with 500
|
|
1349
|
-
*
|
|
1350
|
-
* Delegates the actual burn construction to {@link PTRedeemHandler}
|
|
1351
|
-
* — this handler is pure business logic (shortfall math + on-chain
|
|
1352
|
-
* balance check) on top.
|
|
1353
|
-
*
|
|
1354
|
-
* v1.4 note: user no longer pre-signs a `BurnConsent`. The issuer
|
|
1355
|
-
* backend signs a `BurnRequest` itself (see `PTRedeemHandler`), so
|
|
1356
|
-
* this handler only needs `userAddress + requiredAmount + aaNonce`.
|
|
1357
|
-
*/
|
|
1358
|
-
interface TopUpRedemptionHandlerConfig {
|
|
1359
|
-
ledger: IPointLedger;
|
|
1360
|
-
ptRedeemHandler: PTRedeemHandler;
|
|
1361
|
-
provider: PublicClient;
|
|
1362
|
-
/** PointToken contract address (chain-specific). */
|
|
1363
|
-
pointTokenAddress: Address;
|
|
1364
|
-
}
|
|
1365
|
-
interface TopUpRedemptionRequest {
|
|
1366
|
-
/** Address extracted from the verified JWT — must match `userAddress`. */
|
|
1367
|
-
authenticatedAddress: Address;
|
|
1368
|
-
userAddress: Address;
|
|
1369
|
-
/** Total points the voucher redemption requires off-chain. */
|
|
1370
|
-
requiredAmount: bigint;
|
|
1371
|
-
/** ERC-4337 account nonce for the user's EOA. */
|
|
1372
|
-
aaNonce: bigint;
|
|
1373
|
-
}
|
|
1374
|
-
type TopUpRedemptionResponse = {
|
|
1375
|
-
action: "NO_TOP_UP_NEEDED";
|
|
1376
|
-
offChainBalance: bigint;
|
|
1377
|
-
} | {
|
|
1378
|
-
action: "INSUFFICIENT_ONCHAIN";
|
|
1379
|
-
offChainBalance: bigint;
|
|
1380
|
-
onChainBalance: bigint;
|
|
1381
|
-
shortfall: bigint;
|
|
1382
|
-
} | {
|
|
1383
|
-
action: "TOP_UP_STARTED";
|
|
1384
|
-
shortfall: bigint;
|
|
1385
|
-
redeem: PTRedeemResponse;
|
|
1386
|
-
};
|
|
1387
|
-
declare class TopUpRedemptionError extends Error {
|
|
1388
|
-
code: "UNAUTHORIZED" | "INSUFFICIENT_ONCHAIN_BALANCE" | "LEDGER_NOT_SUPPORTED";
|
|
1389
|
-
constructor(code: "UNAUTHORIZED" | "INSUFFICIENT_ONCHAIN_BALANCE" | "LEDGER_NOT_SUPPORTED", message: string);
|
|
1390
|
-
}
|
|
1391
|
-
declare class TopUpRedemptionHandler {
|
|
1392
|
-
private readonly ledger;
|
|
1393
|
-
private readonly ptRedeemHandler;
|
|
1394
|
-
private readonly provider;
|
|
1395
|
-
private readonly pointTokenAddress;
|
|
1396
|
-
constructor(config: TopUpRedemptionHandlerConfig);
|
|
1397
|
-
handle(request: TopUpRedemptionRequest): Promise<TopUpRedemptionResponse>;
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
1243
|
interface RetryConfig {
|
|
1401
1244
|
maxAttempts?: number;
|
|
1402
1245
|
initialDelayMs?: number;
|
|
@@ -1656,6 +1499,29 @@ interface IPendingUserOpStore {
|
|
|
1656
1499
|
*/
|
|
1657
1500
|
declare function serializeEntryToJsonRpc(entry: PendingUserOpEntry, signature: Hex, variant?: "sponsored" | "fallback"): Record<string, string | null>;
|
|
1658
1501
|
|
|
1502
|
+
/**
|
|
1503
|
+
* In-memory `IPendingUserOpStore` for **single-instance dev / test
|
|
1504
|
+
* harnesses only**.
|
|
1505
|
+
*
|
|
1506
|
+
* Multi-instance deployments (k8s, PM2 cluster) MUST use a shared store
|
|
1507
|
+
* — typically Redis with a TTL key or Postgres with `expires_at`. If
|
|
1508
|
+
* `prepare` lands on instance A and `submit` on instance B, an
|
|
1509
|
+
* in-memory store on A loses the entry.
|
|
1510
|
+
*
|
|
1511
|
+
* Entries are evicted lazily on `get()` if expired. Periodic sweep is
|
|
1512
|
+
* not implemented — the in-memory map's footprint scales with
|
|
1513
|
+
* outstanding pending UserOps, which is bounded by the issuer's lock
|
|
1514
|
+
* duration (default 15 min).
|
|
1515
|
+
*/
|
|
1516
|
+
declare class MemoryPendingUserOpStore implements IPendingUserOpStore {
|
|
1517
|
+
private readonly entries;
|
|
1518
|
+
private readonly now;
|
|
1519
|
+
constructor(now?: () => number);
|
|
1520
|
+
save(lockId: string, entry: PendingUserOpEntry, ttlSeconds: number): Promise<void>;
|
|
1521
|
+
get(lockId: string): Promise<PendingUserOpEntry | null>;
|
|
1522
|
+
delete(lockId: string): Promise<void>;
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1659
1525
|
/**
|
|
1660
1526
|
* Re-shape `UserOpTypedData` so all `bigint` fields become hex strings —
|
|
1661
1527
|
* required for JSON transport over HTTP. Mirrors the inverse of what
|
|
@@ -1932,7 +1798,7 @@ declare function handleMobileSubmit(params: HandleMobileSubmitParams): Promise<{
|
|
|
1932
1798
|
userOpHash: Hex;
|
|
1933
1799
|
}>;
|
|
1934
1800
|
|
|
1935
|
-
type DecodedCall$
|
|
1801
|
+
type DecodedCall$1 = ReturnType<typeof decodeBatchExecuteCalls>[number];
|
|
1936
1802
|
|
|
1937
1803
|
/**
|
|
1938
1804
|
* Structural shape — accepts both the raw `IssuerStateValidator` from
|
|
@@ -2008,9 +1874,9 @@ interface PTClaimResponse {
|
|
|
2008
1874
|
signatureDeadline: bigint;
|
|
2009
1875
|
expiresInSeconds: number;
|
|
2010
1876
|
/** Decoded calls for the sponsored UserOp (convenience for FE-submit path). */
|
|
2011
|
-
calls: DecodedCall$
|
|
1877
|
+
calls: DecodedCall$1[];
|
|
2012
1878
|
/** Decoded calls for the fallback UserOp (when present). */
|
|
2013
|
-
callsFallback?: DecodedCall$
|
|
1879
|
+
callsFallback?: DecodedCall$1[];
|
|
2014
1880
|
}
|
|
2015
1881
|
declare class PTClaimHandler {
|
|
2016
1882
|
private readonly cfg;
|
|
@@ -2018,82 +1884,6 @@ declare class PTClaimHandler {
|
|
|
2018
1884
|
handle(request: PTClaimRequest): Promise<PTClaimResponse>;
|
|
2019
1885
|
}
|
|
2020
1886
|
|
|
2021
|
-
type DecodedCall$1 = ReturnType<typeof decodeBatchExecuteCalls>[number];
|
|
2022
|
-
|
|
2023
|
-
/**
|
|
2024
|
-
* PT → USDT swap handler.
|
|
2025
|
-
*
|
|
2026
|
-
* Quotes via V4 on-chain Quoter (`findBestQuote`), applies slippage,
|
|
2027
|
-
* computes the PT gas-reimbursement fee from `FeeManager`, and builds
|
|
2028
|
-
* two UserOps:
|
|
2029
|
-
*
|
|
2030
|
-
* - **sponsored** — swap (amountIn − fee) + transfer(fee, PAFI). User
|
|
2031
|
-
* holds exactly `amountIn` PT.
|
|
2032
|
-
* - **fallback** — swap full `amountIn`, no PT fee transfer. Built
|
|
2033
|
-
* only when `feeAmount > 0`. User pays gas in ETH directly.
|
|
2034
|
-
*
|
|
2035
|
-
* Re-quotes the sponsored path on `(amountIn − feeAmount)` because the
|
|
2036
|
-
* sponsored path actually swaps that much; the fallback uses the
|
|
2037
|
-
* original quote.
|
|
2038
|
-
*
|
|
2039
|
-
* Caller (controller) layers `sponsorAuth` on top of the returned
|
|
2040
|
-
* userOp. No off-chain ledger state is touched — swap is purely
|
|
2041
|
-
* on-chain.
|
|
2042
|
-
*/
|
|
2043
|
-
type SwapErrorCode = "QUOTE_UNAVAILABLE" | "FEE_EXCEEDS_AMOUNT" | "INVALID_AMOUNT";
|
|
2044
|
-
declare class SwapError extends PafiSdkError {
|
|
2045
|
-
readonly httpStatus: "unprocessable";
|
|
2046
|
-
readonly code: SwapErrorCode;
|
|
2047
|
-
constructor(code: SwapErrorCode, message: string);
|
|
2048
|
-
}
|
|
2049
|
-
interface SwapHandlerConfig {
|
|
2050
|
-
provider: PublicClient;
|
|
2051
|
-
poolsProvider: PoolsProvider;
|
|
2052
|
-
/** Optional — when wired, used to estimate the PT gas-reimbursement fee. */
|
|
2053
|
-
feeService?: FeeManager;
|
|
2054
|
-
/**
|
|
2055
|
-
* Default slippage applied to the V4 quote when the request omits
|
|
2056
|
-
* `slippageBps`. 50 bps = 0.5%.
|
|
2057
|
-
*/
|
|
2058
|
-
defaultSlippageBps?: number;
|
|
2059
|
-
/** Default deadline window in seconds applied when not passed in request. Default 300. */
|
|
2060
|
-
defaultSwapDeadlineSeconds?: number;
|
|
2061
|
-
now?: () => number;
|
|
2062
|
-
}
|
|
2063
|
-
interface SwapRequest {
|
|
2064
|
-
userAddress: Address;
|
|
2065
|
-
chainId: number;
|
|
2066
|
-
pointTokenAddress: Address;
|
|
2067
|
-
amountIn: bigint;
|
|
2068
|
-
/** ERC-4337 account nonce for the user's EOA. */
|
|
2069
|
-
aaNonce: bigint;
|
|
2070
|
-
/** Optional override; falls back to `defaultSlippageBps`. */
|
|
2071
|
-
slippageBps?: number;
|
|
2072
|
-
/** Optional override; falls back to `now() + defaultSwapDeadlineSeconds`. */
|
|
2073
|
-
deadline?: bigint;
|
|
2074
|
-
}
|
|
2075
|
-
interface SwapResponse {
|
|
2076
|
-
/** Sponsored UserOp — swap (amountIn − fee) + PT.transfer(fee). */
|
|
2077
|
-
userOp: PartialUserOperation;
|
|
2078
|
-
/** Fallback UserOp — swap full amountIn, no PT fee transfer. Present only when fee > 0. */
|
|
2079
|
-
fallback?: PartialUserOperation;
|
|
2080
|
-
feeAmount: bigint;
|
|
2081
|
-
/** Quote for the sponsored path (after fee deduction). */
|
|
2082
|
-
estimatedUsdtOut: bigint;
|
|
2083
|
-
minAmountOut: bigint;
|
|
2084
|
-
/** Quote for the fallback path (full amountIn). Present only when fee > 0. */
|
|
2085
|
-
estimatedUsdtOutFallback?: bigint;
|
|
2086
|
-
minAmountOutFallback?: bigint;
|
|
2087
|
-
deadline: bigint;
|
|
2088
|
-
calls: DecodedCall$1[];
|
|
2089
|
-
callsFallback?: DecodedCall$1[];
|
|
2090
|
-
}
|
|
2091
|
-
declare class SwapHandler {
|
|
2092
|
-
private readonly cfg;
|
|
2093
|
-
constructor(config: SwapHandlerConfig);
|
|
2094
|
-
handle(request: SwapRequest): Promise<SwapResponse>;
|
|
2095
|
-
}
|
|
2096
|
-
|
|
2097
1887
|
type DecodedCall = ReturnType<typeof decodeBatchExecuteCalls>[number];
|
|
2098
1888
|
|
|
2099
1889
|
/**
|
|
@@ -2207,47 +1997,6 @@ interface HandleDelegateSubmitResult {
|
|
|
2207
1997
|
}
|
|
2208
1998
|
declare function handleDelegateSubmit(params: HandleDelegateSubmitParams): Promise<HandleDelegateSubmitResult>;
|
|
2209
1999
|
|
|
2210
|
-
/**
|
|
2211
|
-
* Quote PT → USDT for the cashout preview screen.
|
|
2212
|
-
*
|
|
2213
|
-
* Three branches the FE needs distinct handling for:
|
|
2214
|
-
* - `pointAmount = 0` → all zeros, no RPC call.
|
|
2215
|
-
* - no pool / no path → `quoteError: 'QUOTE_UNAVAILABLE'`.
|
|
2216
|
-
* - amountOut < gas reimbursement → `quoteError: 'AMOUNT_TOO_SMALL_FOR_GAS'`.
|
|
2217
|
-
*
|
|
2218
|
-
* Returns derived `netUsdtOut`, `exchangeRate`, and a `suggestedDeadline`
|
|
2219
|
-
* so callers don't need to compute those locally.
|
|
2220
|
-
*
|
|
2221
|
-
* Replaces ~50 LoC of inline quote-handling in issuer controllers.
|
|
2222
|
-
*/
|
|
2223
|
-
interface QuotePointTokenToUsdtParams {
|
|
2224
|
-
provider: PublicClient;
|
|
2225
|
-
chainId: number;
|
|
2226
|
-
pointTokenAddress: Address;
|
|
2227
|
-
pointAmount: bigint;
|
|
2228
|
-
pools: PoolKey[];
|
|
2229
|
-
/** Operator gas-reimbursement quoted in USDT (subtracted from output). */
|
|
2230
|
-
gasFeeUsdt: bigint;
|
|
2231
|
-
/** Override deadline window; default 300 seconds. */
|
|
2232
|
-
deadlineSeconds?: number;
|
|
2233
|
-
now?: () => number;
|
|
2234
|
-
}
|
|
2235
|
-
interface QuotePointTokenToUsdtResult {
|
|
2236
|
-
/** Raw V4 quote on the full point amount, before gas deduction. */
|
|
2237
|
-
estimatedUsdtOut: bigint;
|
|
2238
|
-
/** `estimatedUsdtOut - gasFeeUsdt`, clamped to 0. */
|
|
2239
|
-
netUsdtOut: bigint;
|
|
2240
|
-
/** USDT per 1.0 PT (1e18 raw units), formatted to 8 decimal places. */
|
|
2241
|
-
exchangeRate: string;
|
|
2242
|
-
/** V4 Quoter's gas estimate for the swap — informational. */
|
|
2243
|
-
gasEstimate: bigint;
|
|
2244
|
-
/** Unix seconds — `now + deadlineSeconds`. */
|
|
2245
|
-
suggestedDeadline: number;
|
|
2246
|
-
/** When set, the FE should hide the CTA / show "increase amount". */
|
|
2247
|
-
quoteError?: "QUOTE_UNAVAILABLE" | "AMOUNT_TOO_SMALL_FOR_GAS";
|
|
2248
|
-
}
|
|
2249
|
-
declare function quotePointTokenToUsdt(params: QuotePointTokenToUsdtParams): Promise<QuotePointTokenToUsdtResult>;
|
|
2250
|
-
|
|
2251
2000
|
/**
|
|
2252
2001
|
* Normalized HTTP status the issuer controller should surface for a
|
|
2253
2002
|
* given SDK error. Mirrors `SdkErrorHttpStatus` on `PafiSdkError`.
|
|
@@ -2367,17 +2116,6 @@ interface IssuerServiceConfig {
|
|
|
2367
2116
|
* throws "not configured" at request time.
|
|
2368
2117
|
*/
|
|
2369
2118
|
poolsProvider?: PoolsProvider;
|
|
2370
|
-
/**
|
|
2371
|
-
* Enables `handleClaim`. The factory combines these with the shared
|
|
2372
|
-
* `policy` + `relayService` instances already wired by the factory.
|
|
2373
|
-
* Omit to disable the `/claim` endpoint.
|
|
2374
|
-
*/
|
|
2375
|
-
claim?: {
|
|
2376
|
-
issuerSignerWallet: WalletClient;
|
|
2377
|
-
/** Defaults to the PAFI-deployed BatchExecutor for the target chain. */
|
|
2378
|
-
batchExecutorAddress?: Address;
|
|
2379
|
-
lockDurationMs?: number;
|
|
2380
|
-
};
|
|
2381
2119
|
indexer?: {
|
|
2382
2120
|
fromBlock?: bigint;
|
|
2383
2121
|
cursorStore?: IIndexerCursorStore;
|
|
@@ -2460,8 +2198,6 @@ interface IssuerApiAdapterConfig {
|
|
|
2460
2198
|
ptClaimHandler?: PTClaimHandler | null;
|
|
2461
2199
|
/** Reverse-flow handler. Required for `redeem` / `redeemPrepare`. */
|
|
2462
2200
|
ptRedeemHandler?: PTRedeemHandler | null;
|
|
2463
|
-
/** PT → USDT swap handler. Required for `swap`. */
|
|
2464
|
-
swapHandler?: SwapHandler | null;
|
|
2465
2201
|
/** Orderly perp-deposit handler. Required for `perpDeposit`. */
|
|
2466
2202
|
perpHandler?: PerpDepositHandler | null;
|
|
2467
2203
|
/** Pending UserOp store — required for mobile prepare/submit. */
|
|
@@ -2491,16 +2227,6 @@ interface UserDto {
|
|
|
2491
2227
|
balance: string;
|
|
2492
2228
|
isMinter: boolean;
|
|
2493
2229
|
}
|
|
2494
|
-
interface QuoteDto {
|
|
2495
|
-
pointAmount: string;
|
|
2496
|
-
estimatedUsdtOut: string;
|
|
2497
|
-
gasFeeUsdt: string;
|
|
2498
|
-
netUsdtOut: string;
|
|
2499
|
-
exchangeRate: string;
|
|
2500
|
-
suggestedDeadline: string;
|
|
2501
|
-
gasEstimate: string;
|
|
2502
|
-
quoteError?: "QUOTE_UNAVAILABLE" | "AMOUNT_TOO_SMALL_FOR_GAS";
|
|
2503
|
-
}
|
|
2504
2230
|
interface DecodedCallDto {
|
|
2505
2231
|
to: string;
|
|
2506
2232
|
data: string;
|
|
@@ -2526,17 +2252,6 @@ interface RedeemDto {
|
|
|
2526
2252
|
signatureDeadline: string;
|
|
2527
2253
|
sponsorAuth?: BuiltSponsorAuth;
|
|
2528
2254
|
}
|
|
2529
|
-
interface SwapDto {
|
|
2530
|
-
calls: DecodedCallDto[];
|
|
2531
|
-
callsFallback?: DecodedCallDto[];
|
|
2532
|
-
feeAmount: string;
|
|
2533
|
-
estimatedUsdtOut: string;
|
|
2534
|
-
minAmountOut: string;
|
|
2535
|
-
estimatedUsdtOutFallback?: string;
|
|
2536
|
-
minAmountOutFallback?: string;
|
|
2537
|
-
deadline: string;
|
|
2538
|
-
sponsorAuth?: BuiltSponsorAuth;
|
|
2539
|
-
}
|
|
2540
2255
|
interface PerpDepositDto {
|
|
2541
2256
|
calls: DecodedCallDto[];
|
|
2542
2257
|
callsFallback?: DecodedCallDto[];
|
|
@@ -2586,7 +2301,6 @@ declare class IssuerApiAdapter {
|
|
|
2586
2301
|
gasFee(): Promise<GasFeeDto>;
|
|
2587
2302
|
pools(authenticatedAddress: Address, chainId: number, pointTokenAddress: Address): Promise<PoolsDto>;
|
|
2588
2303
|
user(authenticatedAddress: Address, chainId: number, userAddress: Address, pointTokenAddress: Address): Promise<UserDto>;
|
|
2589
|
-
quote(authenticatedAddress: Address, chainId: number, pointTokenAddress: Address, pointAmount: bigint): Promise<QuoteDto>;
|
|
2590
2304
|
claim(input: {
|
|
2591
2305
|
authenticatedAddress: Address;
|
|
2592
2306
|
chainId: number;
|
|
@@ -2601,14 +2315,6 @@ declare class IssuerApiAdapter {
|
|
|
2601
2315
|
amount: bigint;
|
|
2602
2316
|
aaNonce: bigint;
|
|
2603
2317
|
}): Promise<RedeemDto>;
|
|
2604
|
-
swap(input: {
|
|
2605
|
-
authenticatedAddress: Address;
|
|
2606
|
-
chainId: number;
|
|
2607
|
-
pointTokenAddress: Address;
|
|
2608
|
-
amountIn: bigint;
|
|
2609
|
-
aaNonce: bigint;
|
|
2610
|
-
slippageBps?: number;
|
|
2611
|
-
}): Promise<SwapDto>;
|
|
2612
2318
|
perpDeposit(input: {
|
|
2613
2319
|
authenticatedAddress: Address;
|
|
2614
2320
|
chainId: number;
|
|
@@ -3081,4 +2787,4 @@ declare class IssuerStateValidator {
|
|
|
3081
2787
|
/** SDK package version — bumped on every release */
|
|
3082
2788
|
declare const PAFI_ISSUER_SDK_VERSION = "0.4.0";
|
|
3083
2789
|
|
|
3084
|
-
export { type
|
|
2790
|
+
export { type ApiConfigResponse, type ApiGasFeeResponse, type ApiLoginRequest, type ApiLoginResponse, type ApiNonceResponse, type ApiPoolsRequest, type ApiPoolsResponse, type ApiUserRequest, type ApiUserResponse, type AuthContext, AuthError, type AuthErrorCode, AuthService, type AuthServiceConfig, BalanceAggregator, type BalanceAggregatorConfig, BundlerNotConfiguredError, BundlerRejectedError, type BurnEvent, BurnIndexer, type BurnIndexerConfig, type BurnStatusParams, type BurnStatusResponse, type ClaimDto, type CombinedBalance, type ConfigDto, type DecodedCallDto, DefaultPolicyEngine, type DefaultPolicyEngineOptions, type DelegatePrepareDto, type DelegateStatusDto, FeeManager, type FeeManagerConfig, type GasFeeDto, type HandleDelegateSubmitParams, type HandleDelegateSubmitResult, type HandleMobilePrepareParams, type HandleMobilePrepareResult, type HandleMobileSubmitParams, type IIndexerCursorStore, type IPendingUserOpStore, type IPointLedger, type IPolicyEngine, type ISessionStore, InMemoryCursorStore, IssuerApiAdapter, type IssuerApiAdapterConfig, IssuerApiHandlers, type IssuerApiHandlersConfig, type IssuerRegistryRecord, type IssuerService, type IssuerServiceConfig, IssuerStateError, IssuerStateValidator, LockNotFoundError, type LockedMintRequest, type LoginResult, MemoryPendingUserOpStore, MemorySessionStore, type MemorySessionStoreOptions, type MintEvent, type MintStatusParams, type MintStatusResponse, type MintingStatus, type MobilePrepareDto, type MobileSubmitDto, type NativePtQuoterConfig, NonceManager, PAFI_ISSUER_SDK_VERSION, PTClaimError, PTClaimHandler, type PTClaimHandlerConfig, type PTClaimRequest, type PTClaimResponse, PTRedeemError, PTRedeemHandler, type PTRedeemHandlerConfig, type PTRedeemRequest, type PTRedeemResponse, PafiBackendClient, type PafiBackendConfig, PafiBackendError, type PafiBackendErrorCode, PafiSdkError, type PendingCredit, type PendingUserOpEntry, PendingUserOpForbiddenError, PendingUserOpNotFoundError, type PerpDepositDto, PerpDepositError, PerpDepositHandler, type PerpDepositHandlerConfig, type PerpDepositRequest, type PerpDepositResponse, PointIndexer, type PointIndexerConfig, type PolicyDecision, type PolicyEvalRequest, type PoolsDto, type PoolsProvider, type PreValidateMintResult, type PrepareBurnParams, type PrepareMintParams, type PrepareMobileUserOpParams, type PrepareMobileUserOpResult, type PreparedUserOp, type RedeemDto, type RedeemPrepareDto, RelayError, type RelayErrorCode, RelayService, type RelayUserOpParams, type RelayUserOpRequest, type RelayUserOpResponse, type RequestPaymasterParams, type RetryConfig, type SdkErrorBody, type SdkErrorHttpStatus, type SdkErrorMapperFactories, type SdkErrorStatus, type SerializedUserOpTypedData, type Session, type SponsorshipRequest, type SponsorshipResponse, type SponsorshipTarget, type SponsorshipUserOp, type SubgraphNativeUsdtQuoterConfig, type SubgraphPoolsProviderConfig, type UserDto, authenticateRequest, createIssuerService, createNativePtQuoter, createSdkErrorMapper, createSubgraphNativeUsdtQuoter, createSubgraphPoolsProvider, handleClaimStatus, handleDelegateSubmit, handleMobilePrepare, handleMobileSubmit, handleRedeemStatus, mergePaymasterFields, prepareMobileUserOp, relayUserOp, requestPaymaster, serializeEntryToJsonRpc, serializeUserOpTypedData };
|