@zyfai/sdk 0.2.41 → 0.2.43
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 +19 -0
- package/dist/index.d.mts +82 -2
- package/dist/index.d.ts +82 -2
- package/dist/index.js +112 -43
- package/dist/index.mjs +103 -43
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,6 +100,25 @@ This method:
|
|
|
100
100
|
|
|
101
101
|
## Core Features
|
|
102
102
|
|
|
103
|
+
> **Predeployed (pool) wallets.** Wallets provisioned by ZyFi's predeployment
|
|
104
|
+
> service are already deployed, already have the agent session enabled, and are
|
|
105
|
+
> backend-owned until the user's first deposit rotates ownership to them. The SDK
|
|
106
|
+
> detects these automatically from the sign-in response (`predeployed: true`) and
|
|
107
|
+
> adjusts, with no extra flags from the integrator:
|
|
108
|
+
>
|
|
109
|
+
> - `deploySafe()` returns the assigned wallet without sending a deploy tx.
|
|
110
|
+
> - `createSessionKey()` returns `{ alreadyActive: true }` without prompting a
|
|
111
|
+
> signature — the pool enabled the session at deploy time.
|
|
112
|
+
> - The address is always the backend-assigned one; it is **never** derived with
|
|
113
|
+
> `getDeterministicSafeAddress`.
|
|
114
|
+
>
|
|
115
|
+
> Net effect: onboarding a predeployed wallet takes a **single signature — the
|
|
116
|
+
> USDC deposit** (no wallet-deploy or session-key signatures).
|
|
117
|
+
>
|
|
118
|
+
> The pool's ERC-7579 module addresses are exported as reference constants
|
|
119
|
+
> (`POOL_MODULE_ADDRESSES`, `INTENT_SMART_SESSIONS`, `PROXY_EXECUTOR`, …) for
|
|
120
|
+
> parity/validation only — the SDK does not install them.
|
|
121
|
+
|
|
103
122
|
### 1. Deploy Safe Smart Wallet
|
|
104
123
|
|
|
105
124
|
Deploy a Safe smart wallet:
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chain, PublicClient } from 'viem';
|
|
1
|
+
import { Chain, PublicClient, Address as Address$1 } from 'viem';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Zyfai SDK Types
|
|
@@ -436,6 +436,7 @@ interface SimulateBestPositionsParams {
|
|
|
436
436
|
protocols?: string[];
|
|
437
437
|
pools?: string[];
|
|
438
438
|
userPositions?: UserPosition[];
|
|
439
|
+
partOfZyfiTvl?: boolean;
|
|
439
440
|
}
|
|
440
441
|
interface SimulateCalldataItem {
|
|
441
442
|
contract_address: Address;
|
|
@@ -444,9 +445,17 @@ interface SimulateCalldataItem {
|
|
|
444
445
|
value: string;
|
|
445
446
|
description: string;
|
|
446
447
|
}
|
|
448
|
+
interface AllocationDetail {
|
|
449
|
+
pool_capacity_usd: number;
|
|
450
|
+
zyfi_position_usd: number;
|
|
451
|
+
available_capacity_usd: number;
|
|
452
|
+
fair_share_usd: number;
|
|
453
|
+
overflow_usd: number;
|
|
454
|
+
}
|
|
447
455
|
interface SimulatedPosition {
|
|
448
456
|
protocol: string;
|
|
449
457
|
pool: string;
|
|
458
|
+
rank: number;
|
|
450
459
|
simulated_apy: number;
|
|
451
460
|
combined_apy: number;
|
|
452
461
|
amount: number;
|
|
@@ -455,11 +464,20 @@ interface SimulatedPosition {
|
|
|
455
464
|
tvl: number;
|
|
456
465
|
liquidity: number;
|
|
457
466
|
averageCombinedApy30Days: number;
|
|
467
|
+
allocation_detail: AllocationDetail;
|
|
458
468
|
calldata: SimulateCalldataItem[];
|
|
459
469
|
}
|
|
470
|
+
interface ExcludedPool {
|
|
471
|
+
protocol: string;
|
|
472
|
+
pool: string;
|
|
473
|
+
reason: string;
|
|
474
|
+
detail: string;
|
|
475
|
+
failed_checks?: string[];
|
|
476
|
+
}
|
|
460
477
|
interface SimulateBestPositionsResponse {
|
|
461
478
|
success: boolean;
|
|
462
479
|
data: Record<string, SimulatedPosition[]>;
|
|
480
|
+
excluded: Record<string, ExcludedPool[]>;
|
|
463
481
|
messages: Record<string, string>;
|
|
464
482
|
}
|
|
465
483
|
interface OpportunityPosition {
|
|
@@ -675,6 +693,8 @@ declare class ZyfaiSDK {
|
|
|
675
693
|
private walletClient;
|
|
676
694
|
private authenticatedUserId;
|
|
677
695
|
private hasActiveSessionKey;
|
|
696
|
+
private isPredeployed;
|
|
697
|
+
private connectedSmartWallet;
|
|
678
698
|
private currentProvider;
|
|
679
699
|
private currentChainId;
|
|
680
700
|
private rpcUrls?;
|
|
@@ -856,6 +876,22 @@ declare class ZyfaiSDK {
|
|
|
856
876
|
* @private
|
|
857
877
|
*/
|
|
858
878
|
private getWalletClient;
|
|
879
|
+
/**
|
|
880
|
+
* True when userAddress is the currently connected/authenticated wallet.
|
|
881
|
+
* @private
|
|
882
|
+
*/
|
|
883
|
+
private isConnectedUser;
|
|
884
|
+
/**
|
|
885
|
+
* Resolve the Safe smart wallet address for a user on a chain.
|
|
886
|
+
*
|
|
887
|
+
* Predeployed (pool) wallets are provisioned and owned by the backend at
|
|
888
|
+
* deploy time, so their address CANNOT be derived from the user's EOA with
|
|
889
|
+
* getDeterministicSafeAddress (CREATE2 from the EOA yields the wrong address).
|
|
890
|
+
* For the connected predeployed user we always use the backend-assigned
|
|
891
|
+
* address. Legacy wallets keep the API-first, deterministic-fallback behavior.
|
|
892
|
+
* @private
|
|
893
|
+
*/
|
|
894
|
+
private getSafeAddressFor;
|
|
859
895
|
/**
|
|
860
896
|
* Get smart wallet address for a user
|
|
861
897
|
* Returns the deterministic Safe address for an EOA, or the address itself if already a Safe
|
|
@@ -1695,4 +1731,48 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
|
|
|
1695
1731
|
|
|
1696
1732
|
declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
|
|
1697
1733
|
|
|
1698
|
-
|
|
1734
|
+
/**
|
|
1735
|
+
* Predeployment (pool) module addresses — reference constants.
|
|
1736
|
+
*
|
|
1737
|
+
* These mirror the ERC-7579 module set that ZyFi's predeployment service installs
|
|
1738
|
+
* on a pool smart account. Source of truth: the predeployment repo
|
|
1739
|
+
* `src/infrastructure/chain/modules.ts` — keep these in sync with it.
|
|
1740
|
+
*
|
|
1741
|
+
* FOR PARITY / VALIDATION AND DOCUMENTATION ONLY. The SDK does not install
|
|
1742
|
+
* modules on-chain: legacy wallets are deployed by the backend (SAFE_DEPLOY) and
|
|
1743
|
+
* predeployed wallets are provisioned by the pool. Nothing in the SDK reads these
|
|
1744
|
+
* to build, sign, or derive transactions. They are hardcoded (not recomputed via
|
|
1745
|
+
* `@rhinestone/module-sdk`) on purpose — see SMART_SESSIONS_VALIDATOR below.
|
|
1746
|
+
*/
|
|
1747
|
+
|
|
1748
|
+
/**
|
|
1749
|
+
* Classic SmartSessions validator (installed empty, session enabled later).
|
|
1750
|
+
*
|
|
1751
|
+
* IMPORTANT: this address is VERSION-DEPENDENT. The pool runs
|
|
1752
|
+
* `@rhinestone/module-sdk` 0.4.0, which yields this address; the SDK's local
|
|
1753
|
+
* 0.2.11 yields the older `0x00000000002B0eCfbD0496EE71e01257dA0E37DE`. We pin
|
|
1754
|
+
* the pool's value so the two never silently diverge.
|
|
1755
|
+
*/
|
|
1756
|
+
declare const SMART_SESSIONS_VALIDATOR: Address$1;
|
|
1757
|
+
/** ERC-7739 compatibility fallback (selector 0x84b0196e). */
|
|
1758
|
+
declare const SMART_SESSIONS_FALLBACK: Address$1;
|
|
1759
|
+
/** Intent (SmartSession v1) executor. */
|
|
1760
|
+
declare const INTENT_EXECUTOR: Address$1;
|
|
1761
|
+
/** Proxy executor used by the intent / omni-account session profile. */
|
|
1762
|
+
declare const PROXY_EXECUTOR: Address$1;
|
|
1763
|
+
/** Intent smart-sessions validator — the emissary the pool enables via setConfig. */
|
|
1764
|
+
declare const INTENT_SMART_SESSIONS: Address$1;
|
|
1765
|
+
/** OwnableValidator — the module whose owner set is rotated to the user on deposit. */
|
|
1766
|
+
declare const OWNABLE_VALIDATOR: Address$1;
|
|
1767
|
+
/** Safe 7579 adapter — matches the pool; already used by the SDK for deploys. */
|
|
1768
|
+
declare const SAFE_7579_ADDRESS: Address$1;
|
|
1769
|
+
/** ERC-7579 launchpad — matches the pool; already used by the SDK for deploys. */
|
|
1770
|
+
declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
1771
|
+
/**
|
|
1772
|
+
* The full module set a predeployed (pool) wallet carries, for validation.
|
|
1773
|
+
* Mirrors predeployment `DEFAULT_MODULES` plus OwnableValidator (the latter is
|
|
1774
|
+
* installed by the Rhinestone SDK at deploy, not in the provisioning batch).
|
|
1775
|
+
*/
|
|
1776
|
+
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
1777
|
+
|
|
1778
|
+
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, type LiquidityDropEvent, type LogDepositResponse, 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, type RebalanceFrequencyResponse, type RegisterAgentResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chain, PublicClient } from 'viem';
|
|
1
|
+
import { Chain, PublicClient, Address as Address$1 } from 'viem';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Zyfai SDK Types
|
|
@@ -436,6 +436,7 @@ interface SimulateBestPositionsParams {
|
|
|
436
436
|
protocols?: string[];
|
|
437
437
|
pools?: string[];
|
|
438
438
|
userPositions?: UserPosition[];
|
|
439
|
+
partOfZyfiTvl?: boolean;
|
|
439
440
|
}
|
|
440
441
|
interface SimulateCalldataItem {
|
|
441
442
|
contract_address: Address;
|
|
@@ -444,9 +445,17 @@ interface SimulateCalldataItem {
|
|
|
444
445
|
value: string;
|
|
445
446
|
description: string;
|
|
446
447
|
}
|
|
448
|
+
interface AllocationDetail {
|
|
449
|
+
pool_capacity_usd: number;
|
|
450
|
+
zyfi_position_usd: number;
|
|
451
|
+
available_capacity_usd: number;
|
|
452
|
+
fair_share_usd: number;
|
|
453
|
+
overflow_usd: number;
|
|
454
|
+
}
|
|
447
455
|
interface SimulatedPosition {
|
|
448
456
|
protocol: string;
|
|
449
457
|
pool: string;
|
|
458
|
+
rank: number;
|
|
450
459
|
simulated_apy: number;
|
|
451
460
|
combined_apy: number;
|
|
452
461
|
amount: number;
|
|
@@ -455,11 +464,20 @@ interface SimulatedPosition {
|
|
|
455
464
|
tvl: number;
|
|
456
465
|
liquidity: number;
|
|
457
466
|
averageCombinedApy30Days: number;
|
|
467
|
+
allocation_detail: AllocationDetail;
|
|
458
468
|
calldata: SimulateCalldataItem[];
|
|
459
469
|
}
|
|
470
|
+
interface ExcludedPool {
|
|
471
|
+
protocol: string;
|
|
472
|
+
pool: string;
|
|
473
|
+
reason: string;
|
|
474
|
+
detail: string;
|
|
475
|
+
failed_checks?: string[];
|
|
476
|
+
}
|
|
460
477
|
interface SimulateBestPositionsResponse {
|
|
461
478
|
success: boolean;
|
|
462
479
|
data: Record<string, SimulatedPosition[]>;
|
|
480
|
+
excluded: Record<string, ExcludedPool[]>;
|
|
463
481
|
messages: Record<string, string>;
|
|
464
482
|
}
|
|
465
483
|
interface OpportunityPosition {
|
|
@@ -675,6 +693,8 @@ declare class ZyfaiSDK {
|
|
|
675
693
|
private walletClient;
|
|
676
694
|
private authenticatedUserId;
|
|
677
695
|
private hasActiveSessionKey;
|
|
696
|
+
private isPredeployed;
|
|
697
|
+
private connectedSmartWallet;
|
|
678
698
|
private currentProvider;
|
|
679
699
|
private currentChainId;
|
|
680
700
|
private rpcUrls?;
|
|
@@ -856,6 +876,22 @@ declare class ZyfaiSDK {
|
|
|
856
876
|
* @private
|
|
857
877
|
*/
|
|
858
878
|
private getWalletClient;
|
|
879
|
+
/**
|
|
880
|
+
* True when userAddress is the currently connected/authenticated wallet.
|
|
881
|
+
* @private
|
|
882
|
+
*/
|
|
883
|
+
private isConnectedUser;
|
|
884
|
+
/**
|
|
885
|
+
* Resolve the Safe smart wallet address for a user on a chain.
|
|
886
|
+
*
|
|
887
|
+
* Predeployed (pool) wallets are provisioned and owned by the backend at
|
|
888
|
+
* deploy time, so their address CANNOT be derived from the user's EOA with
|
|
889
|
+
* getDeterministicSafeAddress (CREATE2 from the EOA yields the wrong address).
|
|
890
|
+
* For the connected predeployed user we always use the backend-assigned
|
|
891
|
+
* address. Legacy wallets keep the API-first, deterministic-fallback behavior.
|
|
892
|
+
* @private
|
|
893
|
+
*/
|
|
894
|
+
private getSafeAddressFor;
|
|
859
895
|
/**
|
|
860
896
|
* Get smart wallet address for a user
|
|
861
897
|
* Returns the deterministic Safe address for an EOA, or the address itself if already a Safe
|
|
@@ -1695,4 +1731,48 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
|
|
|
1695
1731
|
|
|
1696
1732
|
declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
|
|
1697
1733
|
|
|
1698
|
-
|
|
1734
|
+
/**
|
|
1735
|
+
* Predeployment (pool) module addresses — reference constants.
|
|
1736
|
+
*
|
|
1737
|
+
* These mirror the ERC-7579 module set that ZyFi's predeployment service installs
|
|
1738
|
+
* on a pool smart account. Source of truth: the predeployment repo
|
|
1739
|
+
* `src/infrastructure/chain/modules.ts` — keep these in sync with it.
|
|
1740
|
+
*
|
|
1741
|
+
* FOR PARITY / VALIDATION AND DOCUMENTATION ONLY. The SDK does not install
|
|
1742
|
+
* modules on-chain: legacy wallets are deployed by the backend (SAFE_DEPLOY) and
|
|
1743
|
+
* predeployed wallets are provisioned by the pool. Nothing in the SDK reads these
|
|
1744
|
+
* to build, sign, or derive transactions. They are hardcoded (not recomputed via
|
|
1745
|
+
* `@rhinestone/module-sdk`) on purpose — see SMART_SESSIONS_VALIDATOR below.
|
|
1746
|
+
*/
|
|
1747
|
+
|
|
1748
|
+
/**
|
|
1749
|
+
* Classic SmartSessions validator (installed empty, session enabled later).
|
|
1750
|
+
*
|
|
1751
|
+
* IMPORTANT: this address is VERSION-DEPENDENT. The pool runs
|
|
1752
|
+
* `@rhinestone/module-sdk` 0.4.0, which yields this address; the SDK's local
|
|
1753
|
+
* 0.2.11 yields the older `0x00000000002B0eCfbD0496EE71e01257dA0E37DE`. We pin
|
|
1754
|
+
* the pool's value so the two never silently diverge.
|
|
1755
|
+
*/
|
|
1756
|
+
declare const SMART_SESSIONS_VALIDATOR: Address$1;
|
|
1757
|
+
/** ERC-7739 compatibility fallback (selector 0x84b0196e). */
|
|
1758
|
+
declare const SMART_SESSIONS_FALLBACK: Address$1;
|
|
1759
|
+
/** Intent (SmartSession v1) executor. */
|
|
1760
|
+
declare const INTENT_EXECUTOR: Address$1;
|
|
1761
|
+
/** Proxy executor used by the intent / omni-account session profile. */
|
|
1762
|
+
declare const PROXY_EXECUTOR: Address$1;
|
|
1763
|
+
/** Intent smart-sessions validator — the emissary the pool enables via setConfig. */
|
|
1764
|
+
declare const INTENT_SMART_SESSIONS: Address$1;
|
|
1765
|
+
/** OwnableValidator — the module whose owner set is rotated to the user on deposit. */
|
|
1766
|
+
declare const OWNABLE_VALIDATOR: Address$1;
|
|
1767
|
+
/** Safe 7579 adapter — matches the pool; already used by the SDK for deploys. */
|
|
1768
|
+
declare const SAFE_7579_ADDRESS: Address$1;
|
|
1769
|
+
/** ERC-7579 launchpad — matches the pool; already used by the SDK for deploys. */
|
|
1770
|
+
declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
1771
|
+
/**
|
|
1772
|
+
* The full module set a predeployed (pool) wallet carries, for validation.
|
|
1773
|
+
* Mirrors predeployment `DEFAULT_MODULES` plus OwnableValidator (the latter is
|
|
1774
|
+
* installed by the Rhinestone SDK at deploy, not in the provisioning batch).
|
|
1775
|
+
*/
|
|
1776
|
+
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
1777
|
+
|
|
1778
|
+
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, type LiquidityDropEvent, type LogDepositResponse, 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, type RebalanceFrequencyResponse, type RegisterAgentResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
DEFAULT_TOKEN_ADDRESSES: () => DEFAULT_TOKEN_ADDRESSES,
|
|
34
|
+
ERC7579_LAUNCHPAD_ADDRESS: () => ERC7579_LAUNCHPAD_ADDRESS2,
|
|
35
|
+
INTENT_EXECUTOR: () => INTENT_EXECUTOR,
|
|
36
|
+
INTENT_SMART_SESSIONS: () => INTENT_SMART_SESSIONS,
|
|
37
|
+
OWNABLE_VALIDATOR: () => OWNABLE_VALIDATOR,
|
|
38
|
+
POOL_MODULE_ADDRESSES: () => POOL_MODULE_ADDRESSES,
|
|
39
|
+
PROXY_EXECUTOR: () => PROXY_EXECUTOR,
|
|
40
|
+
SAFE_7579_ADDRESS: () => SAFE_7579_ADDRESS2,
|
|
41
|
+
SMART_SESSIONS_FALLBACK: () => SMART_SESSIONS_FALLBACK,
|
|
42
|
+
SMART_SESSIONS_VALIDATOR: () => SMART_SESSIONS_VALIDATOR,
|
|
34
43
|
VAULT_ADDRESS: () => VAULT_ADDRESS,
|
|
35
44
|
ZyfaiSDK: () => ZyfaiSDK,
|
|
36
45
|
createBankrProvider: () => createBankrProvider,
|
|
@@ -94,6 +103,7 @@ var ENDPOINTS = {
|
|
|
94
103
|
if (params.protocols?.length) query.push(`protocols=${params.protocols.join(",")}`);
|
|
95
104
|
if (params.pools?.length) query.push(`pools=${params.pools.join(",")}`);
|
|
96
105
|
if (params.userPositions?.length) query.push(`userPositions=${encodeURIComponent(JSON.stringify(params.userPositions))}`);
|
|
106
|
+
if (params.partOfZyfiTvl !== void 0) query.push(`partOfZyfiTvl=${params.partOfZyfiTvl}`);
|
|
97
107
|
return `/simulate/best-positions?${query.join("&")}`;
|
|
98
108
|
},
|
|
99
109
|
// Customization
|
|
@@ -962,6 +972,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
962
972
|
this.walletClient = null;
|
|
963
973
|
this.authenticatedUserId = null;
|
|
964
974
|
this.hasActiveSessionKey = false;
|
|
975
|
+
this.isPredeployed = false;
|
|
976
|
+
this.connectedSmartWallet = null;
|
|
965
977
|
this.currentProvider = null;
|
|
966
978
|
this.currentChainId = null;
|
|
967
979
|
const sdkConfig = typeof config === "string" ? { apiKey: config } : config;
|
|
@@ -1036,6 +1048,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1036
1048
|
this.httpClient.setAuthToken(authToken);
|
|
1037
1049
|
this.authenticatedUserId = loginResponse.userId || null;
|
|
1038
1050
|
this.hasActiveSessionKey = loginResponse.hasActiveSessionKey || false;
|
|
1051
|
+
this.isPredeployed = loginResponse.predeployed || false;
|
|
1052
|
+
this.connectedSmartWallet = loginResponse.smartWallet || null;
|
|
1039
1053
|
} catch (error) {
|
|
1040
1054
|
throw new Error(
|
|
1041
1055
|
`Failed to authenticate user: ${error.message}`
|
|
@@ -1378,6 +1392,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1378
1392
|
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
1379
1393
|
}
|
|
1380
1394
|
this.authenticatedUserId = null;
|
|
1395
|
+
this.isPredeployed = false;
|
|
1396
|
+
this.connectedSmartWallet = null;
|
|
1381
1397
|
this.currentChainId = null;
|
|
1382
1398
|
this.httpClient.clearAuthToken();
|
|
1383
1399
|
if (this.currentProvider?.removeAllListeners) {
|
|
@@ -1468,6 +1484,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1468
1484
|
this.currentChainId = null;
|
|
1469
1485
|
this.authenticatedUserId = null;
|
|
1470
1486
|
this.hasActiveSessionKey = false;
|
|
1487
|
+
this.isPredeployed = false;
|
|
1488
|
+
this.connectedSmartWallet = null;
|
|
1471
1489
|
this.httpClient.clearAuthToken();
|
|
1472
1490
|
}
|
|
1473
1491
|
/**
|
|
@@ -1493,6 +1511,48 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1493
1511
|
return this.walletClient;
|
|
1494
1512
|
}
|
|
1495
1513
|
}
|
|
1514
|
+
/**
|
|
1515
|
+
* True when userAddress is the currently connected/authenticated wallet.
|
|
1516
|
+
* @private
|
|
1517
|
+
*/
|
|
1518
|
+
isConnectedUser(userAddress) {
|
|
1519
|
+
const connected = this.signer?.address ?? this.walletClient?.account?.address;
|
|
1520
|
+
return !!connected && connected.toLowerCase() === userAddress.toLowerCase();
|
|
1521
|
+
}
|
|
1522
|
+
/**
|
|
1523
|
+
* Resolve the Safe smart wallet address for a user on a chain.
|
|
1524
|
+
*
|
|
1525
|
+
* Predeployed (pool) wallets are provisioned and owned by the backend at
|
|
1526
|
+
* deploy time, so their address CANNOT be derived from the user's EOA with
|
|
1527
|
+
* getDeterministicSafeAddress (CREATE2 from the EOA yields the wrong address).
|
|
1528
|
+
* For the connected predeployed user we always use the backend-assigned
|
|
1529
|
+
* address. Legacy wallets keep the API-first, deterministic-fallback behavior.
|
|
1530
|
+
* @private
|
|
1531
|
+
*/
|
|
1532
|
+
async getSafeAddressFor(userAddress, chainId) {
|
|
1533
|
+
if (this.isPredeployed && this.isConnectedUser(userAddress)) {
|
|
1534
|
+
if (this.connectedSmartWallet) return this.connectedSmartWallet;
|
|
1535
|
+
try {
|
|
1536
|
+
const info = await this.getSmartWalletByEOA(userAddress);
|
|
1537
|
+
if (info.smartWallet) return info.smartWallet;
|
|
1538
|
+
} catch {
|
|
1539
|
+
}
|
|
1540
|
+
throw new Error(
|
|
1541
|
+
"Predeployed smart wallet address is not available from the API yet. Ensure the user has signed in so the pool can reserve their wallet."
|
|
1542
|
+
);
|
|
1543
|
+
}
|
|
1544
|
+
try {
|
|
1545
|
+
const info = await this.getSmartWalletByEOA(userAddress);
|
|
1546
|
+
if (info.smartWallet) return info.smartWallet;
|
|
1547
|
+
} catch {
|
|
1548
|
+
}
|
|
1549
|
+
const chainConfig = getChainConfig(chainId, this.rpcUrls);
|
|
1550
|
+
return getDeterministicSafeAddress({
|
|
1551
|
+
safeOwnerAddress: userAddress,
|
|
1552
|
+
chain: chainConfig.chain,
|
|
1553
|
+
publicClient: chainConfig.publicClient
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1496
1556
|
/**
|
|
1497
1557
|
* Get smart wallet address for a user
|
|
1498
1558
|
* Returns the deterministic Safe address for an EOA, or the address itself if already a Safe
|
|
@@ -1509,25 +1569,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1509
1569
|
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
1510
1570
|
}
|
|
1511
1571
|
const chainConfig = getChainConfig(chainId, this.rpcUrls);
|
|
1512
|
-
|
|
1513
|
-
const smartWalletInfo = await this.getSmartWalletByEOA(userAddress);
|
|
1514
|
-
if (smartWalletInfo.smartWallet) {
|
|
1515
|
-
const isDeployed2 = await isSafeDeployed(
|
|
1516
|
-
smartWalletInfo.smartWallet,
|
|
1517
|
-
chainConfig.publicClient
|
|
1518
|
-
);
|
|
1519
|
-
return {
|
|
1520
|
-
address: smartWalletInfo.smartWallet,
|
|
1521
|
-
isDeployed: isDeployed2
|
|
1522
|
-
};
|
|
1523
|
-
}
|
|
1524
|
-
} catch {
|
|
1525
|
-
}
|
|
1526
|
-
const safeAddress = await getDeterministicSafeAddress({
|
|
1527
|
-
safeOwnerAddress: userAddress,
|
|
1528
|
-
chain: chainConfig.chain,
|
|
1529
|
-
publicClient: chainConfig.publicClient
|
|
1530
|
-
});
|
|
1572
|
+
const safeAddress = await this.getSafeAddressFor(userAddress, chainId);
|
|
1531
1573
|
const isDeployed = await isSafeDeployed(
|
|
1532
1574
|
safeAddress,
|
|
1533
1575
|
chainConfig.publicClient
|
|
@@ -1567,6 +1609,20 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1567
1609
|
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
1568
1610
|
}
|
|
1569
1611
|
await this.authenticateUser();
|
|
1612
|
+
if (this.isPredeployed && this.isConnectedUser(userAddress)) {
|
|
1613
|
+
const predeployedAddress = await this.getSafeAddressFor(
|
|
1614
|
+
userAddress,
|
|
1615
|
+
chainId
|
|
1616
|
+
);
|
|
1617
|
+
await this.updateUserProtocols(chainId, strategy);
|
|
1618
|
+
return {
|
|
1619
|
+
success: true,
|
|
1620
|
+
safeAddress: predeployedAddress,
|
|
1621
|
+
txHash: "0x0",
|
|
1622
|
+
status: "deployed",
|
|
1623
|
+
sessionKeyCreated: true
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1570
1626
|
const walletClient = this.getWalletClient(chainId);
|
|
1571
1627
|
const chainConfig = getChainConfig(chainId, this.rpcUrls);
|
|
1572
1628
|
const safeAddress = await getDeterministicSafeAddress({
|
|
@@ -1667,6 +1723,14 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1667
1723
|
"User ID not available. Please ensure authentication completed successfully."
|
|
1668
1724
|
);
|
|
1669
1725
|
}
|
|
1726
|
+
if (this.isPredeployed) {
|
|
1727
|
+
return {
|
|
1728
|
+
success: true,
|
|
1729
|
+
userId: this.authenticatedUserId,
|
|
1730
|
+
message: "Predeployed wallet: agent session is managed by the backend",
|
|
1731
|
+
alreadyActive: true
|
|
1732
|
+
};
|
|
1733
|
+
}
|
|
1670
1734
|
if (this.hasActiveSessionKey) {
|
|
1671
1735
|
return {
|
|
1672
1736
|
success: true,
|
|
@@ -1956,11 +2020,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1956
2020
|
const token = getDefaultTokenAddress(chainId, assetSymbol);
|
|
1957
2021
|
const walletClient = this.getWalletClient();
|
|
1958
2022
|
const chainConfig = getChainConfig(chainId, this.rpcUrls);
|
|
1959
|
-
const safeAddress = await
|
|
1960
|
-
safeOwnerAddress: userAddress,
|
|
1961
|
-
chain: chainConfig.chain,
|
|
1962
|
-
publicClient: chainConfig.publicClient
|
|
1963
|
-
});
|
|
2023
|
+
const safeAddress = await this.getSafeAddressFor(userAddress, chainId);
|
|
1964
2024
|
const isDeployed = await isSafeDeployed(
|
|
1965
2025
|
safeAddress,
|
|
1966
2026
|
chainConfig.publicClient
|
|
@@ -2122,25 +2182,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2122
2182
|
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
2123
2183
|
}
|
|
2124
2184
|
const chainConfig = getChainConfig(chainId, this.rpcUrls);
|
|
2125
|
-
|
|
2126
|
-
try {
|
|
2127
|
-
const smartWalletInfo = await this.getSmartWalletByEOA(userAddress);
|
|
2128
|
-
if (smartWalletInfo.smartWallet) {
|
|
2129
|
-
safeAddress = smartWalletInfo.smartWallet;
|
|
2130
|
-
} else {
|
|
2131
|
-
safeAddress = await getDeterministicSafeAddress({
|
|
2132
|
-
safeOwnerAddress: userAddress,
|
|
2133
|
-
chain: chainConfig.chain,
|
|
2134
|
-
publicClient: chainConfig.publicClient
|
|
2135
|
-
});
|
|
2136
|
-
}
|
|
2137
|
-
} catch {
|
|
2138
|
-
safeAddress = await getDeterministicSafeAddress({
|
|
2139
|
-
safeOwnerAddress: userAddress,
|
|
2140
|
-
chain: chainConfig.chain,
|
|
2141
|
-
publicClient: chainConfig.publicClient
|
|
2142
|
-
});
|
|
2143
|
-
}
|
|
2185
|
+
const safeAddress = await this.getSafeAddressFor(userAddress, chainId);
|
|
2144
2186
|
const isDeployed = await isSafeDeployed(
|
|
2145
2187
|
safeAddress,
|
|
2146
2188
|
chainConfig.publicClient
|
|
@@ -3951,9 +3993,36 @@ function createBankrProvider(config) {
|
|
|
3951
3993
|
};
|
|
3952
3994
|
return provider;
|
|
3953
3995
|
}
|
|
3996
|
+
|
|
3997
|
+
// src/config/modules.ts
|
|
3998
|
+
var SMART_SESSIONS_VALIDATOR = "0x00000000008bDABA73cD9815d79069c247Eb4bDA";
|
|
3999
|
+
var SMART_SESSIONS_FALLBACK = "0x12cae64c42f362e7d5a847c2d33388373f629177";
|
|
4000
|
+
var INTENT_EXECUTOR = "0x00000000005aD9ce1f5035FD62CA96CEf16AdAAF";
|
|
4001
|
+
var PROXY_EXECUTOR = "0xF659d30D4EB88B06A909F20839D8959Bd77d8790";
|
|
4002
|
+
var INTENT_SMART_SESSIONS = "0xad568b3f825a8d5ffc06dd3253526b64d810ae89";
|
|
4003
|
+
var OWNABLE_VALIDATOR = "0x000000000013fdB5234E4E3162a810F54d9f7E98";
|
|
4004
|
+
var SAFE_7579_ADDRESS2 = "0x7579EE8307284F293B1927136486880611F20002";
|
|
4005
|
+
var ERC7579_LAUNCHPAD_ADDRESS2 = "0x7579011aB74c46090561ea277Ba79D510c6C00ff";
|
|
4006
|
+
var POOL_MODULE_ADDRESSES = [
|
|
4007
|
+
SMART_SESSIONS_VALIDATOR,
|
|
4008
|
+
SMART_SESSIONS_FALLBACK,
|
|
4009
|
+
INTENT_EXECUTOR,
|
|
4010
|
+
PROXY_EXECUTOR,
|
|
4011
|
+
INTENT_SMART_SESSIONS,
|
|
4012
|
+
OWNABLE_VALIDATOR
|
|
4013
|
+
];
|
|
3954
4014
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3955
4015
|
0 && (module.exports = {
|
|
3956
4016
|
DEFAULT_TOKEN_ADDRESSES,
|
|
4017
|
+
ERC7579_LAUNCHPAD_ADDRESS,
|
|
4018
|
+
INTENT_EXECUTOR,
|
|
4019
|
+
INTENT_SMART_SESSIONS,
|
|
4020
|
+
OWNABLE_VALIDATOR,
|
|
4021
|
+
POOL_MODULE_ADDRESSES,
|
|
4022
|
+
PROXY_EXECUTOR,
|
|
4023
|
+
SAFE_7579_ADDRESS,
|
|
4024
|
+
SMART_SESSIONS_FALLBACK,
|
|
4025
|
+
SMART_SESSIONS_VALIDATOR,
|
|
3957
4026
|
VAULT_ADDRESS,
|
|
3958
4027
|
ZyfaiSDK,
|
|
3959
4028
|
createBankrProvider,
|
package/dist/index.mjs
CHANGED
|
@@ -51,6 +51,7 @@ var ENDPOINTS = {
|
|
|
51
51
|
if (params.protocols?.length) query.push(`protocols=${params.protocols.join(",")}`);
|
|
52
52
|
if (params.pools?.length) query.push(`pools=${params.pools.join(",")}`);
|
|
53
53
|
if (params.userPositions?.length) query.push(`userPositions=${encodeURIComponent(JSON.stringify(params.userPositions))}`);
|
|
54
|
+
if (params.partOfZyfiTvl !== void 0) query.push(`partOfZyfiTvl=${params.partOfZyfiTvl}`);
|
|
54
55
|
return `/simulate/best-positions?${query.join("&")}`;
|
|
55
56
|
},
|
|
56
57
|
// Customization
|
|
@@ -938,6 +939,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
938
939
|
this.walletClient = null;
|
|
939
940
|
this.authenticatedUserId = null;
|
|
940
941
|
this.hasActiveSessionKey = false;
|
|
942
|
+
this.isPredeployed = false;
|
|
943
|
+
this.connectedSmartWallet = null;
|
|
941
944
|
this.currentProvider = null;
|
|
942
945
|
this.currentChainId = null;
|
|
943
946
|
const sdkConfig = typeof config === "string" ? { apiKey: config } : config;
|
|
@@ -1012,6 +1015,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1012
1015
|
this.httpClient.setAuthToken(authToken);
|
|
1013
1016
|
this.authenticatedUserId = loginResponse.userId || null;
|
|
1014
1017
|
this.hasActiveSessionKey = loginResponse.hasActiveSessionKey || false;
|
|
1018
|
+
this.isPredeployed = loginResponse.predeployed || false;
|
|
1019
|
+
this.connectedSmartWallet = loginResponse.smartWallet || null;
|
|
1015
1020
|
} catch (error) {
|
|
1016
1021
|
throw new Error(
|
|
1017
1022
|
`Failed to authenticate user: ${error.message}`
|
|
@@ -1354,6 +1359,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1354
1359
|
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
1355
1360
|
}
|
|
1356
1361
|
this.authenticatedUserId = null;
|
|
1362
|
+
this.isPredeployed = false;
|
|
1363
|
+
this.connectedSmartWallet = null;
|
|
1357
1364
|
this.currentChainId = null;
|
|
1358
1365
|
this.httpClient.clearAuthToken();
|
|
1359
1366
|
if (this.currentProvider?.removeAllListeners) {
|
|
@@ -1444,6 +1451,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1444
1451
|
this.currentChainId = null;
|
|
1445
1452
|
this.authenticatedUserId = null;
|
|
1446
1453
|
this.hasActiveSessionKey = false;
|
|
1454
|
+
this.isPredeployed = false;
|
|
1455
|
+
this.connectedSmartWallet = null;
|
|
1447
1456
|
this.httpClient.clearAuthToken();
|
|
1448
1457
|
}
|
|
1449
1458
|
/**
|
|
@@ -1469,6 +1478,48 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1469
1478
|
return this.walletClient;
|
|
1470
1479
|
}
|
|
1471
1480
|
}
|
|
1481
|
+
/**
|
|
1482
|
+
* True when userAddress is the currently connected/authenticated wallet.
|
|
1483
|
+
* @private
|
|
1484
|
+
*/
|
|
1485
|
+
isConnectedUser(userAddress) {
|
|
1486
|
+
const connected = this.signer?.address ?? this.walletClient?.account?.address;
|
|
1487
|
+
return !!connected && connected.toLowerCase() === userAddress.toLowerCase();
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Resolve the Safe smart wallet address for a user on a chain.
|
|
1491
|
+
*
|
|
1492
|
+
* Predeployed (pool) wallets are provisioned and owned by the backend at
|
|
1493
|
+
* deploy time, so their address CANNOT be derived from the user's EOA with
|
|
1494
|
+
* getDeterministicSafeAddress (CREATE2 from the EOA yields the wrong address).
|
|
1495
|
+
* For the connected predeployed user we always use the backend-assigned
|
|
1496
|
+
* address. Legacy wallets keep the API-first, deterministic-fallback behavior.
|
|
1497
|
+
* @private
|
|
1498
|
+
*/
|
|
1499
|
+
async getSafeAddressFor(userAddress, chainId) {
|
|
1500
|
+
if (this.isPredeployed && this.isConnectedUser(userAddress)) {
|
|
1501
|
+
if (this.connectedSmartWallet) return this.connectedSmartWallet;
|
|
1502
|
+
try {
|
|
1503
|
+
const info = await this.getSmartWalletByEOA(userAddress);
|
|
1504
|
+
if (info.smartWallet) return info.smartWallet;
|
|
1505
|
+
} catch {
|
|
1506
|
+
}
|
|
1507
|
+
throw new Error(
|
|
1508
|
+
"Predeployed smart wallet address is not available from the API yet. Ensure the user has signed in so the pool can reserve their wallet."
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
try {
|
|
1512
|
+
const info = await this.getSmartWalletByEOA(userAddress);
|
|
1513
|
+
if (info.smartWallet) return info.smartWallet;
|
|
1514
|
+
} catch {
|
|
1515
|
+
}
|
|
1516
|
+
const chainConfig = getChainConfig(chainId, this.rpcUrls);
|
|
1517
|
+
return getDeterministicSafeAddress({
|
|
1518
|
+
safeOwnerAddress: userAddress,
|
|
1519
|
+
chain: chainConfig.chain,
|
|
1520
|
+
publicClient: chainConfig.publicClient
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1472
1523
|
/**
|
|
1473
1524
|
* Get smart wallet address for a user
|
|
1474
1525
|
* Returns the deterministic Safe address for an EOA, or the address itself if already a Safe
|
|
@@ -1485,25 +1536,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1485
1536
|
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
1486
1537
|
}
|
|
1487
1538
|
const chainConfig = getChainConfig(chainId, this.rpcUrls);
|
|
1488
|
-
|
|
1489
|
-
const smartWalletInfo = await this.getSmartWalletByEOA(userAddress);
|
|
1490
|
-
if (smartWalletInfo.smartWallet) {
|
|
1491
|
-
const isDeployed2 = await isSafeDeployed(
|
|
1492
|
-
smartWalletInfo.smartWallet,
|
|
1493
|
-
chainConfig.publicClient
|
|
1494
|
-
);
|
|
1495
|
-
return {
|
|
1496
|
-
address: smartWalletInfo.smartWallet,
|
|
1497
|
-
isDeployed: isDeployed2
|
|
1498
|
-
};
|
|
1499
|
-
}
|
|
1500
|
-
} catch {
|
|
1501
|
-
}
|
|
1502
|
-
const safeAddress = await getDeterministicSafeAddress({
|
|
1503
|
-
safeOwnerAddress: userAddress,
|
|
1504
|
-
chain: chainConfig.chain,
|
|
1505
|
-
publicClient: chainConfig.publicClient
|
|
1506
|
-
});
|
|
1539
|
+
const safeAddress = await this.getSafeAddressFor(userAddress, chainId);
|
|
1507
1540
|
const isDeployed = await isSafeDeployed(
|
|
1508
1541
|
safeAddress,
|
|
1509
1542
|
chainConfig.publicClient
|
|
@@ -1543,6 +1576,20 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1543
1576
|
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
1544
1577
|
}
|
|
1545
1578
|
await this.authenticateUser();
|
|
1579
|
+
if (this.isPredeployed && this.isConnectedUser(userAddress)) {
|
|
1580
|
+
const predeployedAddress = await this.getSafeAddressFor(
|
|
1581
|
+
userAddress,
|
|
1582
|
+
chainId
|
|
1583
|
+
);
|
|
1584
|
+
await this.updateUserProtocols(chainId, strategy);
|
|
1585
|
+
return {
|
|
1586
|
+
success: true,
|
|
1587
|
+
safeAddress: predeployedAddress,
|
|
1588
|
+
txHash: "0x0",
|
|
1589
|
+
status: "deployed",
|
|
1590
|
+
sessionKeyCreated: true
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1546
1593
|
const walletClient = this.getWalletClient(chainId);
|
|
1547
1594
|
const chainConfig = getChainConfig(chainId, this.rpcUrls);
|
|
1548
1595
|
const safeAddress = await getDeterministicSafeAddress({
|
|
@@ -1643,6 +1690,14 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1643
1690
|
"User ID not available. Please ensure authentication completed successfully."
|
|
1644
1691
|
);
|
|
1645
1692
|
}
|
|
1693
|
+
if (this.isPredeployed) {
|
|
1694
|
+
return {
|
|
1695
|
+
success: true,
|
|
1696
|
+
userId: this.authenticatedUserId,
|
|
1697
|
+
message: "Predeployed wallet: agent session is managed by the backend",
|
|
1698
|
+
alreadyActive: true
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1646
1701
|
if (this.hasActiveSessionKey) {
|
|
1647
1702
|
return {
|
|
1648
1703
|
success: true,
|
|
@@ -1932,11 +1987,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1932
1987
|
const token = getDefaultTokenAddress(chainId, assetSymbol);
|
|
1933
1988
|
const walletClient = this.getWalletClient();
|
|
1934
1989
|
const chainConfig = getChainConfig(chainId, this.rpcUrls);
|
|
1935
|
-
const safeAddress = await
|
|
1936
|
-
safeOwnerAddress: userAddress,
|
|
1937
|
-
chain: chainConfig.chain,
|
|
1938
|
-
publicClient: chainConfig.publicClient
|
|
1939
|
-
});
|
|
1990
|
+
const safeAddress = await this.getSafeAddressFor(userAddress, chainId);
|
|
1940
1991
|
const isDeployed = await isSafeDeployed(
|
|
1941
1992
|
safeAddress,
|
|
1942
1993
|
chainConfig.publicClient
|
|
@@ -2098,25 +2149,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2098
2149
|
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
2099
2150
|
}
|
|
2100
2151
|
const chainConfig = getChainConfig(chainId, this.rpcUrls);
|
|
2101
|
-
|
|
2102
|
-
try {
|
|
2103
|
-
const smartWalletInfo = await this.getSmartWalletByEOA(userAddress);
|
|
2104
|
-
if (smartWalletInfo.smartWallet) {
|
|
2105
|
-
safeAddress = smartWalletInfo.smartWallet;
|
|
2106
|
-
} else {
|
|
2107
|
-
safeAddress = await getDeterministicSafeAddress({
|
|
2108
|
-
safeOwnerAddress: userAddress,
|
|
2109
|
-
chain: chainConfig.chain,
|
|
2110
|
-
publicClient: chainConfig.publicClient
|
|
2111
|
-
});
|
|
2112
|
-
}
|
|
2113
|
-
} catch {
|
|
2114
|
-
safeAddress = await getDeterministicSafeAddress({
|
|
2115
|
-
safeOwnerAddress: userAddress,
|
|
2116
|
-
chain: chainConfig.chain,
|
|
2117
|
-
publicClient: chainConfig.publicClient
|
|
2118
|
-
});
|
|
2119
|
-
}
|
|
2152
|
+
const safeAddress = await this.getSafeAddressFor(userAddress, chainId);
|
|
2120
2153
|
const isDeployed = await isSafeDeployed(
|
|
2121
2154
|
safeAddress,
|
|
2122
2155
|
chainConfig.publicClient
|
|
@@ -3927,8 +3960,35 @@ function createBankrProvider(config) {
|
|
|
3927
3960
|
};
|
|
3928
3961
|
return provider;
|
|
3929
3962
|
}
|
|
3963
|
+
|
|
3964
|
+
// src/config/modules.ts
|
|
3965
|
+
var SMART_SESSIONS_VALIDATOR = "0x00000000008bDABA73cD9815d79069c247Eb4bDA";
|
|
3966
|
+
var SMART_SESSIONS_FALLBACK = "0x12cae64c42f362e7d5a847c2d33388373f629177";
|
|
3967
|
+
var INTENT_EXECUTOR = "0x00000000005aD9ce1f5035FD62CA96CEf16AdAAF";
|
|
3968
|
+
var PROXY_EXECUTOR = "0xF659d30D4EB88B06A909F20839D8959Bd77d8790";
|
|
3969
|
+
var INTENT_SMART_SESSIONS = "0xad568b3f825a8d5ffc06dd3253526b64d810ae89";
|
|
3970
|
+
var OWNABLE_VALIDATOR = "0x000000000013fdB5234E4E3162a810F54d9f7E98";
|
|
3971
|
+
var SAFE_7579_ADDRESS2 = "0x7579EE8307284F293B1927136486880611F20002";
|
|
3972
|
+
var ERC7579_LAUNCHPAD_ADDRESS2 = "0x7579011aB74c46090561ea277Ba79D510c6C00ff";
|
|
3973
|
+
var POOL_MODULE_ADDRESSES = [
|
|
3974
|
+
SMART_SESSIONS_VALIDATOR,
|
|
3975
|
+
SMART_SESSIONS_FALLBACK,
|
|
3976
|
+
INTENT_EXECUTOR,
|
|
3977
|
+
PROXY_EXECUTOR,
|
|
3978
|
+
INTENT_SMART_SESSIONS,
|
|
3979
|
+
OWNABLE_VALIDATOR
|
|
3980
|
+
];
|
|
3930
3981
|
export {
|
|
3931
3982
|
DEFAULT_TOKEN_ADDRESSES,
|
|
3983
|
+
ERC7579_LAUNCHPAD_ADDRESS2 as ERC7579_LAUNCHPAD_ADDRESS,
|
|
3984
|
+
INTENT_EXECUTOR,
|
|
3985
|
+
INTENT_SMART_SESSIONS,
|
|
3986
|
+
OWNABLE_VALIDATOR,
|
|
3987
|
+
POOL_MODULE_ADDRESSES,
|
|
3988
|
+
PROXY_EXECUTOR,
|
|
3989
|
+
SAFE_7579_ADDRESS2 as SAFE_7579_ADDRESS,
|
|
3990
|
+
SMART_SESSIONS_FALLBACK,
|
|
3991
|
+
SMART_SESSIONS_VALIDATOR,
|
|
3932
3992
|
VAULT_ADDRESS,
|
|
3933
3993
|
ZyfaiSDK,
|
|
3934
3994
|
createBankrProvider,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.43",
|
|
4
4
|
"description": "TypeScript SDK for Zyfai Yield Optimization Engine - Deploy Safe smart wallets, manage session keys, and interact with DeFi protocols",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|