@zyfai/sdk 1.3.2 → 1.5.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/README.md CHANGED
@@ -378,6 +378,84 @@ Add a wallet address to the SDK API key's allowedWallets list. This endpoint req
378
378
 
379
379
  ### 3. Session Keys
380
380
 
381
+ #### Verify a Smart Sessions v1 enable message
382
+
383
+ For the legacy EOA-owner personal-sign flow, construct an exact, ordered payload
384
+ from the same inputs used by the signer. All flags are explicit: do not guess
385
+ or substitute defaults. For the frontend flow, the Smart Sessions address must
386
+ match the address used by its installed Rhinestone module SDK, which may differ
387
+ from another validator installed on the account.
388
+
389
+ ```ts
390
+ import {
391
+ buildV1ChainSessions, serializeV1ChainSessions, parseV1ChainSessions,
392
+ hashV1SessionEnable, type V1SessionEnableInput,
393
+ } from "@zyfai/sdk";
394
+
395
+ // These values must come from the actual pending signature request.
396
+ // Repeat the entry for every chain, in exactly the signer's order.
397
+ declare const actualInput: V1SessionEnableInput;
398
+ const payload = buildV1ChainSessions([actualInput]);
399
+ const jsonForReviewer = serializeV1ChainSessions(payload);
400
+
401
+ // The reviewer receives the full JSON and recomputes locally.
402
+ const reviewedPayload = parseV1ChainSessions(jsonForReviewer);
403
+ const { permissionEnableHash, personalSignDigest } = hashV1SessionEnable(reviewedPayload);
404
+ console.log({ permissionEnableHash, personalSignDigest });
405
+ ```
406
+
407
+ Each `V1SessionEnableInput` requires the smart-account address, Smart Sessions
408
+ contract address, nonce, three permission flags, and a session containing chain
409
+ ID, session validator and initialisation bytes, salt, paymaster flag, user-op
410
+ policies, ERC-7739 policies and permitted actions. Each action includes its
411
+ contract address, four-byte selector and policy addresses and initialisation
412
+ bytes. The JSON format represents chain IDs and nonces as decimal strings.
413
+ Keep array order and all bytes unchanged. The helper rejects missing fields,
414
+ invalid addresses, malformed bytes, invalid integer ranges and numeric JSON
415
+ chain IDs or nonces.
416
+
417
+ Compare `permissionEnableHash` byte-for-byte with the wallet's displayed
418
+ message. The EIP-191 digest is different from that displayed message. Review
419
+ and decode every policy independently against the actual contracts and ABIs: a
420
+ matching hash does not establish what policy bytes mean or that permissions are
421
+ safe. The application must supply the exact payload; the helper cannot recover
422
+ it from a hash, verify on-chain state, or verify that the export is the one
423
+ passed to the wallet. Regenerate the package whenever inputs or nonces change.
424
+
425
+ #### Verify an owner-signed user operation
426
+
427
+ Partner smart accounts sign their deployment, module installs and session
428
+ enable as one ERC-4337 v0.7 user operation. The wallet shows only the 32-byte
429
+ user operation hash (`message - 0x…`). Ask the app for the exact user operation
430
+ JSON before signing, then recompute the hash and decode the calls offline:
431
+
432
+ ```ts
433
+ import { readFileSync } from "node:fs";
434
+ import { parseUserOperationJson, hashUserOperationV07, decodeUserOperationCalls } from "@zyfai/sdk";
435
+
436
+ const userOp = parseUserOperationJson(readFileSync("userop.json", "utf8"));
437
+ console.log(hashUserOperationV07(userOp, 8453)); // must equal the wallet's message
438
+ console.dir(decodeUserOperationCalls(userOp), { depth: null });
439
+ ```
440
+
441
+ From a checkout of this repository, `npm run build` then
442
+ `npx tsx examples/verify-user-operation.ts userop.json 0x<wallet message>`
443
+ prints the hash, `MATCH` or `MISMATCH`, and a readable list of the calls.
444
+
445
+ The JSON uses the unpacked v0.7 fields (`sender`, `nonce`, `factory`,
446
+ `factoryData`, `callData`, gas limits and fees, `paymaster`,
447
+ `paymasterVerificationGasLimit`, `paymasterPostOpGasLimit`, `paymasterData`).
448
+ Integers are decimal or hex strings. The hash covers every field except the
449
+ signature, so it must be the final operation, after gas and paymaster data
450
+ are filled. A single changed byte gives a different hash.
451
+
452
+ `decodeUserOperationCalls` unwraps the Safe7579 first-deploy `setupSafe`,
453
+ ERC-7579 `execute`, `setRegistry`, `installModule` and Smart Sessions
454
+ `enableSessions`. For a session, check the session signers in
455
+ `sessionValidatorInitData` and that every action targets only the modules you
456
+ expect. Any other call is returned with its target and selector only: decode
457
+ it yourself. A matching hash proves what you sign, not that it is safe.
458
+
381
459
  Session keys enable delegated transaction execution without exposing the main private key.
382
460
 
383
461
  #### Simple Usage (Legacy — deprecated)
@@ -1027,6 +1105,7 @@ const history = await sdk.getHistory(walletAddress, 8453, {
1027
1105
  limit: 50,
1028
1106
  fromDate: "2024-01-01",
1029
1107
  assetType: "eth", // usdc | eth | eurc | usdt | pyusd | nvdac | wbtc
1108
+ // rebalanceLegs: true marks async rebalance request, claim, and redeploy rows
1030
1109
  });
