@zyfai/sdk 1.1.0 → 1.2.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 +3 -3
- package/dist/index.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +36 -12
- package/dist/index.mjs +36 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -500,7 +500,7 @@ if (credited.status === "credited") {
|
|
|
500
500
|
- `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.
|
|
501
501
|
- `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`).
|
|
502
502
|
- If first-deposit protocol patching fails, funding still proceeds. If registration fails after a wallet transfer, use the transfer hash to retry `logDeposit()` after `connectAccount()`.
|
|
503
|
-
- **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, `"aggressive"` or `"yieldmaxxing"`) — same role as the former `deploySafe` strategy argument. Later deposits skip this.
|
|
503
|
+
- **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, `"aggressive"` or `"yieldmaxxing"`) — same role as the former `deploySafe` strategy argument. That first write also opts each configured asset into vaults added later (`autoSelectProtocols`). Later deposits skip this.
|
|
504
504
|
- **`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 `"yieldmaxxing"` 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):
|
|
505
505
|
|
|
506
506
|
```typescript
|
|
@@ -1105,7 +1105,7 @@ console.log("By chain (with rZFI):", apyHistory.weightedApyWithRzfiAfterFeeByCha
|
|
|
1105
1105
|
#### Get Conservative Opportunities (Low Risk)
|
|
1106
1106
|
|
|
1107
1107
|
```typescript
|
|
1108
|
-
//
|
|
1108
|
+
// Live pools. Pass "not_live" as the third argument for retired pools.
|
|
1109
1109
|
const conservativeOpps = await sdk.getConservativeOpportunities(8453, "USDC");
|
|
1110
1110
|
conservativeOpps.data.forEach((o) => {
|
|
1111
1111
|
console.log(`${o.protocolName} - ${o.poolName}: ${o.apy}% APY`);
|
|
@@ -1173,7 +1173,7 @@ console.log(profile.protocols); // Ipor + Superform
|
|
|
1173
1173
|
| Parameter | Default | Notes |
|
|
1174
1174
|
| --- | --- | --- |
|
|
1175
1175
|
| `asset` | — | Required |
|
|
1176
|
-
| `strategy` | the asset's current one | Omit it to recompute the protocol list without changing strategy |
|
|
1176
|
+
| `strategy` | the asset's current one | Omit it to recompute the protocol list without changing strategy. Passing one opts the asset into vaults added later |
|
|
1177
1177
|
| `chains` | every chain the asset exists on | **Additive** — chains already enabled are kept, so this cannot disable one |
|
|
1178
1178
|
|
|
1179
1179
|
This is the method to reach for when changing an existing account's strategy,
|
package/dist/index.d.mts
CHANGED
|
@@ -1653,7 +1653,9 @@ declare class ZyfaiSDK {
|
|
|
1653
1653
|
* @param params.asset - Asset to configure
|
|
1654
1654
|
* @param params.strategy - Strategy to apply; defaults to the one already
|
|
1655
1655
|
* stored for this asset (`"conservative"` on a fresh account), which lets
|
|
1656
|
-
* you recompute a protocol list without changing the strategy
|
|
1656
|
+
* you recompute a protocol list without changing the strategy. Passing a
|
|
1657
|
+
* strategy also opts the asset into vaults added later. Omitting it does
|
|
1658
|
+
* not change that opt-in.
|
|
1657
1659
|
* @param params.chains - Chains to enable. Defaults to every chain the asset
|
|
1658
1660
|
* exists on. **Additive**: chains already enabled are kept, so this cannot
|
|
1659
1661
|
* be used to disable one.
|
|
@@ -1681,7 +1683,8 @@ declare class ZyfaiSDK {
|
|
|
1681
1683
|
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
1682
1684
|
* assets ({@link getManagedAssets}). Prefer this over
|
|
1683
1685
|
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
1684
|
-
* with the tier (including `yieldmaxxing` async venues).
|
|
1686
|
+
* with the tier (including `yieldmaxxing` async venues). The chosen strategy
|
|
1687
|
+
* also opts those assets into vaults added later.
|
|
1685
1688
|
*
|
|
1686
1689
|
* @group Portfolio and execution
|
|
1687
1690
|
*/
|
|
@@ -2614,6 +2617,8 @@ declare class ZyfaiSDK {
|
|
|
2614
2617
|
/**
|
|
2615
2618
|
* Get conservative (low-risk) yield opportunities.
|
|
2616
2619
|
*
|
|
2620
|
+
* Omitting `status` requests live pools only. Pass `"not_live"` for retired pools.
|
|
2621
|
+
*
|
|
2617
2622
|
* @group Analytics and opportunities
|
|
2618
2623
|
*
|
|
2619
2624
|
* @remarks Data API. Partner API key only.
|
|
@@ -2632,6 +2637,8 @@ declare class ZyfaiSDK {
|
|
|
2632
2637
|
/**
|
|
2633
2638
|
* Get balanced (high-risk, high-reward) yield opportunities.
|
|
2634
2639
|
*
|
|
2640
|
+
* Omitting `status` requests live pools only. Pass `"not_live"` for retired pools.
|
|
2641
|
+
*
|
|
2635
2642
|
* @param chainId - Optional chain ID filter
|
|
2636
2643
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
2637
2644
|
* @returns List of balanced opportunities
|
|
@@ -2656,6 +2663,8 @@ declare class ZyfaiSDK {
|
|
|
2656
2663
|
* on Ipor and three on Superform; track the redemption through
|
|
2657
2664
|
* `getPortfolio().portfolio.pendingAsyncWithdrawals`.
|
|
2658
2665
|
*
|
|
2666
|
+
* Omitting `status` requests live pools only. Pass `"not_live"` for retired pools.
|
|
2667
|
+
*
|
|
2659
2668
|
* @param chainId - Optional chain ID filter
|
|
2660
2669
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH")
|
|
2661
2670
|
* @returns List of advanced opportunities
|
package/dist/index.d.ts
CHANGED
|
@@ -1653,7 +1653,9 @@ declare class ZyfaiSDK {
|
|
|
1653
1653
|
* @param params.asset - Asset to configure
|
|
1654
1654
|
* @param params.strategy - Strategy to apply; defaults to the one already
|
|
1655
1655
|
* stored for this asset (`"conservative"` on a fresh account), which lets
|
|
1656
|
-
* you recompute a protocol list without changing the strategy
|
|
1656
|
+
* you recompute a protocol list without changing the strategy. Passing a
|
|
1657
|
+
* strategy also opts the asset into vaults added later. Omitting it does
|
|
1658
|
+
* not change that opt-in.
|
|
1657
1659
|
* @param params.chains - Chains to enable. Defaults to every chain the asset
|
|
1658
1660
|
* exists on. **Additive**: chains already enabled are kept, so this cannot
|
|
1659
1661
|
* be used to disable one.
|
|
@@ -1681,7 +1683,8 @@ declare class ZyfaiSDK {
|
|
|
1681
1683
|
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
1682
1684
|
* assets ({@link getManagedAssets}). Prefer this over
|
|
1683
1685
|
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
1684
|
-
* with the tier (including `yieldmaxxing` async venues).
|
|
1686
|
+
* with the tier (including `yieldmaxxing` async venues). The chosen strategy
|
|
1687
|
+
* also opts those assets into vaults added later.
|
|
1685
1688
|
*
|
|
1686
1689
|
* @group Portfolio and execution
|
|
1687
1690
|
*/
|
|
@@ -2614,6 +2617,8 @@ declare class ZyfaiSDK {
|
|
|
2614
2617
|
/**
|
|
2615
2618
|
* Get conservative (low-risk) yield opportunities.
|
|
2616
2619
|
*
|
|
2620
|
+
* Omitting `status` requests live pools only. Pass `"not_live"` for retired pools.
|
|
2621
|
+
*
|
|
2617
2622
|
* @group Analytics and opportunities
|
|
2618
2623
|
*
|
|
2619
2624
|
* @remarks Data API. Partner API key only.
|
|
@@ -2632,6 +2637,8 @@ declare class ZyfaiSDK {
|
|
|
2632
2637
|
/**
|
|
2633
2638
|
* Get balanced (high-risk, high-reward) yield opportunities.
|
|
2634
2639
|
*
|
|
2640
|
+
* Omitting `status` requests live pools only. Pass `"not_live"` for retired pools.
|
|
2641
|
+
*
|
|
2635
2642
|
* @param chainId - Optional chain ID filter
|
|
2636
2643
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
2637
2644
|
* @returns List of balanced opportunities
|
|
@@ -2656,6 +2663,8 @@ declare class ZyfaiSDK {
|
|
|
2656
2663
|
* on Ipor and three on Superform; track the redemption through
|
|
2657
2664
|
* `getPortfolio().portfolio.pendingAsyncWithdrawals`.
|
|
2658
2665
|
*
|
|
2666
|
+
* Omitting `status` requests live pools only. Pass `"not_live"` for retired pools.
|
|
2667
|
+
*
|
|
2659
2668
|
* @param chainId - Optional chain ID filter
|
|
2660
2669
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH")
|
|
2661
2670
|
* @returns List of advanced opportunities
|
package/dist/index.js
CHANGED
|
@@ -204,27 +204,28 @@ var DATA_ENDPOINTS = {
|
|
|
204
204
|
if (endDate) url += `&endDate=${endDate}`;
|
|
205
205
|
return url;
|
|
206
206
|
},
|
|
207
|
-
// Opportunities
|
|
207
|
+
// Opportunities. Omitted status means live pools. Pass not_live to
|
|
208
|
+
// read retired rows. The data API returns both when status is absent.
|
|
208
209
|
OPPORTUNITIES_SAFE: (chainId, asset, status) => {
|
|
209
210
|
const params = [];
|
|
210
211
|
if (chainId !== void 0) params.push(`chainId=${chainId}`);
|
|
211
212
|
if (asset) params.push(`asset=${asset}`);
|
|
212
|
-
|
|
213
|
-
return
|
|
213
|
+
params.push(`status=${status ?? "live"}`);
|
|
214
|
+
return `/opportunities/safe?${params.join("&")}`;
|
|
214
215
|
},
|
|
215
216
|
OPPORTUNITIES_DEGEN: (chainId, asset, status) => {
|
|
216
217
|
const params = [];
|
|
217
218
|
if (chainId !== void 0) params.push(`chainId=${chainId}`);
|
|
218
219
|
if (asset) params.push(`asset=${asset}`);
|
|
219
|
-
|
|
220
|
-
return
|
|
220
|
+
params.push(`status=${status ?? "live"}`);
|
|
221
|
+
return `/opportunities/degen-strategies?${params.join("&")}`;
|
|
221
222
|
},
|
|
222
223
|
OPPORTUNITIES_ASYNC: (chainId, asset, status) => {
|
|
223
224
|
const params = [];
|
|
224
225
|
if (chainId !== void 0) params.push(`chainId=${chainId}`);
|
|
225
226
|
if (asset) params.push(`asset=${asset}`);
|
|
226
|
-
|
|
227
|
-
return
|
|
227
|
+
params.push(`status=${status ?? "live"}`);
|
|
228
|
+
return `/opportunities/async?${params.join("&")}`;
|
|
228
229
|
},
|
|
229
230
|
// APY History
|
|
230
231
|
DAILY_APY_HISTORY_WEIGHTED: (walletAddress, days) => `/daily-apy-history/weighted-multi-asset/${walletAddress}${days ? `?days=${days}` : ""}`,
|
|
@@ -1634,6 +1635,10 @@ function toPublicStrategyOrUndefined(internalStrategy) {
|
|
|
1634
1635
|
function isValidPublicStrategy(strategy) {
|
|
1635
1636
|
return strategy === "conservative" || strategy === "aggressive" || strategy === "yieldmaxxing";
|
|
1636
1637
|
}
|
|
1638
|
+
function shouldDefaultAutoSelectNewVaults(input) {
|
|
1639
|
+
if (input.requestedStrategy !== void 0) return true;
|
|
1640
|
+
return !input.hasChains && !input.hasProtocols;
|
|
1641
|
+
}
|
|
1637
1642
|
function convertStrategyToPublic(obj) {
|
|
1638
1643
|
if (!obj.strategy) {
|
|
1639
1644
|
const result = { ...obj };
|
|
@@ -3343,20 +3348,26 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3343
3348
|
internalStrategy
|
|
3344
3349
|
);
|
|
3345
3350
|
const mandateChainId = chains.find((c) => !existingChains.includes(c)) ?? chains[0];
|
|
3351
|
+
const autoSelectNewVaults = shouldDefaultAutoSelectNewVaults({
|
|
3352
|
+
requestedStrategy: strategy,
|
|
3353
|
+
hasChains: existingChains.length > 0,
|
|
3354
|
+
hasProtocols: (userDetails.protocols?.length ?? 0) > 0
|
|
3355
|
+
});
|
|
3346
3356
|
return await this.persistDiscoveredAssetProfile(
|
|
3347
3357
|
asset,
|
|
3348
3358
|
effectiveChains,
|
|
3349
3359
|
withPools,
|
|
3350
3360
|
strategy,
|
|
3351
3361
|
mandateChainId,
|
|
3352
|
-
existingChains
|
|
3362
|
+
existingChains,
|
|
3363
|
+
autoSelectNewVaults
|
|
3353
3364
|
);
|
|
3354
3365
|
}
|
|
3355
3366
|
/**
|
|
3356
3367
|
* Persist protocol discovery for one asset (user PATCH or agent deposit-setup).
|
|
3357
3368
|
* @internal
|
|
3358
3369
|
*/
|
|
3359
|
-
async persistDiscoveredAssetProfile(asset, effectiveChains, withPools, strategy, agentDepositChainId, existingChains = []) {
|
|
3370
|
+
async persistDiscoveredAssetProfile(asset, effectiveChains, withPools, strategy, agentDepositChainId, existingChains = [], autoSelectNewVaults = false) {
|
|
3360
3371
|
const internalAsset = convertAssetInternally(asset);
|
|
3361
3372
|
const assetSettings = {
|
|
3362
3373
|
chains: effectiveChains,
|
|
@@ -3365,11 +3376,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3365
3376
|
if (strategy !== void 0) {
|
|
3366
3377
|
assetSettings.rebalanceStrategy = toInternalStrategy(strategy);
|
|
3367
3378
|
}
|
|
3379
|
+
if (autoSelectNewVaults) {
|
|
3380
|
+
assetSettings.autoSelectProtocols = true;
|
|
3381
|
+
}
|
|
3368
3382
|
const configureProfile = () => this.updateUserProfile({
|
|
3369
3383
|
asset,
|
|
3370
3384
|
protocols: withPools,
|
|
3371
3385
|
chains: effectiveChains,
|
|
3372
|
-
...strategy !== void 0 && { strategy }
|
|
3386
|
+
...strategy !== void 0 && { strategy },
|
|
3387
|
+
...autoSelectNewVaults && { autoSelectProtocols: true }
|
|
3373
3388
|
});
|
|
3374
3389
|
if (this.sessionChannel === "agent") {
|
|
3375
3390
|
const chainId = agentDepositChainId ?? effectiveChains[effectiveChains.length - 1] ?? effectiveChains[0];
|
|
@@ -3413,7 +3428,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3413
3428
|
* @param params.asset - Asset to configure
|
|
3414
3429
|
* @param params.strategy - Strategy to apply; defaults to the one already
|
|
3415
3430
|
* stored for this asset (`"conservative"` on a fresh account), which lets
|
|
3416
|
-
* you recompute a protocol list without changing the strategy
|
|
3431
|
+
* you recompute a protocol list without changing the strategy. Passing a
|
|
3432
|
+
* strategy also opts the asset into vaults added later. Omitting it does
|
|
3433
|
+
* not change that opt-in.
|
|
3417
3434
|
* @param params.chains - Chains to enable. Defaults to every chain the asset
|
|
3418
3435
|
* exists on. **Additive**: chains already enabled are kept, so this cannot
|
|
3419
3436
|
* be used to disable one.
|
|
@@ -3472,7 +3489,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3472
3489
|
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
3473
3490
|
* assets ({@link getManagedAssets}). Prefer this over
|
|
3474
3491
|
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
3475
|
-
* with the tier (including `yieldmaxxing` async venues).
|
|
3492
|
+
* with the tier (including `yieldmaxxing` async venues). The chosen strategy
|
|
3493
|
+
* also opts those assets into vaults added later.
|
|
3476
3494
|
*
|
|
3477
3495
|
* @group Portfolio and execution
|
|
3478
3496
|
*/
|
|
@@ -5976,6 +5994,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5976
5994
|
/**
|
|
5977
5995
|
* Get conservative (low-risk) yield opportunities.
|
|
5978
5996
|
*
|
|
5997
|
+
* Omitting `status` requests live pools only. Pass `"not_live"` for retired pools.
|
|
5998
|
+
*
|
|
5979
5999
|
* @group Analytics and opportunities
|
|
5980
6000
|
*
|
|
5981
6001
|
* @remarks Data API. Partner API key only.
|
|
@@ -6023,6 +6043,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
6023
6043
|
/**
|
|
6024
6044
|
* Get balanced (high-risk, high-reward) yield opportunities.
|
|
6025
6045
|
*
|
|
6046
|
+
* Omitting `status` requests live pools only. Pass `"not_live"` for retired pools.
|
|
6047
|
+
*
|
|
6026
6048
|
* @param chainId - Optional chain ID filter
|
|
6027
6049
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
6028
6050
|
* @returns List of balanced opportunities
|
|
@@ -6083,6 +6105,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
6083
6105
|
* on Ipor and three on Superform; track the redemption through
|
|
6084
6106
|
* `getPortfolio().portfolio.pendingAsyncWithdrawals`.
|
|
6085
6107
|
*
|
|
6108
|
+
* Omitting `status` requests live pools only. Pass `"not_live"` for retired pools.
|
|
6109
|
+
*
|
|
6086
6110
|
* @param chainId - Optional chain ID filter
|
|
6087
6111
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH")
|
|
6088
6112
|
* @returns List of advanced opportunities
|
package/dist/index.mjs
CHANGED
|
@@ -130,27 +130,28 @@ var DATA_ENDPOINTS = {
|
|
|
130
130
|
if (endDate) url += `&endDate=${endDate}`;
|
|
131
131
|
return url;
|
|
132
132
|
},
|
|
133
|
-
// Opportunities
|
|
133
|
+
// Opportunities. Omitted status means live pools. Pass not_live to
|
|
134
|
+
// read retired rows. The data API returns both when status is absent.
|
|
134
135
|
OPPORTUNITIES_SAFE: (chainId, asset, status) => {
|
|
135
136
|
const params = [];
|
|
136
137
|
if (chainId !== void 0) params.push(`chainId=${chainId}`);
|
|
137
138
|
if (asset) params.push(`asset=${asset}`);
|
|
138
|
-
|
|
139
|
-
return
|
|
139
|
+
params.push(`status=${status ?? "live"}`);
|
|
140
|
+
return `/opportunities/safe?${params.join("&")}`;
|
|
140
141
|
},
|
|
141
142
|
OPPORTUNITIES_DEGEN: (chainId, asset, status) => {
|
|
142
143
|
const params = [];
|
|
143
144
|
if (chainId !== void 0) params.push(`chainId=${chainId}`);
|
|
144
145
|
if (asset) params.push(`asset=${asset}`);
|
|
145
|
-
|
|
146
|
-
return
|
|
146
|
+
params.push(`status=${status ?? "live"}`);
|
|
147
|
+
return `/opportunities/degen-strategies?${params.join("&")}`;
|
|
147
148
|
},
|
|
148
149
|
OPPORTUNITIES_ASYNC: (chainId, asset, status) => {
|
|
149
150
|
const params = [];
|
|
150
151
|
if (chainId !== void 0) params.push(`chainId=${chainId}`);
|
|
151
152
|
if (asset) params.push(`asset=${asset}`);
|
|
152
|
-
|
|
153
|
-
return
|
|
153
|
+
params.push(`status=${status ?? "live"}`);
|
|
154
|
+
return `/opportunities/async?${params.join("&")}`;
|
|
154
155
|
},
|
|
155
156
|
// APY History
|
|
156
157
|
DAILY_APY_HISTORY_WEIGHTED: (walletAddress, days) => `/daily-apy-history/weighted-multi-asset/${walletAddress}${days ? `?days=${days}` : ""}`,
|
|
@@ -1592,6 +1593,10 @@ function toPublicStrategyOrUndefined(internalStrategy) {
|
|
|
1592
1593
|
function isValidPublicStrategy(strategy) {
|
|
1593
1594
|
return strategy === "conservative" || strategy === "aggressive" || strategy === "yieldmaxxing";
|
|
1594
1595
|
}
|
|
1596
|
+
function shouldDefaultAutoSelectNewVaults(input) {
|
|
1597
|
+
if (input.requestedStrategy !== void 0) return true;
|
|
1598
|
+
return !input.hasChains && !input.hasProtocols;
|
|
1599
|
+
}
|
|
1595
1600
|
function convertStrategyToPublic(obj) {
|
|
1596
1601
|
if (!obj.strategy) {
|
|
1597
1602
|
const result = { ...obj };
|
|
@@ -3301,20 +3306,26 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3301
3306
|
internalStrategy
|
|
3302
3307
|
);
|
|
3303
3308
|
const mandateChainId = chains.find((c) => !existingChains.includes(c)) ?? chains[0];
|
|
3309
|
+
const autoSelectNewVaults = shouldDefaultAutoSelectNewVaults({
|
|
3310
|
+
requestedStrategy: strategy,
|
|
3311
|
+
hasChains: existingChains.length > 0,
|
|
3312
|
+
hasProtocols: (userDetails.protocols?.length ?? 0) > 0
|
|
3313
|
+
});
|
|
3304
3314
|
return await this.persistDiscoveredAssetProfile(
|
|
3305
3315
|
asset,
|
|
3306
3316
|
effectiveChains,
|
|
3307
3317
|
withPools,
|
|
3308
3318
|
strategy,
|
|
3309
3319
|
mandateChainId,
|
|
3310
|
-
existingChains
|
|
3320
|
+
existingChains,
|
|
3321
|
+
autoSelectNewVaults
|
|
3311
3322
|
);
|
|
3312
3323
|
}
|
|
3313
3324
|
/**
|
|
3314
3325
|
* Persist protocol discovery for one asset (user PATCH or agent deposit-setup).
|
|
3315
3326
|
* @internal
|
|
3316
3327
|
*/
|
|
3317
|
-
async persistDiscoveredAssetProfile(asset, effectiveChains, withPools, strategy, agentDepositChainId, existingChains = []) {
|
|
3328
|
+
async persistDiscoveredAssetProfile(asset, effectiveChains, withPools, strategy, agentDepositChainId, existingChains = [], autoSelectNewVaults = false) {
|
|
3318
3329
|
const internalAsset = convertAssetInternally(asset);
|
|
3319
3330
|
const assetSettings = {
|
|
3320
3331
|
chains: effectiveChains,
|
|
@@ -3323,11 +3334,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3323
3334
|
if (strategy !== void 0) {
|
|
3324
3335
|
assetSettings.rebalanceStrategy = toInternalStrategy(strategy);
|
|
3325
3336
|
}
|
|
3337
|
+
if (autoSelectNewVaults) {
|
|
3338
|
+
assetSettings.autoSelectProtocols = true;
|
|
3339
|
+
}
|
|
3326
3340
|
const configureProfile = () => this.updateUserProfile({
|
|
3327
3341
|
asset,
|
|
3328
3342
|
protocols: withPools,
|
|
3329
3343
|
chains: effectiveChains,
|
|
3330
|
-
...strategy !== void 0 && { strategy }
|
|
3344
|
+
...strategy !== void 0 && { strategy },
|
|
3345
|
+
...autoSelectNewVaults && { autoSelectProtocols: true }
|
|
3331
3346
|
});
|
|
3332
3347
|
if (this.sessionChannel === "agent") {
|
|
3333
3348
|
const chainId = agentDepositChainId ?? effectiveChains[effectiveChains.length - 1] ?? effectiveChains[0];
|
|
@@ -3371,7 +3386,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3371
3386
|
* @param params.asset - Asset to configure
|
|
3372
3387
|
* @param params.strategy - Strategy to apply; defaults to the one already
|
|
3373
3388
|
* stored for this asset (`"conservative"` on a fresh account), which lets
|
|
3374
|
-
* you recompute a protocol list without changing the strategy
|
|
3389
|
+
* you recompute a protocol list without changing the strategy. Passing a
|
|
3390
|
+
* strategy also opts the asset into vaults added later. Omitting it does
|
|
3391
|
+
* not change that opt-in.
|
|
3375
3392
|
* @param params.chains - Chains to enable. Defaults to every chain the asset
|
|
3376
3393
|
* exists on. **Additive**: chains already enabled are kept, so this cannot
|
|
3377
3394
|
* be used to disable one.
|
|
@@ -3430,7 +3447,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3430
3447
|
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
3431
3448
|
* assets ({@link getManagedAssets}). Prefer this over
|
|
3432
3449
|
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
3433
|
-
* with the tier (including `yieldmaxxing` async venues).
|
|
3450
|
+
* with the tier (including `yieldmaxxing` async venues). The chosen strategy
|
|
3451
|
+
* also opts those assets into vaults added later.
|
|
3434
3452
|
*
|
|
3435
3453
|
* @group Portfolio and execution
|
|
3436
3454
|
*/
|
|
@@ -5934,6 +5952,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5934
5952
|
/**
|
|
5935
5953
|
* Get conservative (low-risk) yield opportunities.
|
|
5936
5954
|
*
|
|
5955
|
+
* Omitting `status` requests live pools only. Pass `"not_live"` for retired pools.
|
|
5956
|
+
*
|
|
5937
5957
|
* @group Analytics and opportunities
|
|
5938
5958
|
*
|
|
5939
5959
|
* @remarks Data API. Partner API key only.
|
|
@@ -5981,6 +6001,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5981
6001
|
/**
|
|
5982
6002
|
* Get balanced (high-risk, high-reward) yield opportunities.
|
|
5983
6003
|
*
|
|
6004
|
+
* Omitting `status` requests live pools only. Pass `"not_live"` for retired pools.
|
|
6005
|
+
*
|
|
5984
6006
|
* @param chainId - Optional chain ID filter
|
|
5985
6007
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
5986
6008
|
* @returns List of balanced opportunities
|
|
@@ -6041,6 +6063,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
6041
6063
|
* on Ipor and three on Superform; track the redemption through
|
|
6042
6064
|
* `getPortfolio().portfolio.pendingAsyncWithdrawals`.
|
|
6043
6065
|
*
|
|
6066
|
+
* Omitting `status` requests live pools only. Pass `"not_live"` for retired pools.
|
|
6067
|
+
*
|
|
6044
6068
|
* @param chainId - Optional chain ID filter
|
|
6045
6069
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH")
|
|
6046
6070
|
* @returns List of advanced opportunities
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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",
|