@pafi-dev/core 0.20.1 → 0.23.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.d.cts CHANGED
@@ -1499,6 +1499,87 @@ interface DelegateDirectResult {
1499
1499
  */
1500
1500
  declare function delegateDirect(params: DelegateDirectParams): Promise<DelegateDirectResult>;
1501
1501
 
1502
+ interface AttachDelegationIfNeededParams {
1503
+ /**
1504
+ * Public client connected to the chain on which the delegation lives.
1505
+ * The helper uses it to (1) read on-chain code via `eth_getCode` and
1506
+ * (2) read the EOA's tx nonce — both reads must hit the SAME chain
1507
+ * that `chainId` declares, otherwise Pimlico's bundler will reject the
1508
+ * authorization with a chain-mismatch error.
1509
+ */
1510
+ rpc: PublicClient;
1511
+ /**
1512
+ * The user's EOA — the wallet that will become a temporary smart account
1513
+ * via EIP-7702 SetCode. MUST match the `sender` of the UserOp the caller
1514
+ * is about to submit; otherwise the bundler's recovered-signer check
1515
+ * fails ("recovered signer does not match userOperation sender").
1516
+ */
1517
+ account: Address;
1518
+ /**
1519
+ * The implementation address the EOA should delegate to — typically the
1520
+ * Pimlico Simple7702Account / BatchExecutor on the target chain (Base
1521
+ * mainnet: `0xe6Cae83BdE06E4c305530e199D7217f42808555B`).
1522
+ *
1523
+ * The helper compares the on-chain code at `account` against this address.
1524
+ * Mismatch → sign a new authorization to switch the delegate. Match →
1525
+ * return `undefined` (caller passes nothing — extra auth would be wasted
1526
+ * gas + the bundler may reject redundant authorizations).
1527
+ */
1528
+ expectedDelegate: Address;
1529
+ /**
1530
+ * Chain id baked into the EIP-7702 authorization tuple. Must equal the
1531
+ * chain `rpc` connects to.
1532
+ */
1533
+ chainId: number;
1534
+ /**
1535
+ * Privy-shaped authorization signer. Pass `useSign7702Authorization().signAuthorization`
1536
+ * directly on web, or the Expo SDK's equivalent on mobile.
1537
+ *
1538
+ * The helper feeds it `(contractAddress, chainId, nonce)` — the signer
1539
+ * MUST sign with the same private key that controls `account`, otherwise
1540
+ * the recovered signer mismatch above triggers.
1541
+ */
1542
+ signAuthorization: SignAuthorizationFn;
1543
+ }
1544
+ /**
1545
+ * Sign an EIP-7702 authorization for `account` ONLY when the EOA does not
1546
+ * already delegate to `expectedDelegate`. Returns the authorization in the
1547
+ * shape that permissionless / viem expect on
1548
+ * `smartClient.sendTransaction({ authorization, ... })`. Pimlico bundles
1549
+ * the SetCode + UserOp execution into a SINGLE bundler tx — "atomic
1550
+ * activation" — so the user never sees a separate "delegate" step on their
1551
+ * first action.
1552
+ *
1553
+ * Returns `undefined` when the EOA already points at `expectedDelegate`.
1554
+ * Caller spreads the return value into the tx params:
1555
+ *
1556
+ * ```ts
1557
+ * const authPart = await attachDelegationIfNeeded({ ... });
1558
+ * await smartClient.sendTransaction({
1559
+ * to: pointToken,
1560
+ * data: encodeMintCalldata(amount),
1561
+ * ...(authPart ?? {}), // attaches { authorization: ... } only when needed
1562
+ * });
1563
+ * ```
1564
+ *
1565
+ * Cost: 1 `eth_getCode` read every time + 1 `eth_getTransactionCount` +
1566
+ * 1 signature (only the first time per EOA). Subsequent calls collapse to
1567
+ * a single RPC read and return `undefined` — cheap to call before every
1568
+ * UserOp.
1569
+ *
1570
+ * Implementation notes:
1571
+ * - Comparison is case-insensitive (`isDelegatedTo` lowercases both
1572
+ * sides) so passing checksum-cased addresses is safe.
1573
+ * - Nonce is fetched freshly per call to avoid replaying an old nonce
1574
+ * when the FE held the helper params across multiple actions.
1575
+ * - The signed tuple is passed through `buildEip7702Authorization` to
1576
+ * normalise `r` / `s` / `yParity` into the wire shape Pimlico accepts
1577
+ * (handles Privy's bigint `v` and string-hex `yParity` variants).
1578
+ */
1579
+ declare function attachDelegationIfNeeded(params: AttachDelegationIfNeededParams): Promise<{
1580
+ authorization: Eip7702AuthorizationJsonRpc;
1581
+ } | undefined>;
1582
+
1502
1583
  /**
1503
1584
  * Parameters for `createPafiProxyTransport`.
1504
1585
  */
@@ -2650,7 +2731,21 @@ declare function openPafiWebModal(url: string, options?: ModalOpenOptions): Prom
2650
2731
  * MintFeeWrapper. Schema entities: `MintFeeWrapper`, `MintFeeConfig`,
2651
2732
  * `FeeRecipient`, `MintWithFeeEvent`, `FeeDistribution`.
2652
2733
  */
2653
- declare const PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v4";
2734
+ /**
2735
+ * Default subgraph endpoint. Points at `pafi-subgraph-v1` — the deployment
2736
+ * that indexes the V2 contract bucket (IssuerRegistry 0x3e8264…,
2737
+ * PointTokenFactory 0x34f9F8…, TokenRegistry 0x7092b3…, MintingOracle
2738
+ * 0x19F5Ea…, MintFeeWrapper 0x72B8FB…). Despite the "v1" name in the URL
2739
+ * this is the freshest subgraph — naming is a deploy-order artifact, not
2740
+ * a contract-version indicator.
2741
+ *
2742
+ * Previous deployments (`pafi-subgraph-v4`, `v5`) tracked the v1.6
2743
+ * contract bucket and have been retired alongside the v2 cutover.
2744
+ *
2745
+ * Override per-call via `subgraphUrl` parameter when you need to point at
2746
+ * a fork or a private graph node for staging.
2747
+ */
2748
+ declare const PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v1";
2654
2749
  /**
2655
2750
  * Fetch the Uniswap V3 pool(s) for a PAFI PointToken from the subgraph.
2656
2751
  *
@@ -2731,4 +2826,4 @@ declare class PafiSDK {
2731
2826
  signLoginMessage(message: string): Promise<Hex>;
2732
2827
  }
2733
2828
 
2734
- export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildErc20TransferParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, type FallbackInfo, type FeeScenario, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SERVICE_URLS, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_ABI, POINT_TOKEN_BEACON_ADDRESSES, POINT_TOKEN_BURN_SIG_ABI, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_MINT_SIG_ABI, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiErrorType, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSdkError, type PafiServiceUrls, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, QUOTER_V2_ADDRESSES, type QuoteOperatorFeeForTransferConfig, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, SCENARIO_GAS_UNITS, SDK_ERROR_HTTP_STATUS_CODE, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, SignatureVerifyOptions, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V3Path, V3_FACTORY_ADDRESSES, V3_POOL_INIT_CODE_HASH, V3_SWAP_ROUTER_ADDRESSES, VAULT_BEACON_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildErc20TransferUserOp, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, computeV3PoolAddress, createPafiProxyTransport, decodeBatchExecuteCalls, defaultErrorTypeForStatus, delegateDirect, detectDelegateImpl, encodeBatchExecute, encodeV3Path, encodeV3PathReversed, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiServiceUrls, getPafiWebModalAdapter, isDelegatedTo, isDelegatedToTarget, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeeForTransfer, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, splitAuthorizationSig, webPopupAdapter };
2829
+ export { ApiError, type AttachDelegationIfNeededParams, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildErc20TransferParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, type FallbackInfo, type FeeScenario, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SERVICE_URLS, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_ABI, POINT_TOKEN_BEACON_ADDRESSES, POINT_TOKEN_BURN_SIG_ABI, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_MINT_SIG_ABI, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiErrorType, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSdkError, type PafiServiceUrls, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, QUOTER_V2_ADDRESSES, type QuoteOperatorFeeForTransferConfig, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, SCENARIO_GAS_UNITS, SDK_ERROR_HTTP_STATUS_CODE, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, SignatureVerifyOptions, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V3Path, V3_FACTORY_ADDRESSES, V3_POOL_INIT_CODE_HASH, V3_SWAP_ROUTER_ADDRESSES, VAULT_BEACON_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, assembleUserOperation, attachDelegationIfNeeded, buildDelegationUserOp, buildEip7702Authorization, buildErc20TransferUserOp, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, computeV3PoolAddress, createPafiProxyTransport, decodeBatchExecuteCalls, defaultErrorTypeForStatus, delegateDirect, detectDelegateImpl, encodeBatchExecute, encodeV3Path, encodeV3PathReversed, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiServiceUrls, getPafiWebModalAdapter, isDelegatedTo, isDelegatedToTarget, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeeForTransfer, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, splitAuthorizationSig, webPopupAdapter };
package/dist/index.d.ts CHANGED
@@ -1499,6 +1499,87 @@ interface DelegateDirectResult {
1499
1499
  */
1500
1500
  declare function delegateDirect(params: DelegateDirectParams): Promise<DelegateDirectResult>;
1501
1501
 
1502
+ interface AttachDelegationIfNeededParams {
1503
+ /**
1504
+ * Public client connected to the chain on which the delegation lives.
1505
+ * The helper uses it to (1) read on-chain code via `eth_getCode` and
1506
+ * (2) read the EOA's tx nonce — both reads must hit the SAME chain
1507
+ * that `chainId` declares, otherwise Pimlico's bundler will reject the
1508
+ * authorization with a chain-mismatch error.
1509
+ */
1510
+ rpc: PublicClient;
1511
+ /**
1512
+ * The user's EOA — the wallet that will become a temporary smart account
1513
+ * via EIP-7702 SetCode. MUST match the `sender` of the UserOp the caller
1514
+ * is about to submit; otherwise the bundler's recovered-signer check
1515
+ * fails ("recovered signer does not match userOperation sender").
1516
+ */
1517
+ account: Address;
1518
+ /**
1519
+ * The implementation address the EOA should delegate to — typically the
1520
+ * Pimlico Simple7702Account / BatchExecutor on the target chain (Base
1521
+ * mainnet: `0xe6Cae83BdE06E4c305530e199D7217f42808555B`).
1522
+ *
1523
+ * The helper compares the on-chain code at `account` against this address.
1524
+ * Mismatch → sign a new authorization to switch the delegate. Match →
1525
+ * return `undefined` (caller passes nothing — extra auth would be wasted
1526
+ * gas + the bundler may reject redundant authorizations).
1527
+ */
1528
+ expectedDelegate: Address;
1529
+ /**
1530
+ * Chain id baked into the EIP-7702 authorization tuple. Must equal the
1531
+ * chain `rpc` connects to.
1532
+ */
1533
+ chainId: number;
1534
+ /**
1535
+ * Privy-shaped authorization signer. Pass `useSign7702Authorization().signAuthorization`
1536
+ * directly on web, or the Expo SDK's equivalent on mobile.
1537
+ *
1538
+ * The helper feeds it `(contractAddress, chainId, nonce)` — the signer
1539
+ * MUST sign with the same private key that controls `account`, otherwise
1540
+ * the recovered signer mismatch above triggers.
1541
+ */
1542
+ signAuthorization: SignAuthorizationFn;
1543
+ }
1544
+ /**
1545
+ * Sign an EIP-7702 authorization for `account` ONLY when the EOA does not
1546
+ * already delegate to `expectedDelegate`. Returns the authorization in the
1547
+ * shape that permissionless / viem expect on
1548
+ * `smartClient.sendTransaction({ authorization, ... })`. Pimlico bundles
1549
+ * the SetCode + UserOp execution into a SINGLE bundler tx — "atomic
1550
+ * activation" — so the user never sees a separate "delegate" step on their
1551
+ * first action.
1552
+ *
1553
+ * Returns `undefined` when the EOA already points at `expectedDelegate`.
1554
+ * Caller spreads the return value into the tx params:
1555
+ *
1556
+ * ```ts
1557
+ * const authPart = await attachDelegationIfNeeded({ ... });
1558
+ * await smartClient.sendTransaction({
1559
+ * to: pointToken,
1560
+ * data: encodeMintCalldata(amount),
1561
+ * ...(authPart ?? {}), // attaches { authorization: ... } only when needed
1562
+ * });
1563
+ * ```
1564
+ *
1565
+ * Cost: 1 `eth_getCode` read every time + 1 `eth_getTransactionCount` +
1566
+ * 1 signature (only the first time per EOA). Subsequent calls collapse to
1567
+ * a single RPC read and return `undefined` — cheap to call before every
1568
+ * UserOp.
1569
+ *
1570
+ * Implementation notes:
1571
+ * - Comparison is case-insensitive (`isDelegatedTo` lowercases both
1572
+ * sides) so passing checksum-cased addresses is safe.
1573
+ * - Nonce is fetched freshly per call to avoid replaying an old nonce
1574
+ * when the FE held the helper params across multiple actions.
1575
+ * - The signed tuple is passed through `buildEip7702Authorization` to
1576
+ * normalise `r` / `s` / `yParity` into the wire shape Pimlico accepts
1577
+ * (handles Privy's bigint `v` and string-hex `yParity` variants).
1578
+ */
1579
+ declare function attachDelegationIfNeeded(params: AttachDelegationIfNeededParams): Promise<{
1580
+ authorization: Eip7702AuthorizationJsonRpc;
1581
+ } | undefined>;
1582
+
1502
1583
  /**
1503
1584
  * Parameters for `createPafiProxyTransport`.
1504
1585
  */
@@ -2650,7 +2731,21 @@ declare function openPafiWebModal(url: string, options?: ModalOpenOptions): Prom
2650
2731
  * MintFeeWrapper. Schema entities: `MintFeeWrapper`, `MintFeeConfig`,
2651
2732
  * `FeeRecipient`, `MintWithFeeEvent`, `FeeDistribution`.
2652
2733
  */
2653
- declare const PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v4";
2734
+ /**
2735
+ * Default subgraph endpoint. Points at `pafi-subgraph-v1` — the deployment
2736
+ * that indexes the V2 contract bucket (IssuerRegistry 0x3e8264…,
2737
+ * PointTokenFactory 0x34f9F8…, TokenRegistry 0x7092b3…, MintingOracle
2738
+ * 0x19F5Ea…, MintFeeWrapper 0x72B8FB…). Despite the "v1" name in the URL
2739
+ * this is the freshest subgraph — naming is a deploy-order artifact, not
2740
+ * a contract-version indicator.
2741
+ *
2742
+ * Previous deployments (`pafi-subgraph-v4`, `v5`) tracked the v1.6
2743
+ * contract bucket and have been retired alongside the v2 cutover.
2744
+ *
2745
+ * Override per-call via `subgraphUrl` parameter when you need to point at
2746
+ * a fork or a private graph node for staging.
2747
+ */
2748
+ declare const PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v1";
2654
2749
  /**
2655
2750
  * Fetch the Uniswap V3 pool(s) for a PAFI PointToken from the subgraph.
2656
2751
  *
@@ -2731,4 +2826,4 @@ declare class PafiSDK {
2731
2826
  signLoginMessage(message: string): Promise<Hex>;
2732
2827
  }
2733
2828
 
2734
- export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildErc20TransferParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, type FallbackInfo, type FeeScenario, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SERVICE_URLS, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_ABI, POINT_TOKEN_BEACON_ADDRESSES, POINT_TOKEN_BURN_SIG_ABI, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_MINT_SIG_ABI, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiErrorType, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSdkError, type PafiServiceUrls, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, QUOTER_V2_ADDRESSES, type QuoteOperatorFeeForTransferConfig, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, SCENARIO_GAS_UNITS, SDK_ERROR_HTTP_STATUS_CODE, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, SignatureVerifyOptions, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V3Path, V3_FACTORY_ADDRESSES, V3_POOL_INIT_CODE_HASH, V3_SWAP_ROUTER_ADDRESSES, VAULT_BEACON_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildErc20TransferUserOp, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, computeV3PoolAddress, createPafiProxyTransport, decodeBatchExecuteCalls, defaultErrorTypeForStatus, delegateDirect, detectDelegateImpl, encodeBatchExecute, encodeV3Path, encodeV3PathReversed, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiServiceUrls, getPafiWebModalAdapter, isDelegatedTo, isDelegatedToTarget, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeeForTransfer, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, splitAuthorizationSig, webPopupAdapter };
2829
+ export { ApiError, type AttachDelegationIfNeededParams, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildErc20TransferParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, type FallbackInfo, type FeeScenario, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SERVICE_URLS, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_ABI, POINT_TOKEN_BEACON_ADDRESSES, POINT_TOKEN_BURN_SIG_ABI, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_MINT_SIG_ABI, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiErrorType, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSdkError, type PafiServiceUrls, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, QUOTER_V2_ADDRESSES, type QuoteOperatorFeeForTransferConfig, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, SCENARIO_GAS_UNITS, SDK_ERROR_HTTP_STATUS_CODE, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, SignatureVerifyOptions, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V3Path, V3_FACTORY_ADDRESSES, V3_POOL_INIT_CODE_HASH, V3_SWAP_ROUTER_ADDRESSES, VAULT_BEACON_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, assembleUserOperation, attachDelegationIfNeeded, buildDelegationUserOp, buildEip7702Authorization, buildErc20TransferUserOp, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, computeV3PoolAddress, createPafiProxyTransport, decodeBatchExecuteCalls, defaultErrorTypeForStatus, delegateDirect, detectDelegateImpl, encodeBatchExecute, encodeV3Path, encodeV3PathReversed, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiServiceUrls, getPafiWebModalAdapter, isDelegatedTo, isDelegatedToTarget, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeeForTransfer, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, splitAuthorizationSig, webPopupAdapter };
package/dist/index.js CHANGED
@@ -900,11 +900,23 @@ var CONTRACT_ADDRESSES = {
900
900
  // top-level export.
901
901
  permit2: "0xEB450d21ae68D3303Cf5775A54Cc84EE7c3fC8eC",
902
902
  // ── Stablecoins ───────────────────────────────────────────────
903
- // USDT inherited from v1.6 (MockUSDT no new V2 USDT deploy).
904
- usdt: "0x3F7e71B150e97316Bb9f363A32c19CcD36ac2382",
905
- // V2 USDC PAFI ecosystem USDC (custom deploy, NOT canonical Base
906
- // USDC `0x833589fC...`). Paired with the USDC/USD Chainlink feed below.
907
- usdc: "0xf0Fa9eB05fd3a373d3c54775Ff0ed55Dc9cc2D3E",
903
+ // Canonical Base stables the PT pools team deploys against these
904
+ // (verified on-chain: pool `0xB135E06E…` LTR/USDC and `0x6348D133…`
905
+ // JLB/USDC both list `token = 0x833589fC…` = canonical USDC). The
906
+ // earlier PAFI custom-deploy USDT/USDC (MockUSDT `0x3F7e71…` +
907
+ // PAFI V2 USDC `0xf0Fa9eB0…`) were unused by production pools and
908
+ // caused sponsor-relayer's `isStableFeeToken` to fall through to
909
+ // the PT quoter, producing 1e12× INSUFFICIENT_FEE rejects on every
910
+ // swap. See addresses.ts history before 2026-06-16 if archeology
911
+ // is needed.
912
+ //
913
+ // Canonical Tether USDT on Base (Tether's official native deploy,
914
+ // symbol="USDT", name="Tether USD", 6 decimals).
915
+ usdt: "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",
916
+ // Canonical Circle USDC on Base (Coinbase official deploy,
917
+ // symbol="USDC", 6 decimals). Paired with the USDC/USD Chainlink
918
+ // feed below.
919
+ usdc: "0x833589fCD6EDb6E08f4c7C32D4f71b54bdA02913",
908
920
  chainlinkUsdcUsd: "0xEE86BfD4E2B3A1e71a1b45f750791D67e735e4a7",
909
921
  // ── V2 core registries (replaces v1.6) ────────────────────────
910
922
  issuerRegistry: "0x3e82647b0f716f80e65d311354E2C4F0DcFd6997",
@@ -1048,6 +1060,46 @@ function normalizeHex32(value) {
1048
1060
  return "0x" + stripped.padStart(64, "0");
1049
1061
  }
1050
1062
 
1063
+ // src/delegation/attachDelegationIfNeeded.ts
1064
+ var inFlight = /* @__PURE__ */ new Map();
1065
+ function cacheKey(chainId, account) {
1066
+ return `${chainId}:${account.toLowerCase()}`;
1067
+ }
1068
+ async function attachDelegationIfNeeded(params) {
1069
+ const key = cacheKey(params.chainId, params.account);
1070
+ const existing = inFlight.get(key);
1071
+ if (existing) return existing;
1072
+ const promise = doAttach(params).finally(() => {
1073
+ inFlight.delete(key);
1074
+ });
1075
+ inFlight.set(key, promise);
1076
+ return promise;
1077
+ }
1078
+ async function doAttach(params) {
1079
+ const { rpc, account, expectedDelegate, chainId, signAuthorization } = params;
1080
+ if (await isDelegatedTo(rpc, account, expectedDelegate)) {
1081
+ return void 0;
1082
+ }
1083
+ const nonce = await rpc.getTransactionCount({ address: account });
1084
+ const rawAuth = await signAuthorization({
1085
+ contractAddress: expectedDelegate,
1086
+ chainId,
1087
+ nonce
1088
+ });
1089
+ const authorization = {
1090
+ chainId: toHexQuantity(rawAuth.chainId),
1091
+ address: rawAuth.contractAddress ?? rawAuth.address ?? expectedDelegate,
1092
+ nonce: toHexQuantity(BigInt(rawAuth.nonce)),
1093
+ r: rawAuth.r,
1094
+ s: rawAuth.s,
1095
+ yParity: typeof rawAuth.yParity === "string" ? rawAuth.yParity.startsWith("0x") ? rawAuth.yParity : `0x${rawAuth.yParity}` : `0x${rawAuth.yParity}`
1096
+ };
1097
+ return { authorization };
1098
+ }
1099
+ function toHexQuantity(n) {
1100
+ return `0x${BigInt(n).toString(16)}`;
1101
+ }
1102
+
1051
1103
  // src/transport/proxyTransport.ts
1052
1104
  import { http } from "viem";
1053
1105
  function createPafiProxyTransport(params) {
@@ -1107,7 +1159,7 @@ import { parseAbi as parseAbi3 } from "viem";
1107
1159
 
1108
1160
  // src/subgraph/pools.ts
1109
1161
  import { isAddress } from "viem";
1110
- var PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v4";
1162
+ var PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v1";
1111
1163
  var POOL_QUERY = `
1112
1164
  query GetPoolForPointToken($id: ID!) {
1113
1165
  pafiToken(id: $id) {
@@ -1796,6 +1848,7 @@ export {
1796
1848
  ZERO_VALUE,
1797
1849
  assembleUserOperation,
1798
1850
  assertDomainMatchesContract,
1851
+ attachDelegationIfNeeded,
1799
1852
  buildAndSignSponsorAuth,
1800
1853
  buildBurnRequestTypedData,
1801
1854
  buildDelegationUserOp,