1031
1110
  history.data.forEach((tx) => {
1032
1111
  console.log(tx.action, tx.transactionHash);
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- import { Chain, PublicClient, Address as Address$1 } from 'viem';
1
+ import { Chain, PublicClient, Address as Address$1, Hex as Hex$1 } from 'viem';
2
+ import { hashChainSessions } from '@rhinestone/module-sdk';
2
3
 
3
4
  /**
4
5
  * Public TypeScript types for `@zyfai/sdk` request/response shapes and events.
@@ -1049,6 +1050,12 @@ interface CustomizeBatchRequest {
1049
1050
  interface CustomizeBatchResponse {
1050
1051
  success: boolean;
1051
1052
  }
1053
+ interface GetAvailablePoolsOptions {
1054
+ /** Omit pools whose status is not live. Default false. */
1055
+ liveOnly?: boolean;
1056
+ /** Include each pool's status. Default false. */
1057
+ includeStatus?: boolean;
1058
+ }
1052
1059
  interface GetPoolsResponse {
1053
1060
  success: boolean;
1054
1061
  pools: string[];
@@ -2561,6 +2568,8 @@ declare class ZyfaiSDK {
2561
2568
  fromDate?: string;
2562
2569
  toDate?: string;
2563
2570
  assetType?: HistoryAssetType;
2571
+ /** Mark async rebalance request, claim, and redeploy rows as rebalance. */
2572
+ rebalanceLegs?: boolean;
2564
2573
  }): Promise<HistoryResponse>;
2565
2574
  /**
2566
2575
  * Get onchain earnings for a wallet.
@@ -2927,6 +2936,7 @@ declare class ZyfaiSDK {
2927
2936
  *
2928
2937
  * @param protocolId - The protocol UUID
2929
2938
  * @param strategy - Optional {@link Strategy} filter
2939
+ * @param options - `liveOnly` omits not-live pools. `includeStatus` adds each pool's status. Both default off.
2930
2940
  * @returns List of available pool names
2931
2941
  *
2932
2942
  * @example
@@ -2942,7 +2952,7 @@ declare class ZyfaiSDK {
2942
2952
  * );
2943
2953
  * ```
2944
2954
  */
2945
- getAvailablePools(protocolId: string, strategy?: Strategy): Promise<GetPoolsResponse>;
2955
+ getAvailablePools(protocolId: string, strategy?: Strategy, options?: GetAvailablePoolsOptions): Promise<GetPoolsResponse>;
2946
2956
  /**
2947
2957
  * Simulate the best yield positions for a given amount, splitting it across
2948
2958
  * the top-ranked pools (up to minSplit positions) for the requested chains/strategy.
@@ -3135,6 +3145,109 @@ declare class ZyfaiSDK {
3135
3145
  subscribeToEvents(handlers: ZyfaiEventHandlers, filters?: ZyfaiEventFilters): () => void;
3136
3146
  }
3137
3147
 
3148
+ /** Exact ordered v1 chain sessions used to construct a permission enable hash. */
3149
+ type V1ChainSessions = Parameters<typeof hashChainSessions>[0];
3150
+ /** Inputs for one chain, with all signing flags specified explicitly. */
3151
+ interface V1SessionEnableInput {
3152
+ account: Address$1;
3153
+ smartSession: Address$1;
3154
+ nonce: bigint;
3155
+ session: Session;
3156
+ permitGenericPolicy: boolean;
3157
+ permitAdminAccess: boolean;
3158
+ ignoreSecurityAttestations: boolean;
3159
+ }
3160
+ /** Construct the ordered payload from the same inputs used by the v1 signer. */
3161
+ declare function buildV1ChainSessions(inputs: V1SessionEnableInput[]): V1ChainSessions;
3162
+ /** Encode a complete payload as JSON with decimal strings for chain IDs and nonces. */
3163
+ declare function serializeV1ChainSessions(chainSessions: V1ChainSessions): string;
3164
+ /** Parse and validate a JSON payload produced by {@link serializeV1ChainSessions}. */
3165
+ declare function parseV1ChainSessions(json: string): V1ChainSessions;
3166
+ /**
3167
+ * Recompute the message shown by personal-sign wallets and its EIP-191 digest.
3168
+ *
3169
+ * @remarks
3170
+ * The input must be the complete ordered payload used by the signer. A matching
3171
+ * hash does not establish that the encoded permissions are safe or intended.
3172
+ */
3173
+ declare function hashV1SessionEnable(chainSessions: V1ChainSessions): {
3174
+ permissionEnableHash: Hex$1;
3175
+ personalSignDigest: Hex$1;
3176
+ };
3177
+
3178
+ /** ERC-4337 EntryPoint v0.7, the one Zyfai smart accounts use. */
3179
+ declare const ENTRY_POINT_V07_ADDRESS: Address$1;
3180
+ /**
3181
+ * Unpacked ERC-4337 v0.7 user operation, as held by the app before signing.
3182
+ * The signature is not part of the hash and is ignored.
3183
+ */
3184
+ interface VerifiableUserOperation {
3185
+ sender: Address$1;
3186
+ nonce: bigint;
3187
+ factory?: Address$1;
3188
+ factoryData?: Hex$1;
3189
+ callData: Hex$1;
3190
+ callGasLimit: bigint;
3191
+ verificationGasLimit: bigint;
3192
+ preVerificationGas: bigint;
3193
+ maxFeePerGas: bigint;
3194
+ maxPriorityFeePerGas: bigint;
3195
+ paymaster?: Address$1;
3196
+ paymasterVerificationGasLimit?: bigint;
3197
+ paymasterPostOpGasLimit?: bigint;
3198
+ paymasterData?: Hex$1;
3199
+ }
3200
+ /** One call found inside a user operation's `callData`, nested calls included. */
3201
+ interface DecodedUserOperationCall {
3202
+ target: Address$1;
3203
+ value: bigint;
3204
+ selector: Hex$1;
3205
+ /** Set when the selector is one of the account, module or session functions this helper knows. */
3206
+ functionName?: "setupSafe" | "execute" | "setRegistry" | "installModule" | "enableSessions";
3207
+ args?: readonly unknown[];
3208
+ /** Calls executed by `setupSafe` or `execute`. */
3209
+ calls?: DecodedUserOperationCall[];
3210
+ }
3211
+ /**
3212
+ * Parse a user operation exported as JSON by the app that asks for the signature.
3213
+ *
3214
+ * @remarks
3215
+ * Integer fields must be strings, decimal (`"71473"`) or hex (`"0x11731"`), so large nonces keep
3216
+ * their precision. Addresses and bytes are hex strings. Unknown fields, such as `signature`, are ignored.
3217
+ *
3218
+ * @param json - The user operation JSON.
3219
+ * @returns The parsed {@link VerifiableUserOperation}.
3220
+ * @throws `Invalid user operation JSON` when a field is missing or malformed.
3221
+ */
3222
+ declare function parseUserOperationJson(json: string): VerifiableUserOperation;
3223
+ /**
3224
+ * Recompute the ERC-4337 v0.7 user operation hash, the 32 bytes a wallet shows as `message - 0x…`.
3225
+ *
3226
+ * @remarks
3227
+ * Offline and dependency-free: this is `EntryPoint.getUserOpHash` written out field by field, so a
3228
+ * reviewer can check it against the EntryPoint source. Zyfai's owner-signed operations (account
3229
+ * deployment, module install, session enable) are signed with `personal_sign` over this hash.
3230
+ *
3231
+ * @param userOp - The exact user operation the app will submit, after gas and paymaster fields are filled.
3232
+ * @param chainId - The chain the operation runs on, for example `8453` for Base.
3233
+ * @param entryPoint - Defaults to {@link ENTRY_POINT_V07_ADDRESS}.
3234
+ * @returns The user operation hash.
3235
+ */
3236
+ declare function hashUserOperationV07(userOp: VerifiableUserOperation, chainId: number | bigint, entryPoint?: Address$1): Hex$1;
3237
+ /**
3238
+ * Decode what a user operation will execute on the smart account.
3239
+ *
3240
+ * @remarks
3241
+ * Understands the Safe7579 first-deploy `setupSafe`, ERC-7579 `execute` (single and batch),
3242
+ * `setRegistry`, `installModule` and Smart Sessions `enableSessions`. Any other call is returned
3243
+ * with its target, value and selector only: decode it yourself before signing. Decoding does not
3244
+ * judge whether a module, policy or session signer is safe.
3245
+ *
3246
+ * @param userOp - The user operation, as parsed by {@link parseUserOperationJson}.
3247
+ * @returns The top-level call on the account, with nested calls under `calls`.
3248
+ */
3249
+ declare function decodeUserOperationCalls(userOp: Pick<VerifiableUserOperation, "sender" | "callData">): DecodedUserOperationCall;
3250
+
3138
3251
  /**
3139
3252
  * Bankr EIP-1193 Provider Adapter
3140
3253
  *
@@ -3354,4 +3467,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
3354
3467
  */
3355
3468
  declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
3356
3469
 
3357
- export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BaseMerklCampaignId, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_RELAY_SLIPPAGE_BPS, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositPositionOutcome, type DepositResponse, type DepositRoute, type DepositRouteInput, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstPermitDepositStatus, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryAssetType, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, type LiquidityDropEvent, type LogDepositResponse, MAX_RELAY_SLIPPAGE_BPS, type MerklCampaign, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, RELAY_SLIPPAGE_PRESETS_BPS, type RebalanceFrequencyResponse, type RegisterAgentResponse, type RzfiClaimResponse, type RzfiClaimTransaction, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type SendDepositParams, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type SwapDepositOrder, type SwapDepositParams, type SwapDepositQuote, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeAssetType, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WaitForDepositPositionOptions, type WaitForWithdrawCompleteOptions, type WaitForWithdrawSettlementOptions, type WalletTVL, type WithdrawAsyncLeg, type WithdrawLifecycleResponse, type WithdrawLifecycleStatus, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, isSupportedChain, resolveDepositRoute, resolveRelaySlippageBps, type staleBalances };
3470
+ export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BaseMerklCampaignId, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_RELAY_SLIPPAGE_BPS, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DecodedUserOperationCall, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositPositionOutcome, type DepositResponse, type DepositRoute, type DepositRouteInput, ENTRY_POINT_V07_ADDRESS, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstPermitDepositStatus, type FirstTopupResponse, type GetAvailablePoolsOptions, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryAssetType, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, type LiquidityDropEvent, type LogDepositResponse, MAX_RELAY_SLIPPAGE_BPS, type MerklCampaign, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, RELAY_SLIPPAGE_PRESETS_BPS, type RebalanceFrequencyResponse, type RegisterAgentResponse, type RzfiClaimResponse, type RzfiClaimTransaction, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type SendDepositParams, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type SwapDepositOrder, type SwapDepositParams, type SwapDepositQuote, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, type V1ChainSessions, type V1SessionEnableInput, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VerifiableUserOperation, type VolumeAssetType, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WaitForDepositPositionOptions, type WaitForWithdrawCompleteOptions, type WaitForWithdrawSettlementOptions, type WalletTVL, type WithdrawAsyncLeg, type WithdrawLifecycleResponse, type WithdrawLifecycleStatus, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, buildV1ChainSessions, createBankrProvider, decodeUserOperationCalls, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, hashUserOperationV07, hashV1SessionEnable, isSupportedChain, parseUserOperationJson, parseV1ChainSessions, resolveDepositRoute, resolveRelaySlippageBps, serializeV1ChainSessions, type staleBalances };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { Chain, PublicClient, Address as Address$1 } from 'viem';
1
+ import { Chain, PublicClient, Address as Address$1, Hex as Hex$1 } from 'viem';
2
+ import { hashChainSessions } from '@rhinestone/module-sdk';
2
3
 
