@zyfai/sdk 0.2.57 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +260 -71
- package/dist/index.d.mts +716 -122
- package/dist/index.d.ts +716 -122
- package/dist/index.js +1115 -275
- package/dist/index.mjs +1115 -275
- package/package.json +9 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Chain, PublicClient, Address as Address$1 } from 'viem';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Public TypeScript types for `@zyfai/sdk` request/response shapes and events.
|
|
5
5
|
*/
|
|
6
|
+
/** Checksummed Ethereum address. */
|
|
6
7
|
type Address = `0x${string}`;
|
|
8
|
+
/** Hex-encoded byte string (e.g. signatures, calldata). */
|
|
7
9
|
type Hex = `0x${string}`;
|
|
8
10
|
/**
|
|
9
11
|
* Public strategy names.
|
|
@@ -12,20 +14,85 @@ type Hex = `0x${string}`;
|
|
|
12
14
|
*/
|
|
13
15
|
type Strategy = "conservative" | "aggressive" | "yieldmaxxing";
|
|
14
16
|
/** Public asset symbols supported by the SDK */
|
|
15
|
-
type SupportedAsset = "USDC" | "WETH" | "EURC";
|
|
17
|
+
type SupportedAsset = "USDC" | "WETH" | "EURC" | "NVDAc";
|
|
18
|
+
/** Optional per-chain RPC URLs for on-chain reads and writes. */
|
|
16
19
|
interface RpcUrlsConfig {
|
|
20
|
+
/** Ethereum mainnet */
|
|
17
21
|
1?: string;
|
|
22
|
+
/** Base */
|
|
18
23
|
8453?: string;
|
|
24
|
+
/** Arbitrum One */
|
|
19
25
|
42161?: string;
|
|
20
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* SDK constructor configuration.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* A single partner `apiKey` authenticates both execution and data API calls.
|
|
32
|
+
*/
|
|
21
33
|
interface SDKConfig {
|
|
34
|
+
/** Partner API key from [sdk.zyf.ai](https://sdk.zyf.ai). */
|
|
22
35
|
apiKey: string;
|
|
36
|
+
/** Override default viem RPC endpoints per chain. */
|
|
23
37
|
rpcUrls?: RpcUrlsConfig;
|
|
38
|
+
/** Optional attribution string sent on SIWE login. */
|
|
24
39
|
referralSource?: string;
|
|
25
40
|
/** @internal Local integration tests only — not part of the public SDK contract. */
|
|
26
41
|
executionApiUrl?: string;
|
|
27
42
|
/** @internal Local integration tests only — not part of the public SDK contract. */
|
|
28
43
|
dataApiUrl?: string;
|
|
44
|
+
/** @internal Override client-side minimum portfolio checks (local integration). */
|
|
45
|
+
bypassMinPortfolio?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Pre-authenticated user session for server-side SDK clients (e.g. MCP).
|
|
49
|
+
* Skips SIWE `connectAccount` when the Zyfai access token is already known.
|
|
50
|
+
*/
|
|
51
|
+
/** Agent autonomy limits for MCP / delegated management. */
|
|
52
|
+
interface AgentMandate {
|
|
53
|
+
id: string;
|
|
54
|
+
oauthClientId: string;
|
|
55
|
+
/** Maximum USD of one deposit. Not total capital under management. */
|
|
56
|
+
maxDepositUsd?: string | null;
|
|
57
|
+
allowedChainIds: number[];
|
|
58
|
+
allowedAssets: string[];
|
|
59
|
+
allowRebalance: boolean;
|
|
60
|
+
allowWithdraw: boolean;
|
|
61
|
+
expiresAt?: string | null;
|
|
62
|
+
}
|
|
63
|
+
interface UpsertAgentMandateRequest {
|
|
64
|
+
oauthClientId: string;
|
|
65
|
+
/** Maximum USD of one deposit. Not total capital under management. */
|
|
66
|
+
maxDepositUsd?: string | null;
|
|
67
|
+
allowedChainIds?: number[];
|
|
68
|
+
allowedAssets?: string[];
|
|
69
|
+
allowRebalance?: boolean;
|
|
70
|
+
allowWithdraw?: boolean;
|
|
71
|
+
expiresAt?: string | null;
|
|
72
|
+
}
|
|
73
|
+
/** One-time prepare → enter binding for MCP deposit flows (least-unit amount). */
|
|
74
|
+
interface CreateAgentEnterIntentRequest {
|
|
75
|
+
chainId: number;
|
|
76
|
+
amount: string;
|
|
77
|
+
asset: SupportedAsset;
|
|
78
|
+
strategy?: Strategy;
|
|
79
|
+
}
|
|
80
|
+
interface AgentEnterIntent {
|
|
81
|
+
actionId: string;
|
|
82
|
+
expiresAt: string;
|
|
83
|
+
}
|
|
84
|
+
interface ConsumeAgentEnterIntentRequest {
|
|
85
|
+
chainId: number;
|
|
86
|
+
amount: string;
|
|
87
|
+
asset: SupportedAsset;
|
|
88
|
+
}
|
|
89
|
+
interface UserSessionAuth {
|
|
90
|
+
/** Zyfai execution API JWT from SIWE login. */
|
|
91
|
+
accessToken: string;
|
|
92
|
+
/** Authenticated user id when available. */
|
|
93
|
+
userId?: string;
|
|
94
|
+
/** User EOA address (checksum) for address binding checks. */
|
|
95
|
+
eoa?: Address;
|
|
29
96
|
}
|
|
30
97
|
interface DeploySafeResponse {
|
|
31
98
|
success: boolean;
|
|
@@ -66,6 +133,22 @@ interface UpdateUserProfileResponse {
|
|
|
66
133
|
asset?: SupportedAsset;
|
|
67
134
|
}
|
|
68
135
|
/** @internal */
|
|
136
|
+
interface LoginResponse {
|
|
137
|
+
userId: string;
|
|
138
|
+
accessToken?: string;
|
|
139
|
+
refreshToken?: string;
|
|
140
|
+
tokenExpires?: number;
|
|
141
|
+
hasActiveSessionKey?: boolean;
|
|
142
|
+
smartWallet?: string | null;
|
|
143
|
+
/**
|
|
144
|
+
* True when the smart wallet was provisioned by the predeployment pool
|
|
145
|
+
* (backend-owned at deploy, rotated to the user on first deposit). Such
|
|
146
|
+
* wallets are already deployed with the agent session enabled, so the client
|
|
147
|
+
* skips deploy, never signs a session key, and never derives the address.
|
|
148
|
+
*/
|
|
149
|
+
predeployed?: boolean;
|
|
150
|
+
}
|
|
151
|
+
/** @internal */
|
|
69
152
|
interface AddSessionKeyResponse {
|
|
70
153
|
id: string;
|
|
71
154
|
hash: string;
|
|
@@ -408,9 +491,8 @@ interface OnchainEarnings {
|
|
|
408
491
|
totalEarningsByToken: TokenEarnings;
|
|
409
492
|
totalEarningsByChain?: ChainTokenEarnings;
|
|
410
493
|
/**
|
|
411
|
-
* Net totals: lifetime + unrealized + current × (1 - feeRate).
|
|
412
|
-
*
|
|
413
|
-
* Does not apply feeRate to lifetime (already crystallised).
|
|
494
|
+
* Net totals: (lifetime + unrealized + current) × (1 - feeRate).
|
|
495
|
+
* Ledger buckets are gross. Crystallized yield is fee × 10.
|
|
414
496
|
*/
|
|
415
497
|
totalEarningsByTokenWithFee: TokenEarnings;
|
|
416
498
|
totalEarningsByChainWithFee?: ChainTokenEarnings;
|
|
@@ -460,16 +542,20 @@ interface DebankPortfolioResponse {
|
|
|
460
542
|
totalValueUsd: number;
|
|
461
543
|
chains: Record<string, ChainPortfolio>;
|
|
462
544
|
}
|
|
545
|
+
/** Yield opportunity row from the data API opportunities endpoints. */
|
|
463
546
|
interface Opportunity {
|
|
547
|
+
/** Opportunity identifier. */
|
|
464
548
|
id: string;
|
|
465
549
|
protocolId: string;
|
|
466
550
|
protocolName: string;
|
|
467
551
|
poolName: string;
|
|
468
552
|
chainId: number;
|
|
553
|
+
/** Gross APY percentage. */
|
|
469
554
|
apy: number;
|
|
470
555
|
tvl?: number;
|
|
471
556
|
asset?: string;
|
|
472
557
|
risk?: string;
|
|
558
|
+
/** Public {@link Strategy} bucket for this pool. */
|
|
473
559
|
strategyType: Strategy;
|
|
474
560
|
status?: string;
|
|
475
561
|
}
|
|
@@ -519,21 +605,58 @@ interface RebalanceFrequencyResponse {
|
|
|
519
605
|
frequency: number;
|
|
520
606
|
description?: string;
|
|
521
607
|
}
|
|
608
|
+
/** Result of {@link ZyfaiSDK.sendDeposit} and {@link ZyfaiSDK.depositFunds}. */
|
|
522
609
|
interface DepositResponse {
|
|
523
610
|
success: boolean;
|
|
611
|
+
/** On-chain ERC-20 transfer transaction hash. */
|
|
524
612
|
txHash: string;
|
|
613
|
+
/** Safe address that received the transfer. */
|
|
525
614
|
smartWallet: string;
|
|
615
|
+
/** Deposited amount in least units (decimal string). */
|
|
526
616
|
amount: string;
|
|
617
|
+
/**
|
|
618
|
+
* Deposit lifecycle record. After `sendDeposit`, status is usually
|
|
619
|
+
* `handover_pending` until {@link ZyfaiSDK.waitForDepositCredit} completes.
|
|
620
|
+
*/
|
|
621
|
+
registration: DepositLifecycleResponse;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Custody handover and balance-credit states for a registered deposit.
|
|
625
|
+
*
|
|
626
|
+
* @remarks
|
|
627
|
+
* `credited` with `balanceCredited: true` means funds are investable.
|
|
628
|
+
*/
|
|
629
|
+
type DepositLifecycleStatus = "handover_pending" | "credited" | "recovered_to_eoa";
|
|
630
|
+
/** Deposit registration and credit lifecycle (execution API). */
|
|
631
|
+
interface DepositLifecycleResponse {
|
|
632
|
+
/** Lifecycle id — pass to {@link ZyfaiSDK.getDepositStatus} / {@link ZyfaiSDK.waitForDepositCredit}. */
|
|
633
|
+
id: string;
|
|
634
|
+
status: DepositLifecycleStatus;
|
|
635
|
+
/** True when the Safe balance reflects the deposit. */
|
|
636
|
+
balanceCredited: boolean;
|
|
637
|
+
/** Backend URL for status polling (informational). */
|
|
638
|
+
statusUrl: string;
|
|
527
639
|
}
|
|
528
640
|
interface LogDepositResponse {
|
|
529
641
|
success: boolean;
|
|
530
642
|
message: string;
|
|
643
|
+
deposit: DepositLifecycleResponse;
|
|
531
644
|
}
|
|
645
|
+
/** Polling overrides for {@link ZyfaiSDK.waitForDepositCredit}. */
|
|
646
|
+
interface WaitForDepositCreditOptions {
|
|
647
|
+
/** Milliseconds between {@link ZyfaiSDK.getDepositStatus} calls. */
|
|
648
|
+
intervalMs?: number;
|
|
649
|
+
/** Maximum wait before throwing `DepositCreditTimeoutError`. */
|
|
650
|
+
timeoutMs?: number;
|
|
651
|
+
}
|
|
652
|
+
/** Result of {@link ZyfaiSDK.withdrawFunds}. */
|
|
532
653
|
interface WithdrawResponse {
|
|
533
654
|
success: boolean;
|
|
534
655
|
message: string;
|
|
656
|
+
/** Present once the withdrawal transaction is submitted on-chain. */
|
|
535
657
|
txHash?: string;
|
|
536
658
|
type: "full" | "partial";
|
|
659
|
+
/** Withdrawn amount in least units (decimal string). */
|
|
537
660
|
amount: string;
|
|
538
661
|
}
|
|
539
662
|
interface AddWalletToSdkResponse {
|
|
@@ -566,7 +689,9 @@ interface UserPosition {
|
|
|
566
689
|
pool: string;
|
|
567
690
|
tvl: number;
|
|
568
691
|
}
|
|
692
|
+
/** Input for {@link ZyfaiSDK.simulateBestPositions}. */
|
|
569
693
|
interface SimulateBestPositionsParams {
|
|
694
|
+
/** Human-readable amount (not least units). */
|
|
570
695
|
amount: number;
|
|
571
696
|
token: string;
|
|
572
697
|
networks: number | number[];
|
|
@@ -613,6 +738,7 @@ interface ExcludedPool {
|
|
|
613
738
|
detail: string;
|
|
614
739
|
failed_checks?: string[];
|
|
615
740
|
}
|
|
741
|
+
/** Simulation result keyed by chain id string. */
|
|
616
742
|
interface SimulateBestPositionsResponse {
|
|
617
743
|
success: boolean;
|
|
618
744
|
data: Record<string, SimulatedPosition[]>;
|
|
@@ -669,10 +795,13 @@ interface RegisterAgentResponse {
|
|
|
669
795
|
chainId: number;
|
|
670
796
|
smartWallet: string;
|
|
671
797
|
}
|
|
798
|
+
/** One protocol/pool customization row for {@link ZyfaiSDK.customizeBatch}. */
|
|
672
799
|
interface CustomizationConfig {
|
|
673
800
|
protocolId: string;
|
|
801
|
+
/** Pool display names; empty when `autoselect` is true. */
|
|
674
802
|
pools: string[];
|
|
675
803
|
chainId: number;
|
|
804
|
+
/** When true, the engine picks pools automatically. */
|
|
676
805
|
autoselect: boolean;
|
|
677
806
|
}
|
|
678
807
|
interface CustomizeBatchRequest {
|
|
@@ -781,11 +910,13 @@ interface LiquidityDropEvent {
|
|
|
781
910
|
windowMinutes: number;
|
|
782
911
|
timestamp: string;
|
|
783
912
|
}
|
|
913
|
+
/** Optional subscribe filters for {@link ZyfaiSDK.subscribeToEvents}. */
|
|
784
914
|
interface ZyfaiEventFilters {
|
|
785
915
|
chains?: string[];
|
|
786
916
|
protocols?: string[];
|
|
787
917
|
pools?: string[];
|
|
788
918
|
}
|
|
919
|
+
/** WebSocket event callbacks for {@link ZyfaiSDK.subscribeToEvents}. */
|
|
789
920
|
interface ZyfaiEventHandlers {
|
|
790
921
|
onDepeg?: (data: DepegEvent) => void;
|
|
791
922
|
onNewCollateralDetected?: (data: NewCollateralDetectedEvent) => void;
|
|
@@ -794,32 +925,49 @@ interface ZyfaiEventHandlers {
|
|
|
794
925
|
}
|
|
795
926
|
|
|
796
927
|
/**
|
|
797
|
-
* Chain
|
|
798
|
-
*
|
|
928
|
+
* Chain configuration for SDK execution chains (Ethereum, Base, Arbitrum).
|
|
929
|
+
*
|
|
930
|
+
* @remarks
|
|
931
|
+
* Sonic and other data-only chains may appear in asset metadata but are not
|
|
932
|
+
* {@link SupportedChainId} execution targets.
|
|
799
933
|
*/
|
|
800
934
|
|
|
935
|
+
/** Chain IDs supported for deposits, withdrawals, and on-chain SDK calls. */
|
|
801
936
|
type SupportedChainId = 1 | 8453 | 42161;
|
|
937
|
+
/** viem chain, RPC URL, and public client for a {@link SupportedChainId}. */
|
|
802
938
|
interface ChainConfig {
|
|
803
939
|
chain: Chain;
|
|
804
940
|
rpcUrl: string;
|
|
805
941
|
publicClient: PublicClient;
|
|
806
942
|
}
|
|
943
|
+
/** Default USDC token addresses per execution chain. */
|
|
807
944
|
declare const DEFAULT_TOKEN_ADDRESSES: Record<SupportedChainId, string>;
|
|
945
|
+
/**
|
|
946
|
+
* Resolve the canonical ERC-20 address for an asset on a chain.
|
|
947
|
+
*
|
|
948
|
+
* @param chainId - Execution chain
|
|
949
|
+
* @param asset - Asset symbol (defaults to USDC)
|
|
950
|
+
* @returns Token contract address
|
|
951
|
+
* @throws If the asset is not configured on the chain
|
|
952
|
+
*/
|
|
808
953
|
declare const getDefaultTokenAddress: (chainId: SupportedChainId, asset?: string) => string;
|
|
809
954
|
/**
|
|
810
955
|
* Get chain configuration for a given chain ID.
|
|
811
956
|
*
|
|
812
957
|
* @param chainId - Supported chain ID
|
|
813
|
-
* @param rpcUrls - Optional per-chain RPC URL overrides
|
|
958
|
+
* @param rpcUrls - Optional per-chain RPC URL overrides from {@link SDKConfig}
|
|
959
|
+
* @returns Chain metadata and a viem `PublicClient`
|
|
960
|
+
* @throws If `chainId` is not supported
|
|
814
961
|
*/
|
|
815
962
|
declare const getChainConfig: (chainId: SupportedChainId, rpcUrls?: RpcUrlsConfig) => ChainConfig;
|
|
816
963
|
/**
|
|
817
|
-
* Check
|
|
964
|
+
* Check whether a numeric chain id is an SDK execution chain.
|
|
965
|
+
*
|
|
966
|
+
* @param chainId - Chain id to test
|
|
967
|
+
* @returns True when `chainId` is {@link SupportedChainId}
|
|
818
968
|
*/
|
|
819
969
|
declare const isSupportedChain: (chainId: number) => chainId is SupportedChainId;
|
|
820
|
-
/**
|
|
821
|
-
* Get all supported chain IDs
|
|
822
|
-
*/
|
|
970
|
+
/** List all {@link SupportedChainId} values. */
|
|
823
971
|
declare const getSupportedChainIds: () => SupportedChainId[];
|
|
824
972
|
|
|
825
973
|
/**
|
|
@@ -836,6 +984,20 @@ type DailyApyHistoryPeriod = `${AllowedHistoryDays}D`;
|
|
|
836
984
|
* Zyfai SDK Main Class
|
|
837
985
|
*/
|
|
838
986
|
|
|
987
|
+
/**
|
|
988
|
+
* Client for Zyfai execution (`api.zyf.ai`) and intelligence (`defiapi.zyf.ai`) APIs.
|
|
989
|
+
*
|
|
990
|
+
* @remarks
|
|
991
|
+
* The connected wallet from {@link ZyfaiSDK.connectAccount} is used for **signing only**
|
|
992
|
+
* (SIWE, on-chain transfers). Pass the user's **EOA** as `userAddress` on execution
|
|
993
|
+
* methods; the backend resolves the assigned Safe.
|
|
994
|
+
*
|
|
995
|
+
* First-time onboarding uses predeployed Safes: {@link ZyfaiSDK.sendDeposit} handles
|
|
996
|
+
* session and deploy-on-first-deposit without {@link ZyfaiSDK.deploySafe} or
|
|
997
|
+
* {@link ZyfaiSDK.createSessionKey}.
|
|
998
|
+
*
|
|
999
|
+
* @see {@link https://docs.zyf.ai/docs/sdk/agent-quickstart | Agent quickstart}
|
|
1000
|
+
*/
|
|
839
1001
|
declare class ZyfaiSDK {
|
|
840
1002
|
private httpClient;
|
|
841
1003
|
private signer;
|
|
@@ -848,12 +1010,77 @@ declare class ZyfaiSDK {
|
|
|
848
1010
|
private currentChainId;
|
|
849
1011
|
private rpcUrls?;
|
|
850
1012
|
private referralSource?;
|
|
1013
|
+
/** EOA of the active user session (bearer or SIWE). Cleared on disconnect. */
|
|
1014
|
+
private sessionEoa;
|
|
1015
|
+
/**
|
|
1016
|
+
* Create an SDK instance with an existing Zyfai user JWT (no wallet connected).
|
|
1017
|
+
*
|
|
1018
|
+
* @group Authentication and wallet
|
|
1019
|
+
*/
|
|
1020
|
+
static forUser(config: SDKConfig | string, session: UserSessionAuth): ZyfaiSDK;
|
|
1021
|
+
/** Alias for MCP delegated grants (scoped agent JWT). */
|
|
1022
|
+
static forDelegatedGrant(config: SDKConfig | string, session: UserSessionAuth): ZyfaiSDK;
|
|
1023
|
+
/**
|
|
1024
|
+
* Attach a Zyfai user JWT for API calls without `connectAccount`.
|
|
1025
|
+
*
|
|
1026
|
+
* @group Authentication and wallet
|
|
1027
|
+
*/
|
|
1028
|
+
applyUserSession(session: UserSessionAuth): void;
|
|
851
1029
|
/**
|
|
852
|
-
*
|
|
1030
|
+
* @internal Attach headers to execution API requests (MCP server agent channel).
|
|
1031
|
+
*/
|
|
1032
|
+
setExecutionRequestHeaders(headers: Record<string, string>): void;
|
|
1033
|
+
/** EOA of the active user session, if one is bound. */
|
|
1034
|
+
getSessionEoa(): Address | null;
|
|
1035
|
+
/**
|
|
1036
|
+
* Complete SIWE login with a prepared message and signature (OAuth consent, MCP).
|
|
1037
|
+
*
|
|
1038
|
+
* @group Authentication and wallet
|
|
1039
|
+
*
|
|
1040
|
+
* @param params.message - SIWE message fields (same shape as login API body)
|
|
1041
|
+
* @param params.signature - Wallet signature over the prepared SIWE string
|
|
1042
|
+
* @param params.origin - Origin header value; must match `message.uri`
|
|
1043
|
+
*/
|
|
1044
|
+
authenticateWithSignature(params: {
|
|
1045
|
+
message: {
|
|
1046
|
+
address: string;
|
|
1047
|
+
chainId: number;
|
|
1048
|
+
domain: string;
|
|
1049
|
+
nonce: string;
|
|
1050
|
+
statement?: string;
|
|
1051
|
+
uri: string;
|
|
1052
|
+
version: string;
|
|
1053
|
+
issuedAt: string;
|
|
1054
|
+
resources?: string[];
|
|
1055
|
+
notBefore?: string;
|
|
1056
|
+
expirationTime?: string;
|
|
1057
|
+
};
|
|
1058
|
+
signature: Hex;
|
|
1059
|
+
origin?: string;
|
|
1060
|
+
}): Promise<LoginResponse>;
|
|
1061
|
+
/**
|
|
1062
|
+
* Warn that a legacy method is deprecated in favor of sendDeposit.
|
|
853
1063
|
* Predeployed wallets no longer require deploySafe / createSessionKey.
|
|
854
1064
|
*/
|
|
855
1065
|
private warnDeprecatedOnboardingMethod;
|
|
856
1066
|
private readonly executionApiUrl;
|
|
1067
|
+
private readonly bypassMinPortfolio;
|
|
1068
|
+
/**
|
|
1069
|
+
* Create an SDK instance bound to a partner API key.
|
|
1070
|
+
*
|
|
1071
|
+
* @param config - API key string or {@link SDKConfig} with optional `rpcUrls` and `referralSource`
|
|
1072
|
+
*
|
|
1073
|
+
* @remarks
|
|
1074
|
+
* `@internal` fields on {@link SDKConfig} (`executionApiUrl`, `dataApiUrl`,
|
|
1075
|
+
* `bypassMinPortfolio`) are for local integration tests only.
|
|
1076
|
+
*
|
|
1077
|
+
* @throws If `apiKey` is missing
|
|
1078
|
+
*
|
|
1079
|
+
* @example
|
|
1080
|
+
* ```typescript
|
|
1081
|
+
* const sdk = new ZyfaiSDK({ apiKey: process.env.ZYFAI_API_KEY! });
|
|
1082
|
+
* ```
|
|
1083
|
+
*/
|
|
857
1084
|
constructor(config: SDKConfig | string);
|
|
858
1085
|
/**
|
|
859
1086
|
* Authenticate user with SIWE (Sign-In with Ethereum) & JWT token
|
|
@@ -867,8 +1094,12 @@ declare class ZyfaiSDK {
|
|
|
867
1094
|
* Update user profile with Smart Wallet address and chain configuration
|
|
868
1095
|
* This method requires SIWE authentication and is automatically called after deploySafe
|
|
869
1096
|
*
|
|
870
|
-
* @
|
|
871
|
-
*
|
|
1097
|
+
* @group Portfolio and execution
|
|
1098
|
+
*
|
|
1099
|
+
* @param request - Profile fields to update (per-asset settings supported)
|
|
1100
|
+
* @returns Updated user profile from the execution API
|
|
1101
|
+
*
|
|
1102
|
+
* @throws If strategy is invalid or authentication fails
|
|
872
1103
|
*
|
|
873
1104
|
* @example
|
|
874
1105
|
* ```typescript
|
|
@@ -883,8 +1114,12 @@ declare class ZyfaiSDK {
|
|
|
883
1114
|
* Pause the agent by clearing all protocols
|
|
884
1115
|
* Sets the user's protocols to an empty array, effectively pausing automated operations
|
|
885
1116
|
*
|
|
1117
|
+
* @group Portfolio and execution
|
|
1118
|
+
*
|
|
886
1119
|
* @returns Response indicating success and updated user details
|
|
887
1120
|
*
|
|
1121
|
+
* @remarks Requires {@link ZyfaiSDK.connectAccount} (SIWE).
|
|
1122
|
+
*
|
|
888
1123
|
* @example
|
|
889
1124
|
* ```typescript
|
|
890
1125
|
* const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
|
|
@@ -902,8 +1137,12 @@ declare class ZyfaiSDK {
|
|
|
902
1137
|
* Resume the agent by restoring protocols based on user's strategy for each asset
|
|
903
1138
|
* Fetches available protocols and assigns them based on each asset's strategy
|
|
904
1139
|
*
|
|
1140
|
+
* @group Portfolio and execution
|
|
1141
|
+
*
|
|
905
1142
|
* @returns Response indicating success and updated user details
|
|
906
1143
|
*
|
|
1144
|
+
* @remarks Requires {@link ZyfaiSDK.connectAccount} (SIWE).
|
|
1145
|
+
*
|
|
907
1146
|
* @example
|
|
908
1147
|
* ```typescript
|
|
909
1148
|
* const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
|
|
@@ -921,9 +1160,16 @@ declare class ZyfaiSDK {
|
|
|
921
1160
|
* Enable splitting for the user's account
|
|
922
1161
|
* When enabled, deposits are split across multiple protocols based on minSplits setting
|
|
923
1162
|
*
|
|
924
|
-
* @
|
|
1163
|
+
* @group Portfolio and execution
|
|
1164
|
+
*
|
|
1165
|
+
* @param minSplits - Minimum protocols to split across (max 4)
|
|
1166
|
+
* @defaultValue 1
|
|
925
1167
|
* @returns Response indicating success and updated user details
|
|
926
1168
|
*
|
|
1169
|
+
* @remarks Requires {@link ZyfaiSDK.connectAccount} (SIWE).
|
|
1170
|
+
*
|
|
1171
|
+
* @throws If `minSplits` exceeds 4
|
|
1172
|
+
*
|
|
927
1173
|
* @example
|
|
928
1174
|
* ```typescript
|
|
929
1175
|
* const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
|
|
@@ -941,8 +1187,12 @@ declare class ZyfaiSDK {
|
|
|
941
1187
|
* Disable splitting for the user's account
|
|
942
1188
|
* When disabled, deposits will not be split across multiple protocols
|
|
943
1189
|
*
|
|
1190
|
+
* @group Portfolio and execution
|
|
1191
|
+
*
|
|
944
1192
|
* @returns Response indicating success and updated user details
|
|
945
1193
|
*
|
|
1194
|
+
* @remarks Requires {@link ZyfaiSDK.connectAccount} (SIWE).
|
|
1195
|
+
*
|
|
946
1196
|
* @example
|
|
947
1197
|
* ```typescript
|
|
948
1198
|
* const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
|
|
@@ -960,9 +1210,13 @@ declare class ZyfaiSDK {
|
|
|
960
1210
|
* Update the minimum number of splits for the user's account
|
|
961
1211
|
* This controls across how many protocols deposits should be distributed
|
|
962
1212
|
*
|
|
963
|
-
* @
|
|
1213
|
+
* @group Portfolio and execution
|
|
1214
|
+
*
|
|
1215
|
+
* @param minSplits - Minimum number of protocols to split across (at least 1)
|
|
964
1216
|
* @returns Response indicating success and updated user details
|
|
965
1217
|
*
|
|
1218
|
+
* @throws If `minSplits` is less than 1
|
|
1219
|
+
*
|
|
966
1220
|
* @example
|
|
967
1221
|
* ```typescript
|
|
968
1222
|
* const sdk = new ZyfaiSDK({ apiKey: 'your-api-key' });
|
|
@@ -998,12 +1252,20 @@ declare class ZyfaiSDK {
|
|
|
998
1252
|
*/
|
|
999
1253
|
private handleAccountsChanged;
|
|
1000
1254
|
/**
|
|
1001
|
-
* Connect account for signing
|
|
1002
|
-
*
|
|
1255
|
+
* Connect an account for signing (SIWE and on-chain transfers).
|
|
1256
|
+
*
|
|
1257
|
+
* @remarks
|
|
1258
|
+
* Required before user-scoped execution calls (deposits, withdrawals, profile).
|
|
1259
|
+
* Data API reads typically need only the API key.
|
|
1003
1260
|
*
|
|
1004
|
-
* @
|
|
1005
|
-
*
|
|
1006
|
-
* @
|
|
1261
|
+
* @group Authentication and wallet
|
|
1262
|
+
*
|
|
1263
|
+
* @param account - Private key hex string or EIP-1193 wallet provider
|
|
1264
|
+
* @param chainId - Initial chain for RPC and SIWE
|
|
1265
|
+
* @defaultValue 8453
|
|
1266
|
+
* @returns The connected EOA address (checksum)
|
|
1267
|
+
*
|
|
1268
|
+
* @throws If the chain is unsupported or the provider returns no accounts
|
|
1007
1269
|
*
|
|
1008
1270
|
* @example
|
|
1009
1271
|
* // With private key
|
|
@@ -1016,8 +1278,11 @@ declare class ZyfaiSDK {
|
|
|
1016
1278
|
*/
|
|
1017
1279
|
connectAccount(account: string | any, chainId?: SupportedChainId): Promise<Address>;
|
|
1018
1280
|
/**
|
|
1019
|
-
*
|
|
1020
|
-
*
|
|
1281
|
+
* Clear the connected wallet, SIWE session, and cached smart-wallet state.
|
|
1282
|
+
*
|
|
1283
|
+
* @group Authentication and wallet
|
|
1284
|
+
*
|
|
1285
|
+
* @returns Resolves when local SDK state is cleared
|
|
1021
1286
|
*
|
|
1022
1287
|
* @example
|
|
1023
1288
|
* ```typescript
|
|
@@ -1044,24 +1309,32 @@ declare class ZyfaiSDK {
|
|
|
1044
1309
|
*/
|
|
1045
1310
|
private getSafeAddressFor;
|
|
1046
1311
|
/**
|
|
1047
|
-
*
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
1312
|
+
* Resolve the Safe smart wallet for an EOA on a chain.
|
|
1313
|
+
*
|
|
1314
|
+
* @remarks
|
|
1315
|
+
* Predeployed pool wallets use a backend-assigned address; legacy wallets use
|
|
1316
|
+
* a deterministic CREATE2 address.
|
|
1317
|
+
*
|
|
1318
|
+
* @group Authentication and wallet
|
|
1050
1319
|
*
|
|
1051
1320
|
* @param userAddress - User's EOA address
|
|
1052
1321
|
* @param chainId - Target chain ID
|
|
1053
|
-
* @returns Smart wallet address, deployment status, and
|
|
1054
|
-
*
|
|
1055
|
-
*
|
|
1322
|
+
* @returns Smart wallet address, deployment status, and on-chain ownership flag
|
|
1323
|
+
*
|
|
1324
|
+
* @throws If `userAddress` is missing or `chainId` is unsupported
|
|
1056
1325
|
*/
|
|
1057
1326
|
getSmartWalletAddress(userAddress: string, chainId: SupportedChainId): Promise<SmartWalletResponse>;
|
|
1058
1327
|
/**
|
|
1059
1328
|
* Deploy Safe Smart Wallet for a user
|
|
1060
1329
|
*
|
|
1061
|
-
* @deprecated Prefer
|
|
1330
|
+
* @deprecated Prefer {@link ZyfaiSDK.sendDeposit}. Predeployed Safes and session keys are
|
|
1062
1331
|
* managed automatically on first deposit. This method remains available for
|
|
1063
1332
|
* legacy flows.
|
|
1064
1333
|
*
|
|
1334
|
+
* @see {@link ZyfaiSDK.sendDeposit}
|
|
1335
|
+
*
|
|
1336
|
+
* @group Deposits and withdrawals
|
|
1337
|
+
*
|
|
1065
1338
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
1066
1339
|
* @param chainId - Target chain ID
|
|
1067
1340
|
* @param strategy - Optional strategy selection: "conservative" (default), "aggressive" or "yieldmaxxing"
|
|
@@ -1070,8 +1343,9 @@ declare class ZyfaiSDK {
|
|
|
1070
1343
|
*
|
|
1071
1344
|
* @example
|
|
1072
1345
|
* ```typescript
|
|
1073
|
-
* // Preferred:
|
|
1074
|
-
* await sdk.
|
|
1346
|
+
* // Preferred: sendDeposit handles predeployed wallet onboarding
|
|
1347
|
+
* const sent = await sdk.sendDeposit(userAddress, 8453, amount, "USDC");
|
|
1348
|
+
* await sdk.waitForDepositCredit(sent.registration.id, 8453);
|
|
1075
1349
|
*
|
|
1076
1350
|
* // Legacy: deploy with default conservative strategy
|
|
1077
1351
|
* await sdk.deploySafe(userAddress, 8453);
|
|
@@ -1082,18 +1356,23 @@ declare class ZyfaiSDK {
|
|
|
1082
1356
|
* Create session key with auto-fetched configuration from Zyfai API
|
|
1083
1357
|
* This is the simplified method that automatically fetches session configuration
|
|
1084
1358
|
*
|
|
1085
|
-
* @deprecated Prefer
|
|
1359
|
+
* @deprecated Prefer {@link ZyfaiSDK.sendDeposit}. Predeployed wallets already have the
|
|
1086
1360
|
* agent session enabled; session activation is handled after first deposit.
|
|
1087
1361
|
* This method remains available for legacy flows.
|
|
1088
1362
|
*
|
|
1363
|
+
* @see {@link ZyfaiSDK.sendDeposit}
|
|
1364
|
+
*
|
|
1365
|
+
* @group Deposits and withdrawals
|
|
1366
|
+
*
|
|
1089
1367
|
* @param userAddress - User's EOA or Safe address
|
|
1090
1368
|
* @param chainId - Target chain ID
|
|
1091
1369
|
* @returns Session key response with signature and nonces
|
|
1092
1370
|
*
|
|
1093
1371
|
* @example
|
|
1094
1372
|
* ```typescript
|
|
1095
|
-
* // Preferred:
|
|
1096
|
-
* await sdk.
|
|
1373
|
+
* // Preferred: sendDeposit handles session onboarding for predeployed wallets
|
|
1374
|
+
* const sent = await sdk.sendDeposit(userAddress, 8453, amount, "USDC");
|
|
1375
|
+
* await sdk.waitForDepositCredit(sent.registration.id, 8453);
|
|
1097
1376
|
*
|
|
1098
1377
|
* // Legacy:
|
|
1099
1378
|
* const result = await sdk.createSessionKey(userAddress, 8453);
|
|
@@ -1116,7 +1395,7 @@ declare class ZyfaiSDK {
|
|
|
1116
1395
|
* asset/chain/strategy combo.
|
|
1117
1396
|
* 4. Persist via `updateUserProfile` (writes `assetTypeSettings`).
|
|
1118
1397
|
*
|
|
1119
|
-
* Called from `deploySafe` after every path, and from `
|
|
1398
|
+
* Called from `deploySafe` after every path, and from `sendDeposit` on
|
|
1120
1399
|
* the account's first deposit (when USDC chains are still empty).
|
|
1121
1400
|
*
|
|
1122
1401
|
* @internal
|
|
@@ -1127,6 +1406,47 @@ declare class ZyfaiSDK {
|
|
|
1127
1406
|
* @internal
|
|
1128
1407
|
*/
|
|
1129
1408
|
private updateUserProtocolsForAsset;
|
|
1409
|
+
/**
|
|
1410
|
+
* Switch one asset to a strategy and select the protocols that go with it.
|
|
1411
|
+
*
|
|
1412
|
+
* `updateUserProfile` stores a strategy but does not compute a protocol
|
|
1413
|
+
* list, so on its own it leaves the asset with nothing to deploy into. This
|
|
1414
|
+
* method does both in one call: it resolves the protocols that support the
|
|
1415
|
+
* asset on the requested chains under the requested strategy, drops those
|
|
1416
|
+
* with no pool available, and persists strategy, chains and protocols
|
|
1417
|
+
* together.
|
|
1418
|
+
*
|
|
1419
|
+
* Mostly needed for assets that are not set up by the account's first
|
|
1420
|
+
* deposit, or to change an existing account's strategy — `sendDeposit`
|
|
1421
|
+
* ignores its `strategy` argument after the first deposit.
|
|
1422
|
+
*
|
|
1423
|
+
* @param params.asset - Asset to configure
|
|
1424
|
+
* @param params.strategy - Strategy to apply; defaults to the one already
|
|
1425
|
+
* stored for this asset (`"conservative"` on a fresh account), which lets
|
|
1426
|
+
* you recompute a protocol list without changing the strategy
|
|
1427
|
+
* @param params.chains - Chains to enable. Defaults to every chain the asset
|
|
1428
|
+
* exists on. **Additive**: chains already enabled are kept, so this cannot
|
|
1429
|
+
* be used to disable one.
|
|
1430
|
+
* @group Portfolio and execution
|
|
1431
|
+
*
|
|
1432
|
+
* @returns The updated profile for that asset
|
|
1433
|
+
*
|
|
1434
|
+
* @example
|
|
1435
|
+
* ```typescript
|
|
1436
|
+
* // NVDAc only lives in async protocols, so it needs "yieldmaxxing".
|
|
1437
|
+
* // Chains default to Base, the only chain it exists on.
|
|
1438
|
+
* const profile = await sdk.setAssetStrategy({
|
|
1439
|
+
* asset: "NVDAc",
|
|
1440
|
+
* strategy: "yieldmaxxing",
|
|
1441
|
+
* });
|
|
1442
|
+
* console.log(profile.protocols); // Ipor + Superform
|
|
1443
|
+
* ```
|
|
1444
|
+
*/
|
|
1445
|
+
setAssetStrategy(params: {
|
|
1446
|
+
asset: SupportedAsset;
|
|
1447
|
+
strategy?: Strategy;
|
|
1448
|
+
chains?: SupportedChainId[];
|
|
1449
|
+
}): Promise<UpdateUserProfileResponse>;
|
|
1130
1450
|
/**
|
|
1131
1451
|
* Drop protocols that have no pools on any of the selected chains for the
|
|
1132
1452
|
* requested asset. The /customization/pools endpoint filters server-side on
|
|
@@ -1144,55 +1464,6 @@ declare class ZyfaiSDK {
|
|
|
1144
1464
|
* Convert session nonces from bigint[] to number[]
|
|
1145
1465
|
*/
|
|
1146
1466
|
private normalizeSessionNonces;
|
|
1147
|
-
/**
|
|
1148
|
-
* Deposit funds from EOA to Safe smart wallet
|
|
1149
|
-
* Transfers tokens from the connected wallet to the user's Safe and logs the deposit
|
|
1150
|
-
*
|
|
1151
|
-
* Token address is selected from `asset` for the given chain:
|
|
1152
|
-
* - Ethereum Mainnet (1), Base (8453), Arbitrum (42161): USDC or WETH
|
|
1153
|
-
* - Ethereum Mainnet (1), Base (8453): EURC
|
|
1154
|
-
*
|
|
1155
|
-
* On the account's first deposit (USDC profile has no chains yet), patches
|
|
1156
|
-
* protocol selection for USDC, WETH, and EURC across all supported chains
|
|
1157
|
-
* (EURC on Mainnet/Base only) before the transfer and log_deposit.
|
|
1158
|
-
* Pass `strategy` to select protocols for that first-deposit setup
|
|
1159
|
-
* (same role as the former `deploySafe` strategy argument). On every later
|
|
1160
|
-
* deposit the argument is ignored without error, since re-running the patch
|
|
1161
|
-
* would overwrite a protocol selection the user may have customised. To
|
|
1162
|
-
* change the strategy of an existing account, call
|
|
1163
|
-
* `updateUserProfile({ asset, strategy })`.
|
|
1164
|
-
*
|
|
1165
|
-
* Minimum portfolio balance enforced (Safe balance + deposit amount):
|
|
1166
|
-
* - Stablecoins: `MIN_PORTFOLIO_BALANCE` (Mainnet 10,000 USDC/EURC; Base/Arbitrum 100)
|
|
1167
|
-
* - WETH: about $10,000 on Mainnet, $100 on Base/Arbitrum, from Data API `/price?token=eth`
|
|
1168
|
-
*
|
|
1169
|
-
* @param userAddress - User's address (owner of the Safe)
|
|
1170
|
-
* @param chainId - Target chain ID
|
|
1171
|
-
* @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
|
|
1172
|
-
* @param asset - Asset symbol: "USDC", "WETH", or "EURC".
|
|
1173
|
-
* EURC is supported on Ethereum Mainnet and Base only.
|
|
1174
|
-
* @param strategy - Optional strategy for first-deposit protocol patching:
|
|
1175
|
-
* "conservative" (default), "aggressive" or "yieldmaxxing". Ignored on
|
|
1176
|
-
* later deposits — use `updateUserProfile` to change an existing account.
|
|
1177
|
-
* @returns Deposit response with transaction hash
|
|
1178
|
-
*
|
|
1179
|
-
* @example
|
|
1180
|
-
* ```typescript
|
|
1181
|
-
* // Deposit 10,000 USDC (6 decimals) to Safe on Base
|
|
1182
|
-
* const result = await sdk.depositFunds(
|
|
1183
|
-
* "0xUser...",
|
|
1184
|
-
* 8453,
|
|
1185
|
-
* "10000000000",
|
|
1186
|
-
* "USDC"
|
|
1187
|
-
* );
|
|
1188
|
-
*
|
|
1189
|
-
* // First deposit with aggressive strategy
|
|
1190
|
-
* await sdk.depositFunds(userAddress, 8453, "10000000000", "USDC", "aggressive");
|
|
1191
|
-
*
|
|
1192
|
-
* // Changing the strategy of an account that has already deposited
|
|
1193
|
-
* await sdk.updateUserProfile({ asset: "USDC", strategy: "yieldmaxxing" });
|
|
1194
|
-
* ```
|
|
1195
|
-
*/
|
|
1196
1467
|
/**
|
|
1197
1468
|
* Deploy the connected predeployed (pool) wallet on one or more chains.
|
|
1198
1469
|
*
|
|
@@ -1203,11 +1474,20 @@ declare class ZyfaiSDK {
|
|
|
1203
1474
|
* resolves once all requested chains have landed on-chain. Idempotent — chains
|
|
1204
1475
|
* already deployed are a no-op.
|
|
1205
1476
|
*
|
|
1206
|
-
* Optional for deposits: `
|
|
1477
|
+
* Optional for deposits: `sendDeposit` no longer pre-deploys the target chain — the ERC20
|
|
1207
1478
|
* transfer lands on the counterfactual address and the backend deploys + hands over on first
|
|
1208
1479
|
* deposit (report-deposit). Use this only to pre-provision chains ahead of time.
|
|
1209
1480
|
*
|
|
1210
|
-
* @
|
|
1481
|
+
* @group Deposits and withdrawals
|
|
1482
|
+
*
|
|
1483
|
+
* @param chainIds - Chain IDs to deploy the wallet on (e.g. `[1, 42161]`)
|
|
1484
|
+
* @returns Deployment summary from the execution API
|
|
1485
|
+
*
|
|
1486
|
+
* @throws If `chainIds` is empty or contains an unsupported chain
|
|
1487
|
+
*
|
|
1488
|
+
* @remarks
|
|
1489
|
+
* Requires {@link ZyfaiSDK.connectAccount} (SIWE). Optional ahead of deposits;
|
|
1490
|
+
* {@link ZyfaiSDK.sendDeposit} can deploy on first deposit for predeployed wallets.
|
|
1211
1491
|
*/
|
|
1212
1492
|
deployOnChains(chainIds: SupportedChainId[]): Promise<{
|
|
1213
1493
|
success: boolean;
|
|
@@ -1215,11 +1495,128 @@ declare class ZyfaiSDK {
|
|
|
1215
1495
|
chains: number[];
|
|
1216
1496
|
status: string;
|
|
1217
1497
|
}>;
|
|
1498
|
+
/**
|
|
1499
|
+
* Transfer funds from the connected EOA to the user's Safe and register the deposit.
|
|
1500
|
+
*
|
|
1501
|
+
* @remarks
|
|
1502
|
+
* Execution API + on-chain ERC-20 `transfer`. Confirms the transaction, then calls
|
|
1503
|
+
* {@link ZyfaiSDK.logDeposit}. Pair with {@link ZyfaiSDK.waitForDepositCredit} for
|
|
1504
|
+
* investable balance. Custom-wallet flows: {@link ZyfaiSDK.buildDepositTransfer},
|
|
1505
|
+
* {@link ZyfaiSDK.logDeposit}, {@link ZyfaiSDK.getDepositStatus}.
|
|
1506
|
+
*
|
|
1507
|
+
* Requires {@link ZyfaiSDK.connectAccount}. Pass the **EOA** as `userAddress`.
|
|
1508
|
+
*
|
|
1509
|
+
* @group Deposits and withdrawals
|
|
1510
|
+
*
|
|
1511
|
+
* @param userAddress - Owner EOA (not the Safe)
|
|
1512
|
+
* @param chainId - Chain for the transfer
|
|
1513
|
+
* @param amount - Amount in least units (string integer)
|
|
1514
|
+
* @param asset - Asset symbol (`USDC`, `WETH`, `EURC`, `NVDAc`)
|
|
1515
|
+
* @param strategy - Optional first-deposit {@link Strategy}
|
|
1516
|
+
* @returns Transfer receipt and deposit registration (not yet credited until polled)
|
|
1517
|
+
*
|
|
1518
|
+
* @throws If validation fails, minimum portfolio is not met, Safe is unavailable, or transfer/register fails
|
|
1519
|
+
*
|
|
1520
|
+
* @example
|
|
1521
|
+
* ```typescript
|
|
1522
|
+
* await sdk.connectAccount(provider);
|
|
1523
|
+
* const sent = await sdk.sendDeposit(eoa, 8453, "10000000", "USDC", "conservative");
|
|
1524
|
+
* await sdk.waitForDepositCredit(sent.registration.id, 8453);
|
|
1525
|
+
* ```
|
|
1526
|
+
*/
|
|
1527
|
+
sendDeposit(userAddress: string, chainId: SupportedChainId, amount: string, asset: string, strategy?: Strategy): Promise<DepositResponse>;
|
|
1528
|
+
/**
|
|
1529
|
+
* @deprecated Compatibility convenience method. Prefer {@link ZyfaiSDK.sendDeposit} followed by
|
|
1530
|
+
* {@link ZyfaiSDK.waitForDepositCredit} when the caller owns the completion UX.
|
|
1531
|
+
*
|
|
1532
|
+
* @see {@link ZyfaiSDK.sendDeposit}
|
|
1533
|
+
*
|
|
1534
|
+
* @group Deposits and withdrawals
|
|
1535
|
+
*/
|
|
1218
1536
|
depositFunds(userAddress: string, chainId: SupportedChainId, amount: string, asset: string, strategy?: Strategy): Promise<DepositResponse>;
|
|
1537
|
+
/**
|
|
1538
|
+
* Build ERC-20 transfer calldata for a custom signer or sponsored tx flow.
|
|
1539
|
+
*
|
|
1540
|
+
* @remarks
|
|
1541
|
+
* Compose with {@link ZyfaiSDK.ensureFirstDepositSetup}, submit the transfer, then
|
|
1542
|
+
* {@link ZyfaiSDK.logDeposit} and {@link ZyfaiSDK.waitForDepositCredit}.
|
|
1543
|
+
*
|
|
1544
|
+
* @group Deposits and withdrawals
|
|
1545
|
+
*
|
|
1546
|
+
* @param params.userAddress - Owner EOA
|
|
1547
|
+
* @param params.chainId - Target chain
|
|
1548
|
+
* @param params.amount - Least units (string integer)
|
|
1549
|
+
* @param params.asset - {@link SupportedAsset}
|
|
1550
|
+
* @returns Safe address, token, and encoded `transfer` calldata
|
|
1551
|
+
*
|
|
1552
|
+
* @throws If inputs are invalid or the Safe address cannot be resolved
|
|
1553
|
+
*/
|
|
1554
|
+
buildDepositTransfer(params: {
|
|
1555
|
+
userAddress: string;
|
|
1556
|
+
chainId: SupportedChainId;
|
|
1557
|
+
amount: string;
|
|
1558
|
+
asset: SupportedAsset;
|
|
1559
|
+
}): Promise<{
|
|
1560
|
+
safeAddress: Address;
|
|
1561
|
+
tokenAddress: Address;
|
|
1562
|
+
to: Address;
|
|
1563
|
+
data: Hex;
|
|
1564
|
+
value: "0";
|
|
1565
|
+
}>;
|
|
1566
|
+
/** Apply the same per-asset minimum portfolio rule as sendDeposit. */
|
|
1567
|
+
private enforceMinimumPortfolioBalance;
|
|
1568
|
+
/**
|
|
1569
|
+
* Idempotently apply the first-deposit profile configuration for builders
|
|
1570
|
+
* composing an advanced custom transfer flow. Most custom-wallet
|
|
1571
|
+
* integrations can use this with `buildDepositTransfer()` and `logDeposit()`.
|
|
1572
|
+
*
|
|
1573
|
+
* When setup runs (`applied: true`), protocol configuration is persisted
|
|
1574
|
+
* before returning. Failures throw so callers can abort before submitting a
|
|
1575
|
+
* transfer. High-level deposit methods still treat setup as best-effort.
|
|
1576
|
+
*
|
|
1577
|
+
* @group Deposits and withdrawals
|
|
1578
|
+
*
|
|
1579
|
+
* @param strategy - Optional first-deposit {@link Strategy}
|
|
1580
|
+
* @returns `{ applied: true }` when chain/protocol config was written; `false` if already configured
|
|
1581
|
+
*
|
|
1582
|
+
* @throws If strategy is invalid or setup did not persist
|
|
1583
|
+
*/
|
|
1584
|
+
ensureFirstDepositSetup(strategy?: Strategy): Promise<{
|
|
1585
|
+
applied: boolean;
|
|
1586
|
+
}>;
|
|
1587
|
+
/**
|
|
1588
|
+
* Prepare entering a position: persist first-deposit profile when needed and
|
|
1589
|
+
* return ERC-20 transfer calldata for the user to sign (does not broadcast).
|
|
1590
|
+
*
|
|
1591
|
+
* @group Deposits and withdrawals
|
|
1592
|
+
*/
|
|
1593
|
+
prepareEnterPosition(params: {
|
|
1594
|
+
userAddress: string;
|
|
1595
|
+
chainId: SupportedChainId;
|
|
1596
|
+
amount: string;
|
|
1597
|
+
asset: SupportedAsset;
|
|
1598
|
+
strategy?: Strategy;
|
|
1599
|
+
}): Promise<{
|
|
1600
|
+
phase: "prepare_transfer";
|
|
1601
|
+
setup: {
|
|
1602
|
+
applied: boolean;
|
|
1603
|
+
};
|
|
1604
|
+
transfer: {
|
|
1605
|
+
safeAddress: Address;
|
|
1606
|
+
tokenAddress: Address;
|
|
1607
|
+
to: Address;
|
|
1608
|
+
data: Hex;
|
|
1609
|
+
value: "0";
|
|
1610
|
+
};
|
|
1611
|
+
}>;
|
|
1612
|
+
/** Best-effort first-deposit setup shared by both high-level deposit flows. */
|
|
1613
|
+
private prepareFirstDeposit;
|
|
1614
|
+
/** Shared post-transfer registration path for every deposit flow. */
|
|
1615
|
+
private registerDeposit;
|
|
1219
1616
|
/**
|
|
1220
1617
|
* Log a deposit that was executed client-side.
|
|
1221
1618
|
*
|
|
1222
|
-
* `
|
|
1619
|
+
* `sendDeposit()` already calls this after the ERC20 transfer. If you send the
|
|
1223
1620
|
* transfer yourself (front, Privy, Biconomy, custom wallet) you **must** call
|
|
1224
1621
|
* `logDeposit` — otherwise the backend never sees the deposit: a reserved pool
|
|
1225
1622
|
* wallet stays reserved (no ownership rotation), and yield/agent tracking does
|
|
@@ -1243,8 +1640,12 @@ declare class ZyfaiSDK {
|
|
|
1243
1640
|
* @param chainId - Chain ID where the deposit was made
|
|
1244
1641
|
* @param txHash - Transaction hash of the deposit
|
|
1245
1642
|
* @param amount - Amount in least decimal units (e.g., "100000000" for 100 USDC with 6 decimals)
|
|
1246
|
-
* @param tokenAddress - Optional
|
|
1247
|
-
* @returns Log deposit response with
|
|
1643
|
+
* @param tokenAddress - Optional token contract (defaults per chain)
|
|
1644
|
+
* @returns Log deposit response with lifecycle record
|
|
1645
|
+
*
|
|
1646
|
+
* @group Deposits and withdrawals
|
|
1647
|
+
*
|
|
1648
|
+
* @throws If inputs are invalid or the execution API rejects registration
|
|
1248
1649
|
*
|
|
1249
1650
|
* @example
|
|
1250
1651
|
* ```typescript
|
|
@@ -1264,6 +1665,45 @@ declare class ZyfaiSDK {
|
|
|
1264
1665
|
* ```
|
|
1265
1666
|
*/
|
|
1266
1667
|
logDeposit(chainId: SupportedChainId, txHash: string, amount: string, tokenAddress?: string): Promise<LogDepositResponse>;
|
|
1668
|
+
/**
|
|
1669
|
+
* Fetch custody handover and balance-credit status for a registered deposit.
|
|
1670
|
+
*
|
|
1671
|
+
* @remarks
|
|
1672
|
+
* `status === "credited"` with `balanceCredited === true` means funds are investable.
|
|
1673
|
+
* Requires {@link ZyfaiSDK.connectAccount} (SIWE).
|
|
1674
|
+
*
|
|
1675
|
+
* @group Deposits and withdrawals
|
|
1676
|
+
*
|
|
1677
|
+
* @param depositId - Id from {@link LogDepositResponse} / {@link DepositResponse.registration}
|
|
1678
|
+
* @returns {@link DepositLifecycleResponse}
|
|
1679
|
+
*
|
|
1680
|
+
* @throws If `depositId` is missing
|
|
1681
|
+
*/
|
|
1682
|
+
getDepositStatus(depositId: string): Promise<DepositLifecycleResponse>;
|
|
1683
|
+
/**
|
|
1684
|
+
* Await deposit credit after `logDeposit` returns `handover_pending`.
|
|
1685
|
+
*
|
|
1686
|
+
* Polls `getDepositStatus` until `status === "credited"` and
|
|
1687
|
+
* `balanceCredited === true`. Rejects on recovery, timeout, or poll errors.
|
|
1688
|
+
*
|
|
1689
|
+
* Poll interval and timeout are chain-specific. Mainnet defaults to a 2s
|
|
1690
|
+
* interval and 1 minute ceiling; Base/Arbitrum use tighter polling (~500ms /
|
|
1691
|
+
* ~250ms) with a ~20 second completion window. Override `timeoutMs` when a
|
|
1692
|
+
* caller intentionally wants to wait longer than the normal UX window.
|
|
1693
|
+
*
|
|
1694
|
+
* Requires {@link ZyfaiSDK.connectAccount} on the same SDK instance.
|
|
1695
|
+
*
|
|
1696
|
+
* @group Deposits and withdrawals
|
|
1697
|
+
*
|
|
1698
|
+
* @param depositId - Deposit lifecycle id
|
|
1699
|
+
* @param chainId - Chain (controls poll interval and default timeout)
|
|
1700
|
+
* @param options - Optional `intervalMs` and `timeoutMs` overrides
|
|
1701
|
+
* @returns Final lifecycle record when credited
|
|
1702
|
+
*
|
|
1703
|
+
* @throws `DepositCreditTimeoutError` when the poll window elapses without credit
|
|
1704
|
+
* @throws If deposit recovers to EOA or polling fails
|
|
1705
|
+
*/
|
|
1706
|
+
waitForDepositCredit(depositId: string, chainId: SupportedChainId, options?: WaitForDepositCreditOptions): Promise<DepositLifecycleResponse>;
|
|
1267
1707
|
/**
|
|
1268
1708
|
* Withdraw funds from Safe smart wallet
|
|
1269
1709
|
* Initiates a withdrawal request to the Zyfai API
|
|
@@ -1283,6 +1723,13 @@ declare class ZyfaiSDK {
|
|
|
1283
1723
|
* When every source is an async pool nothing settles on-chain at that point,
|
|
1284
1724
|
* so `txHash` is `undefined` on a successful call.
|
|
1285
1725
|
*
|
|
1726
|
+
* **One redemption per pool at a time.** While an entry for a pool is
|
|
1727
|
+
* `REQUESTED` or `CLAIMABLE`, the backend drops a further withdrawal aimed at
|
|
1728
|
+
* that same pool — the protocols behind it (ERC-7540) hold a single request
|
|
1729
|
+
* slot per user. This method throws rather than reporting that no-op as a
|
|
1730
|
+
* success. It only throws when nothing the call could reach is withdrawable:
|
|
1731
|
+
* another pool, another asset or an idle Safe balance still goes through.
|
|
1732
|
+
*
|
|
1286
1733
|
* Once requested, that amount can no longer be withdrawn: it is gone from
|
|
1287
1734
|
* both the position snapshot and the Safe balance, so a second call silently
|
|
1288
1735
|
* returns only what is left. Validate user-entered amounts against
|
|
@@ -1291,8 +1738,13 @@ declare class ZyfaiSDK {
|
|
|
1291
1738
|
*
|
|
1292
1739
|
* @param userAddress - User's address (owner of the Safe)
|
|
1293
1740
|
* @param chainId - Target chain ID
|
|
1294
|
-
* @param amount - Optional
|
|
1295
|
-
* @
|
|
1741
|
+
* @param amount - Optional amount in least units (partial withdrawal); omit for full withdraw
|
|
1742
|
+
* @param tokenSymbol - Optional asset symbol when withdrawing a specific token
|
|
1743
|
+
* @returns Withdraw response with message and optional transaction hash
|
|
1744
|
+
*
|
|
1745
|
+
* @group Deposits and withdrawals
|
|
1746
|
+
*
|
|
1747
|
+
* @throws If `userAddress` or `chainId` is invalid, or the execution API rejects the request
|
|
1296
1748
|
*
|
|
1297
1749
|
* @example
|
|
1298
1750
|
* ```typescript
|
|
@@ -1310,11 +1762,25 @@ declare class ZyfaiSDK {
|
|
|
1310
1762
|
*/
|
|
1311
1763
|
withdrawFunds(userAddress: string, chainId: SupportedChainId, amount?: string, tokenSymbol?: string): Promise<WithdrawResponse>;
|
|
1312
1764
|
/**
|
|
1313
|
-
*
|
|
1765
|
+
* Turn a withdrawal the backend would silently drop — one aimed only at
|
|
1766
|
+
* async pools that already hold an in-flight redemption — into an error, so
|
|
1767
|
+
* the caller gets an answer rather than a `success: true` no-op.
|
|
1768
|
+
*
|
|
1769
|
+
* @internal
|
|
1770
|
+
*/
|
|
1771
|
+
private assertAsyncRedemptionSlotFree;
|
|
1772
|
+
/**
|
|
1773
|
+
* Get available DeFi protocols and pools for a specific chain.
|
|
1774
|
+
*
|
|
1775
|
+
* @group Portfolio and execution
|
|
1776
|
+
*
|
|
1777
|
+
* @remarks Execution API. Partner API key only.
|
|
1314
1778
|
*
|
|
1315
1779
|
* @param chainId - Target chain ID
|
|
1316
1780
|
* @returns List of available protocols with their pools and APY data
|
|
1317
1781
|
*
|
|
1782
|
+
* @throws If `chainId` is unsupported
|
|
1783
|
+
*
|
|
1318
1784
|
* @example
|
|
1319
1785
|
* ```typescript
|
|
1320
1786
|
* const protocols = await sdk.getAvailableProtocols(8453);
|
|
@@ -1325,11 +1791,15 @@ declare class ZyfaiSDK {
|
|
|
1325
1791
|
*/
|
|
1326
1792
|
getAvailableProtocols(chainId: SupportedChainId): Promise<ProtocolsResponse>;
|
|
1327
1793
|
/**
|
|
1328
|
-
* Get
|
|
1794
|
+
* Get active DeFi positions for a user.
|
|
1795
|
+
*
|
|
1796
|
+
* @group Portfolio and execution
|
|
1797
|
+
*
|
|
1798
|
+
* @remarks Execution API (`/data/position`). Pass the **EOA**; the SDK resolves the Safe.
|
|
1329
1799
|
*
|
|
1330
1800
|
* @param userAddress - User's EOA address
|
|
1331
|
-
* @param chainId -
|
|
1332
|
-
* @returns User's positions across
|
|
1801
|
+
* @param chainId - Chain used to resolve the Safe (defaults to Base `8453`)
|
|
1802
|
+
* @returns User's positions across protocols
|
|
1333
1803
|
*
|
|
1334
1804
|
* @example
|
|
1335
1805
|
* ```typescript
|
|
@@ -1376,9 +1846,16 @@ declare class ZyfaiSDK {
|
|
|
1376
1846
|
* Do not add `CLAIMED` withdrawals either (the array keeps them for 24
|
|
1377
1847
|
* hours); their funds are back in the Safe and already counted.
|
|
1378
1848
|
*
|
|
1849
|
+
* @group Portfolio and execution
|
|
1850
|
+
*
|
|
1851
|
+
* @remarks Data API portfolio endpoint. See {@link PortfolioDetailed.pendingAsyncWithdrawals}
|
|
1852
|
+
* when using {@link Strategy | yieldmaxxing}.
|
|
1853
|
+
*
|
|
1379
1854
|
* @param userAddress - User's EOA address
|
|
1380
1855
|
* @returns Portfolio with optional fee-adjusted balance fields
|
|
1381
1856
|
*
|
|
1857
|
+
* @throws If `userAddress` is missing
|
|
1858
|
+
*
|
|
1382
1859
|
* @example
|
|
1383
1860
|
* ```typescript
|
|
1384
1861
|
* const { portfolio } = await sdk.getPortfolio(userAddress);
|
|
@@ -1392,10 +1869,15 @@ declare class ZyfaiSDK {
|
|
|
1392
1869
|
*/
|
|
1393
1870
|
getPortfolio(userAddress: string): Promise<PortfolioDetailedResponse>;
|
|
1394
1871
|
/**
|
|
1395
|
-
* Get
|
|
1396
|
-
*
|
|
1872
|
+
* Get the authenticated user's profile for an asset.
|
|
1873
|
+
*
|
|
1874
|
+
* @group Portfolio and execution
|
|
1397
1875
|
*
|
|
1398
|
-
* @
|
|
1876
|
+
* @remarks Execution API. Requires {@link ZyfaiSDK.connectAccount} (SIWE).
|
|
1877
|
+
*
|
|
1878
|
+
* @param asset - Asset slice of the profile to return
|
|
1879
|
+
* @defaultValue `"USDC"`
|
|
1880
|
+
* @returns User details including smart wallet, chains, and protocols
|
|
1399
1881
|
*
|
|
1400
1882
|
* @example
|
|
1401
1883
|
* ```typescript
|
|
@@ -1407,9 +1889,13 @@ declare class ZyfaiSDK {
|
|
|
1407
1889
|
*/
|
|
1408
1890
|
getUserDetails(asset?: SupportedAsset): Promise<UpdateUserProfileResponse>;
|
|
1409
1891
|
/**
|
|
1410
|
-
* Get total value locked (TVL) across all Zyfai accounts
|
|
1892
|
+
* Get total value locked (TVL) across all Zyfai accounts.
|
|
1893
|
+
*
|
|
1894
|
+
* @group Analytics and opportunities
|
|
1411
1895
|
*
|
|
1412
|
-
* @
|
|
1896
|
+
* @remarks Data API. Partner API key only; SIWE not required.
|
|
1897
|
+
*
|
|
1898
|
+
* @returns Total TVL in USD
|
|
1413
1899
|
*
|
|
1414
1900
|
* @example
|
|
1415
1901
|
* ```typescript
|
|
@@ -1419,7 +1905,11 @@ declare class ZyfaiSDK {
|
|
|
1419
1905
|
*/
|
|
1420
1906
|
getTVL(): Promise<TVLResponse>;
|
|
1421
1907
|
/**
|
|
1422
|
-
* Get APY per strategy for a specific chain
|
|
1908
|
+
* Get APY per strategy for a specific chain.
|
|
1909
|
+
*
|
|
1910
|
+
* @group Analytics and opportunities
|
|
1911
|
+
*
|
|
1912
|
+
* @remarks Data API. Partner API key only.
|
|
1423
1913
|
*
|
|
1424
1914
|
* @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
|
|
1425
1915
|
* @param days - Time period: 7, 14, or 30
|
|
@@ -1436,7 +1926,11 @@ declare class ZyfaiSDK {
|
|
|
1436
1926
|
*/
|
|
1437
1927
|
getAPYPerStrategy(crossChain?: boolean, days?: number, strategy?: Strategy, chainId?: number, tokenSymbol?: string): Promise<APYPerStrategyResponse>;
|
|
1438
1928
|
/**
|
|
1439
|
-
* Get total volume across all Zyfai accounts
|
|
1929
|
+
* Get total volume across all Zyfai accounts.
|
|
1930
|
+
*
|
|
1931
|
+
* @group Analytics and opportunities
|
|
1932
|
+
*
|
|
1933
|
+
* @remarks Data API. Partner API key only.
|
|
1440
1934
|
*
|
|
1441
1935
|
* @returns Total volume in USD
|
|
1442
1936
|
*
|
|
@@ -1448,7 +1942,11 @@ declare class ZyfaiSDK {
|
|
|
1448
1942
|
*/
|
|
1449
1943
|
getVolume(assetType?: "usdc" | "eth" | "eurc"): Promise<VolumeResponse>;
|
|
1450
1944
|
/**
|
|
1451
|
-
* Get active wallets for a specific chain
|
|
1945
|
+
* Get active wallets for a specific chain.
|
|
1946
|
+
*
|
|
1947
|
+
* @group Analytics and opportunities
|
|
1948
|
+
*
|
|
1949
|
+
* @remarks Data API. Partner API key only.
|
|
1452
1950
|
*
|
|
1453
1951
|
* @param chainId - Chain ID to filter wallets
|
|
1454
1952
|
* @returns List of active wallets on the specified chain
|
|
@@ -1461,7 +1959,11 @@ declare class ZyfaiSDK {
|
|
|
1461
1959
|
*/
|
|
1462
1960
|
getActiveWallets(chainId: number): Promise<ActiveWalletsResponse>;
|
|
1463
1961
|
/**
|
|
1464
|
-
* Get smart wallets associated with an EOA address
|
|
1962
|
+
* Get smart wallets associated with an EOA address.
|
|
1963
|
+
*
|
|
1964
|
+
* @group Analytics and opportunities
|
|
1965
|
+
*
|
|
1966
|
+
* @remarks Data API. Partner API key only.
|
|
1465
1967
|
*
|
|
1466
1968
|
* @param eoaAddress - EOA (externally owned account) address
|
|
1467
1969
|
* @returns List of smart wallets owned by the EOA
|
|
@@ -1474,7 +1976,11 @@ declare class ZyfaiSDK {
|
|
|
1474
1976
|
*/
|
|
1475
1977
|
getSmartWalletByEOA(eoaAddress: string): Promise<SmartWalletByEOAResponse>;
|
|
1476
1978
|
/**
|
|
1477
|
-
* Get the first topup (deposit) information for a wallet
|
|
1979
|
+
* Get the first topup (deposit) information for a wallet.
|
|
1980
|
+
*
|
|
1981
|
+
* @group Analytics and opportunities
|
|
1982
|
+
*
|
|
1983
|
+
* @remarks Data API. Partner API key only.
|
|
1478
1984
|
*
|
|
1479
1985
|
* @param walletAddress - Smart wallet address
|
|
1480
1986
|
* @param chainId - Chain ID
|
|
@@ -1488,7 +1994,11 @@ declare class ZyfaiSDK {
|
|
|
1488
1994
|
*/
|
|
1489
1995
|
getFirstTopup(walletAddress: string, chainId: number): Promise<FirstTopupResponse>;
|
|
1490
1996
|
/**
|
|
1491
|
-
* Get transaction history for a wallet
|
|
1997
|
+
* Get transaction history for a wallet.
|
|
1998
|
+
*
|
|
1999
|
+
* @group Analytics and opportunities
|
|
2000
|
+
*
|
|
2001
|
+
* @remarks Data API. Partner API key only.
|
|
1492
2002
|
*
|
|
1493
2003
|
* @param walletAddress - Smart wallet address
|
|
1494
2004
|
* @param chainId - Chain ID
|
|
@@ -1512,11 +2022,15 @@ declare class ZyfaiSDK {
|
|
|
1512
2022
|
assetType?: "usdc" | "eth" | "eurc";
|
|
1513
2023
|
}): Promise<HistoryResponse>;
|
|
1514
2024
|
/**
|
|
1515
|
-
* Get onchain earnings for a wallet
|
|
2025
|
+
* Get onchain earnings for a wallet.
|
|
2026
|
+
*
|
|
2027
|
+
* @group Analytics and opportunities
|
|
2028
|
+
*
|
|
2029
|
+
* @remarks Data API. Partner API key only.
|
|
1516
2030
|
*
|
|
1517
2031
|
* Includes gross totals plus net-of-fee totals:
|
|
1518
|
-
* `totalEarningsByTokenWithFee = lifetime + unrealized + current × (1 - feeRate)`.
|
|
1519
|
-
*
|
|
2032
|
+
* `totalEarningsByTokenWithFee = (lifetime + unrealized + current) × (1 - feeRate)`.
|
|
2033
|
+
* Ledger buckets are gross, so the keep-rate applies to all three.
|
|
1520
2034
|
*
|
|
1521
2035
|
* @param walletAddress - Smart wallet address
|
|
1522
2036
|
* @returns Onchain earnings data with per-token breakdowns
|
|
@@ -1573,7 +2087,11 @@ declare class ZyfaiSDK {
|
|
|
1573
2087
|
*/
|
|
1574
2088
|
getDailyEarnings(walletAddress: string, startDate?: string, endDate?: string): Promise<DailyEarningsResponse>;
|
|
1575
2089
|
/**
|
|
1576
|
-
* Get conservative (low-risk) yield opportunities
|
|
2090
|
+
* Get conservative (low-risk) yield opportunities.
|
|
2091
|
+
*
|
|
2092
|
+
* @group Analytics and opportunities
|
|
2093
|
+
*
|
|
2094
|
+
* @remarks Data API. Partner API key only.
|
|
1577
2095
|
*
|
|
1578
2096
|
* @param chainId - Optional chain ID filter
|
|
1579
2097
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
@@ -1739,6 +2257,10 @@ declare class ZyfaiSDK {
|
|
|
1739
2257
|
* Allows granular control over which pools to use for each protocol on each chain.
|
|
1740
2258
|
* This is useful for advanced users who want to target specific pools with desired APY/risk profiles.
|
|
1741
2259
|
*
|
|
2260
|
+
* @group Customization and simulation
|
|
2261
|
+
*
|
|
2262
|
+
* @remarks Execution API. Requires {@link ZyfaiSDK.connectAccount} (SIWE).
|
|
2263
|
+
*
|
|
1742
2264
|
* @param customizations - Array of customization configurations
|
|
1743
2265
|
* @returns Response indicating success
|
|
1744
2266
|
*
|
|
@@ -1767,14 +2289,56 @@ declare class ZyfaiSDK {
|
|
|
1767
2289
|
* ]);
|
|
1768
2290
|
* ```
|
|
1769
2291
|
*/
|
|
2292
|
+
/**
|
|
2293
|
+
* Get the user's agent management mandate (autonomy limits).
|
|
2294
|
+
*
|
|
2295
|
+
* @group Agent management
|
|
2296
|
+
*/
|
|
2297
|
+
getAgentMandate(oauthClientId?: string): Promise<{
|
|
2298
|
+
data: AgentMandate | null;
|
|
2299
|
+
}>;
|
|
2300
|
+
/**
|
|
2301
|
+
* Create or update the user's agent management mandate.
|
|
2302
|
+
*
|
|
2303
|
+
* @group Agent management
|
|
2304
|
+
*/
|
|
2305
|
+
setAgentMandate(request: UpsertAgentMandateRequest): Promise<{
|
|
2306
|
+
data: AgentMandate;
|
|
2307
|
+
}>;
|
|
2308
|
+
/**
|
|
2309
|
+
* Revoke the user's agent management mandate.
|
|
2310
|
+
*
|
|
2311
|
+
* @group Agent management
|
|
2312
|
+
*/
|
|
2313
|
+
revokeAgentMandate(oauthClientId: string): Promise<{
|
|
2314
|
+
success: boolean;
|
|
2315
|
+
}>;
|
|
2316
|
+
/**
|
|
2317
|
+
* Reserve a one-time action id before the user signs an ERC-20 transfer.
|
|
2318
|
+
*
|
|
2319
|
+
* @group Agent management
|
|
2320
|
+
*/
|
|
2321
|
+
createAgentEnterIntent(request: CreateAgentEnterIntentRequest): Promise<{
|
|
2322
|
+
data: AgentEnterIntent;
|
|
2323
|
+
}>;
|
|
2324
|
+
/**
|
|
2325
|
+
* Consume a one-time action id when registering the signed deposit.
|
|
2326
|
+
*
|
|
2327
|
+
* @group Agent management
|
|
2328
|
+
*/
|
|
2329
|
+
consumeAgentEnterIntent(actionId: string, request: ConsumeAgentEnterIntentRequest): Promise<void>;
|
|
1770
2330
|
customizeBatch(customizations: CustomizationConfig[]): Promise<CustomizeBatchResponse>;
|
|
1771
2331
|
/**
|
|
1772
2332
|
* Get available pools for a protocol.
|
|
1773
2333
|
*
|
|
1774
2334
|
* Returns the list of pools available for a given protocol, optionally filtered by strategy.
|
|
1775
2335
|
*
|
|
2336
|
+
* @group Customization and simulation
|
|
2337
|
+
*
|
|
2338
|
+
* @remarks Execution API. Partner API key only.
|
|
2339
|
+
*
|
|
1776
2340
|
* @param protocolId - The protocol UUID
|
|
1777
|
-
* @param strategy - Optional
|
|
2341
|
+
* @param strategy - Optional {@link Strategy} filter
|
|
1778
2342
|
* @returns List of available pool names
|
|
1779
2343
|
*
|
|
1780
2344
|
* @example
|
|
@@ -1799,7 +2363,11 @@ declare class ZyfaiSDK {
|
|
|
1799
2363
|
* calldata contains a "<RECEIVER>" placeholder that must be replaced with the
|
|
1800
2364
|
* actual receiving address (e.g. the user's Safe) before sending the transaction.
|
|
1801
2365
|
*
|
|
1802
|
-
* @
|
|
2366
|
+
* @group Customization and simulation
|
|
2367
|
+
*
|
|
2368
|
+
* @remarks Data API simulation endpoint. Partner API key only.
|
|
2369
|
+
*
|
|
2370
|
+
* @param params - {@link SimulateBestPositionsParams}
|
|
1803
2371
|
* @returns Chain-keyed map of simulated positions with calldata
|
|
1804
2372
|
*
|
|
1805
2373
|
* @example
|
|
@@ -1822,6 +2390,10 @@ declare class ZyfaiSDK {
|
|
|
1822
2390
|
* Returns the pools that are currently configured for the authenticated user
|
|
1823
2391
|
* for a given protocol and chain combination.
|
|
1824
2392
|
*
|
|
2393
|
+
* @group Customization and simulation
|
|
2394
|
+
*
|
|
2395
|
+
* @remarks Execution API. Requires {@link ZyfaiSDK.connectAccount} (SIWE).
|
|
2396
|
+
*
|
|
1825
2397
|
* @param protocolId - The protocol UUID
|
|
1826
2398
|
* @param chainId - The chain ID
|
|
1827
2399
|
* @returns Currently selected pools and autoselect status
|
|
@@ -1867,10 +2439,13 @@ declare class ZyfaiSDK {
|
|
|
1867
2439
|
*/
|
|
1868
2440
|
registerAgentOnIdentityRegistry(smartWallet: string, chainId: SupportedChainId): Promise<RegisterAgentResponse>;
|
|
1869
2441
|
/**
|
|
1870
|
-
* Deposit assets into the Zyfai Vault
|
|
1871
|
-
*
|
|
2442
|
+
* Deposit assets into the Zyfai Vault (USDC on Base by default).
|
|
2443
|
+
*
|
|
2444
|
+
* @group Vault
|
|
1872
2445
|
*
|
|
1873
|
-
* @
|
|
2446
|
+
* @remarks On-chain vault flow via connected wallet. Requires {@link ZyfaiSDK.connectAccount}.
|
|
2447
|
+
*
|
|
2448
|
+
* @param amount - Human-readable amount (e.g. `"100"` USDC)
|
|
1874
2449
|
* @param asset - Asset to deposit (default: "USDC")
|
|
1875
2450
|
* @returns Deposit transaction result
|
|
1876
2451
|
*
|
|
@@ -1946,9 +2521,14 @@ declare class ZyfaiSDK {
|
|
|
1946
2521
|
* Events: depeg, liquidity_trap, liquidity_restored, pool_status_change,
|
|
1947
2522
|
* new_collateral_detected, liquidity_drop.
|
|
1948
2523
|
*
|
|
1949
|
-
* @
|
|
1950
|
-
*
|
|
1951
|
-
* @
|
|
2524
|
+
* @group Realtime events
|
|
2525
|
+
*
|
|
2526
|
+
* @remarks Connects to defi-api WebSocket (`WS_ENDPOINT`). Auto-reconnects every 3s until
|
|
2527
|
+
* the returned cleanup function is called.
|
|
2528
|
+
*
|
|
2529
|
+
* @param handlers - {@link ZyfaiEventHandlers}
|
|
2530
|
+
* @param filters - Optional {@link ZyfaiEventFilters} sent on subscribe
|
|
2531
|
+
* @returns Cleanup function — call it to close the connection and stop reconnecting
|
|
1952
2532
|
*
|
|
1953
2533
|
* @example
|
|
1954
2534
|
* ```typescript
|
|
@@ -1998,8 +2578,13 @@ interface BankrProviderConfig {
|
|
|
1998
2578
|
* const sdk = new ZyfaiSDK({ apiKey: process.env.ZYFAI_API_KEY });
|
|
1999
2579
|
*
|
|
2000
2580
|
* const address = await sdk.connectAccount(provider);
|
|
2001
|
-
* await sdk.
|
|
2581
|
+
* const sent = await sdk.sendDeposit(address, 8453, "10000000", "USDC", "conservative");
|
|
2582
|
+
* await sdk.waitForDepositCredit(sent.registration.id, 8453);
|
|
2002
2583
|
* ```
|
|
2584
|
+
*
|
|
2585
|
+
* @remarks
|
|
2586
|
+
* The provider implements EIP-1193 methods used by the SDK (`eth_requestAccounts`,
|
|
2587
|
+
* `eth_chainId`, `personal_sign`, `eth_sendTransaction`, etc.).
|
|
2003
2588
|
*/
|
|
2004
2589
|
declare function createBankrProvider(config: BankrProviderConfig): {
|
|
2005
2590
|
/**
|
|
@@ -2034,6 +2619,7 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
|
|
|
2034
2619
|
* examples, internal tooling).
|
|
2035
2620
|
*/
|
|
2036
2621
|
|
|
2622
|
+
/** Backend stack selector for URL helper functions. */
|
|
2037
2623
|
type BackendEnvironment = "production" | "staging" | "local";
|
|
2038
2624
|
/** Execution API (zyfai-api) origin — no `/api/v1` suffix. */
|
|
2039
2625
|
declare const EXECUTION_API_BASE_URLS: {
|
|
@@ -2066,8 +2652,16 @@ declare const STAGING_WS_URL: "wss://staging-defiapi.zyf.ai/ws/events";
|
|
|
2066
2652
|
declare const LOCAL_EXECUTION_API_BASE_URL: "http://localhost:3000";
|
|
2067
2653
|
declare const LOCAL_DATA_API_BASE_URL: "http://localhost:3000";
|
|
2068
2654
|
declare const LOCAL_WS_URL: "ws://localhost:3000/ws/events";
|
|
2655
|
+
/**
|
|
2656
|
+
* Execution API origin for an environment (no `/api/v1` suffix).
|
|
2657
|
+
*
|
|
2658
|
+
* @remarks The default {@link ZyfaiSDK} instance always uses production unless
|
|
2659
|
+
* `@internal` test overrides are set on {@link SDKConfig}.
|
|
2660
|
+
*/
|
|
2069
2661
|
declare function getExecutionApiBaseUrl(environment?: BackendEnvironment): string;
|
|
2662
|
+
/** Data API origin for an environment (no `/api/v2` suffix). */
|
|
2070
2663
|
declare function getDataApiBaseUrl(environment?: BackendEnvironment): string;
|
|
2664
|
+
/** Defi-api WebSocket URL (includes `/ws/events`). */
|
|
2071
2665
|
declare function getWsUrl(environment?: BackendEnvironment): string;
|
|
2072
2666
|
|
|
2073
2667
|
declare const VAULT_ADDRESS: "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
|
|
@@ -2116,4 +2710,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
2116
2710
|
*/
|
|
2117
2711
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
2118
2712
|
|
|
2119
|
-
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 BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, 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, 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, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, 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, WS_ENDPOINT, WS_URLS, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
|
|
2713
|
+
export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AgentMandate, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, 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, 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, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UpsertAgentMandateRequest, type UserPosition, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
|