@zyfai/sdk 0.2.25 → 0.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +205 -7
- package/dist/index.d.ts +205 -7
- package/dist/index.js +670 -10
- package/dist/index.mjs +668 -10
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -21,8 +21,8 @@ interface DeploySafeResponse {
|
|
|
21
21
|
safeAddress: Address;
|
|
22
22
|
txHash: string;
|
|
23
23
|
status: "deployed" | "failed";
|
|
24
|
+
sessionKeyCreated?: boolean;
|
|
24
25
|
}
|
|
25
|
-
/** @internal */
|
|
26
26
|
interface UpdateUserProfileRequest {
|
|
27
27
|
strategy?: string;
|
|
28
28
|
protocols?: string[];
|
|
@@ -121,7 +121,6 @@ interface Portfolio {
|
|
|
121
121
|
smartWallet?: Address;
|
|
122
122
|
positions?: PositionSlot[];
|
|
123
123
|
hasActiveSessionKey?: boolean;
|
|
124
|
-
hasBalance?: boolean;
|
|
125
124
|
newSessionKeyAvailable?: boolean;
|
|
126
125
|
contracts?: Address[];
|
|
127
126
|
omniAccount?: boolean;
|
|
@@ -132,6 +131,16 @@ interface Portfolio {
|
|
|
132
131
|
executorProxy?: boolean;
|
|
133
132
|
assetTypeSettings?: AssetTypeSettings;
|
|
134
133
|
}
|
|
134
|
+
interface PortfolioDetailed {
|
|
135
|
+
hasBalance?: boolean;
|
|
136
|
+
staleBalances?: string[];
|
|
137
|
+
hasActiveSessionKey?: boolean;
|
|
138
|
+
positions?: PositionSlot[];
|
|
139
|
+
portfolioByAssetType?: Record<string, {
|
|
140
|
+
balance: string;
|
|
141
|
+
decimals: number;
|
|
142
|
+
}>;
|
|
143
|
+
}
|
|
135
144
|
interface AssetTypeSettings {
|
|
136
145
|
[assetType: string]: {
|
|
137
146
|
rebalanceStrategy?: string;
|
|
@@ -163,6 +172,11 @@ interface PortfolioResponse {
|
|
|
163
172
|
userAddress: string;
|
|
164
173
|
portfolio: Portfolio;
|
|
165
174
|
}
|
|
175
|
+
interface PortfolioDetailedResponse {
|
|
176
|
+
success: boolean;
|
|
177
|
+
userAddress: string;
|
|
178
|
+
portfolio: PortfolioDetailed;
|
|
179
|
+
}
|
|
166
180
|
interface TVLResponse {
|
|
167
181
|
success: boolean;
|
|
168
182
|
totalTvl: number;
|
|
@@ -258,9 +272,6 @@ type TokenEarnings = Record<string, string>;
|
|
|
258
272
|
interface OnchainEarnings {
|
|
259
273
|
walletAddress: string;
|
|
260
274
|
totalEarningsByToken: TokenEarnings;
|
|
261
|
-
lifetimeEarningsByToken: TokenEarnings;
|
|
262
|
-
currentEarningsByChain: Record<string, TokenEarnings>;
|
|
263
|
-
unrealizedEarnings: Record<string, TokenEarnings>;
|
|
264
275
|
lastCheckTimestamp?: string;
|
|
265
276
|
lastLogDate?: Record<string, string | null>;
|
|
266
277
|
}
|
|
@@ -501,6 +512,37 @@ interface Session {
|
|
|
501
512
|
permitERC4337Paymaster: boolean;
|
|
502
513
|
chainId: bigint;
|
|
503
514
|
}
|
|
515
|
+
type VaultAsset = "USDC";
|
|
516
|
+
interface VaultDepositResponse {
|
|
517
|
+
success: boolean;
|
|
518
|
+
txHash: string;
|
|
519
|
+
amount: string;
|
|
520
|
+
asset: VaultAsset;
|
|
521
|
+
vaultAddress: Address;
|
|
522
|
+
}
|
|
523
|
+
interface VaultWithdrawResponse {
|
|
524
|
+
success: boolean;
|
|
525
|
+
txHash: string;
|
|
526
|
+
withdrawKey: Hex;
|
|
527
|
+
status: "pending" | "claimable";
|
|
528
|
+
}
|
|
529
|
+
interface VaultClaimResponse {
|
|
530
|
+
success: boolean;
|
|
531
|
+
txHash: string;
|
|
532
|
+
claimed: boolean;
|
|
533
|
+
}
|
|
534
|
+
interface VaultWithdrawStatusResponse {
|
|
535
|
+
success: boolean;
|
|
536
|
+
withdrawKey: Hex | null;
|
|
537
|
+
isClaimable: boolean;
|
|
538
|
+
isPending: boolean;
|
|
539
|
+
nonce: bigint;
|
|
540
|
+
}
|
|
541
|
+
interface VaultSharesResponse {
|
|
542
|
+
success: boolean;
|
|
543
|
+
shares: bigint;
|
|
544
|
+
symbol: string;
|
|
545
|
+
}
|
|
504
546
|
|
|
505
547
|
type SupportedChainId = 8453 | 42161 | 9745;
|
|
506
548
|
interface ChainConfig {
|
|
@@ -732,6 +774,7 @@ declare class ZyfaiSDK {
|
|
|
732
774
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
733
775
|
* @param chainId - Target chain ID
|
|
734
776
|
* @param strategy - Optional strategy selection: "conservative" (default) or "aggressive"
|
|
777
|
+
* @param createSessionKey - If true, automatically creates a session key after deployment (default: false)
|
|
735
778
|
* @returns Deployment response with Safe address and transaction hash
|
|
736
779
|
*
|
|
737
780
|
* @example
|
|
@@ -741,9 +784,12 @@ declare class ZyfaiSDK {
|
|
|
741
784
|
*
|
|
742
785
|
* // Deploy with aggressive strategy
|
|
743
786
|
* await sdk.deploySafe(userAddress, 8453, "aggressive");
|
|
787
|
+
*
|
|
788
|
+
* // Deploy and automatically create session key
|
|
789
|
+
* await sdk.deploySafe(userAddress, 8453, "conservative", true);
|
|
744
790
|
* ```
|
|
745
791
|
*/
|
|
746
|
-
deploySafe(userAddress: string, chainId: SupportedChainId, strategy?: Strategy): Promise<DeploySafeResponse>;
|
|
792
|
+
deploySafe(userAddress: string, chainId: SupportedChainId, strategy?: Strategy, createSessionKey?: boolean): Promise<DeploySafeResponse>;
|
|
747
793
|
/**
|
|
748
794
|
* Create session key with auto-fetched configuration from Zyfai API
|
|
749
795
|
* This is the simplified method that automatically fetches session configuration
|
|
@@ -903,6 +949,23 @@ declare class ZyfaiSDK {
|
|
|
903
949
|
* ```
|
|
904
950
|
*/
|
|
905
951
|
getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PortfolioResponse>;
|
|
952
|
+
/**
|
|
953
|
+
* Get all active positions and portfolio for a user
|
|
954
|
+
*
|
|
955
|
+
* @param userAddress - User's EOA address
|
|
956
|
+
* @param chainId - Optional: Filter by specific chain ID
|
|
957
|
+
* @returns User's positions across all protocols
|
|
958
|
+
*
|
|
959
|
+
* @example
|
|
960
|
+
* ```typescript
|
|
961
|
+
* // Get all positions across all chains
|
|
962
|
+
* const positions = await sdk.getPositions(userAddress);
|
|
963
|
+
*
|
|
964
|
+
* // Get positions on a specific chain
|
|
965
|
+
* const basePositions = await sdk.getPositions(userAddress, 8453);
|
|
966
|
+
* ```
|
|
967
|
+
*/
|
|
968
|
+
getPortfolio(userAddress: string): Promise<PortfolioDetailedResponse>;
|
|
906
969
|
/**
|
|
907
970
|
* Get current authenticated user details
|
|
908
971
|
* Requires SIWE authentication
|
|
@@ -1312,6 +1375,141 @@ declare class ZyfaiSDK {
|
|
|
1312
1375
|
* ```
|
|
1313
1376
|
*/
|
|
1314
1377
|
registerAgentOnIdentityRegistry(smartWallet: string, chainId: SupportedChainId): Promise<RegisterAgentResponse>;
|
|
1378
|
+
/**
|
|
1379
|
+
* Deposit assets into the Zyfai Vault
|
|
1380
|
+
* Currently only supports USDC on Base chain
|
|
1381
|
+
*
|
|
1382
|
+
* @param amount - Amount to deposit (in human readable format, e.g., "100" for 100 USDC)
|
|
1383
|
+
* @param asset - Asset to deposit (default: "USDC")
|
|
1384
|
+
* @returns Deposit transaction result
|
|
1385
|
+
*
|
|
1386
|
+
* @example
|
|
1387
|
+
* ```typescript
|
|
1388
|
+
* const result = await sdk.vaultDeposit("100", "USDC");
|
|
1389
|
+
* console.log("Deposited:", result.txHash);
|
|
1390
|
+
* ```
|
|
1391
|
+
*/
|
|
1392
|
+
vaultDeposit(amount: string, asset?: VaultAsset, chainId?: SupportedChainId): Promise<VaultDepositResponse>;
|
|
1393
|
+
/**
|
|
1394
|
+
* Request withdrawal from the Zyfai Vault
|
|
1395
|
+
* Withdrawals are async - use getVaultWithdrawStatus and vaultClaim after
|
|
1396
|
+
*
|
|
1397
|
+
* @param shares - Amount of shares to redeem (optional, defaults to all shares)
|
|
1398
|
+
* @returns Withdraw request result with withdrawKey
|
|
1399
|
+
*
|
|
1400
|
+
* @example
|
|
1401
|
+
* ```typescript
|
|
1402
|
+
* const result = await sdk.vaultWithdraw();
|
|
1403
|
+
* console.log("Withdraw key:", result.withdrawKey);
|
|
1404
|
+
* // Later, check status and claim
|
|
1405
|
+
* ```
|
|
1406
|
+
*/
|
|
1407
|
+
vaultWithdraw(shares?: string, chainId?: SupportedChainId): Promise<VaultWithdrawResponse>;
|
|
1408
|
+
/**
|
|
1409
|
+
* Get the status of a pending withdrawal
|
|
1410
|
+
*
|
|
1411
|
+
* @param withdrawKey - The withdraw key to check (optional, gets latest if not provided)
|
|
1412
|
+
* @returns Withdraw status
|
|
1413
|
+
*
|
|
1414
|
+
* @example
|
|
1415
|
+
* ```typescript
|
|
1416
|
+
* const status = await sdk.getVaultWithdrawStatus();
|
|
1417
|
+
* if (status.isClaimable) {
|
|
1418
|
+
* await sdk.vaultClaim(status.withdrawKey);
|
|
1419
|
+
* }
|
|
1420
|
+
* ```
|
|
1421
|
+
*/
|
|
1422
|
+
getVaultWithdrawStatus(withdrawKey?: Hex, chainId?: SupportedChainId): Promise<VaultWithdrawStatusResponse>;
|
|
1423
|
+
/**
|
|
1424
|
+
* Claim a completed withdrawal from the Zyfai Vault
|
|
1425
|
+
*
|
|
1426
|
+
* @param withdrawKey - The withdraw key to claim
|
|
1427
|
+
* @returns Claim transaction result
|
|
1428
|
+
*
|
|
1429
|
+
* @example
|
|
1430
|
+
* ```typescript
|
|
1431
|
+
* const status = await sdk.getVaultWithdrawStatus();
|
|
1432
|
+
* if (status.isClaimable) {
|
|
1433
|
+
* const claim = await sdk.vaultClaim(status.withdrawKey);
|
|
1434
|
+
* console.log("Claimed:", claim.txHash);
|
|
1435
|
+
* }
|
|
1436
|
+
* ```
|
|
1437
|
+
*/
|
|
1438
|
+
vaultClaim(withdrawKey: Hex, chainId?: SupportedChainId): Promise<VaultClaimResponse>;
|
|
1439
|
+
/**
|
|
1440
|
+
* Get vault shares info for the connected wallet
|
|
1441
|
+
*
|
|
1442
|
+
* @param userAddress - Optional user address (defaults to connected wallet)
|
|
1443
|
+
* @returns Vault shares balance and token symbol
|
|
1444
|
+
*
|
|
1445
|
+
* @example
|
|
1446
|
+
* ```typescript
|
|
1447
|
+
* const { shares, symbol } = await sdk.getVaultShares();
|
|
1448
|
+
* console.log(`Balance: ${shares} ${symbol}`);
|
|
1449
|
+
* ```
|
|
1450
|
+
*/
|
|
1451
|
+
getVaultShares(userAddress?: string, chainId?: SupportedChainId): Promise<VaultSharesResponse>;
|
|
1315
1452
|
}
|
|
1316
1453
|
|
|
1317
|
-
|
|
1454
|
+
/**
|
|
1455
|
+
* Bankr EIP-1193 Provider Adapter
|
|
1456
|
+
*
|
|
1457
|
+
* Wraps Bankr's Agent API Sign endpoint to create an EIP-1193 compatible provider.
|
|
1458
|
+
* This allows using Bankr wallets with any EIP-1193 compatible SDK without exposing private keys.
|
|
1459
|
+
*
|
|
1460
|
+
* @see https://docs.bankr.bot/agent-api/sign-endpoint
|
|
1461
|
+
*/
|
|
1462
|
+
interface BankrProviderConfig {
|
|
1463
|
+
/** Bankr API key with signing permissions */
|
|
1464
|
+
apiKey: string;
|
|
1465
|
+
/** Base URL for Bankr API (default: https://api.bankr.bot) */
|
|
1466
|
+
baseUrl?: string;
|
|
1467
|
+
/** Default chain ID (default: 8453 - Base) */
|
|
1468
|
+
chainId?: number;
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Creates an EIP-1193 compatible provider that uses Bankr's Agent API for signing.
|
|
1472
|
+
*
|
|
1473
|
+
* @param config - Bankr provider configuration
|
|
1474
|
+
* @returns EIP-1193 compatible provider object
|
|
1475
|
+
*
|
|
1476
|
+
* @example
|
|
1477
|
+
* ```typescript
|
|
1478
|
+
* import { createBankrProvider } from '@zyfai/sdk';
|
|
1479
|
+
* import { ZyfaiSDK } from '@zyfai/sdk';
|
|
1480
|
+
*
|
|
1481
|
+
* const provider = createBankrProvider({ apiKey: process.env.BANKR_API_KEY });
|
|
1482
|
+
* const sdk = new ZyfaiSDK({ apiKey: process.env.ZYFAI_API_KEY });
|
|
1483
|
+
*
|
|
1484
|
+
* const address = await sdk.connectAccount(provider);
|
|
1485
|
+
* await sdk.deploySafe(address, 8453, 'conservative', true);
|
|
1486
|
+
* ```
|
|
1487
|
+
*/
|
|
1488
|
+
declare function createBankrProvider(config: BankrProviderConfig): {
|
|
1489
|
+
/**
|
|
1490
|
+
* EIP-1193 request method
|
|
1491
|
+
* Routes RPC calls to appropriate Bankr API endpoints
|
|
1492
|
+
*/
|
|
1493
|
+
request({ method, params }: {
|
|
1494
|
+
method: string;
|
|
1495
|
+
params?: any[];
|
|
1496
|
+
}): Promise<any>;
|
|
1497
|
+
/**
|
|
1498
|
+
* Event listener stub (required by EIP-1193)
|
|
1499
|
+
* Bankr API doesn't support real-time events
|
|
1500
|
+
*/
|
|
1501
|
+
on: (event: string, callback: (...args: any[]) => void) => void;
|
|
1502
|
+
/**
|
|
1503
|
+
* Remove event listener stub (required by EIP-1193)
|
|
1504
|
+
*/
|
|
1505
|
+
removeListener: (event: string, callback: (...args: any[]) => void) => void;
|
|
1506
|
+
/**
|
|
1507
|
+
* Check if this is a Bankr provider
|
|
1508
|
+
*/
|
|
1509
|
+
isBankr: boolean;
|
|
1510
|
+
};
|
|
1511
|
+
type BankrProvider = ReturnType<typeof createBankrProvider>;
|
|
1512
|
+
|
|
1513
|
+
declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
|
|
1514
|
+
|
|
1515
|
+
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type LogDepositResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type Portfolio, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
|
package/dist/index.d.ts
CHANGED
|
@@ -21,8 +21,8 @@ interface DeploySafeResponse {
|
|
|
21
21
|
safeAddress: Address;
|
|
22
22
|
txHash: string;
|
|
23
23
|
status: "deployed" | "failed";
|
|
24
|
+
sessionKeyCreated?: boolean;
|
|
24
25
|
}
|
|
25
|
-
/** @internal */
|
|
26
26
|
interface UpdateUserProfileRequest {
|
|
27
27
|
strategy?: string;
|
|
28
28
|
protocols?: string[];
|
|
@@ -121,7 +121,6 @@ interface Portfolio {
|
|
|
121
121
|
smartWallet?: Address;
|
|
122
122
|
positions?: PositionSlot[];
|
|
123
123
|
hasActiveSessionKey?: boolean;
|
|
124
|
-
hasBalance?: boolean;
|
|
125
124
|
newSessionKeyAvailable?: boolean;
|
|
126
125
|
contracts?: Address[];
|
|
127
126
|
omniAccount?: boolean;
|
|
@@ -132,6 +131,16 @@ interface Portfolio {
|
|
|
132
131
|
executorProxy?: boolean;
|
|
133
132
|
assetTypeSettings?: AssetTypeSettings;
|
|
134
133
|
}
|
|
134
|
+
interface PortfolioDetailed {
|
|
135
|
+
hasBalance?: boolean;
|
|
136
|
+
staleBalances?: string[];
|
|
137
|
+
hasActiveSessionKey?: boolean;
|
|
138
|
+
positions?: PositionSlot[];
|
|
139
|
+
portfolioByAssetType?: Record<string, {
|
|
140
|
+
balance: string;
|
|
141
|
+
decimals: number;
|
|
142
|
+
}>;
|
|
143
|
+
}
|
|
135
144
|
interface AssetTypeSettings {
|
|
136
145
|
[assetType: string]: {
|
|
137
146
|
rebalanceStrategy?: string;
|
|
@@ -163,6 +172,11 @@ interface PortfolioResponse {
|
|
|
163
172
|
userAddress: string;
|
|
164
173
|
portfolio: Portfolio;
|
|
165
174
|
}
|
|
175
|
+
interface PortfolioDetailedResponse {
|
|
176
|
+
success: boolean;
|
|
177
|
+
userAddress: string;
|
|
178
|
+
portfolio: PortfolioDetailed;
|
|
179
|
+
}
|
|
166
180
|
interface TVLResponse {
|
|
167
181
|
success: boolean;
|
|
168
182
|
totalTvl: number;
|
|
@@ -258,9 +272,6 @@ type TokenEarnings = Record<string, string>;
|
|
|
258
272
|
interface OnchainEarnings {
|
|
259
273
|
walletAddress: string;
|
|
260
274
|
totalEarningsByToken: TokenEarnings;
|
|
261
|
-
lifetimeEarningsByToken: TokenEarnings;
|
|
262
|
-
currentEarningsByChain: Record<string, TokenEarnings>;
|
|
263
|
-
unrealizedEarnings: Record<string, TokenEarnings>;
|
|
264
275
|
lastCheckTimestamp?: string;
|
|
265
276
|
lastLogDate?: Record<string, string | null>;
|
|
266
277
|
}
|
|
@@ -501,6 +512,37 @@ interface Session {
|
|
|
501
512
|
permitERC4337Paymaster: boolean;
|
|
502
513
|
chainId: bigint;
|
|
503
514
|
}
|
|
515
|
+
type VaultAsset = "USDC";
|
|
516
|
+
interface VaultDepositResponse {
|
|
517
|
+
success: boolean;
|
|
518
|
+
txHash: string;
|
|
519
|
+
amount: string;
|
|
520
|
+
asset: VaultAsset;
|
|
521
|
+
vaultAddress: Address;
|
|
522
|
+
}
|
|
523
|
+
interface VaultWithdrawResponse {
|
|
524
|
+
success: boolean;
|
|
525
|
+
txHash: string;
|
|
526
|
+
withdrawKey: Hex;
|
|
527
|
+
status: "pending" | "claimable";
|
|
528
|
+
}
|
|
529
|
+
interface VaultClaimResponse {
|
|
530
|
+
success: boolean;
|
|
531
|
+
txHash: string;
|
|
532
|
+
claimed: boolean;
|
|
533
|
+
}
|
|
534
|
+
interface VaultWithdrawStatusResponse {
|
|
535
|
+
success: boolean;
|
|
536
|
+
withdrawKey: Hex | null;
|
|
537
|
+
isClaimable: boolean;
|
|
538
|
+
isPending: boolean;
|
|
539
|
+
nonce: bigint;
|
|
540
|
+
}
|
|
541
|
+
interface VaultSharesResponse {
|
|
542
|
+
success: boolean;
|
|
543
|
+
shares: bigint;
|
|
544
|
+
symbol: string;
|
|
545
|
+
}
|
|
504
546
|
|
|
505
547
|
type SupportedChainId = 8453 | 42161 | 9745;
|
|
506
548
|
interface ChainConfig {
|
|
@@ -732,6 +774,7 @@ declare class ZyfaiSDK {
|
|
|
732
774
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
733
775
|
* @param chainId - Target chain ID
|
|
734
776
|
* @param strategy - Optional strategy selection: "conservative" (default) or "aggressive"
|
|
777
|
+
* @param createSessionKey - If true, automatically creates a session key after deployment (default: false)
|
|
735
778
|
* @returns Deployment response with Safe address and transaction hash
|
|
736
779
|
*
|
|
737
780
|
* @example
|
|
@@ -741,9 +784,12 @@ declare class ZyfaiSDK {
|
|
|
741
784
|
*
|
|
742
785
|
* // Deploy with aggressive strategy
|
|
743
786
|
* await sdk.deploySafe(userAddress, 8453, "aggressive");
|
|
787
|
+
*
|
|
788
|
+
* // Deploy and automatically create session key
|
|
789
|
+
* await sdk.deploySafe(userAddress, 8453, "conservative", true);
|
|
744
790
|
* ```
|
|
745
791
|
*/
|
|
746
|
-
deploySafe(userAddress: string, chainId: SupportedChainId, strategy?: Strategy): Promise<DeploySafeResponse>;
|
|
792
|
+
deploySafe(userAddress: string, chainId: SupportedChainId, strategy?: Strategy, createSessionKey?: boolean): Promise<DeploySafeResponse>;
|
|
747
793
|
/**
|
|
748
794
|
* Create session key with auto-fetched configuration from Zyfai API
|
|
749
795
|
* This is the simplified method that automatically fetches session configuration
|
|
@@ -903,6 +949,23 @@ declare class ZyfaiSDK {
|
|
|
903
949
|
* ```
|
|
904
950
|
*/
|
|
905
951
|
getPositions(userAddress: string, chainId?: SupportedChainId): Promise<PortfolioResponse>;
|
|
952
|
+
/**
|
|
953
|
+
* Get all active positions and portfolio for a user
|
|
954
|
+
*
|
|
955
|
+
* @param userAddress - User's EOA address
|
|
956
|
+
* @param chainId - Optional: Filter by specific chain ID
|
|
957
|
+
* @returns User's positions across all protocols
|
|
958
|
+
*
|
|
959
|
+
* @example
|
|
960
|
+
* ```typescript
|
|
961
|
+
* // Get all positions across all chains
|
|
962
|
+
* const positions = await sdk.getPositions(userAddress);
|
|
963
|
+
*
|
|
964
|
+
* // Get positions on a specific chain
|
|
965
|
+
* const basePositions = await sdk.getPositions(userAddress, 8453);
|
|
966
|
+
* ```
|
|
967
|
+
*/
|
|
968
|
+
getPortfolio(userAddress: string): Promise<PortfolioDetailedResponse>;
|
|
906
969
|
/**
|
|
907
970
|
* Get current authenticated user details
|
|
908
971
|
* Requires SIWE authentication
|
|
@@ -1312,6 +1375,141 @@ declare class ZyfaiSDK {
|
|
|
1312
1375
|
* ```
|
|
1313
1376
|
*/
|
|
1314
1377
|
registerAgentOnIdentityRegistry(smartWallet: string, chainId: SupportedChainId): Promise<RegisterAgentResponse>;
|
|
1378
|
+
/**
|
|
1379
|
+
* Deposit assets into the Zyfai Vault
|
|
1380
|
+
* Currently only supports USDC on Base chain
|
|
1381
|
+
*
|
|
1382
|
+
* @param amount - Amount to deposit (in human readable format, e.g., "100" for 100 USDC)
|
|
1383
|
+
* @param asset - Asset to deposit (default: "USDC")
|
|
1384
|
+
* @returns Deposit transaction result
|
|
1385
|
+
*
|
|
1386
|
+
* @example
|
|
1387
|
+
* ```typescript
|
|
1388
|
+
* const result = await sdk.vaultDeposit("100", "USDC");
|
|
1389
|
+
* console.log("Deposited:", result.txHash);
|
|
1390
|
+
* ```
|
|
1391
|
+
*/
|
|
1392
|
+
vaultDeposit(amount: string, asset?: VaultAsset, chainId?: SupportedChainId): Promise<VaultDepositResponse>;
|
|
1393
|
+
/**
|
|
1394
|
+
* Request withdrawal from the Zyfai Vault
|
|
1395
|
+
* Withdrawals are async - use getVaultWithdrawStatus and vaultClaim after
|
|
1396
|
+
*
|
|
1397
|
+
* @param shares - Amount of shares to redeem (optional, defaults to all shares)
|
|
1398
|
+
* @returns Withdraw request result with withdrawKey
|
|
1399
|
+
*
|
|
1400
|
+
* @example
|
|
1401
|
+
* ```typescript
|
|
1402
|
+
* const result = await sdk.vaultWithdraw();
|
|
1403
|
+
* console.log("Withdraw key:", result.withdrawKey);
|
|
1404
|
+
* // Later, check status and claim
|
|
1405
|
+
* ```
|
|
1406
|
+
*/
|
|
1407
|
+
vaultWithdraw(shares?: string, chainId?: SupportedChainId): Promise<VaultWithdrawResponse>;
|
|
1408
|
+
/**
|
|
1409
|
+
* Get the status of a pending withdrawal
|
|
1410
|
+
*
|
|
1411
|
+
* @param withdrawKey - The withdraw key to check (optional, gets latest if not provided)
|
|
1412
|
+
* @returns Withdraw status
|
|
1413
|
+
*
|
|
1414
|
+
* @example
|
|
1415
|
+
* ```typescript
|
|
1416
|
+
* const status = await sdk.getVaultWithdrawStatus();
|
|
1417
|
+
* if (status.isClaimable) {
|
|
1418
|
+
* await sdk.vaultClaim(status.withdrawKey);
|
|
1419
|
+
* }
|
|
1420
|
+
* ```
|
|
1421
|
+
*/
|
|
1422
|
+
getVaultWithdrawStatus(withdrawKey?: Hex, chainId?: SupportedChainId): Promise<VaultWithdrawStatusResponse>;
|
|
1423
|
+
/**
|
|
1424
|
+
* Claim a completed withdrawal from the Zyfai Vault
|
|
1425
|
+
*
|
|
1426
|
+
* @param withdrawKey - The withdraw key to claim
|
|
1427
|
+
* @returns Claim transaction result
|
|
1428
|
+
*
|
|
1429
|
+
* @example
|
|
1430
|
+
* ```typescript
|
|
1431
|
+
* const status = await sdk.getVaultWithdrawStatus();
|
|
1432
|
+
* if (status.isClaimable) {
|
|
1433
|
+
* const claim = await sdk.vaultClaim(status.withdrawKey);
|
|
1434
|
+
* console.log("Claimed:", claim.txHash);
|
|
1435
|
+
* }
|
|
1436
|
+
* ```
|
|
1437
|
+
*/
|
|
1438
|
+
vaultClaim(withdrawKey: Hex, chainId?: SupportedChainId): Promise<VaultClaimResponse>;
|
|
1439
|
+
/**
|
|
1440
|
+
* Get vault shares info for the connected wallet
|
|
1441
|
+
*
|
|
1442
|
+
* @param userAddress - Optional user address (defaults to connected wallet)
|
|
1443
|
+
* @returns Vault shares balance and token symbol
|
|
1444
|
+
*
|
|
1445
|
+
* @example
|
|
1446
|
+
* ```typescript
|
|
1447
|
+
* const { shares, symbol } = await sdk.getVaultShares();
|
|
1448
|
+
* console.log(`Balance: ${shares} ${symbol}`);
|
|
1449
|
+
* ```
|
|
1450
|
+
*/
|
|
1451
|
+
getVaultShares(userAddress?: string, chainId?: SupportedChainId): Promise<VaultSharesResponse>;
|
|
1315
1452
|
}
|
|
1316
1453
|
|
|
1317
|
-
|
|
1454
|
+
/**
|
|
1455
|
+
* Bankr EIP-1193 Provider Adapter
|
|
1456
|
+
*
|
|
1457
|
+
* Wraps Bankr's Agent API Sign endpoint to create an EIP-1193 compatible provider.
|
|
1458
|
+
* This allows using Bankr wallets with any EIP-1193 compatible SDK without exposing private keys.
|
|
1459
|
+
*
|
|
1460
|
+
* @see https://docs.bankr.bot/agent-api/sign-endpoint
|
|
1461
|
+
*/
|
|
1462
|
+
interface BankrProviderConfig {
|
|
1463
|
+
/** Bankr API key with signing permissions */
|
|
1464
|
+
apiKey: string;
|
|
1465
|
+
/** Base URL for Bankr API (default: https://api.bankr.bot) */
|
|
1466
|
+
baseUrl?: string;
|
|
1467
|
+
/** Default chain ID (default: 8453 - Base) */
|
|
1468
|
+
chainId?: number;
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Creates an EIP-1193 compatible provider that uses Bankr's Agent API for signing.
|
|
1472
|
+
*
|
|
1473
|
+
* @param config - Bankr provider configuration
|
|
1474
|
+
* @returns EIP-1193 compatible provider object
|
|
1475
|
+
*
|
|
1476
|
+
* @example
|
|
1477
|
+
* ```typescript
|
|
1478
|
+
* import { createBankrProvider } from '@zyfai/sdk';
|
|
1479
|
+
* import { ZyfaiSDK } from '@zyfai/sdk';
|
|
1480
|
+
*
|
|
1481
|
+
* const provider = createBankrProvider({ apiKey: process.env.BANKR_API_KEY });
|
|
1482
|
+
* const sdk = new ZyfaiSDK({ apiKey: process.env.ZYFAI_API_KEY });
|
|
1483
|
+
*
|
|
1484
|
+
* const address = await sdk.connectAccount(provider);
|
|
1485
|
+
* await sdk.deploySafe(address, 8453, 'conservative', true);
|
|
1486
|
+
* ```
|
|
1487
|
+
*/
|
|
1488
|
+
declare function createBankrProvider(config: BankrProviderConfig): {
|
|
1489
|
+
/**
|
|
1490
|
+
* EIP-1193 request method
|
|
1491
|
+
* Routes RPC calls to appropriate Bankr API endpoints
|
|
1492
|
+
*/
|
|
1493
|
+
request({ method, params }: {
|
|
1494
|
+
method: string;
|
|
1495
|
+
params?: any[];
|
|
1496
|
+
}): Promise<any>;
|
|
1497
|
+
/**
|
|
1498
|
+
* Event listener stub (required by EIP-1193)
|
|
1499
|
+
* Bankr API doesn't support real-time events
|
|
1500
|
+
*/
|
|
1501
|
+
on: (event: string, callback: (...args: any[]) => void) => void;
|
|
1502
|
+
/**
|
|
1503
|
+
* Remove event listener stub (required by EIP-1193)
|
|
1504
|
+
*/
|
|
1505
|
+
removeListener: (event: string, callback: (...args: any[]) => void) => void;
|
|
1506
|
+
/**
|
|
1507
|
+
* Check if this is a Bankr provider
|
|
1508
|
+
*/
|
|
1509
|
+
isBankr: boolean;
|
|
1510
|
+
};
|
|
1511
|
+
type BankrProvider = ReturnType<typeof createBankrProvider>;
|
|
1512
|
+
|
|
1513
|
+
declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
|
|
1514
|
+
|
|
1515
|
+
export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type ApyPosition, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type LogDepositResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type Portfolio, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, createBankrProvider, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
|