3
4
  /**
4
5
  * Public TypeScript types for `@zyfai/sdk` request/response shapes and events.
@@ -1049,6 +1050,12 @@ interface CustomizeBatchRequest {
1049
1050
  interface CustomizeBatchResponse {
1050
1051
  success: boolean;
1051
1052
  }
1053
+ interface GetAvailablePoolsOptions {
1054
+ /** Omit pools whose status is not live. Default false. */
1055
+ liveOnly?: boolean;
1056
+ /** Include each pool's status. Default false. */
1057
+ includeStatus?: boolean;
1058
+ }
1052
1059
  interface GetPoolsResponse {
1053
1060
  success: boolean;
1054
1061
  pools: string[];
@@ -2561,6 +2568,8 @@ declare class ZyfaiSDK {
2561
2568
  fromDate?: string;
2562
2569
  toDate?: string;
2563
2570
  assetType?: HistoryAssetType;
2571
+ /** Mark async rebalance request, claim, and redeploy rows as rebalance. */
2572
+ rebalanceLegs?: boolean;
2564
2573
  }): Promise<HistoryResponse>;
2565
2574
  /**
2566
2575
  * Get onchain earnings for a wallet.
@@ -2927,6 +2936,7 @@ declare class ZyfaiSDK {
2927
2936
  *
2928
2937
  * @param protocolId - The protocol UUID
2929
2938
  * @param strategy - Optional {@link Strategy} filter
2939
+ * @param options - `liveOnly` omits not-live pools. `includeStatus` adds each pool's status. Both default off.
2930
2940
  * @returns List of available pool names
2931
2941
  *
2932
2942
  * @example
@@ -2942,7 +2952,7 @@ declare class ZyfaiSDK {
2942
2952
  * );
2943
2953
  * ```
2944
2954
  */
2945
- getAvailablePools(protocolId: string, strategy?: Strategy): Promise<GetPoolsResponse>;
2955
+ getAvailablePools(protocolId: string, strategy?: Strategy, options?: GetAvailablePoolsOptions): Promise<GetPoolsResponse>;
2946
2956
  /**
2947
2957
  * Simulate the best yield positions for a given amount, splitting it across
2948
2958
  * the top-ranked pools (up to minSplit positions) for the requested chains/strategy.
@@ -3135,6 +3145,109 @@ declare class ZyfaiSDK {
3135
3145
  subscribeToEvents(handlers: ZyfaiEventHandlers, filters?: ZyfaiEventFilters): () => void;
3136
3146
  }
3137
3147
 
3148
+ /** Exact ordered v1 chain sessions used to construct a permission enable hash. */
3149
+ type V1ChainSessions = Parameters<typeof hashChainSessions>[0];
3150
+ /** Inputs for one chain, with all signing flags specified explicitly. */
3151
+ interface V1SessionEnableInput {
3152
+ account: Address$1;
3153
+ smartSession: Address$1;
3154
+ nonce: bigint;
3155
+ session: Session;
3156
+ permitGenericPolicy: boolean;
3157
+ permitAdminAccess: boolean;
3158
+ ignoreSecurityAttestations: boolean;
3159
+ }
3160
+ /** Construct the ordered payload from the same inputs used by the v1 signer. */
3161
+ declare function buildV1ChainSessions(inputs: V1SessionEnableInput[]): V1ChainSessions;
3162
+ /** Encode a complete payload as JSON with decimal strings for chain IDs and nonces. */
3163
+ declare function serializeV1ChainSessions(chainSessions: V1ChainSessions): string;
3164
+ /** Parse and validate a JSON payload produced by {@link serializeV1ChainSessions}. */
3165
+ declare function parseV1ChainSessions(json: string): V1ChainSessions;
3166
+ /**
3167
+ * Recompute the message shown by personal-sign wallets and its EIP-191 digest.
3168
+ *
3169
+ * @remarks
3170
+ * The input must be the complete ordered payload used by the signer. A matching
3171
+ * hash does not establish that the encoded permissions are safe or intended.
3172
+ */
3173
+ declare function hashV1SessionEnable(chainSessions: V1ChainSessions): {
3174
+ permissionEnableHash: Hex$1;
3175
+ personalSignDigest: Hex$1;
3176
+ };
3177
+
3178
+ /** ERC-4337 EntryPoint v0.7, the one Zyfai smart accounts use. */
3179
+ declare const ENTRY_POINT_V07_ADDRESS: Address$1;
3180
+ /**
3181
+ * Unpacked ERC-4337 v0.7 user operation, as held by the app before signing.
3182
+ * The signature is not part of the hash and is ignored.
3183
+ */
3184
+ interface VerifiableUserOperation {
3185
+ sender: Address$1;
3186
+ nonce: bigint;
3187
+ factory?: Address$1;
3188
+ factoryData?: Hex$1;
3189
+ callData: Hex$1;
3190
+ callGasLimit: bigint;
3191
+ verificationGasLimit: bigint;
3192
+ preVerificationGas: bigint;
3193
+ maxFeePerGas: bigint;
3194
+ maxPriorityFeePerGas: bigint;
3195
+ paymaster?: Address$1;
3196
+ paymasterVerificationGasLimit?: bigint;
3197
+ paymasterPostOpGasLimit?: bigint;
3198
+ paymasterData?: Hex$1;
3199
+ }
3200
+ /** One call found inside a user operation's `callData`, nested calls included. */
3201
+ interface DecodedUserOperationCall {
3202
+ target: Address$1;
3203
+ value: bigint;
3204
+ selector: Hex$1;
3205
+ /** Set when the selector is one of the account, module or session functions this helper knows. */
3206
+ functionName?: "setupSafe" | "execute" | "setRegistry" | "installModule" | "enableSessions";
3207
+ args?: readonly unknown[];
3208
+ /** Calls executed by `setupSafe` or `execute`. */
3209
+ calls?: DecodedUserOperationCall[];
3210
+ }
3211
+ /**
3212
+ * Parse a user operation exported as JSON by the app that asks for the signature.
3213
+ *
3214
+ * @remarks
3215
+ * Integer fields must be strings, decimal (`"71473"`) or hex (`"0x11731"`), so large nonces keep
3216
+ * their precision. Addresses and bytes are hex strings. Unknown fields, such as `signature`, are ignored.
3217
+ *
3218
+ * @param json - The user operation JSON.
3219
+ * @returns The parsed {@link VerifiableUserOperation}.
3220
+ * @throws `Invalid user operation JSON` when a field is missing or malformed.
3221
+ */
3222
+ declare function parseUserOperationJson(json: string): VerifiableUserOperation;
3223
+ /**
3224
+ * Recompute the ERC-4337 v0.7 user operation hash, the 32 bytes a wallet shows as `message - 0x…`.
3225
+ *
3226
+ * @remarks
3227
+ * Offline and dependency-free: this is `EntryPoint.getUserOpHash` written out field by field, so a
3228
+ * reviewer can check it against the EntryPoint source. Zyfai's owner-signed operations (account
3229
+ * deployment, module install, session enable) are signed with `personal_sign` over this hash.
3230
+ *
3231
+ * @param userOp - The exact user operation the app will submit, after gas and paymaster fields are filled.
3232
+ * @param chainId - The chain the operation runs on, for example `8453` for Base.
3233
+ * @param entryPoint - Defaults to {@link ENTRY_POINT_V07_ADDRESS}.
3234
+ * @returns The user operation hash.
3235
+ */
3236
+ declare function hashUserOperationV07(userOp: VerifiableUserOperation, chainId: number | bigint, entryPoint?: Address$1): Hex$1;
3237
+ /**
3238
+ * Decode what a user operation will execute on the smart account.
3239
+ *
3240
+ * @remarks
3241
+ * Understands the Safe7579 first-deploy `setupSafe`, ERC-7579 `execute` (single and batch),
3242
+ * `setRegistry`, `installModule` and Smart Sessions `enableSessions`. Any other call is returned
3243
+ * with its target, value and selector only: decode it yourself before signing. Decoding does not
3244
+ * judge whether a module, policy or session signer is safe.
3245
+ *
3246
+ * @param userOp - The user operation, as parsed by {@link parseUserOperationJson}.
3247
+ * @returns The top-level call on the account, with nested calls under `calls`.
3248
+ */
3249
+ declare function decodeUserOperationCalls(userOp: Pick<VerifiableUserOperation, "sender" | "callData">): DecodedUserOperationCall;
3250
+
3138
3251
  /**
3139
3252
  * Bankr EIP-1193 Provider Adapter
3140
3253
  *
@@ -3354,4 +3467,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
3354
3467
  */
