@zyfai/sdk 0.13.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -30
- package/dist/index.d.mts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +31 -31
- package/dist/index.mjs +31 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -163,8 +163,8 @@ console.log("Is Deployed:", walletInfo.isDeployed);
|
|
|
163
163
|
// Deploy the Safe with default conservative strategy (automatically checks if already deployed)
|
|
164
164
|
const result = await sdk.deploySafe(userAddress, 8453);
|
|
165
165
|
|
|
166
|
-
// Or deploy with
|
|
167
|
-
const
|
|
166
|
+
// Or deploy with balance strategy
|
|
167
|
+
const balanceResult = await sdk.deploySafe(userAddress, 8453, "balanced");
|
|
168
168
|
|
|
169
169
|
if (result.success) {
|
|
170
170
|
console.log("Safe Address:", result.safeAddress);
|
|
@@ -178,8 +178,8 @@ if (result.success) {
|
|
|
178
178
|
**Strategy Options:**
|
|
179
179
|
|
|
180
180
|
- `"conservative"` (default): Low-risk, stable yield strategy
|
|
181
|
-
- `"
|
|
182
|
-
- `"
|
|
181
|
+
- `"balanced"`: High-risk, high-reward strategy
|
|
182
|
+
- `"advanced"`: Balance plus protocols with delayed withdrawals — see [Strategies](#strategies)
|
|
183
183
|
|
|
184
184
|
### 2. Multi-Chain Support
|
|
185
185
|
|
|
@@ -335,8 +335,8 @@ Deploy a Safe smart wallet for a user. **Deployment is handled by the backend AP
|
|
|
335
335
|
- `chainId`: Target chain ID
|
|
336
336
|
- `strategy`: Optional strategy selection (default: `"conservative"`)
|
|
337
337
|
- `"conservative"`: Low-risk, stable yield strategy (default)
|
|
338
|
-
- `"
|
|
339
|
-
- `"
|
|
338
|
+
- `"balanced"`: High-risk, high-reward strategy
|
|
339
|
+
- `"advanced"`: Balance plus protocols with delayed withdrawals — see [Strategies](#strategies)
|
|
340
340
|
|
|
341
341
|
**Returns:**
|
|
342
342
|
|
|
@@ -447,15 +447,15 @@ const sent = await sdk.sendDeposit(
|
|
|
447
447
|
// Await custody credit only when this UI needs the completion state.
|
|
448
448
|
const credited = await sdk.waitForDepositCredit(sent.registration.id, 8453);
|
|
449
449
|
|
|
450
|
-
// First deposit with
|
|
451
|
-
const
|
|
450
|
+
// First deposit with balance strategy (protocol patching)
|
|
451
|
+
const balanceSent = await sdk.sendDeposit(
|
|
452
452
|
userAddress,
|
|
453
453
|
8453,
|
|
454
454
|
"10000000",
|
|
455
455
|
"USDC",
|
|
456
|
-
"
|
|
456
|
+
"balanced",
|
|
457
457
|
);
|
|
458
|
-
await sdk.waitForDepositCredit(
|
|
458
|
+
await sdk.waitForDepositCredit(balanceSent.registration.id, 8453);
|
|
459
459
|
|
|
460
460
|
if (credited.status === "credited") {
|
|
461
461
|
console.log("Deposit credited!");
|
|
@@ -486,11 +486,11 @@ if (credited.status === "credited") {
|
|
|
486
486
|
- `sendDeposit()` confirms the transfer (or the Relay fill) and registers its lifecycle, then returns its ID. Call `waitForDepositPosition()` when the UI should wait until allocation finishes. `waitForDepositCredit()` is the shorter wait for credited balance only.
|
|
487
487
|
- `depositFunds()` remains a compatibility wrapper that calls both steps and waits through the normal completion window; it **rejects** if credit is not confirmed in that window (track in-flight deposits with `getDepositStatus()` or call `waitForDepositCredit()` with a longer `timeoutMs`).
|
|
488
488
|
- If first-deposit protocol patching fails, the transfer still runs. `sendDeposit()` throws if deposit registration is not accepted; retry `logDeposit()` after `connectAccount()`.
|
|
489
|
-
- **First deposit only** (before transfer + `log_deposit`): if the USDC profile has no `chains` yet, the SDK patches protocols for **USDC, WETH, EURC, USDT, PYUSD, and NVDAc**, each across the chains it exists on (EURC on Mainnet/Base, USDT and PYUSD on Mainnet, NVDAc on Base → `assetTypeSettings.[usdc|eth|eurc|usdt|pyusd|nvdac]`). Pass optional `strategy` (`"conservative"` default, `"
|
|
490
|
-
- **`strategy` is ignored on later deposits, and no error is raised.** Re-running the patch would overwrite a protocol selection the user may have customised, so passing `"
|
|
489
|
+
- **First deposit only** (before transfer + `log_deposit`): if the USDC profile has no `chains` yet, the SDK patches protocols for **USDC, WETH, EURC, USDT, PYUSD, and NVDAc**, each across the chains it exists on (EURC on Mainnet/Base, USDT and PYUSD on Mainnet, NVDAc on Base → `assetTypeSettings.[usdc|eth|eurc|usdt|pyusd|nvdac]`). Pass optional `strategy` (`"conservative"` default, `"balanced"` or `"advanced"`) — same role as the former `deploySafe` strategy argument. Later deposits skip this.
|
|
490
|
+
- **`strategy` is ignored on later deposits, and no error is raised.** Re-running the patch would overwrite a protocol selection the user may have customised, so passing `"advanced"` to an account that has already deposited leaves it on its current strategy. To change an existing account, use `setStrategyWithProtocols` or `setAssetStrategy` (not `updateUserProfile` alone):
|
|
491
491
|
|
|
492
492
|
```typescript
|
|
493
|
-
await sdk.setStrategyWithProtocols({ strategy: "
|
|
493
|
+
await sdk.setStrategyWithProtocols({ strategy: "advanced" });
|
|
494
494
|
```
|
|
495
495
|
|
|
496
496
|
#### Deposit With an External Wallet (Sponsored Transactions)
|
|
@@ -598,7 +598,7 @@ if (result.success) {
|
|
|
598
598
|
- Check the `message` field for the withdrawal status
|
|
599
599
|
- Use `getHistory()` to track the withdrawal transaction once it's processed
|
|
600
600
|
|
|
601
|
-
**Delayed withdrawals (`
|
|
601
|
+
**Delayed withdrawals (`advanced` strategy)**
|
|
602
602
|
|
|
603
603
|
Positions held in protocols with asynchronous withdrawals (Ipor, Superform)
|
|
604
604
|
cannot be exited on demand. For those the backend sends the immediately
|
|
@@ -752,7 +752,7 @@ it from exactly two sources: the underlying amount of every deployed position,
|
|
|
752
752
|
and the idle balances sitting in the Safe. Anything that is in neither place is
|
|
753
753
|
missing from it.
|
|
754
754
|
|
|
755
|
-
That gap is real under the `
|
|
755
|
+
That gap is real under the `advanced` strategy. When the agent requests a
|
|
756
756
|
redemption from a delayed-withdrawal protocol, the position leaves the snapshot
|
|
757
757
|
immediately while the funds stay in the vault for a day or three. During that
|
|
758
758
|
window they are in no balance field — only in `pendingAsyncWithdrawals`.
|
|
@@ -839,7 +839,7 @@ const user = await sdk.getUserDetails();
|
|
|
839
839
|
console.log("Smart Wallet:", user.user.smartWallet);
|
|
840
840
|
console.log("Active Chains:", user.user.chains);
|
|
841
841
|
console.log("Active Protocols:", user.user.protocols);
|
|
842
|
-
console.log("Strategy:", user.user.strategy); // "conservative" | "
|
|
842
|
+
console.log("Strategy:", user.user.strategy); // "conservative" | "balanced" | "advanced"
|
|
843
843
|
console.log("Has Active Session:", user.user.hasActiveSessionKey);
|
|
844
844
|
|
|
845
845
|
// Feature flags
|
|
@@ -860,7 +860,7 @@ console.log("Wallet Type:", user.user.walletType);
|
|
|
860
860
|
|
|
861
861
|
**Available Fields:**
|
|
862
862
|
- **Core Info**: `id`, `address`, `smartWallet`, `chains`, `protocols`
|
|
863
|
-
- **Strategy**: `strategy` (conservative,
|
|
863
|
+
- **Strategy**: `strategy` (conservative, balance or grow)
|
|
864
864
|
- **Session**: `hasActiveSessionKey` (boolean)
|
|
865
865
|
- **Features**: `autocompounding`, `autoSelectProtocols`, `omniAccount`, `crosschainStrategy`, `executorProxy`, `splitting`, `minSplits`
|
|
866
866
|
- **Optional**: `email`, `telegramId`, `agentName`, `walletType`, `customization`, `registered`
|
|
@@ -1120,16 +1120,16 @@ asyncOpps.data.forEach((o) => {
|
|
|
1120
1120
|
#### Strategies
|
|
1121
1121
|
|
|
1122
1122
|
Every method that takes a `strategy` accepts one of three values. Each tier is a
|
|
1123
|
-
superset of the previous one:
|
|
1124
|
-
and
|
|
1123
|
+
superset of the previous one: a `balanced`-tier user also gets conservative pools,
|
|
1124
|
+
and an `advanced`-tier user gets everything.
|
|
1125
1125
|
|
|
1126
1126
|
| Strategy | Backend value | Pools unlocked |
|
|
1127
1127
|
| --- | --- | --- |
|
|
1128
1128
|
| `conservative` (default) | `safe_strategy` | Low-risk pools only |
|
|
1129
|
-
| `
|
|
1130
|
-
| `
|
|
1129
|
+
| `balanced` | `degen_strategy` | Conservative + higher-risk pools |
|
|
1130
|
+
| `advanced` | `async_strategy` | Balance + pools with **delayed withdrawals** |
|
|
1131
1131
|
|
|
1132
|
-
`
|
|
1132
|
+
`advanced` is the only strategy that changes how withdrawals behave. It
|
|
1133
1133
|
unlocks protocols (Ipor, Superform) that cannot be exited on demand: a
|
|
1134
1134
|
redemption has to be requested, then claimed once the protocol releases the
|
|
1135
1135
|
funds — roughly a day on Ipor, three on Superform. The agent handles both steps,
|
|
@@ -1146,12 +1146,12 @@ entry in `getManagedAssets()` when `asset` is omitted:
|
|
|
1146
1146
|
|
|
1147
1147
|
```typescript
|
|
1148
1148
|
const profiles = await sdk.setStrategyWithProtocols({
|
|
1149
|
-
strategy: "
|
|
1149
|
+
strategy: "advanced",
|
|
1150
1150
|
});
|
|
1151
1151
|
// Or a single asset:
|
|
1152
1152
|
const profile = await sdk.setAssetStrategy({
|
|
1153
1153
|
asset: "NVDAc",
|
|
1154
|
-
strategy: "
|
|
1154
|
+
strategy: "advanced",
|
|
1155
1155
|
});
|
|
1156
1156
|
console.log(profile.protocols); // Ipor + Superform
|
|
1157
1157
|
```
|
|
@@ -1173,8 +1173,8 @@ resuming after `pauseAgent`.
|
|
|
1173
1173
|
**8 decimals, Base only**. It behaves like any other asset — same `sendDeposit`,
|
|
1174
1174
|
`withdrawFunds` and `getPortfolio` — with three differences worth planning for.
|
|
1175
1175
|
|
|
1176
|
-
**It only exists under `
|
|
1177
|
-
and Superform, are both async-only, so a `conservative` or `
|
|
1176
|
+
**It only exists under `advanced`.** The two protocols that hold it, Ipor
|
|
1177
|
+
and Superform, are both async-only, so a `conservative` or `balanced` profile
|
|
1178
1178
|
resolves to zero protocols for NVDAc and the agent has nothing to deploy into.
|
|
1179
1179
|
Every NVDAc withdrawal is therefore a delayed one — read
|
|
1180
1180
|
[Total balance](#total-balance) before showing a balance.
|
|
@@ -1191,7 +1191,7 @@ unaffected. `getPortfolio` returns ready-to-display copy in
|
|
|
1191
1191
|
```typescript
|
|
1192
1192
|
// Existing account: one call sets the strategy and selects the protocols.
|
|
1193
1193
|
// Chains default to Base, the only one NVDAc exists on.
|
|
1194
|
-
await sdk.setAssetStrategy({ asset: "NVDAc", strategy: "
|
|
1194
|
+
await sdk.setAssetStrategy({ asset: "NVDAc", strategy: "advanced" });
|
|
1195
1195
|
|
|
1196
1196
|
// 1 NVDAc = 100000000 (8 decimals). Must leave at least ~$10 in the Safe.
|
|
1197
1197
|
const sentNvda = await sdk.sendDeposit(userAddress, 8453, "100000000", "NVDAc");
|
|
@@ -1286,7 +1286,7 @@ All examples are available in the `examples/` directory:
|
|
|
1286
1286
|
|
|
1287
1287
|
### Opportunities & Rebalancing
|
|
1288
1288
|
|
|
1289
|
-
21. **`get-opportunities.ts`** - Get conservative and
|
|
1289
|
+
21. **`get-opportunities.ts`** - Get conservative and balance yield opportunities
|
|
1290
1290
|
22. **`get-rebalance-info.ts`** - Get rebalance events and frequency tier
|
|
1291
1291
|
|
|
1292
1292
|
### Premium Features
|
|
@@ -1336,8 +1336,8 @@ async function main() {
|
|
|
1336
1336
|
// Deploy Safe with default conservative strategy
|
|
1337
1337
|
const result = await sdk.deploySafe(userAddress, 8453);
|
|
1338
1338
|
|
|
1339
|
-
// Or deploy with
|
|
1340
|
-
// const result = await sdk.deploySafe(userAddress, 8453, "
|
|
1339
|
+
// Or deploy with balance strategy
|
|
1340
|
+
// const result = await sdk.deploySafe(userAddress, 8453, "balanced");
|
|
1341
1341
|
|
|
1342
1342
|
if (result.success) {
|
|
1343
1343
|
console.log("✅ Successfully deployed Safe");
|
package/dist/index.d.mts
CHANGED
|
@@ -10,10 +10,10 @@ type Address = `0x${string}`;
|
|
|
10
10
|
type Hex = `0x${string}`;
|
|
11
11
|
/**
|
|
12
12
|
* Public strategy names.
|
|
13
|
-
* `
|
|
13
|
+
* `advanced` unlocks protocols with asynchronous (delayed) withdrawals —
|
|
14
14
|
* see `PortfolioDetailed.pendingAsyncWithdrawals`.
|
|
15
15
|
*/
|
|
16
|
-
type Strategy = "conservative" | "
|
|
16
|
+
type Strategy = "conservative" | "balanced" | "advanced";
|
|
17
17
|
/** Public asset symbols supported by the SDK */
|
|
18
18
|
type SupportedAsset = "USDC" | "WETH" | "EURC" | "USDT" | "PYUSD" | "NVDAc";
|
|
19
19
|
/** Optional per-chain RPC URLs for on-chain reads and writes. */
|
|
@@ -1548,7 +1548,7 @@ declare class ZyfaiSDK {
|
|
|
1548
1548
|
*
|
|
1549
1549
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
1550
1550
|
* @param chainId - Target chain ID
|
|
1551
|
-
* @param strategy - Optional strategy selection: "conservative" (default), "
|
|
1551
|
+
* @param strategy - Optional strategy selection: "conservative" (default), "balanced" or "advanced"
|
|
1552
1552
|
* @param createSessionKey - If true, automatically creates a session key after deployment (default: false)
|
|
1553
1553
|
* @returns Deployment response with Safe address and transaction hash
|
|
1554
1554
|
*
|
|
@@ -1649,11 +1649,11 @@ declare class ZyfaiSDK {
|
|
|
1649
1649
|
*
|
|
1650
1650
|
* @example
|
|
1651
1651
|
* ```typescript
|
|
1652
|
-
* // NVDAc only lives in async protocols, so it needs "
|
|
1652
|
+
* // NVDAc only lives in async protocols, so it needs "advanced".
|
|
1653
1653
|
* // Chains default to Base, the only chain it exists on.
|
|
1654
1654
|
* const profile = await sdk.setAssetStrategy({
|
|
1655
1655
|
* asset: "NVDAc",
|
|
1656
|
-
* strategy: "
|
|
1656
|
+
* strategy: "advanced",
|
|
1657
1657
|
* });
|
|
1658
1658
|
* console.log(profile.protocols); // Ipor + Superform
|
|
1659
1659
|
* ```
|
|
@@ -1667,7 +1667,7 @@ declare class ZyfaiSDK {
|
|
|
1667
1667
|
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
1668
1668
|
* assets ({@link getManagedAssets}). Prefer this over
|
|
1669
1669
|
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
1670
|
-
* with the tier (including `
|
|
1670
|
+
* with the tier (including `advanced` async venues).
|
|
1671
1671
|
*
|
|
1672
1672
|
* @group Portfolio and execution
|
|
1673
1673
|
*/
|
|
@@ -2176,7 +2176,7 @@ declare class ZyfaiSDK {
|
|
|
2176
2176
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
2177
2177
|
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
2178
2178
|
*
|
|
2179
|
-
* **Delayed withdrawals.** Positions held under the `"
|
|
2179
|
+
* **Delayed withdrawals.** Positions held under the `"advanced"`
|
|
2180
2180
|
* strategy sit in protocols that cannot be exited on demand. For those the
|
|
2181
2181
|
* backend transfers the immediately available portion, then queues a
|
|
2182
2182
|
* redemption for the rest and forwards the funds to the EOA once the
|
|
@@ -2290,7 +2290,7 @@ declare class ZyfaiSDK {
|
|
|
2290
2290
|
* a snapshot, so net values can differ slightly from a fully live calc.
|
|
2291
2291
|
*
|
|
2292
2292
|
* **Total balance.** `portfolioByAssetType` sums deployed positions and idle
|
|
2293
|
-
* Safe balances, and nothing else. Under the `"
|
|
2293
|
+
* Safe balances, and nothing else. Under the `"advanced"` strategy a
|
|
2294
2294
|
* redemption in flight has already left its position and has not landed in
|
|
2295
2295
|
* the Safe yet, so its funds appear in no balance field at all. That makes
|
|
2296
2296
|
* two distinct numbers:
|
|
@@ -2315,7 +2315,7 @@ declare class ZyfaiSDK {
|
|
|
2315
2315
|
* @group Portfolio and execution
|
|
2316
2316
|
*
|
|
2317
2317
|
* @remarks Data API portfolio endpoint. See {@link PortfolioDetailed.pendingAsyncWithdrawals}
|
|
2318
|
-
* when using {@link Strategy |
|
|
2318
|
+
* when using {@link Strategy | grow}.
|
|
2319
2319
|
*
|
|
2320
2320
|
* @param userAddress - User's EOA address
|
|
2321
2321
|
* @returns Portfolio with optional fee-adjusted balance fields
|
|
@@ -2397,7 +2397,7 @@ declare class ZyfaiSDK {
|
|
|
2397
2397
|
*
|
|
2398
2398
|
* @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
|
|
2399
2399
|
* @param days - Time period: 7, 14, or 30
|
|
2400
|
-
* @param strategy - Strategy type: "conservative" (default), "
|
|
2400
|
+
* @param strategy - Strategy type: "conservative" (default), "balanced" or "advanced"
|
|
2401
2401
|
* @param chainId - Optional chain ID filter
|
|
2402
2402
|
* @param tokenSymbol - Optional token symbol filter (e.g. "USDC", "WETH", "WBTC")
|
|
2403
2403
|
* @returns APY per strategy for a specific chain
|
|
@@ -2603,15 +2603,15 @@ declare class ZyfaiSDK {
|
|
|
2603
2603
|
*/
|
|
2604
2604
|
getAggressiveOpportunities(chainId?: number, asset?: string, status?: "live" | "not_live"): Promise<OpportunitiesResponse>;
|
|
2605
2605
|
/**
|
|
2606
|
-
* Get
|
|
2607
|
-
* `"
|
|
2606
|
+
* Get grow opportunities — pools reachable only with the
|
|
2607
|
+
* `"advanced"` strategy, including protocols whose withdrawals are
|
|
2608
2608
|
* asynchronous (Ipor, Superform). Exiting these pools takes about a day
|
|
2609
2609
|
* on Ipor and three on Superform; track the redemption through
|
|
2610
2610
|
* `getPortfolio().portfolio.pendingAsyncWithdrawals`.
|
|
2611
2611
|
*
|
|
2612
2612
|
* @param chainId - Optional chain ID filter
|
|
2613
2613
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH")
|
|
2614
|
-
* @returns List of
|
|
2614
|
+
* @returns List of grow opportunities
|
|
2615
2615
|
*
|
|
2616
2616
|
* @example
|
|
2617
2617
|
* ```typescript
|
package/dist/index.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ type Address = `0x${string}`;
|
|
|
10
10
|
type Hex = `0x${string}`;
|
|
11
11
|
/**
|
|
12
12
|
* Public strategy names.
|
|
13
|
-
* `
|
|
13
|
+
* `advanced` unlocks protocols with asynchronous (delayed) withdrawals —
|
|
14
14
|
* see `PortfolioDetailed.pendingAsyncWithdrawals`.
|
|
15
15
|
*/
|
|
16
|
-
type Strategy = "conservative" | "
|
|
16
|
+
type Strategy = "conservative" | "balanced" | "advanced";
|
|
17
17
|
/** Public asset symbols supported by the SDK */
|
|
18
18
|
type SupportedAsset = "USDC" | "WETH" | "EURC" | "USDT" | "PYUSD" | "NVDAc";
|
|
19
19
|
/** Optional per-chain RPC URLs for on-chain reads and writes. */
|
|
@@ -1548,7 +1548,7 @@ declare class ZyfaiSDK {
|
|
|
1548
1548
|
*
|
|
1549
1549
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
1550
1550
|
* @param chainId - Target chain ID
|
|
1551
|
-
* @param strategy - Optional strategy selection: "conservative" (default), "
|
|
1551
|
+
* @param strategy - Optional strategy selection: "conservative" (default), "balanced" or "advanced"
|
|
1552
1552
|
* @param createSessionKey - If true, automatically creates a session key after deployment (default: false)
|
|
1553
1553
|
* @returns Deployment response with Safe address and transaction hash
|
|
1554
1554
|
*
|
|
@@ -1649,11 +1649,11 @@ declare class ZyfaiSDK {
|
|
|
1649
1649
|
*
|
|
1650
1650
|
* @example
|
|
1651
1651
|
* ```typescript
|
|
1652
|
-
* // NVDAc only lives in async protocols, so it needs "
|
|
1652
|
+
* // NVDAc only lives in async protocols, so it needs "advanced".
|
|
1653
1653
|
* // Chains default to Base, the only chain it exists on.
|
|
1654
1654
|
* const profile = await sdk.setAssetStrategy({
|
|
1655
1655
|
* asset: "NVDAc",
|
|
1656
|
-
* strategy: "
|
|
1656
|
+
* strategy: "advanced",
|
|
1657
1657
|
* });
|
|
1658
1658
|
* console.log(profile.protocols); // Ipor + Superform
|
|
1659
1659
|
* ```
|
|
@@ -1667,7 +1667,7 @@ declare class ZyfaiSDK {
|
|
|
1667
1667
|
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
1668
1668
|
* assets ({@link getManagedAssets}). Prefer this over
|
|
1669
1669
|
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
1670
|
-
* with the tier (including `
|
|
1670
|
+
* with the tier (including `advanced` async venues).
|
|
1671
1671
|
*
|
|
1672
1672
|
* @group Portfolio and execution
|
|
1673
1673
|
*/
|
|
@@ -2176,7 +2176,7 @@ declare class ZyfaiSDK {
|
|
|
2176
2176
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
2177
2177
|
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
2178
2178
|
*
|
|
2179
|
-
* **Delayed withdrawals.** Positions held under the `"
|
|
2179
|
+
* **Delayed withdrawals.** Positions held under the `"advanced"`
|
|
2180
2180
|
* strategy sit in protocols that cannot be exited on demand. For those the
|
|
2181
2181
|
* backend transfers the immediately available portion, then queues a
|
|
2182
2182
|
* redemption for the rest and forwards the funds to the EOA once the
|
|
@@ -2290,7 +2290,7 @@ declare class ZyfaiSDK {
|
|
|
2290
2290
|
* a snapshot, so net values can differ slightly from a fully live calc.
|
|
2291
2291
|
*
|
|
2292
2292
|
* **Total balance.** `portfolioByAssetType` sums deployed positions and idle
|
|
2293
|
-
* Safe balances, and nothing else. Under the `"
|
|
2293
|
+
* Safe balances, and nothing else. Under the `"advanced"` strategy a
|
|
2294
2294
|
* redemption in flight has already left its position and has not landed in
|
|
2295
2295
|
* the Safe yet, so its funds appear in no balance field at all. That makes
|
|
2296
2296
|
* two distinct numbers:
|
|
@@ -2315,7 +2315,7 @@ declare class ZyfaiSDK {
|
|
|
2315
2315
|
* @group Portfolio and execution
|
|
2316
2316
|
*
|
|
2317
2317
|
* @remarks Data API portfolio endpoint. See {@link PortfolioDetailed.pendingAsyncWithdrawals}
|
|
2318
|
-
* when using {@link Strategy |
|
|
2318
|
+
* when using {@link Strategy | grow}.
|
|
2319
2319
|
*
|
|
2320
2320
|
* @param userAddress - User's EOA address
|
|
2321
2321
|
* @returns Portfolio with optional fee-adjusted balance fields
|
|
@@ -2397,7 +2397,7 @@ declare class ZyfaiSDK {
|
|
|
2397
2397
|
*
|
|
2398
2398
|
* @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
|
|
2399
2399
|
* @param days - Time period: 7, 14, or 30
|
|
2400
|
-
* @param strategy - Strategy type: "conservative" (default), "
|
|
2400
|
+
* @param strategy - Strategy type: "conservative" (default), "balanced" or "advanced"
|
|
2401
2401
|
* @param chainId - Optional chain ID filter
|
|
2402
2402
|
* @param tokenSymbol - Optional token symbol filter (e.g. "USDC", "WETH", "WBTC")
|
|
2403
2403
|
* @returns APY per strategy for a specific chain
|
|
@@ -2603,15 +2603,15 @@ declare class ZyfaiSDK {
|
|
|
2603
2603
|
*/
|
|
2604
2604
|
getAggressiveOpportunities(chainId?: number, asset?: string, status?: "live" | "not_live"): Promise<OpportunitiesResponse>;
|
|
2605
2605
|
/**
|
|
2606
|
-
* Get
|
|
2607
|
-
* `"
|
|
2606
|
+
* Get grow opportunities — pools reachable only with the
|
|
2607
|
+
* `"advanced"` strategy, including protocols whose withdrawals are
|
|
2608
2608
|
* asynchronous (Ipor, Superform). Exiting these pools takes about a day
|
|
2609
2609
|
* on Ipor and three on Superform; track the redemption through
|
|
2610
2610
|
* `getPortfolio().portfolio.pendingAsyncWithdrawals`.
|
|
2611
2611
|
*
|
|
2612
2612
|
* @param chainId - Optional chain ID filter
|
|
2613
2613
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH")
|
|
2614
|
-
* @returns List of
|
|
2614
|
+
* @returns List of grow opportunities
|
|
2615
2615
|
*
|
|
2616
2616
|
* @example
|
|
2617
2617
|
* ```typescript
|
package/dist/index.js
CHANGED
|
@@ -1005,7 +1005,7 @@ var ASSET_CONFIGS = {
|
|
|
1005
1005
|
enabled: true
|
|
1006
1006
|
},
|
|
1007
1007
|
// Coinbase B20 tokenized NVIDIA equity. Base only, and only reachable through
|
|
1008
|
-
// protocols with delayed withdrawals — see the `
|
|
1008
|
+
// protocols with delayed withdrawals — see the `advanced` strategy.
|
|
1009
1009
|
NVDAc: {
|
|
1010
1010
|
symbol: "NVDAc",
|
|
1011
1011
|
assetType: "nvdac",
|
|
@@ -1550,15 +1550,15 @@ var signSessionKey = async (config, sessions, allPublicClients, signingParams) =
|
|
|
1550
1550
|
};
|
|
1551
1551
|
|
|
1552
1552
|
// src/utils/strategy.ts
|
|
1553
|
-
var PUBLIC_STRATEGIES = `"conservative", "
|
|
1553
|
+
var PUBLIC_STRATEGIES = `"conservative", "balanced" or "advanced"`;
|
|
1554
1554
|
var SUPPORTED_ASSETS = Object.entries(ASSET_CONFIGS).filter(([, config]) => config?.enabled === true).map(([symbol]) => `"${symbol}"`).join(", ");
|
|
1555
1555
|
function toInternalStrategy(publicStrategy) {
|
|
1556
1556
|
switch (publicStrategy) {
|
|
1557
1557
|
case "conservative":
|
|
1558
1558
|
return "safe_strategy";
|
|
1559
|
-
case "
|
|
1559
|
+
case "balanced":
|
|
1560
1560
|
return "degen_strategy";
|
|
1561
|
-
case "
|
|
1561
|
+
case "advanced":
|
|
1562
1562
|
return "async_strategy";
|
|
1563
1563
|
default:
|
|
1564
1564
|
throw new Error(
|
|
@@ -1571,10 +1571,10 @@ function toPublicStrategy(internalStrategy) {
|
|
|
1571
1571
|
return "conservative";
|
|
1572
1572
|
}
|
|
1573
1573
|
if (internalStrategy === "degen_strategy" || internalStrategy === "degen") {
|
|
1574
|
-
return "
|
|
1574
|
+
return "balanced";
|
|
1575
1575
|
}
|
|
1576
1576
|
if (internalStrategy === "async_strategy" || internalStrategy === "async") {
|
|
1577
|
-
return "
|
|
1577
|
+
return "advanced";
|
|
1578
1578
|
}
|
|
1579
1579
|
throw new Error(
|
|
1580
1580
|
`Invalid internal strategy: ${internalStrategy}. Must be "safe_strategy", "degen_strategy" or "async_strategy".`
|
|
@@ -1591,7 +1591,7 @@ function toPublicStrategyOrUndefined(internalStrategy) {
|
|
|
1591
1591
|
}
|
|
1592
1592
|
}
|
|
1593
1593
|
function isValidPublicStrategy(strategy) {
|
|
1594
|
-
return strategy === "conservative" || strategy === "
|
|
1594
|
+
return strategy === "conservative" || strategy === "balanced" || strategy === "advanced";
|
|
1595
1595
|
}
|
|
1596
1596
|
function convertStrategyToPublic(obj) {
|
|
1597
1597
|
if (!obj.strategy) {
|
|
@@ -2363,7 +2363,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2363
2363
|
if (request.strategy) {
|
|
2364
2364
|
if (!isValidPublicStrategy(request.strategy)) {
|
|
2365
2365
|
throw new Error(
|
|
2366
|
-
`Invalid strategy: ${request.strategy}. Must be "conservative", "
|
|
2366
|
+
`Invalid strategy: ${request.strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
2367
2367
|
);
|
|
2368
2368
|
}
|
|
2369
2369
|
rebalanceStrategy = toInternalStrategy(request.strategy);
|
|
@@ -2934,7 +2934,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2934
2934
|
*
|
|
2935
2935
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
2936
2936
|
* @param chainId - Target chain ID
|
|
2937
|
-
* @param strategy - Optional strategy selection: "conservative" (default), "
|
|
2937
|
+
* @param strategy - Optional strategy selection: "conservative" (default), "balanced" or "advanced"
|
|
2938
2938
|
* @param createSessionKey - If true, automatically creates a session key after deployment (default: false)
|
|
2939
2939
|
* @returns Deployment response with Safe address and transaction hash
|
|
2940
2940
|
*
|
|
@@ -3382,11 +3382,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3382
3382
|
*
|
|
3383
3383
|
* @example
|
|
3384
3384
|
* ```typescript
|
|
3385
|
-
* // NVDAc only lives in async protocols, so it needs "
|
|
3385
|
+
* // NVDAc only lives in async protocols, so it needs "advanced".
|
|
3386
3386
|
* // Chains default to Base, the only chain it exists on.
|
|
3387
3387
|
* const profile = await sdk.setAssetStrategy({
|
|
3388
3388
|
* asset: "NVDAc",
|
|
3389
|
-
* strategy: "
|
|
3389
|
+
* strategy: "advanced",
|
|
3390
3390
|
* });
|
|
3391
3391
|
* console.log(profile.protocols); // Ipor + Superform
|
|
3392
3392
|
* ```
|
|
@@ -3396,7 +3396,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3396
3396
|
try {
|
|
3397
3397
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
3398
3398
|
throw new Error(
|
|
3399
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
3399
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
3400
3400
|
);
|
|
3401
3401
|
}
|
|
3402
3402
|
const supported = getAssetChainIds(asset);
|
|
@@ -3431,7 +3431,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3431
3431
|
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
3432
3432
|
* assets ({@link getManagedAssets}). Prefer this over
|
|
3433
3433
|
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
3434
|
-
* with the tier (including `
|
|
3434
|
+
* with the tier (including `advanced` async venues).
|
|
3435
3435
|
*
|
|
3436
3436
|
* @group Portfolio and execution
|
|
3437
3437
|
*/
|
|
@@ -3439,7 +3439,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3439
3439
|
const { strategy, asset, chains } = params;
|
|
3440
3440
|
if (!isValidPublicStrategy(strategy)) {
|
|
3441
3441
|
throw new Error(
|
|
3442
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
3442
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
3443
3443
|
);
|
|
3444
3444
|
}
|
|
3445
3445
|
const assets = asset ? [asset] : getManagedAssets();
|
|
@@ -3636,7 +3636,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3636
3636
|
}
|
|
3637
3637
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
3638
3638
|
throw new Error(
|
|
3639
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
3639
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
3640
3640
|
);
|
|
3641
3641
|
}
|
|
3642
3642
|
const assetSymbol = resolveAssetSymbol(asset);
|
|
@@ -4514,7 +4514,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4514
4514
|
async ensureFirstDepositSetup(strategy) {
|
|
4515
4515
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
4516
4516
|
throw new Error(
|
|
4517
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
4517
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
4518
4518
|
);
|
|
4519
4519
|
}
|
|
4520
4520
|
await this.authenticateUser();
|
|
@@ -4547,7 +4547,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4547
4547
|
const { strategy, asset, chainId } = params;
|
|
4548
4548
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
4549
4549
|
throw new Error(
|
|
4550
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
4550
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
4551
4551
|
);
|
|
4552
4552
|
}
|
|
4553
4553
|
await this.authenticateUser();
|
|
@@ -4930,7 +4930,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4930
4930
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
4931
4931
|
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
4932
4932
|
*
|
|
4933
|
-
* **Delayed withdrawals.** Positions held under the `"
|
|
4933
|
+
* **Delayed withdrawals.** Positions held under the `"advanced"`
|
|
4934
4934
|
* strategy sit in protocols that cannot be exited on demand. For those the
|
|
4935
4935
|
* backend transfers the immediately available portion, then queues a
|
|
4936
4936
|
* redemption for the rest and forwards the funds to the EOA once the
|
|
@@ -5177,7 +5177,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5177
5177
|
* a snapshot, so net values can differ slightly from a fully live calc.
|
|
5178
5178
|
*
|
|
5179
5179
|
* **Total balance.** `portfolioByAssetType` sums deployed positions and idle
|
|
5180
|
-
* Safe balances, and nothing else. Under the `"
|
|
5180
|
+
* Safe balances, and nothing else. Under the `"advanced"` strategy a
|
|
5181
5181
|
* redemption in flight has already left its position and has not landed in
|
|
5182
5182
|
* the Safe yet, so its funds appear in no balance field at all. That makes
|
|
5183
5183
|
* two distinct numbers:
|
|
@@ -5202,7 +5202,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5202
5202
|
* @group Portfolio and execution
|
|
5203
5203
|
*
|
|
5204
5204
|
* @remarks Data API portfolio endpoint. See {@link PortfolioDetailed.pendingAsyncWithdrawals}
|
|
5205
|
-
* when using {@link Strategy |
|
|
5205
|
+
* when using {@link Strategy | grow}.
|
|
5206
5206
|
*
|
|
5207
5207
|
* @param userAddress - User's EOA address
|
|
5208
5208
|
* @returns Portfolio with optional fee-adjusted balance fields
|
|
@@ -5400,7 +5400,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5400
5400
|
*
|
|
5401
5401
|
* @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
|
|
5402
5402
|
* @param days - Time period: 7, 14, or 30
|
|
5403
|
-
* @param strategy - Strategy type: "conservative" (default), "
|
|
5403
|
+
* @param strategy - Strategy type: "conservative" (default), "balanced" or "advanced"
|
|
5404
5404
|
* @param chainId - Optional chain ID filter
|
|
5405
5405
|
* @param tokenSymbol - Optional token symbol filter (e.g. "USDC", "WETH", "WBTC")
|
|
5406
5406
|
* @returns APY per strategy for a specific chain
|
|
@@ -5876,7 +5876,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5876
5876
|
return {
|
|
5877
5877
|
success: true,
|
|
5878
5878
|
chainId,
|
|
5879
|
-
strategyType: "
|
|
5879
|
+
strategyType: "balanced",
|
|
5880
5880
|
data: Array.isArray(data) ? data.map((o) => ({
|
|
5881
5881
|
id: o.id,
|
|
5882
5882
|
protocolId: o.protocol_id || o.protocolId,
|
|
@@ -5887,7 +5887,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5887
5887
|
tvl: o.tvl || o.zyfiTvl,
|
|
5888
5888
|
asset: o.asset || o.underlying_token,
|
|
5889
5889
|
risk: o.risk,
|
|
5890
|
-
strategyType: "
|
|
5890
|
+
strategyType: "balanced",
|
|
5891
5891
|
status: o.status
|
|
5892
5892
|
})) : []
|
|
5893
5893
|
};
|
|
@@ -5898,15 +5898,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5898
5898
|
}
|
|
5899
5899
|
}
|
|
5900
5900
|
/**
|
|
5901
|
-
* Get
|
|
5902
|
-
* `"
|
|
5901
|
+
* Get grow opportunities — pools reachable only with the
|
|
5902
|
+
* `"advanced"` strategy, including protocols whose withdrawals are
|
|
5903
5903
|
* asynchronous (Ipor, Superform). Exiting these pools takes about a day
|
|
5904
5904
|
* on Ipor and three on Superform; track the redemption through
|
|
5905
5905
|
* `getPortfolio().portfolio.pendingAsyncWithdrawals`.
|
|
5906
5906
|
*
|
|
5907
5907
|
* @param chainId - Optional chain ID filter
|
|
5908
5908
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH")
|
|
5909
|
-
* @returns List of
|
|
5909
|
+
* @returns List of grow opportunities
|
|
5910
5910
|
*
|
|
5911
5911
|
* @example
|
|
5912
5912
|
* ```typescript
|
|
@@ -5923,7 +5923,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5923
5923
|
return {
|
|
5924
5924
|
success: true,
|
|
5925
5925
|
chainId,
|
|
5926
|
-
strategyType: "
|
|
5926
|
+
strategyType: "advanced",
|
|
5927
5927
|
data: Array.isArray(data) ? data.map((o) => ({
|
|
5928
5928
|
id: o.id,
|
|
5929
5929
|
protocolId: o.protocol_id || o.protocolId,
|
|
@@ -5934,13 +5934,13 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5934
5934
|
tvl: o.tvl || o.zyfiTvl,
|
|
5935
5935
|
asset: o.asset || o.underlying_token,
|
|
5936
5936
|
risk: o.risk,
|
|
5937
|
-
strategyType: "
|
|
5937
|
+
strategyType: "advanced",
|
|
5938
5938
|
status: o.status
|
|
5939
5939
|
})) : []
|
|
5940
5940
|
};
|
|
5941
5941
|
} catch (error) {
|
|
5942
5942
|
throw new Error(
|
|
5943
|
-
`Failed to get
|
|
5943
|
+
`Failed to get grow opportunities: ${error.message}`
|
|
5944
5944
|
);
|
|
5945
5945
|
}
|
|
5946
5946
|
}
|
|
@@ -6465,7 +6465,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
6465
6465
|
if (strategy) {
|
|
6466
6466
|
if (!isValidPublicStrategy(strategy)) {
|
|
6467
6467
|
throw new Error(
|
|
6468
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
6468
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
6469
6469
|
);
|
|
6470
6470
|
}
|
|
6471
6471
|
internalStrategy = toInternalStrategy(strategy);
|
|
@@ -6515,7 +6515,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
6515
6515
|
try {
|
|
6516
6516
|
if (!isValidPublicStrategy(params.strategy)) {
|
|
6517
6517
|
throw new Error(
|
|
6518
|
-
`Invalid strategy: ${params.strategy}. Must be "conservative", "
|
|
6518
|
+
`Invalid strategy: ${params.strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
6519
6519
|
);
|
|
6520
6520
|
}
|
|
6521
6521
|
const internalStrategy = toInternalStrategy(params.strategy);
|
package/dist/index.mjs
CHANGED
|
@@ -943,7 +943,7 @@ var ASSET_CONFIGS = {
|
|
|
943
943
|
enabled: true
|
|
944
944
|
},
|
|
945
945
|
// Coinbase B20 tokenized NVIDIA equity. Base only, and only reachable through
|
|
946
|
-
// protocols with delayed withdrawals — see the `
|
|
946
|
+
// protocols with delayed withdrawals — see the `advanced` strategy.
|
|
947
947
|
NVDAc: {
|
|
948
948
|
symbol: "NVDAc",
|
|
949
949
|
assetType: "nvdac",
|
|
@@ -1507,15 +1507,15 @@ var signSessionKey = async (config, sessions, allPublicClients, signingParams) =
|
|
|
1507
1507
|
};
|
|
1508
1508
|
|
|
1509
1509
|
// src/utils/strategy.ts
|
|
1510
|
-
var PUBLIC_STRATEGIES = `"conservative", "
|
|
1510
|
+
var PUBLIC_STRATEGIES = `"conservative", "balanced" or "advanced"`;
|
|
1511
1511
|
var SUPPORTED_ASSETS = Object.entries(ASSET_CONFIGS).filter(([, config]) => config?.enabled === true).map(([symbol]) => `"${symbol}"`).join(", ");
|
|
1512
1512
|
function toInternalStrategy(publicStrategy) {
|
|
1513
1513
|
switch (publicStrategy) {
|
|
1514
1514
|
case "conservative":
|
|
1515
1515
|
return "safe_strategy";
|
|
1516
|
-
case "
|
|
1516
|
+
case "balanced":
|
|
1517
1517
|
return "degen_strategy";
|
|
1518
|
-
case "
|
|
1518
|
+
case "advanced":
|
|
1519
1519
|
return "async_strategy";
|
|
1520
1520
|
default:
|
|
1521
1521
|
throw new Error(
|
|
@@ -1528,10 +1528,10 @@ function toPublicStrategy(internalStrategy) {
|
|
|
1528
1528
|
return "conservative";
|
|
1529
1529
|
}
|
|
1530
1530
|
if (internalStrategy === "degen_strategy" || internalStrategy === "degen") {
|
|
1531
|
-
return "
|
|
1531
|
+
return "balanced";
|
|
1532
1532
|
}
|
|
1533
1533
|
if (internalStrategy === "async_strategy" || internalStrategy === "async") {
|
|
1534
|
-
return "
|
|
1534
|
+
return "advanced";
|
|
1535
1535
|
}
|
|
1536
1536
|
throw new Error(
|
|
1537
1537
|
`Invalid internal strategy: ${internalStrategy}. Must be "safe_strategy", "degen_strategy" or "async_strategy".`
|
|
@@ -1548,7 +1548,7 @@ function toPublicStrategyOrUndefined(internalStrategy) {
|
|
|
1548
1548
|
}
|
|
1549
1549
|
}
|
|
1550
1550
|
function isValidPublicStrategy(strategy) {
|
|
1551
|
-
return strategy === "conservative" || strategy === "
|
|
1551
|
+
return strategy === "conservative" || strategy === "balanced" || strategy === "advanced";
|
|
1552
1552
|
}
|
|
1553
1553
|
function convertStrategyToPublic(obj) {
|
|
1554
1554
|
if (!obj.strategy) {
|
|
@@ -2320,7 +2320,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2320
2320
|
if (request.strategy) {
|
|
2321
2321
|
if (!isValidPublicStrategy(request.strategy)) {
|
|
2322
2322
|
throw new Error(
|
|
2323
|
-
`Invalid strategy: ${request.strategy}. Must be "conservative", "
|
|
2323
|
+
`Invalid strategy: ${request.strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
2324
2324
|
);
|
|
2325
2325
|
}
|
|
2326
2326
|
rebalanceStrategy = toInternalStrategy(request.strategy);
|
|
@@ -2891,7 +2891,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2891
2891
|
*
|
|
2892
2892
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
2893
2893
|
* @param chainId - Target chain ID
|
|
2894
|
-
* @param strategy - Optional strategy selection: "conservative" (default), "
|
|
2894
|
+
* @param strategy - Optional strategy selection: "conservative" (default), "balanced" or "advanced"
|
|
2895
2895
|
* @param createSessionKey - If true, automatically creates a session key after deployment (default: false)
|
|
2896
2896
|
* @returns Deployment response with Safe address and transaction hash
|
|
2897
2897
|
*
|
|
@@ -3339,11 +3339,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3339
3339
|
*
|
|
3340
3340
|
* @example
|
|
3341
3341
|
* ```typescript
|
|
3342
|
-
* // NVDAc only lives in async protocols, so it needs "
|
|
3342
|
+
* // NVDAc only lives in async protocols, so it needs "advanced".
|
|
3343
3343
|
* // Chains default to Base, the only chain it exists on.
|
|
3344
3344
|
* const profile = await sdk.setAssetStrategy({
|
|
3345
3345
|
* asset: "NVDAc",
|
|
3346
|
-
* strategy: "
|
|
3346
|
+
* strategy: "advanced",
|
|
3347
3347
|
* });
|
|
3348
3348
|
* console.log(profile.protocols); // Ipor + Superform
|
|
3349
3349
|
* ```
|
|
@@ -3353,7 +3353,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3353
3353
|
try {
|
|
3354
3354
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
3355
3355
|
throw new Error(
|
|
3356
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
3356
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
3357
3357
|
);
|
|
3358
3358
|
}
|
|
3359
3359
|
const supported = getAssetChainIds(asset);
|
|
@@ -3388,7 +3388,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3388
3388
|
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
3389
3389
|
* assets ({@link getManagedAssets}). Prefer this over
|
|
3390
3390
|
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
3391
|
-
* with the tier (including `
|
|
3391
|
+
* with the tier (including `advanced` async venues).
|
|
3392
3392
|
*
|
|
3393
3393
|
* @group Portfolio and execution
|
|
3394
3394
|
*/
|
|
@@ -3396,7 +3396,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3396
3396
|
const { strategy, asset, chains } = params;
|
|
3397
3397
|
if (!isValidPublicStrategy(strategy)) {
|
|
3398
3398
|
throw new Error(
|
|
3399
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
3399
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
3400
3400
|
);
|
|
3401
3401
|
}
|
|
3402
3402
|
const assets = asset ? [asset] : getManagedAssets();
|
|
@@ -3593,7 +3593,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3593
3593
|
}
|
|
3594
3594
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
3595
3595
|
throw new Error(
|
|
3596
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
3596
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
3597
3597
|
);
|
|
3598
3598
|
}
|
|
3599
3599
|
const assetSymbol = resolveAssetSymbol(asset);
|
|
@@ -4471,7 +4471,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4471
4471
|
async ensureFirstDepositSetup(strategy) {
|
|
4472
4472
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
4473
4473
|
throw new Error(
|
|
4474
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
4474
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
4475
4475
|
);
|
|
4476
4476
|
}
|
|
4477
4477
|
await this.authenticateUser();
|
|
@@ -4504,7 +4504,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4504
4504
|
const { strategy, asset, chainId } = params;
|
|
4505
4505
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
4506
4506
|
throw new Error(
|
|
4507
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
4507
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
4508
4508
|
);
|
|
4509
4509
|
}
|
|
4510
4510
|
await this.authenticateUser();
|
|
@@ -4887,7 +4887,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4887
4887
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
4888
4888
|
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
4889
4889
|
*
|
|
4890
|
-
* **Delayed withdrawals.** Positions held under the `"
|
|
4890
|
+
* **Delayed withdrawals.** Positions held under the `"advanced"`
|
|
4891
4891
|
* strategy sit in protocols that cannot be exited on demand. For those the
|
|
4892
4892
|
* backend transfers the immediately available portion, then queues a
|
|
4893
4893
|
* redemption for the rest and forwards the funds to the EOA once the
|
|
@@ -5134,7 +5134,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5134
5134
|
* a snapshot, so net values can differ slightly from a fully live calc.
|
|
5135
5135
|
*
|
|
5136
5136
|
* **Total balance.** `portfolioByAssetType` sums deployed positions and idle
|
|
5137
|
-
* Safe balances, and nothing else. Under the `"
|
|
5137
|
+
* Safe balances, and nothing else. Under the `"advanced"` strategy a
|
|
5138
5138
|
* redemption in flight has already left its position and has not landed in
|
|
5139
5139
|
* the Safe yet, so its funds appear in no balance field at all. That makes
|
|
5140
5140
|
* two distinct numbers:
|
|
@@ -5159,7 +5159,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5159
5159
|
* @group Portfolio and execution
|
|
5160
5160
|
*
|
|
5161
5161
|
* @remarks Data API portfolio endpoint. See {@link PortfolioDetailed.pendingAsyncWithdrawals}
|
|
5162
|
-
* when using {@link Strategy |
|
|
5162
|
+
* when using {@link Strategy | grow}.
|
|
5163
5163
|
*
|
|
5164
5164
|
* @param userAddress - User's EOA address
|
|
5165
5165
|
* @returns Portfolio with optional fee-adjusted balance fields
|
|
@@ -5357,7 +5357,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5357
5357
|
*
|
|
5358
5358
|
* @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
|
|
5359
5359
|
* @param days - Time period: 7, 14, or 30
|
|
5360
|
-
* @param strategy - Strategy type: "conservative" (default), "
|
|
5360
|
+
* @param strategy - Strategy type: "conservative" (default), "balanced" or "advanced"
|
|
5361
5361
|
* @param chainId - Optional chain ID filter
|
|
5362
5362
|
* @param tokenSymbol - Optional token symbol filter (e.g. "USDC", "WETH", "WBTC")
|
|
5363
5363
|
* @returns APY per strategy for a specific chain
|
|
@@ -5833,7 +5833,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5833
5833
|
return {
|
|
5834
5834
|
success: true,
|
|
5835
5835
|
chainId,
|
|
5836
|
-
strategyType: "
|
|
5836
|
+
strategyType: "balanced",
|
|
5837
5837
|
data: Array.isArray(data) ? data.map((o) => ({
|
|
5838
5838
|
id: o.id,
|
|
5839
5839
|
protocolId: o.protocol_id || o.protocolId,
|
|
@@ -5844,7 +5844,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5844
5844
|
tvl: o.tvl || o.zyfiTvl,
|
|
5845
5845
|
asset: o.asset || o.underlying_token,
|
|
5846
5846
|
risk: o.risk,
|
|
5847
|
-
strategyType: "
|
|
5847
|
+
strategyType: "balanced",
|
|
5848
5848
|
status: o.status
|
|
5849
5849
|
})) : []
|
|
5850
5850
|
};
|
|
@@ -5855,15 +5855,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5855
5855
|
}
|
|
5856
5856
|
}
|
|
5857
5857
|
/**
|
|
5858
|
-
* Get
|
|
5859
|
-
* `"
|
|
5858
|
+
* Get grow opportunities — pools reachable only with the
|
|
5859
|
+
* `"advanced"` strategy, including protocols whose withdrawals are
|
|
5860
5860
|
* asynchronous (Ipor, Superform). Exiting these pools takes about a day
|
|
5861
5861
|
* on Ipor and three on Superform; track the redemption through
|
|
5862
5862
|
* `getPortfolio().portfolio.pendingAsyncWithdrawals`.
|
|
5863
5863
|
*
|
|
5864
5864
|
* @param chainId - Optional chain ID filter
|
|
5865
5865
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH")
|
|
5866
|
-
* @returns List of
|
|
5866
|
+
* @returns List of grow opportunities
|
|
5867
5867
|
*
|
|
5868
5868
|
* @example
|
|
5869
5869
|
* ```typescript
|
|
@@ -5880,7 +5880,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5880
5880
|
return {
|
|
5881
5881
|
success: true,
|
|
5882
5882
|
chainId,
|
|
5883
|
-
strategyType: "
|
|
5883
|
+
strategyType: "advanced",
|
|
5884
5884
|
data: Array.isArray(data) ? data.map((o) => ({
|
|
5885
5885
|
id: o.id,
|
|
5886
5886
|
protocolId: o.protocol_id || o.protocolId,
|
|
@@ -5891,13 +5891,13 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5891
5891
|
tvl: o.tvl || o.zyfiTvl,
|
|
5892
5892
|
asset: o.asset || o.underlying_token,
|
|
5893
5893
|
risk: o.risk,
|
|
5894
|
-
strategyType: "
|
|
5894
|
+
strategyType: "advanced",
|
|
5895
5895
|
status: o.status
|
|
5896
5896
|
})) : []
|
|
5897
5897
|
};
|
|
5898
5898
|
} catch (error) {
|
|
5899
5899
|
throw new Error(
|
|
5900
|
-
`Failed to get
|
|
5900
|
+
`Failed to get grow opportunities: ${error.message}`
|
|
5901
5901
|
);
|
|
5902
5902
|
}
|
|
5903
5903
|
}
|
|
@@ -6422,7 +6422,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
6422
6422
|
if (strategy) {
|
|
6423
6423
|
if (!isValidPublicStrategy(strategy)) {
|
|
6424
6424
|
throw new Error(
|
|
6425
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
6425
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
6426
6426
|
);
|
|
6427
6427
|
}
|
|
6428
6428
|
internalStrategy = toInternalStrategy(strategy);
|
|
@@ -6472,7 +6472,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
6472
6472
|
try {
|
|
6473
6473
|
if (!isValidPublicStrategy(params.strategy)) {
|
|
6474
6474
|
throw new Error(
|
|
6475
|
-
`Invalid strategy: ${params.strategy}. Must be "conservative", "
|
|
6475
|
+
`Invalid strategy: ${params.strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
6476
6476
|
);
|
|
6477
6477
|
}
|
|
6478
6478
|
const internalStrategy = toInternalStrategy(params.strategy);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "TypeScript SDK for self-custodial Zyfai yield agents: discover DeFi opportunities and manage deposits, withdrawals, positions, and strategies across Ethereum, Base, and Arbitrum",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|