@pafi-dev/issuer 0.5.43 → 0.6.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 +219 -435
- package/dist/index.cjs +45 -304
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -153
- package/dist/index.d.ts +4 -153
- package/dist/index.js +21 -285
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1798,7 +1798,7 @@ declare function handleMobileSubmit(params: HandleMobileSubmitParams): Promise<{
|
|
|
1798
1798
|
userOpHash: Hex;
|
|
1799
1799
|
}>;
|
|
1800
1800
|
|
|
1801
|
-
type DecodedCall$
|
|
1801
|
+
type DecodedCall$1 = ReturnType<typeof decodeBatchExecuteCalls>[number];
|
|
1802
1802
|
|
|
1803
1803
|
/**
|
|
1804
1804
|
* Structural shape — accepts both the raw `IssuerStateValidator` from
|
|
@@ -1874,9 +1874,9 @@ interface PTClaimResponse {
|
|
|
1874
1874
|
signatureDeadline: bigint;
|
|
1875
1875
|
expiresInSeconds: number;
|
|
1876
1876
|
/** Decoded calls for the sponsored UserOp (convenience for FE-submit path). */
|
|
1877
|
-
calls: DecodedCall$
|
|
1877
|
+
calls: DecodedCall$1[];
|
|
1878
1878
|
/** Decoded calls for the fallback UserOp (when present). */
|
|
1879
|
-
callsFallback?: DecodedCall$
|
|
1879
|
+
callsFallback?: DecodedCall$1[];
|
|
1880
1880
|
}
|
|
1881
1881
|
declare class PTClaimHandler {
|
|
1882
1882
|
private readonly cfg;
|
|
@@ -1884,82 +1884,6 @@ declare class PTClaimHandler {
|
|
|
1884
1884
|
handle(request: PTClaimRequest): Promise<PTClaimResponse>;
|
|
1885
1885
|
}
|
|
1886
1886
|
|
|
1887
|
-
type DecodedCall$1 = ReturnType<typeof decodeBatchExecuteCalls>[number];
|
|
1888
|
-
|
|
1889
|
-
/**
|
|
1890
|
-
* PT → USDT swap handler.
|
|
1891
|
-
*
|
|
1892
|
-
* Quotes via V4 on-chain Quoter (`findBestQuote`), applies slippage,
|
|
1893
|
-
* computes the PT gas-reimbursement fee from `FeeManager`, and builds
|
|
1894
|
-
* two UserOps:
|
|
1895
|
-
*
|
|
1896
|
-
* - **sponsored** — swap (amountIn − fee) + transfer(fee, PAFI). User
|
|
1897
|
-
* holds exactly `amountIn` PT.
|
|
1898
|
-
* - **fallback** — swap full `amountIn`, no PT fee transfer. Built
|
|
1899
|
-
* only when `feeAmount > 0`. User pays gas in ETH directly.
|
|
1900
|
-
*
|
|
1901
|
-
* Re-quotes the sponsored path on `(amountIn − feeAmount)` because the
|
|
1902
|
-
* sponsored path actually swaps that much; the fallback uses the
|
|
1903
|
-
* original quote.
|
|
1904
|
-
*
|
|
1905
|
-
* Caller (controller) layers `sponsorAuth` on top of the returned
|
|
1906
|
-
* userOp. No off-chain ledger state is touched — swap is purely
|
|
1907
|
-
* on-chain.
|
|
1908
|
-
*/
|
|
1909
|
-
type SwapErrorCode = "QUOTE_UNAVAILABLE" | "FEE_EXCEEDS_AMOUNT" | "INVALID_AMOUNT";
|
|
1910
|
-
declare class SwapError extends PafiSdkError {
|
|
1911
|
-
readonly httpStatus: "unprocessable";
|
|
1912
|
-
readonly code: SwapErrorCode;
|
|
1913
|
-
constructor(code: SwapErrorCode, message: string);
|
|
1914
|
-
}
|
|
1915
|
-
interface SwapHandlerConfig {
|
|
1916
|
-
provider: PublicClient;
|
|
1917
|
-
poolsProvider: PoolsProvider;
|
|
1918
|
-
/** Optional — when wired, used to estimate the PT gas-reimbursement fee. */
|
|
1919
|
-
feeService?: FeeManager;
|
|
1920
|
-
/**
|
|
1921
|
-
* Default slippage applied to the V4 quote when the request omits
|
|
1922
|
-
* `slippageBps`. 50 bps = 0.5%.
|
|
1923
|
-
*/
|
|
1924
|
-
defaultSlippageBps?: number;
|
|
1925
|
-
/** Default deadline window in seconds applied when not passed in request. Default 300. */
|
|
1926
|
-
defaultSwapDeadlineSeconds?: number;
|
|
1927
|
-
now?: () => number;
|
|
1928
|
-
}
|
|
1929
|
-
interface SwapRequest {
|
|
1930
|
-
userAddress: Address;
|
|
1931
|
-
chainId: number;
|
|
1932
|
-
pointTokenAddress: Address;
|
|
1933
|
-
amountIn: bigint;
|
|
1934
|
-
/** ERC-4337 account nonce for the user's EOA. */
|
|
1935
|
-
aaNonce: bigint;
|
|
1936
|
-
/** Optional override; falls back to `defaultSlippageBps`. */
|
|
1937
|
-
slippageBps?: number;
|
|
1938
|
-
/** Optional override; falls back to `now() + defaultSwapDeadlineSeconds`. */
|
|
1939
|
-
deadline?: bigint;
|
|
1940
|
-
}
|
|
1941
|
-
interface SwapResponse {
|
|
1942
|
-
/** Sponsored UserOp — swap (amountIn − fee) + PT.transfer(fee). */
|
|
1943
|
-
userOp: PartialUserOperation;
|
|
1944
|
-
/** Fallback UserOp — swap full amountIn, no PT fee transfer. Present only when fee > 0. */
|
|
1945
|
-
fallback?: PartialUserOperation;
|
|
1946
|
-
feeAmount: bigint;
|
|
1947
|
-
/** Quote for the sponsored path (after fee deduction). */
|
|
1948
|
-
estimatedUsdtOut: bigint;
|
|
1949
|
-
minAmountOut: bigint;
|
|
1950
|
-
/** Quote for the fallback path (full amountIn). Present only when fee > 0. */
|
|
1951
|
-
estimatedUsdtOutFallback?: bigint;
|
|
1952
|
-
minAmountOutFallback?: bigint;
|
|
1953
|
-
deadline: bigint;
|
|
1954
|
-
calls: DecodedCall$1[];
|
|
1955
|
-
callsFallback?: DecodedCall$1[];
|
|
1956
|
-
}
|
|
1957
|
-
declare class SwapHandler {
|
|
1958
|
-
private readonly cfg;
|
|
1959
|
-
constructor(config: SwapHandlerConfig);
|
|
1960
|
-
handle(request: SwapRequest): Promise<SwapResponse>;
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
1887
|
type DecodedCall = ReturnType<typeof decodeBatchExecuteCalls>[number];
|
|
1964
1888
|
|
|
1965
1889
|
/**
|
|
@@ -2073,47 +1997,6 @@ interface HandleDelegateSubmitResult {
|
|
|
2073
1997
|
}
|
|
2074
1998
|
declare function handleDelegateSubmit(params: HandleDelegateSubmitParams): Promise<HandleDelegateSubmitResult>;
|
|
2075
1999
|
|
|
2076
|
-
/**
|
|
2077
|
-
* Quote PT → USDT for the cashout preview screen.
|
|
2078
|
-
*
|
|
2079
|
-
* Three branches the FE needs distinct handling for:
|
|
2080
|
-
* - `pointAmount = 0` → all zeros, no RPC call.
|
|
2081
|
-
* - no pool / no path → `quoteError: 'QUOTE_UNAVAILABLE'`.
|
|
2082
|
-
* - amountOut < gas reimbursement → `quoteError: 'AMOUNT_TOO_SMALL_FOR_GAS'`.
|
|
2083
|
-
*
|
|
2084
|
-
* Returns derived `netUsdtOut`, `exchangeRate`, and a `suggestedDeadline`
|
|
2085
|
-
* so callers don't need to compute those locally.
|
|
2086
|
-
*
|
|
2087
|
-
* Replaces ~50 LoC of inline quote-handling in issuer controllers.
|
|
2088
|
-
*/
|
|
2089
|
-
interface QuotePointTokenToUsdtParams {
|
|
2090
|
-
provider: PublicClient;
|
|
2091
|
-
chainId: number;
|
|
2092
|
-
pointTokenAddress: Address;
|
|
2093
|
-
pointAmount: bigint;
|
|
2094
|
-
pools: PoolKey[];
|
|
2095
|
-
/** Operator gas-reimbursement quoted in USDT (subtracted from output). */
|
|
2096
|
-
gasFeeUsdt: bigint;
|
|
2097
|
-
/** Override deadline window; default 300 seconds. */
|
|
2098
|
-
deadlineSeconds?: number;
|
|
2099
|
-
now?: () => number;
|
|
2100
|
-
}
|
|
2101
|
-
interface QuotePointTokenToUsdtResult {
|
|
2102
|
-
/** Raw V4 quote on the full point amount, before gas deduction. */
|
|
2103
|
-
estimatedUsdtOut: bigint;
|
|
2104
|
-
/** `estimatedUsdtOut - gasFeeUsdt`, clamped to 0. */
|
|
2105
|
-
netUsdtOut: bigint;
|
|
2106
|
-
/** USDT per 1.0 PT (1e18 raw units), formatted to 8 decimal places. */
|
|
2107
|
-
exchangeRate: string;
|
|
2108
|
-
/** V4 Quoter's gas estimate for the swap — informational. */
|
|
2109
|
-
gasEstimate: bigint;
|
|
2110
|
-
/** Unix seconds — `now + deadlineSeconds`. */
|
|
2111
|
-
suggestedDeadline: number;
|
|
2112
|
-
/** When set, the FE should hide the CTA / show "increase amount". */
|
|
2113
|
-
quoteError?: "QUOTE_UNAVAILABLE" | "AMOUNT_TOO_SMALL_FOR_GAS";
|
|
2114
|
-
}
|
|
2115
|
-
declare function quotePointTokenToUsdt(params: QuotePointTokenToUsdtParams): Promise<QuotePointTokenToUsdtResult>;
|
|
2116
|
-
|
|
2117
2000
|
/**
|
|
2118
2001
|
* Normalized HTTP status the issuer controller should surface for a
|
|
2119
2002
|
* given SDK error. Mirrors `SdkErrorHttpStatus` on `PafiSdkError`.
|
|
@@ -2315,8 +2198,6 @@ interface IssuerApiAdapterConfig {
|
|
|
2315
2198
|
ptClaimHandler?: PTClaimHandler | null;
|
|
2316
2199
|
/** Reverse-flow handler. Required for `redeem` / `redeemPrepare`. */
|
|
2317
2200
|
ptRedeemHandler?: PTRedeemHandler | null;
|
|
2318
|
-
/** PT → USDT swap handler. Required for `swap`. */
|
|
2319
|
-
swapHandler?: SwapHandler | null;
|
|
2320
2201
|
/** Orderly perp-deposit handler. Required for `perpDeposit`. */
|
|
2321
2202
|
perpHandler?: PerpDepositHandler | null;
|
|
2322
2203
|
/** Pending UserOp store — required for mobile prepare/submit. */
|
|
@@ -2346,16 +2227,6 @@ interface UserDto {
|
|
|
2346
2227
|
balance: string;
|
|
2347
2228
|
isMinter: boolean;
|
|
2348
2229
|
}
|
|
2349
|
-
interface QuoteDto {
|
|
2350
|
-
pointAmount: string;
|
|
2351
|
-
estimatedUsdtOut: string;
|
|
2352
|
-
gasFeeUsdt: string;
|
|
2353
|
-
netUsdtOut: string;
|
|
2354
|
-
exchangeRate: string;
|
|
2355
|
-
suggestedDeadline: string;
|
|
2356
|
-
gasEstimate: string;
|
|
2357
|
-
quoteError?: "QUOTE_UNAVAILABLE" | "AMOUNT_TOO_SMALL_FOR_GAS";
|
|
2358
|
-
}
|
|
2359
2230
|
interface DecodedCallDto {
|
|
2360
2231
|
to: string;
|
|
2361
2232
|
data: string;
|
|
@@ -2381,17 +2252,6 @@ interface RedeemDto {
|
|
|
2381
2252
|
signatureDeadline: string;
|
|
2382
2253
|
sponsorAuth?: BuiltSponsorAuth;
|
|
2383
2254
|
}
|
|
2384
|
-
interface SwapDto {
|
|
2385
|
-
calls: DecodedCallDto[];
|
|
2386
|
-
callsFallback?: DecodedCallDto[];
|
|
2387
|
-
feeAmount: string;
|
|
2388
|
-
estimatedUsdtOut: string;
|
|
2389
|
-
minAmountOut: string;
|
|
2390
|
-
estimatedUsdtOutFallback?: string;
|
|
2391
|
-
minAmountOutFallback?: string;
|
|
2392
|
-
deadline: string;
|
|
2393
|
-
sponsorAuth?: BuiltSponsorAuth;
|
|
2394
|
-
}
|
|
2395
2255
|
interface PerpDepositDto {
|
|
2396
2256
|
calls: DecodedCallDto[];
|
|
2397
2257
|
callsFallback?: DecodedCallDto[];
|
|
@@ -2441,7 +2301,6 @@ declare class IssuerApiAdapter {
|
|
|
2441
2301
|
gasFee(): Promise<GasFeeDto>;
|
|
2442
2302
|
pools(authenticatedAddress: Address, chainId: number, pointTokenAddress: Address): Promise<PoolsDto>;
|
|
2443
2303
|
user(authenticatedAddress: Address, chainId: number, userAddress: Address, pointTokenAddress: Address): Promise<UserDto>;
|
|
2444
|
-
quote(authenticatedAddress: Address, chainId: number, pointTokenAddress: Address, pointAmount: bigint): Promise<QuoteDto>;
|
|
2445
2304
|
claim(input: {
|
|
2446
2305
|
authenticatedAddress: Address;
|
|
2447
2306
|
chainId: number;
|
|
@@ -2456,14 +2315,6 @@ declare class IssuerApiAdapter {
|
|
|
2456
2315
|
amount: bigint;
|
|
2457
2316
|
aaNonce: bigint;
|
|
2458
2317
|
}): Promise<RedeemDto>;
|
|
2459
|
-
swap(input: {
|
|
2460
|
-
authenticatedAddress: Address;
|
|
2461
|
-
chainId: number;
|
|
2462
|
-
pointTokenAddress: Address;
|
|
2463
|
-
amountIn: bigint;
|
|
2464
|
-
aaNonce: bigint;
|
|
2465
|
-
slippageBps?: number;
|
|
2466
|
-
}): Promise<SwapDto>;
|
|
2467
2318
|
perpDeposit(input: {
|
|
2468
2319
|
authenticatedAddress: Address;
|
|
2469
2320
|
chainId: number;
|
|
@@ -2936,4 +2787,4 @@ declare class IssuerStateValidator {
|
|
|
2936
2787
|
/** SDK package version — bumped on every release */
|
|
2937
2788
|
declare const PAFI_ISSUER_SDK_VERSION = "0.4.0";
|
|
2938
2789
|
|
|
2939
|
-
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
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1798,7 +1798,7 @@ declare function handleMobileSubmit(params: HandleMobileSubmitParams): Promise<{
|
|
|
1798
1798
|
userOpHash: Hex;
|
|
1799
1799
|
}>;
|
|
1800
1800
|
|
|
1801
|
-
type DecodedCall$
|
|
1801
|
+
type DecodedCall$1 = ReturnType<typeof decodeBatchExecuteCalls>[number];
|
|
1802
1802
|
|
|
1803
1803
|
/**
|
|
1804
1804
|
* Structural shape — accepts both the raw `IssuerStateValidator` from
|
|
@@ -1874,9 +1874,9 @@ interface PTClaimResponse {
|
|
|
1874
1874
|
signatureDeadline: bigint;
|
|
1875
1875
|
expiresInSeconds: number;
|
|
1876
1876
|
/** Decoded calls for the sponsored UserOp (convenience for FE-submit path). */
|
|
1877
|
-
calls: DecodedCall$
|
|
1877
|
+
calls: DecodedCall$1[];
|
|
1878
1878
|
/** Decoded calls for the fallback UserOp (when present). */
|
|
1879
|
-
callsFallback?: DecodedCall$
|
|
1879
|
+
callsFallback?: DecodedCall$1[];
|
|
1880
1880
|
}
|
|
1881
1881
|
declare class PTClaimHandler {
|
|
1882
1882
|
private readonly cfg;
|
|
@@ -1884,82 +1884,6 @@ declare class PTClaimHandler {
|
|
|
1884
1884
|
handle(request: PTClaimRequest): Promise<PTClaimResponse>;
|
|
1885
1885
|
}
|
|
1886
1886
|
|
|
1887
|
-
type DecodedCall$1 = ReturnType<typeof decodeBatchExecuteCalls>[number];
|
|
1888
|
-
|
|
1889
|
-
/**
|
|
1890
|
-
* PT → USDT swap handler.
|
|
1891
|
-
*
|
|
1892
|
-
* Quotes via V4 on-chain Quoter (`findBestQuote`), applies slippage,
|
|
1893
|
-
* computes the PT gas-reimbursement fee from `FeeManager`, and builds
|
|
1894
|
-
* two UserOps:
|
|
1895
|
-
*
|
|
1896
|
-
* - **sponsored** — swap (amountIn − fee) + transfer(fee, PAFI). User
|
|
1897
|
-
* holds exactly `amountIn` PT.
|
|
1898
|
-
* - **fallback** — swap full `amountIn`, no PT fee transfer. Built
|
|
1899
|
-
* only when `feeAmount > 0`. User pays gas in ETH directly.
|
|
1900
|
-
*
|
|
1901
|
-
* Re-quotes the sponsored path on `(amountIn − feeAmount)` because the
|
|
1902
|
-
* sponsored path actually swaps that much; the fallback uses the
|
|
1903
|
-
* original quote.
|
|
1904
|
-
*
|
|
1905
|
-
* Caller (controller) layers `sponsorAuth` on top of the returned
|
|
1906
|
-
* userOp. No off-chain ledger state is touched — swap is purely
|
|
1907
|
-
* on-chain.
|
|
1908
|
-
*/
|
|
1909
|
-
type SwapErrorCode = "QUOTE_UNAVAILABLE" | "FEE_EXCEEDS_AMOUNT" | "INVALID_AMOUNT";
|
|
1910
|
-
declare class SwapError extends PafiSdkError {
|
|
1911
|
-
readonly httpStatus: "unprocessable";
|
|
1912
|
-
readonly code: SwapErrorCode;
|
|
1913
|
-
constructor(code: SwapErrorCode, message: string);
|
|
1914
|
-
}
|
|
1915
|
-
interface SwapHandlerConfig {
|
|
1916
|
-
provider: PublicClient;
|
|
1917
|
-
poolsProvider: PoolsProvider;
|
|
1918
|
-
/** Optional — when wired, used to estimate the PT gas-reimbursement fee. */
|
|
1919
|
-
feeService?: FeeManager;
|
|
1920
|
-
/**
|
|
1921
|
-
* Default slippage applied to the V4 quote when the request omits
|
|
1922
|
-
* `slippageBps`. 50 bps = 0.5%.
|
|
1923
|
-
*/
|
|
1924
|
-
defaultSlippageBps?: number;
|
|
1925
|
-
/** Default deadline window in seconds applied when not passed in request. Default 300. */
|
|
1926
|
-
defaultSwapDeadlineSeconds?: number;
|
|
1927
|
-
now?: () => number;
|
|
1928
|
-
}
|
|
1929
|
-
interface SwapRequest {
|
|
1930
|
-
userAddress: Address;
|
|
1931
|
-
chainId: number;
|
|
1932
|
-
pointTokenAddress: Address;
|
|
1933
|
-
amountIn: bigint;
|
|
1934
|
-
/** ERC-4337 account nonce for the user's EOA. */
|
|
1935
|
-
aaNonce: bigint;
|
|
1936
|
-
/** Optional override; falls back to `defaultSlippageBps`. */
|
|
1937
|
-
slippageBps?: number;
|
|
1938
|
-
/** Optional override; falls back to `now() + defaultSwapDeadlineSeconds`. */
|
|
1939
|
-
deadline?: bigint;
|
|
1940
|
-
}
|
|
1941
|
-
interface SwapResponse {
|
|
1942
|
-
/** Sponsored UserOp — swap (amountIn − fee) + PT.transfer(fee). */
|
|
1943
|
-
userOp: PartialUserOperation;
|
|
1944
|
-
/** Fallback UserOp — swap full amountIn, no PT fee transfer. Present only when fee > 0. */
|
|
1945
|
-
fallback?: PartialUserOperation;
|
|
1946
|
-
feeAmount: bigint;
|
|
1947
|
-
/** Quote for the sponsored path (after fee deduction). */
|
|
1948
|
-
estimatedUsdtOut: bigint;
|
|
1949
|
-
minAmountOut: bigint;
|
|
1950
|
-
/** Quote for the fallback path (full amountIn). Present only when fee > 0. */
|
|
1951
|
-
estimatedUsdtOutFallback?: bigint;
|
|
1952
|
-
minAmountOutFallback?: bigint;
|
|
1953
|
-
deadline: bigint;
|
|
1954
|
-
calls: DecodedCall$1[];
|
|
1955
|
-
callsFallback?: DecodedCall$1[];
|
|
1956
|
-
}
|
|
1957
|
-
declare class SwapHandler {
|
|
1958
|
-
private readonly cfg;
|
|
1959
|
-
constructor(config: SwapHandlerConfig);
|
|
1960
|
-
handle(request: SwapRequest): Promise<SwapResponse>;
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
1887
|
type DecodedCall = ReturnType<typeof decodeBatchExecuteCalls>[number];
|
|
1964
1888
|
|
|
1965
1889
|
/**
|
|
@@ -2073,47 +1997,6 @@ interface HandleDelegateSubmitResult {
|
|
|
2073
1997
|
}
|
|
2074
1998
|
declare function handleDelegateSubmit(params: HandleDelegateSubmitParams): Promise<HandleDelegateSubmitResult>;
|
|
2075
1999
|
|
|
2076
|
-
/**
|
|
2077
|
-
* Quote PT → USDT for the cashout preview screen.
|
|
2078
|
-
*
|
|
2079
|
-
* Three branches the FE needs distinct handling for:
|
|
2080
|
-
* - `pointAmount = 0` → all zeros, no RPC call.
|
|
2081
|
-
* - no pool / no path → `quoteError: 'QUOTE_UNAVAILABLE'`.
|
|
2082
|
-
* - amountOut < gas reimbursement → `quoteError: 'AMOUNT_TOO_SMALL_FOR_GAS'`.
|
|
2083
|
-
*
|
|
2084
|
-
* Returns derived `netUsdtOut`, `exchangeRate`, and a `suggestedDeadline`
|
|
2085
|
-
* so callers don't need to compute those locally.
|
|
2086
|
-
*
|
|
2087
|
-
* Replaces ~50 LoC of inline quote-handling in issuer controllers.
|
|
2088
|
-
*/
|
|
2089
|
-
interface QuotePointTokenToUsdtParams {
|
|
2090
|
-
provider: PublicClient;
|
|
2091
|
-
chainId: number;
|
|
2092
|
-
pointTokenAddress: Address;
|
|
2093
|
-
pointAmount: bigint;
|
|
2094
|
-
pools: PoolKey[];
|
|
2095
|
-
/** Operator gas-reimbursement quoted in USDT (subtracted from output). */
|
|
2096
|
-
gasFeeUsdt: bigint;
|
|
2097
|
-
/** Override deadline window; default 300 seconds. */
|
|
2098
|
-
deadlineSeconds?: number;
|
|
2099
|
-
now?: () => number;
|
|
2100
|
-
}
|
|
2101
|
-
interface QuotePointTokenToUsdtResult {
|
|
2102
|
-
/** Raw V4 quote on the full point amount, before gas deduction. */
|
|
2103
|
-
estimatedUsdtOut: bigint;
|
|
2104
|
-
/** `estimatedUsdtOut - gasFeeUsdt`, clamped to 0. */
|
|
2105
|
-
netUsdtOut: bigint;
|
|
2106
|
-
/** USDT per 1.0 PT (1e18 raw units), formatted to 8 decimal places. */
|
|
2107
|
-
exchangeRate: string;
|
|
2108
|
-
/** V4 Quoter's gas estimate for the swap — informational. */
|
|
2109
|
-
gasEstimate: bigint;
|
|
2110
|
-
/** Unix seconds — `now + deadlineSeconds`. */
|
|
2111
|
-
suggestedDeadline: number;
|
|
2112
|
-
/** When set, the FE should hide the CTA / show "increase amount". */
|
|
2113
|
-
quoteError?: "QUOTE_UNAVAILABLE" | "AMOUNT_TOO_SMALL_FOR_GAS";
|
|
2114
|
-
}
|
|
2115
|
-
declare function quotePointTokenToUsdt(params: QuotePointTokenToUsdtParams): Promise<QuotePointTokenToUsdtResult>;
|
|
2116
|
-
|
|
2117
2000
|
/**
|
|
2118
2001
|
* Normalized HTTP status the issuer controller should surface for a
|
|
2119
2002
|
* given SDK error. Mirrors `SdkErrorHttpStatus` on `PafiSdkError`.
|
|
@@ -2315,8 +2198,6 @@ interface IssuerApiAdapterConfig {
|
|
|
2315
2198
|
ptClaimHandler?: PTClaimHandler | null;
|
|
2316
2199
|
/** Reverse-flow handler. Required for `redeem` / `redeemPrepare`. */
|
|
2317
2200
|
ptRedeemHandler?: PTRedeemHandler | null;
|
|
2318
|
-
/** PT → USDT swap handler. Required for `swap`. */
|
|
2319
|
-
swapHandler?: SwapHandler | null;
|
|
2320
2201
|
/** Orderly perp-deposit handler. Required for `perpDeposit`. */
|
|
2321
2202
|
perpHandler?: PerpDepositHandler | null;
|
|
2322
2203
|
/** Pending UserOp store — required for mobile prepare/submit. */
|
|
@@ -2346,16 +2227,6 @@ interface UserDto {
|
|
|
2346
2227
|
balance: string;
|
|
2347
2228
|
isMinter: boolean;
|
|
2348
2229
|
}
|
|
2349
|
-
interface QuoteDto {
|
|
2350
|
-
pointAmount: string;
|
|
2351
|
-
estimatedUsdtOut: string;
|
|
2352
|
-
gasFeeUsdt: string;
|
|
2353
|
-
netUsdtOut: string;
|
|
2354
|
-
exchangeRate: string;
|
|
2355
|
-
suggestedDeadline: string;
|
|
2356
|
-
gasEstimate: string;
|
|
2357
|
-
quoteError?: "QUOTE_UNAVAILABLE" | "AMOUNT_TOO_SMALL_FOR_GAS";
|
|
2358
|
-
}
|
|
2359
2230
|
interface DecodedCallDto {
|
|
2360
2231
|
to: string;
|
|
2361
2232
|
data: string;
|
|
@@ -2381,17 +2252,6 @@ interface RedeemDto {
|
|
|
2381
2252
|
signatureDeadline: string;
|
|
2382
2253
|
sponsorAuth?: BuiltSponsorAuth;
|
|
2383
2254
|
}
|
|
2384
|
-
interface SwapDto {
|
|
2385
|
-
calls: DecodedCallDto[];
|
|
2386
|
-
callsFallback?: DecodedCallDto[];
|
|
2387
|
-
feeAmount: string;
|
|
2388
|
-
estimatedUsdtOut: string;
|
|
2389
|
-
minAmountOut: string;
|
|
2390
|
-
estimatedUsdtOutFallback?: string;
|
|
2391
|
-
minAmountOutFallback?: string;
|
|
2392
|
-
deadline: string;
|
|
2393
|
-
sponsorAuth?: BuiltSponsorAuth;
|
|
2394
|
-
}
|
|
2395
2255
|
interface PerpDepositDto {
|
|
2396
2256
|
calls: DecodedCallDto[];
|
|
2397
2257
|
callsFallback?: DecodedCallDto[];
|
|
@@ -2441,7 +2301,6 @@ declare class IssuerApiAdapter {
|
|
|
2441
2301
|
gasFee(): Promise<GasFeeDto>;
|
|
2442
2302
|
pools(authenticatedAddress: Address, chainId: number, pointTokenAddress: Address): Promise<PoolsDto>;
|
|
2443
2303
|
user(authenticatedAddress: Address, chainId: number, userAddress: Address, pointTokenAddress: Address): Promise<UserDto>;
|
|
2444
|
-
quote(authenticatedAddress: Address, chainId: number, pointTokenAddress: Address, pointAmount: bigint): Promise<QuoteDto>;
|
|
2445
2304
|
claim(input: {
|
|
2446
2305
|
authenticatedAddress: Address;
|
|
2447
2306
|
chainId: number;
|
|
@@ -2456,14 +2315,6 @@ declare class IssuerApiAdapter {
|
|
|
2456
2315
|
amount: bigint;
|
|
2457
2316
|
aaNonce: bigint;
|
|
2458
2317
|
}): Promise<RedeemDto>;
|
|
2459
|
-
swap(input: {
|
|
2460
|
-
authenticatedAddress: Address;
|
|
2461
|
-
chainId: number;
|
|
2462
|
-
pointTokenAddress: Address;
|
|
2463
|
-
amountIn: bigint;
|
|
2464
|
-
aaNonce: bigint;
|
|
2465
|
-
slippageBps?: number;
|
|
2466
|
-
}): Promise<SwapDto>;
|
|
2467
2318
|
perpDeposit(input: {
|
|
2468
2319
|
authenticatedAddress: Address;
|
|
2469
2320
|
chainId: number;
|
|
@@ -2936,4 +2787,4 @@ declare class IssuerStateValidator {
|
|
|
2936
2787
|
/** SDK package version — bumped on every release */
|
|
2937
2788
|
declare const PAFI_ISSUER_SDK_VERSION = "0.4.0";
|
|
2938
2789
|
|
|
2939
|
-
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
|
|
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 };
|