3355
3468
  declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
3356
3469
 
3357
- export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BaseMerklCampaignId, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_RELAY_SLIPPAGE_BPS, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositPositionOutcome, type DepositResponse, type DepositRoute, type DepositRouteInput, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstPermitDepositStatus, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryAssetType, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, type LiquidityDropEvent, type LogDepositResponse, MAX_RELAY_SLIPPAGE_BPS, type MerklCampaign, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, RELAY_SLIPPAGE_PRESETS_BPS, type RebalanceFrequencyResponse, type RegisterAgentResponse, type RzfiClaimResponse, type RzfiClaimTransaction, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type SendDepositParams, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type SwapDepositOrder, type SwapDepositParams, type SwapDepositQuote, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeAssetType, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WaitForDepositPositionOptions, type WaitForWithdrawCompleteOptions, type WaitForWithdrawSettlementOptions, type WalletTVL, type WithdrawAsyncLeg, type WithdrawLifecycleResponse, type WithdrawLifecycleStatus, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, isSupportedChain, resolveDepositRoute, resolveRelaySlippageBps, type staleBalances };
3470
+ export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BaseMerklCampaignId, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_RELAY_SLIPPAGE_BPS, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DecodedUserOperationCall, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositPositionOutcome, type DepositResponse, type DepositRoute, type DepositRouteInput, ENTRY_POINT_V07_ADDRESS, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstPermitDepositStatus, type FirstTopupResponse, type GetAvailablePoolsOptions, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryAssetType, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, type LiquidityDropEvent, type LogDepositResponse, MAX_RELAY_SLIPPAGE_BPS, type MerklCampaign, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, RELAY_SLIPPAGE_PRESETS_BPS, type RebalanceFrequencyResponse, type RegisterAgentResponse, type RzfiClaimResponse, type RzfiClaimTransaction, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type SendDepositParams, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type SwapDepositOrder, type SwapDepositParams, type SwapDepositQuote, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, type V1ChainSessions, type V1SessionEnableInput, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VerifiableUserOperation, type VolumeAssetType, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WaitForDepositPositionOptions, type WaitForWithdrawCompleteOptions, type WaitForWithdrawSettlementOptions, type WalletTVL, type WithdrawAsyncLeg, type WithdrawLifecycleResponse, type WithdrawLifecycleStatus, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, buildV1ChainSessions, createBankrProvider, decodeUserOperationCalls, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, hashUserOperationV07, hashV1SessionEnable, isSupportedChain, parseUserOperationJson, parseV1ChainSessions, resolveDepositRoute, resolveRelaySlippageBps, serializeV1ChainSessions, type staleBalances };
package/dist/index.js CHANGED
@@ -36,6 +36,7 @@ __export(index_exports, {
36
36
  DATA_API_ENDPOINT: () => DATA_API_ENDPOINT,
37
37
  DEFAULT_RELAY_SLIPPAGE_BPS: () => DEFAULT_RELAY_SLIPPAGE_BPS,
38
38
  DEFAULT_TOKEN_ADDRESSES: () => DEFAULT_TOKEN_ADDRESSES,
39
+ ENTRY_POINT_V07_ADDRESS: () => ENTRY_POINT_V07_ADDRESS,
39
40
  ERC7579_LAUNCHPAD_ADDRESS: () => ERC7579_LAUNCHPAD_ADDRESS,
40
41
  EXECUTION_API_BASE_URLS: () => EXECUTION_API_BASE_URLS,
41
42
  INTENT_EXECUTOR: () => INTENT_EXECUTOR,
@@ -58,7 +59,9 @@ __export(index_exports, {
58
59
  WS_ENDPOINT: () => WS_ENDPOINT,
59
60
  WS_URLS: () => WS_URLS,
60
61
  ZyfaiSDK: () => ZyfaiSDK,
62
+ buildV1ChainSessions: () => buildV1ChainSessions,
61
63
  createBankrProvider: () => createBankrProvider,
64
+ decodeUserOperationCalls: () => decodeUserOperationCalls,
62
65
  getChainConfig: () => getChainConfig,
63
66
  getDataApiBaseUrl: () => getDataApiBaseUrl,
64
67
  getDefaultTokenAddress: () => getDefaultTokenAddress,
@@ -66,9 +69,14 @@ __export(index_exports, {
66
69
  getManagedAssets: () => getManagedAssets,
67
70
  getSupportedChainIds: () => getSupportedChainIds,
68
71
  getWsUrl: () => getWsUrl,
72
+ hashUserOperationV07: () => hashUserOperationV07,
73
+ hashV1SessionEnable: () => hashV1SessionEnable,
69
74
  isSupportedChain: () => isSupportedChain,
75
+ parseUserOperationJson: () => parseUserOperationJson,
76
+ parseV1ChainSessions: () => parseV1ChainSessions,
70
77
  resolveDepositRoute: () => resolveDepositRoute,
71
- resolveRelaySlippageBps: () => resolveRelaySlippageBps
78
+ resolveRelaySlippageBps: () => resolveRelaySlippageBps,
79
+ serializeV1ChainSessions: () => serializeV1ChainSessions
72
80
  });
73
81
  module.exports = __toCommonJS(index_exports);
74
82
 
@@ -187,7 +195,13 @@ var ENDPOINTS = {
187
195
  },
188
196
  // Customization
189
197
  CUSTOMIZE_BATCH: "/customization/customize-batch",
190
- CUSTOMIZATION_POOLS: (protocolId, strategy) => `/customization/pools?protocolId=${protocolId}${strategy ? `&strategy=${strategy}` : ""}`,
198
+ CUSTOMIZATION_POOLS: (protocolId, strategy, options) => {
199
+ const query = [`protocolId=${protocolId}`];
200
+ if (strategy) query.push(`strategy=${strategy}`);
201
+ if (options?.liveOnly) query.push("liveOnly=true");
202
+ if (options?.includeStatus) query.push("includeStatus=true");
203
+ return `/customization/pools?${query.join("&")}`;
204
+ },
191
205
  CUSTOMIZATION_SELECTED_POOLS: (protocolId, chainId) => `/customization/selected-pools?protocolId=${protocolId}&chainId=${chainId}`
192
206
  };
193
207
  var DATA_ENDPOINTS = {
@@ -5852,6 +5866,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
5852
5866
  if (options?.offset) endpoint += `&offset=${options.offset}`;
5853
5867
  if (options?.fromDate) endpoint += `&fromDate=${options.fromDate}`;
5854
5868
  if (options?.toDate) endpoint += `&toDate=${options.toDate}`;
5869
+ if (options?.rebalanceLegs) endpoint += `&rebalanceLegs=true`;
5855
5870
  const response = await this.httpClient.get(endpoint);
5856
5871
  const convertedData = convertStrategiesToPublic(
5857
5872
  response.data || []
@@ -6700,6 +6715,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
6700
6715
  *
6701
6716
  * @param protocolId - The protocol UUID
6702
6717
  * @param strategy - Optional {@link Strategy} filter
6718
+ * @param options - `liveOnly` omits not-live pools. `includeStatus` adds each pool's status. Both default off.
6703
6719
  * @returns List of available pool names
6704
6720
  *
6705
6721
  * @example
@@ -6715,7 +6731,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
6715
6731
  * );
6716
6732
  * ```
6717
6733
  */
6718
- async getAvailablePools(protocolId, strategy) {
6734
+ async getAvailablePools(protocolId, strategy, options) {
6719
6735
  try {
6720
6736
  let internalStrategy;
6721
6737
  if (strategy) {
@@ -6727,7 +6743,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
6727
6743
  internalStrategy = toInternalStrategy(strategy);
6728
6744
  }
6729
6745
  const response = await this.httpClient.get(
6730
- ENDPOINTS.CUSTOMIZATION_POOLS(protocolId, internalStrategy)
6746
+ ENDPOINTS.CUSTOMIZATION_POOLS(
6747
+ protocolId,
6748
+ internalStrategy,
6749
+ options
6750
+ )
6731
6751
  );
6732
6752
  return response;
6733
6753
  } catch (error) {
@@ -7338,6 +7358,206 @@ var _ZyfaiSDK = class _ZyfaiSDK {
7338
7358
  _ZyfaiSDK.IDENTITY_REGISTRY_CHAIN_IDS = [8453, 42161];
7339
7359
  var ZyfaiSDK = _ZyfaiSDK;
7340
7360
 
7361
+ // src/utils/session-verification.ts
7362
+ var import_module_sdk2 = require("@rhinestone/module-sdk");
7363
+ var import_viem7 = require("viem");
7364
+ function buildV1ChainSessions(inputs) {
7365
+ const chainSessions = inputs.map(({ account, smartSession, nonce, session, permitGenericPolicy, permitAdminAccess, ignoreSecurityAttestations }) => ({
7366
+ chainId: session.chainId,
7367
+ session: {
7368
+ account,
7369
+ smartSession,
7370
+ nonce,
7371
+ sessionValidator: session.sessionValidator,
7372
+ sessionValidatorInitData: session.sessionValidatorInitData,
7373
+ salt: session.salt,
7374
+ permissions: {
7375
+ permitGenericPolicy,
7376
+ permitAdminAccess,
7377
+ ignoreSecurityAttestations,
7378
+ permitERC4337Paymaster: session.permitERC4337Paymaster,
7379
+ userOpPolicies: session.userOpPolicies,
7380
+ erc7739Policies: session.erc7739Policies,
7381
+ actions: session.actions
7382
+ }
7383
+ }
7384
+ }));
7385
+ validateV1ChainSessions(chainSessions);
7386
+ return chainSessions;
7387
+ }
7388
+ function validateV1ChainSessions(sessions) {
7389
+ const fail = () => {
7390
+ throw new Error("Invalid v1 chain session payload");
7391
+ };
7392
+ const address = (v) => typeof v === "string" && (0, import_viem7.isAddress)(v);
7393
+ const hex = (v, bytes) => typeof v === "string" && (0, import_viem7.isHex)(v, { strict: true }) && v.length % 2 === 0 && (bytes === void 0 || (0, import_viem7.size)(v) === bytes);
7394
+ const policies = (v) => Array.isArray(v) && v.every((p) => p && address(p.policy) && hex(p.initData));
7395
+ if (!Array.isArray(sessions) || !sessions.length) fail();
7396
+ for (const entry of sessions) {
7397
+ const s = entry?.session;
7398
+ const p = s?.permissions;
7399
+ if (typeof entry?.chainId !== "bigint" || entry.chainId < 0n || entry.chainId >= 2n ** 64n || !s || typeof s.nonce !== "bigint" || s.nonce < 0n || s.nonce >= 2n ** 256n || !address(s.account) || !address(s.smartSession) || !address(s.sessionValidator) || !hex(s.sessionValidatorInitData) || !hex(s.salt, 32) || !p || typeof p.permitGenericPolicy !== "boolean" || typeof p.permitAdminAccess !== "boolean" || typeof p.ignoreSecurityAttestations !== "boolean" || typeof p.permitERC4337Paymaster !== "boolean" || !policies(p.userOpPolicies) || !p.erc7739Policies || !policies(p.erc7739Policies.erc1271Policies) || !Array.isArray(p.erc7739Policies.allowedERC7739Content) || !p.erc7739Policies.allowedERC7739Content.every((c) => c && hex(c.appDomainSeparator, 32) && Array.isArray(c.contentName) && c.contentName.every((n) => typeof n === "string")) || !Array.isArray(p.actions) || !p.actions.every((a) => a && address(a.actionTarget) && hex(a.actionTargetSelector, 4) && policies(a.actionPolicies))) fail();
7400
+ }
7401
+ }
7402
+ function serializeV1ChainSessions(chainSessions) {
7403
+ validateV1ChainSessions(chainSessions);
7404
+ return JSON.stringify(chainSessions.map((entry) => ({
7405
+ ...entry,
7406
+ chainId: entry.chainId.toString(),
7407
+ session: { ...entry.session, nonce: entry.session.nonce.toString() }
7408
+ })), null, 2);
7409
+ }
7410
+ function parseV1ChainSessions(json) {
7411
+ const parsed = JSON.parse(json);
7412
+ if (!Array.isArray(parsed) || !parsed.length) throw new Error("Invalid v1 chain session payload");
7413
+ const decimal = (v) => typeof v === "string" && /^(0|[1-9][0-9]*)$/.test(v);
7414
+ const sessions = parsed.map((entry) => {
7415
+ if (!entry || !decimal(entry.chainId) || !entry.session || !decimal(entry.session.nonce)) {
7416
+ throw new Error("Chain IDs and nonces must be decimal strings");
7417
+ }
7418
+ return { ...entry, chainId: BigInt(entry.chainId), session: { ...entry.session, nonce: BigInt(entry.session.nonce) } };
7419
+ });
7420
+ validateV1ChainSessions(sessions);
7421
+ return sessions;
7422
+ }
7423
+ function hashV1SessionEnable(chainSessions) {
7424
+ validateV1ChainSessions(chainSessions);
7425
+ const permissionEnableHash = (0, import_module_sdk2.hashChainSessions)(chainSessions);
7426
+ return { permissionEnableHash, personalSignDigest: (0, import_viem7.hashMessage)({ raw: permissionEnableHash }) };
7427
+ }
7428
+
7429
+ // src/utils/userop-verification.ts
7430
+ var import_viem8 = require("viem");
7431
+ var ENTRY_POINT_V07_ADDRESS = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
7432
+ var KNOWN_CALLS_ABI = (0, import_viem8.parseAbi)([
7433
+ "function setupSafe((address singleton, address[] owners, uint256 threshold, address setupTo, bytes setupData, address safe7579, (address module, bytes initData)[] validators, bytes callData) initData)",
7434
+ "function execute(bytes32 mode, bytes executionCalldata)",
7435
+ "function setRegistry(address registry, address[] attesters, uint8 threshold)",
7436
+ "function installModule(uint256 moduleTypeId, address module, bytes initData)",
7437
+ "function enableSessions((address sessionValidator, bytes sessionValidatorInitData, bytes32 salt, (address policy, bytes initData)[] userOpPolicies, ((bytes32 appDomainSeparator, string[] contentName)[] allowedERC7739Content, (address policy, bytes initData)[] erc1271Policies) erc7739Policies, (bytes4 actionTargetSelector, address actionTarget, (address policy, bytes initData)[] actionPolicies)[] actions, bool permitERC4337Paymaster)[] sessions)"
7438
+ ]);
7439
+ var ERC7579_CALLTYPE_SINGLE = "0x00";
7440
+ var ERC7579_CALLTYPE_BATCH = "0x01";
7441
+ var INTEGER_FIELDS = [
7442
+ "nonce",
7443
+ "callGasLimit",
7444
+ "verificationGasLimit",
7445
+ "preVerificationGas",
7446
+ "maxFeePerGas",
7447
+ "maxPriorityFeePerGas",
7448
+ "paymasterVerificationGasLimit",
7449
+ "paymasterPostOpGasLimit"
7450
+ ];
7451
+ function parseUserOperationJson(json) {
7452
+ const raw = JSON.parse(json);
7453
+ const fail = () => {
7454
+ throw new Error("Invalid user operation JSON");
7455
+ };
7456
+ if (!raw || typeof raw !== "object") fail();
7457
+ const input = raw;
7458
+ const integer = (v) => typeof v === "string" && /^(0|[1-9][0-9]*|0x[0-9a-fA-F]+)$/.test(v) ? BigInt(v) : fail();
7459
+ const bytes = (v) => typeof v === "string" && (0, import_viem8.isHex)(v, { strict: true }) && v.length % 2 === 0 ? v : fail();
7460
+ const address = (v) => typeof v === "string" && (0, import_viem8.isAddress)(v, { strict: false }) ? v : fail();
7461
+ const op = {
7462
+ sender: address(input.sender),
7463
+ nonce: integer(input.nonce),
7464
+ callData: bytes(input.callData),
7465
+ callGasLimit: integer(input.callGasLimit),
7466
+ verificationGasLimit: integer(input.verificationGasLimit),
7467
+ preVerificationGas: integer(input.preVerificationGas),
7468
+ maxFeePerGas: integer(input.maxFeePerGas),
7469
+ maxPriorityFeePerGas: integer(input.maxPriorityFeePerGas)
7470
+ };
7471
+ if (input.factory !== void 0 && input.factory !== null) {
7472
+ op.factory = address(input.factory);
7473
+ op.factoryData = bytes(input.factoryData ?? "0x");
7474
+ }
7475
+ if (input.paymaster !== void 0 && input.paymaster !== null) {
7476
+ op.paymaster = address(input.paymaster);
7477
+ op.paymasterVerificationGasLimit = integer(input.paymasterVerificationGasLimit ?? "0");
7478
+ op.paymasterPostOpGasLimit = integer(input.paymasterPostOpGasLimit ?? "0");
7479
+ op.paymasterData = bytes(input.paymasterData ?? "0x");
7480
+ }
7481
+ for (const field of INTEGER_FIELDS) {
7482
+ const value = op[field];
7483
+ if (value !== void 0 && value >= 2n ** 256n) fail();
7484
+ }
7485
+ return op;
7486
+ }
7487
+ var uint128 = (value) => (0, import_viem8.numberToHex)(value, { size: 16 });
7488
+ function hashUserOperationV07(userOp, chainId, entryPoint = ENTRY_POINT_V07_ADDRESS) {
7489
+ const initCode = userOp.factory ? (0, import_viem8.concat)([userOp.factory, userOp.factoryData ?? "0x"]) : "0x";
7490
+ const paymasterAndData = userOp.paymaster ? (0, import_viem8.concat)([
7491
+ userOp.paymaster,
7492
+ uint128(userOp.paymasterVerificationGasLimit ?? 0n),
7493
+ uint128(userOp.paymasterPostOpGasLimit ?? 0n),
7494
+ userOp.paymasterData ?? "0x"
7495
+ ]) : "0x";
7496
+ const packed = (0, import_viem8.encodeAbiParameters)(
7497
+ [
7498
+ { type: "address" },
7499
+ { type: "uint256" },
7500
+ { type: "bytes32" },
7501
+ { type: "bytes32" },
7502
+ { type: "bytes32" },
7503
+ { type: "uint256" },
7504
+ { type: "bytes32" },
7505
+ { type: "bytes32" }
7506
+ ],
7507
+ [
7508
+ userOp.sender,
7509
+ userOp.nonce,
7510
+ (0, import_viem8.keccak256)(initCode),
7511
+ (0, import_viem8.keccak256)(userOp.callData),
7512
+ (0, import_viem8.concat)([uint128(userOp.verificationGasLimit), uint128(userOp.callGasLimit)]),
7513
+ userOp.preVerificationGas,
7514
+ (0, import_viem8.concat)([uint128(userOp.maxPriorityFeePerGas), uint128(userOp.maxFeePerGas)]),
7515
+ (0, import_viem8.keccak256)(paymasterAndData)
7516
+ ]
7517
+ );
7518
+ return (0, import_viem8.keccak256)(
7519
+ (0, import_viem8.encodeAbiParameters)(
7520
+ [{ type: "bytes32" }, { type: "address" }, { type: "uint256" }],
7521
+ [(0, import_viem8.keccak256)(packed), entryPoint, BigInt(chainId)]
7522
+ )
7523
+ );
7524
+ }
7525
+ function decodeCall(target, value, data) {
7526
+ const call = { target, value, selector: (0, import_viem8.size)(data) >= 4 ? (0, import_viem8.slice)(data, 0, 4) : "0x" };
7527
+ let decoded;
7528
+ try {
7529
+ decoded = (0, import_viem8.decodeFunctionData)({ abi: KNOWN_CALLS_ABI, data });
7530
+ } catch {
7531
+ return call;
7532
+ }
7533
+ call.functionName = decoded.functionName;
7534
+ call.args = decoded.args;
7535
+ if (decoded.functionName === "setupSafe") {
7536
+ const [initData] = decoded.args;
7537
+ call.calls = [decodeCall(target, 0n, initData.callData)];
7538
+ } else if (decoded.functionName === "execute") {
7539
+ const [mode, executionCalldata] = decoded.args;
7540
+ const callType = (0, import_viem8.slice)(mode, 0, 1);
7541
+ if (callType === ERC7579_CALLTYPE_BATCH) {
7542
+ const [executions] = (0, import_viem8.decodeAbiParameters)(
7543
+ [{ type: "tuple[]", components: [{ type: "address", name: "target" }, { type: "uint256", name: "value" }, { type: "bytes", name: "callData" }] }],
7544
+ executionCalldata
7545
+ );
7546
+ call.calls = executions.map((e) => decodeCall(e.target, e.value, e.callData));
7547
+ } else if (callType === ERC7579_CALLTYPE_SINGLE) {
7548
+ call.calls = [decodeCall(
7549
+ (0, import_viem8.slice)(executionCalldata, 0, 20),
7550
+ BigInt((0, import_viem8.slice)(executionCalldata, 20, 52)),
7551
+ (0, import_viem8.size)(executionCalldata) > 52 ? (0, import_viem8.slice)(executionCalldata, 52) : "0x"
7552
+ )];
7553
+ }
7554
+ }
7555
+ return call;
7556
+ }
7557
+ function decodeUserOperationCalls(userOp) {
7558
+ return decodeCall(userOp.sender, 0n, userOp.callData);
7559
+ }
7560
+
7341
7561
  // src/providers/bankr.ts
7342
7562
  function createBankrProvider(config) {
7343
7563
  const {
@@ -7511,6 +7731,7 @@ function createBankrProvider(config) {
7511
7731
  DATA_API_ENDPOINT,
7512
7732
  DEFAULT_RELAY_SLIPPAGE_BPS,
7513
7733
  DEFAULT_TOKEN_ADDRESSES,
7734
+ ENTRY_POINT_V07_ADDRESS,
7514
7735
  ERC7579_LAUNCHPAD_ADDRESS,
7515
7736
  EXECUTION_API_BASE_URLS,
7516
7737
  INTENT_EXECUTOR,
@@ -7533,7 +7754,9 @@ function createBankrProvider(config) {
7533
7754
  WS_ENDPOINT,
7534
7755
  WS_URLS,
7535
7756
  ZyfaiSDK,
7757
+ buildV1ChainSessions,
7536
7758
  createBankrProvider,
7759
+ decodeUserOperationCalls,
7537
7760
  getChainConfig,
7538
7761
  getDataApiBaseUrl,
7539
7762
  getDefaultTokenAddress,
@@ -7541,7 +7764,12 @@ function createBankrProvider(config) {
7541
7764
  getManagedAssets,
7542
7765
  getSupportedChainIds,
7543
7766
  getWsUrl,
7767
+ hashUserOperationV07,
7768
+ hashV1SessionEnable,
7544
7769
  isSupportedChain,
7770
+ parseUserOperationJson,
7771
+ parseV1ChainSessions,
7545
7772
  resolveDepositRoute,
7546
- resolveRelaySlippageBps
7773
+ resolveRelaySlippageBps,
7774
+ serializeV1ChainSessions
7547
7775
  });
package/dist/index.mjs CHANGED
@@ -113,7 +113,13 @@ var ENDPOINTS = {
113
113
  },
114
114
  // Customization
115
115
  CUSTOMIZE_BATCH: "/customization/customize-batch",
116
- CUSTOMIZATION_POOLS: (protocolId, strategy) => `/customization/pools?protocolId=${protocolId}${strategy ? `&strategy=${strategy}` : ""}`,
116
+ CUSTOMIZATION_POOLS: (protocolId, strategy, options) => {
117
+ const query = [`protocolId=${protocolId}`];
118
+ if (strategy) query.push(`strategy=${strategy}`);
119
+ if (options?.liveOnly) query.push("liveOnly=true");
120
+ if (options?.includeStatus) query.push("includeStatus=true");
121
+ return `/customization/pools?${query.join("&")}`;
122
+ },
117
123
  CUSTOMIZATION_SELECTED_POOLS: (protocolId, chainId) => `/customization/selected-pools?protocolId=${protocolId}&chainId=${chainId}`
118
124
  };
119
125
  var DATA_ENDPOINTS = {
@@ -5810,6 +5816,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
5810
5816
  if (options?.offset) endpoint += `&offset=${options.offset}`;
5811
5817
  if (options?.fromDate) endpoint += `&fromDate=${options.fromDate}`;
5812
5818
  if (options?.toDate) endpoint += `&toDate=${options.toDate}`;
5819
+ if (options?.rebalanceLegs) endpoint += `&rebalanceLegs=true`;
5813
5820
  const response = await this.httpClient.get(endpoint);
5814
5821
  const convertedData = convertStrategiesToPublic(
5815
5822
  response.data || []
@@ -6658,6 +6665,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
6658
6665
  *
6659
6666
  * @param protocolId - The protocol UUID
6660
6667
  * @param strategy - Optional {@link Strategy} filter
6668
+ * @param options - `liveOnly` omits not-live pools. `includeStatus` adds each pool's status. Both default off.
6661
6669
  * @returns List of available pool names
6662
6670
  *
6663
6671
  * @example
@@ -6673,7 +6681,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
6673
6681
  * );
6674
6682
  * ```
6675
6683
  */
6676
- async getAvailablePools(protocolId, strategy) {
6684
+ async getAvailablePools(protocolId, strategy, options) {
6677
6685
  try {
6678
6686
  let internalStrategy;
6679
6687
  if (strategy) {
@@ -6685,7 +6693,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
6685
6693
  internalStrategy = toInternalStrategy(strategy);
6686
6694
  }
6687
6695
  const response = await this.httpClient.get(
6688
- ENDPOINTS.CUSTOMIZATION_POOLS(protocolId, internalStrategy)
6696
+ ENDPOINTS.CUSTOMIZATION_POOLS(
6697
+ protocolId,
6698
+ internalStrategy,
6699
+ options
6700
+ )
6689
6701
  );
6690
6702
  return response;
6691
6703
  } catch (error) {
@@ -7296,6 +7308,218 @@ var _ZyfaiSDK = class _ZyfaiSDK {
7296
7308
  _ZyfaiSDK.IDENTITY_REGISTRY_CHAIN_IDS = [8453, 42161];
7297
7309
  var ZyfaiSDK = _ZyfaiSDK;
7298
7310
 
7311
+ // src/utils/session-verification.ts
7312
+ import { hashChainSessions } from "@rhinestone/module-sdk";
7313
+ import { hashMessage, isAddress, isHex, size } from "viem";
7314
+ function buildV1ChainSessions(inputs) {
7315
+ const chainSessions = inputs.map(({ account, smartSession, nonce, session, permitGenericPolicy, permitAdminAccess, ignoreSecurityAttestations }) => ({
7316
+ chainId: session.chainId,
7317
+ session: {
7318
+ account,
7319
+ smartSession,
7320
+ nonce,
7321
+ sessionValidator: session.sessionValidator,
7322
+ sessionValidatorInitData: session.sessionValidatorInitData,
7323
+ salt: session.salt,
7324
+ permissions: {
7325
+ permitGenericPolicy,
7326
+ permitAdminAccess,
7327
+ ignoreSecurityAttestations,
7328
+ permitERC4337Paymaster: session.permitERC4337Paymaster,
7329
+ userOpPolicies: session.userOpPolicies,
7330
+ erc7739Policies: session.erc7739Policies,
7331
+ actions: session.actions
7332
+ }
7333
+ }
7334
+ }));
7335
+ validateV1ChainSessions(chainSessions);
7336
+ return chainSessions;
7337
+ }
7338
+ function validateV1ChainSessions(sessions) {
7339
+ const fail = () => {
7340
+ throw new Error("Invalid v1 chain session payload");
7341
+ };
7342
+ const address = (v) => typeof v === "string" && isAddress(v);
7343
+ const hex = (v, bytes) => typeof v === "string" && isHex(v, { strict: true }) && v.length % 2 === 0 && (bytes === void 0 || size(v) === bytes);
7344
+ const policies = (v) => Array.isArray(v) && v.every((p) => p && address(p.policy) && hex(p.initData));
7345
+ if (!Array.isArray(sessions) || !sessions.length) fail();
7346
+ for (const entry of sessions) {
7347
+ const s = entry?.session;
7348
+ const p = s?.permissions;
7349
+ if (typeof entry?.chainId !== "bigint" || entry.chainId < 0n || entry.chainId >= 2n ** 64n || !s || typeof s.nonce !== "bigint" || s.nonce < 0n || s.nonce >= 2n ** 256n || !address(s.account) || !address(s.smartSession) || !address(s.sessionValidator) || !hex(s.sessionValidatorInitData) || !hex(s.salt, 32) || !p || typeof p.permitGenericPolicy !== "boolean" || typeof p.permitAdminAccess !== "boolean" || typeof p.ignoreSecurityAttestations !== "boolean" || typeof p.permitERC4337Paymaster !== "boolean" || !policies(p.userOpPolicies) || !p.erc7739Policies || !policies(p.erc7739Policies.erc1271Policies) || !Array.isArray(p.erc7739Policies.allowedERC7739Content) || !p.erc7739Policies.allowedERC7739Content.every((c) => c && hex(c.appDomainSeparator, 32) && Array.isArray(c.contentName) && c.contentName.every((n) => typeof n === "string")) || !Array.isArray(p.actions) || !p.actions.every((a) => a && address(a.actionTarget) && hex(a.actionTargetSelector, 4) && policies(a.actionPolicies))) fail();
7350
+ }
7351
+ }
7352
+ function serializeV1ChainSessions(chainSessions) {
7353
+ validateV1ChainSessions(chainSessions);
7354
+ return JSON.stringify(chainSessions.map((entry) => ({
7355
+ ...entry,
7356
+ chainId: entry.chainId.toString(),
7357
+ session: { ...entry.session, nonce: entry.session.nonce.toString() }
7358
+ })), null, 2);
7359
+ }
7360
+ function parseV1ChainSessions(json) {
7361
+ const parsed = JSON.parse(json);
7362
+ if (!Array.isArray(parsed) || !parsed.length) throw new Error("Invalid v1 chain session payload");
7363
+ const decimal = (v) => typeof v === "string" && /^(0|[1-9][0-9]*)$/.test(v);
7364
+ const sessions = parsed.map((entry) => {
7365
+ if (!entry || !decimal(entry.chainId) || !entry.session || !decimal(entry.session.nonce)) {
7366
+ throw new Error("Chain IDs and nonces must be decimal strings");
7367
+ }
7368
+ return { ...entry, chainId: BigInt(entry.chainId), session: { ...entry.session, nonce: BigInt(entry.session.nonce) } };
7369
+ });
7370
+ validateV1ChainSessions(sessions);
7371
+ return sessions;
7372
+ }
7373
+ function hashV1SessionEnable(chainSessions) {
7374
+ validateV1ChainSessions(chainSessions);
7375
+ const permissionEnableHash = hashChainSessions(chainSessions);
7376
+ return { permissionEnableHash, personalSignDigest: hashMessage({ raw: permissionEnableHash }) };
7377
+ }
7378
+
7379
+ // src/utils/userop-verification.ts
7380
+ import {
7381
+ concat,
7382
+ decodeAbiParameters,
7383
+ decodeFunctionData,
7384
+ encodeAbiParameters,
7385
+ isAddress as isAddress2,
7386
+ isHex as isHex2,
7387
+ keccak256,
7388
+ numberToHex,
7389
+ parseAbi as parseAbi2,
7390
+ size as size2,
7391
+ slice
7392
+ } from "viem";
7393
+ var ENTRY_POINT_V07_ADDRESS = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
7394
+ var KNOWN_CALLS_ABI = parseAbi2([
7395
+ "function setupSafe((address singleton, address[] owners, uint256 threshold, address setupTo, bytes setupData, address safe7579, (address module, bytes initData)[] validators, bytes callData) initData)",
7396
+ "function execute(bytes32 mode, bytes executionCalldata)",
7397
+ "function setRegistry(address registry, address[] attesters, uint8 threshold)",
7398
+ "function installModule(uint256 moduleTypeId, address module, bytes initData)",
7399
+ "function enableSessions((address sessionValidator, bytes sessionValidatorInitData, bytes32 salt, (address policy, bytes initData)[] userOpPolicies, ((bytes32 appDomainSeparator, string[] contentName)[] allowedERC7739Content, (address policy, bytes initData)[] erc1271Policies) erc7739Policies, (bytes4 actionTargetSelector, address actionTarget, (address policy, bytes initData)[] actionPolicies)[] actions, bool permitERC4337Paymaster)[] sessions)"
7400
+ ]);
7401
+ var ERC7579_CALLTYPE_SINGLE = "0x00";
7402
+ var ERC7579_CALLTYPE_BATCH = "0x01";
7403
+ var INTEGER_FIELDS = [
7404
+ "nonce",
7405
+ "callGasLimit",
7406
+ "verificationGasLimit",
7407
+ "preVerificationGas",
7408
+ "maxFeePerGas",
7409
+ "maxPriorityFeePerGas",
7410
+ "paymasterVerificationGasLimit",
7411
+ "paymasterPostOpGasLimit"
7412
+ ];
7413
+ function parseUserOperationJson(json) {
7414
+ const raw = JSON.parse(json);
7415
+ const fail = () => {
7416
+ throw new Error("Invalid user operation JSON");
7417
+ };
7418
+ if (!raw || typeof raw !== "object") fail();
7419
+ const input = raw;
7420
+ const integer = (v) => typeof v === "string" && /^(0|[1-9][0-9]*|0x[0-9a-fA-F]+)$/.test(v) ? BigInt(v) : fail();
7421
+ const bytes = (v) => typeof v === "string" && isHex2(v, { strict: true }) && v.length % 2 === 0 ? v : fail();
7422
+ const address = (v) => typeof v === "string" && isAddress2(v, { strict: false }) ? v : fail();
7423
+ const op = {
7424
+ sender: address(input.sender),
7425
+ nonce: integer(input.nonce),
7426
+ callData: bytes(input.callData),
7427
+ callGasLimit: integer(input.callGasLimit),
7428
+ verificationGasLimit: integer(input.verificationGasLimit),
7429
+ preVerificationGas: integer(input.preVerificationGas),
7430
+ maxFeePerGas: integer(input.maxFeePerGas),
7431
+ maxPriorityFeePerGas: integer(input.maxPriorityFeePerGas)
7432
+ };
7433
+ if (input.factory !== void 0 && input.factory !== null) {
7434
+ op.factory = address(input.factory);
7435
+ op.factoryData = bytes(input.factoryData ?? "0x");
7436
+ }
7437
+ if (input.paymaster !== void 0 && input.paymaster !== null) {
7438
+ op.paymaster = address(input.paymaster);
7439
+ op.paymasterVerificationGasLimit = integer(input.paymasterVerificationGasLimit ?? "0");
7440
+ op.paymasterPostOpGasLimit = integer(input.paymasterPostOpGasLimit ?? "0");
7441
+ op.paymasterData = bytes(input.paymasterData ?? "0x");
7442
+ }
7443
+ for (const field of INTEGER_FIELDS) {
7444
+ const value = op[field];
7445
+ if (value !== void 0 && value >= 2n ** 256n) fail();
7446
+ }
7447
+ return op;
7448
+ }
7449
+ var uint128 = (value) => numberToHex(value, { size: 16 });
7450
+ function hashUserOperationV07(userOp, chainId, entryPoint = ENTRY_POINT_V07_ADDRESS) {
7451
+ const initCode = userOp.factory ? concat([userOp.factory, userOp.factoryData ?? "0x"]) : "0x";
7452
+ const paymasterAndData = userOp.paymaster ? concat([
7453
+ userOp.paymaster,
7454
+ uint128(userOp.paymasterVerificationGasLimit ?? 0n),
7455
+ uint128(userOp.paymasterPostOpGasLimit ?? 0n),
7456
+ userOp.paymasterData ?? "0x"
7457
+ ]) : "0x";
7458
+ const packed = encodeAbiParameters(
7459
+ [
7460
+ { type: "address" },
7461
+ { type: "uint256" },
7462
+ { type: "bytes32" },
7463
+ { type: "bytes32" },
7464
+ { type: "bytes32" },
7465
+ { type: "uint256" },
7466
+ { type: "bytes32" },
7467
+ { type: "bytes32" }
7468
+ ],
7469
+ [
7470
+ userOp.sender,
7471
+ userOp.nonce,
7472
+ keccak256(initCode),
7473
+ keccak256(userOp.callData),
7474
+ concat([uint128(userOp.verificationGasLimit), uint128(userOp.callGasLimit)]),
7475
+ userOp.preVerificationGas,
7476
+ concat([uint128(userOp.maxPriorityFeePerGas), uint128(userOp.maxFeePerGas)]),
7477
+ keccak256(paymasterAndData)
7478
+ ]
7479
+ );
7480
+ return keccak256(
7481
+ encodeAbiParameters(
7482
+ [{ type: "bytes32" }, { type: "address" }, { type: "uint256" }],
7483
+ [keccak256(packed), entryPoint, BigInt(chainId)]
7484
+ )
7485
+ );
7486
+ }
7487
+ function decodeCall(target, value, data) {
7488
+ const call = { target, value, selector: size2(data) >= 4 ? slice(data, 0, 4) : "0x" };
7489
+ let decoded;
7490
+ try {
7491
+ decoded = decodeFunctionData({ abi: KNOWN_CALLS_ABI, data });
7492
+ } catch {
7493
+ return call;
7494
+ }
7495
+ call.functionName = decoded.functionName;
7496
+ call.args = decoded.args;
7497
+ if (decoded.functionName === "setupSafe") {
7498
+ const [initData] = decoded.args;
7499
+ call.calls = [decodeCall(target, 0n, initData.callData)];
7500
+ } else if (decoded.functionName === "execute") {
7501
+ const [mode, executionCalldata] = decoded.args;
7502
+ const callType = slice(mode, 0, 1);
7503
+ if (callType === ERC7579_CALLTYPE_BATCH) {
7504
+ const [executions] = decodeAbiParameters(
7505
+ [{ type: "tuple[]", components: [{ type: "address", name: "target" }, { type: "uint256", name: "value" }, { type: "bytes", name: "callData" }] }],
7506
+ executionCalldata
7507
+ );
7508
+ call.calls = executions.map((e) => decodeCall(e.target, e.value, e.callData));
7509
+ } else if (callType === ERC7579_CALLTYPE_SINGLE) {
7510
+ call.calls = [decodeCall(
7511
+ slice(executionCalldata, 0, 20),
7512
+ BigInt(slice(executionCalldata, 20, 52)),
7513
+ size2(executionCalldata) > 52 ? slice(executionCalldata, 52) : "0x"
7514
+ )];
7515
+ }
7516
+ }
7517
+ return call;
7518
+ }
7519
+ function decodeUserOperationCalls(userOp) {
7520
+ return decodeCall(userOp.sender, 0n, userOp.callData);
7521
+ }
7522
+
7299
7523
  // src/providers/bankr.ts
7300
7524
  function createBankrProvider(config) {
7301
7525
  const {
@@ -7468,6 +7692,7 @@ export {
7468
7692
  DATA_API_ENDPOINT,
7469
7693
  DEFAULT_RELAY_SLIPPAGE_BPS,
7470
7694
  DEFAULT_TOKEN_ADDRESSES,
7695
+ ENTRY_POINT_V07_ADDRESS,
7471
7696
  ERC7579_LAUNCHPAD_ADDRESS,
7472
7697
  EXECUTION_API_BASE_URLS,
7473
7698
  INTENT_EXECUTOR,
@@ -7490,7 +7715,9 @@ export {
7490
7715
  WS_ENDPOINT,
7491
7716
  WS_URLS,
7492
7717
  ZyfaiSDK,
7718
+ buildV1ChainSessions,
7493
7719
  createBankrProvider,
7720
+ decodeUserOperationCalls,
7494
7721
  getChainConfig,
7495
7722
  getDataApiBaseUrl,
7496
7723
  getDefaultTokenAddress,
@@ -7498,7 +7725,12 @@ export {
7498
7725
  getManagedAssets,
7499
7726
  getSupportedChainIds,
7500
7727
  getWsUrl,
7728
+ hashUserOperationV07,
7729
+ hashV1SessionEnable,
7501
7730
  isSupportedChain,
7731
+ parseUserOperationJson,
7732
+ parseV1ChainSessions,
7502
7733
  resolveDepositRoute,
7503
- resolveRelaySlippageBps
7734
+ resolveRelaySlippageBps,
7735
+ serializeV1ChainSessions
7504
7736
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "1.3.2",
3
+ "version": "1.5.0",
4
4
  "description": "TypeScript SDK for self-custodial Zyfai yield agents: discover DeFi opportunities and manage deposits, withdrawals, positions, and strategies across Ethereum, Base, and Arbitrum",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",