@zyfai/sdk 1.0.0 → 1.1.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/dist/index.mjs CHANGED
@@ -54,6 +54,9 @@ var ENDPOINTS = {
54
54
  USER_WITHDRAW: "/users/withdraw/v2",
55
55
  PARTIAL_WITHDRAW: "/users/partial-withdraw/v2",
56
56
  LOG_DEPOSIT: "/users/log_deposit/v2",
57
+ FIRST_PERMIT_DEPOSIT: "/users/me/permit-deposit",
58
+ FIRST_PERMIT_DEPOSIT_PREPARE: "/users/me/permit-deposit/prepare",
59
+ FIRST_PERMIT_DEPOSIT_SUBMIT: (id) => `/users/me/permit-deposit/${encodeURIComponent(id)}/submit`,
57
60
  FUNDING_ORDERS: "/users/me/funding-orders",
58
61
  FUNDING_ORDER: (orderId) => `/users/me/funding-orders/${encodeURIComponent(orderId)}`,
59
62
  FUNDING_ORDER_QUOTE: (orderId) => `/users/me/funding-orders/${encodeURIComponent(orderId)}/quote`,
@@ -261,8 +264,9 @@ var HttpClient = class {
261
264
  case 403:
262
265
  throw new Error("Forbidden: Access denied");
263
266
  case 404:
264
- throw new Error(
265
- `Not found: ${data.message || "Resource not found"}`
267
+ throw Object.assign(
268
+ new Error(`Not found: ${data.message || "Resource not found"}`),
269
+ { status }
266
270
  );
267
271
  case 429:
268
272
  throw new Error("Rate limit exceeded. Please try again later.");
@@ -385,6 +389,20 @@ var HttpClient = class {
385
389
  };
386
390
 
387
391
  // src/utils/poll.ts
392
+ async function pollUntil(fn, predicate, options) {
393
+ const intervalMs = options?.intervalMs ?? 5e3;
394
+ const timeoutMs = options?.timeoutMs ?? 12e4;
395
+ const label = options?.label ?? "condition";
396
+ const started = Date.now();
397
+ while (Date.now() - started < timeoutMs) {
398
+ const value = await fn();
399
+ if (predicate(value)) {
400
+ return { value, elapsedMs: Date.now() - started };
401
+ }
402
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
403
+ }
404
+ throw new Error(`Timed out waiting for ${label} after ${timeoutMs}ms`);
405
+ }
388
406
  function sleep(ms) {
389
407
  return new Promise((resolve) => setTimeout(resolve, ms));
390
408
  }
@@ -818,6 +836,7 @@ import {
818
836
  custom,
819
837
  http as http2,
820
838
  getAddress as getAddress2,
839
+ isAddressEqual as isAddressEqual2,
821
840
  encodeFunctionData as encodeFunctionData2,
822
841
  defineChain
823
842
  } from "viem";
@@ -943,7 +962,7 @@ var ASSET_CONFIGS = {
943
962
  enabled: true
944
963
  },
945
964
  // Coinbase B20 tokenized NVIDIA equity. Base only, and only reachable through
946
- // protocols with delayed withdrawals — see the `advanced` strategy.
965
+ // protocols with delayed withdrawals — see the `yieldmaxxing` strategy.
947
966
  NVDAc: {
948
967
  symbol: "NVDAc",
949
968
  assetType: "nvdac",
@@ -1136,6 +1155,29 @@ var positiveUnits = (value) => {
1136
1155
  };
1137
1156
  var resolveCollateralMinimum = (storedMinimum, quote) => positiveUnits(storedMinimum) ?? positiveUnits(quote.details?.currencyOut?.minimumAmount) ?? positiveUnits(quote.details?.currencyOut?.amount) ?? "0";
1138
1157
 
1158
+ // src/deposits/first-permit-deposit.ts
1159
+ import { isAddressEqual } from "viem";
1160
+ var firstPermitTypes = {
1161
+ Permit: [
1162
+ { name: "owner", type: "address" },
1163
+ { name: "spender", type: "address" },
1164
+ { name: "value", type: "uint256" },
1165
+ { name: "nonce", type: "uint256" },
1166
+ { name: "deadline", type: "uint256" }
1167
+ ]
1168
+ };
1169
+ function matchesFirstPermitDeposit(intent, request) {
1170
+ return intent.chainId === request.chainId && isAddressEqual(intent.token, request.token) && intent.amount === request.amount.toString();
1171
+ }
1172
+ function validateFirstPermit({ domain, message }, request) {
1173
+ const value = BigInt(message.value);
1174
+ const nonce = BigInt(message.nonce);
1175
+ if (domain.chainId !== request.chainId || !isAddressEqual(domain.verifyingContract, request.token) || !isAddressEqual(message.owner, request.owner) || !isAddressEqual(message.spender, request.safe) || value !== request.amount || nonce < 0n || !Number.isSafeInteger(message.deadline) || message.deadline <= Math.floor(Date.now() / 1e3)) {
1176
+ throw new Error("Prepared permit does not match this deposit");
1177
+ }
1178
+ return { ...message, value, nonce, deadline: BigInt(message.deadline) };
1179
+ }
1180
+
1139
1181
  // src/deposits/relay-slippage.ts
1140
1182
  var DEFAULT_RELAY_SLIPPAGE_BPS = 200;
1141
1183
  var MAX_RELAY_SLIPPAGE_BPS = 500;
@@ -1507,15 +1549,15 @@ var signSessionKey = async (config, sessions, allPublicClients, signingParams) =
1507
1549
  };
1508
1550
 
1509
1551
  // src/utils/strategy.ts
1510
- var PUBLIC_STRATEGIES = `"conservative", "balanced" or "advanced"`;
1552
+ var PUBLIC_STRATEGIES = `"conservative", "aggressive" or "yieldmaxxing"`;
1511
1553
  var SUPPORTED_ASSETS = Object.entries(ASSET_CONFIGS).filter(([, config]) => config?.enabled === true).map(([symbol]) => `"${symbol}"`).join(", ");
1512
1554
  function toInternalStrategy(publicStrategy) {
1513
1555
  switch (publicStrategy) {
1514
1556
  case "conservative":
1515
1557
  return "safe_strategy";
1516
- case "balanced":
1558
+ case "aggressive":
1517
1559
  return "degen_strategy";
1518
- case "advanced":
1560
+ case "yieldmaxxing":
1519
1561
  return "async_strategy";
1520
1562
  default:
1521
1563
  throw new Error(
@@ -1528,10 +1570,10 @@ function toPublicStrategy(internalStrategy) {
1528
1570
  return "conservative";
1529
1571
  }
1530
1572
  if (internalStrategy === "degen_strategy" || internalStrategy === "degen") {
1531
- return "balanced";
1573
+ return "aggressive";
1532
1574
  }
1533
1575
  if (internalStrategy === "async_strategy" || internalStrategy === "async") {
1534
- return "advanced";
1576
+ return "yieldmaxxing";
1535
1577
  }
1536
1578
  throw new Error(
1537
1579
  `Invalid internal strategy: ${internalStrategy}. Must be "safe_strategy", "degen_strategy" or "async_strategy".`
@@ -1548,7 +1590,7 @@ function toPublicStrategyOrUndefined(internalStrategy) {
1548
1590
  }
1549
1591
  }
1550
1592
  function isValidPublicStrategy(strategy) {
1551
- return strategy === "conservative" || strategy === "balanced" || strategy === "advanced";
1593
+ return strategy === "conservative" || strategy === "aggressive" || strategy === "yieldmaxxing";
1552
1594
  }
1553
1595
  function convertStrategyToPublic(obj) {
1554
1596
  if (!obj.strategy) {
@@ -2320,7 +2362,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2320
2362
  if (request.strategy) {
2321
2363
  if (!isValidPublicStrategy(request.strategy)) {
2322
2364
  throw new Error(
2323
- `Invalid strategy: ${request.strategy}. Must be "conservative", "balanced" or "advanced".`
2365
+ `Invalid strategy: ${request.strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
2324
2366
  );
2325
2367
  }
2326
2368
  rebalanceStrategy = toInternalStrategy(request.strategy);
@@ -2891,7 +2933,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
2891
2933
  *
2892
2934
  * @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
2893
2935
  * @param chainId - Target chain ID
2894
- * @param strategy - Optional strategy selection: "conservative" (default), "balanced" or "advanced"
2936
+ * @param strategy - Optional strategy selection: "conservative" (default), "aggressive" or "yieldmaxxing"
2895
2937
  * @param createSessionKey - If true, automatically creates a session key after deployment (default: false)
2896
2938
  * @returns Deployment response with Safe address and transaction hash
2897
2939
  *
@@ -3339,11 +3381,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3339
3381
  *
3340
3382
  * @example
3341
3383
  * ```typescript
3342
- * // NVDAc only lives in async protocols, so it needs "advanced".
3384
+ * // NVDAc only lives in async protocols, so it needs "yieldmaxxing".
3343
3385
  * // Chains default to Base, the only chain it exists on.
3344
3386
  * const profile = await sdk.setAssetStrategy({
3345
3387
  * asset: "NVDAc",
3346
- * strategy: "advanced",
3388
+ * strategy: "yieldmaxxing",
3347
3389
  * });
3348
3390
  * console.log(profile.protocols); // Ipor + Superform
3349
3391
  * ```
@@ -3353,7 +3395,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3353
3395
  try {
3354
3396
  if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
3355
3397
  throw new Error(
3356
- `Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
3398
+ `Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
3357
3399
  );
3358
3400
  }
3359
3401
  const supported = getAssetChainIds(asset);
@@ -3388,7 +3430,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3388
3430
  * Apply a strategy and auto-select matching protocols for one or all managed
3389
3431
  * assets ({@link getManagedAssets}). Prefer this over
3390
3432
  * {@link updateUserProfile} when changing strategy so protocols stay aligned
3391
- * with the tier (including `advanced` async venues).
3433
+ * with the tier (including `yieldmaxxing` async venues).
3392
3434
  *
3393
3435
  * @group Portfolio and execution
3394
3436
  */
@@ -3396,7 +3438,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3396
3438
  const { strategy, asset, chains } = params;
3397
3439
  if (!isValidPublicStrategy(strategy)) {
3398
3440
  throw new Error(
3399
- `Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
3441
+ `Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
3400
3442
  );
3401
3443
  }
3402
3444
  const assets = asset ? [asset] : getManagedAssets();
@@ -3545,14 +3587,16 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3545
3587
  return this.httpClient.post(ENDPOINTS.DEPLOY_CHAINS, { chainIds });
3546
3588
  }
3547
3589
  /**
3548
- * Transfer a collateral token the wallet already holds into the Safe.
3590
+ * Deposit a collateral token the wallet already holds into the Safe.
3549
3591
  *
3550
3592
  * @remarks
3551
3593
  * Use this when the connected wallet holds the strategy collateral on the
3552
3594
  * deposit chain. {@link ZyfaiSDK.sendDeposit} calls this automatically in
3553
3595
  * that case. A different token uses {@link ZyfaiSDK.sendSwapDeposit}.
3554
3596
  *
3555
- * Confirms the ERC-20 `transfer`, then calls {@link ZyfaiSDK.logDeposit}.
3597
+ * Eligible first deposits sign an ERC-2612 permit and the backend sponsors and
3598
+ * registers the pull. Other direct deposits confirm an ERC-20 transfer and
3599
+ * call {@link ZyfaiSDK.logDeposit}.
3556
3600
  * Requires {@link ZyfaiSDK.connectAccount}. Pass the **EOA** as `userAddress`.
3557
3601
  *
3558
3602
  * @group Deposits and withdrawals
@@ -3576,6 +3620,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3576
3620
  * ```
3577
3621
  */
3578
3622
  async sendDirectDeposit(userAddress, chainId, amount, asset, strategy) {
3623
+ return this.sendCollateralDeposit(userAddress, chainId, amount, asset, strategy, true);
3624
+ }
3625
+ async sendCollateralDeposit(userAddress, chainId, amount, asset, strategy, allowPermit) {
3579
3626
  try {
3580
3627
  if (!userAddress) {
3581
3628
  throw new Error("User address is required");
@@ -3593,7 +3640,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3593
3640
  }
3594
3641
  if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
3595
3642
  throw new Error(
3596
- `Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
3643
+ `Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
3597
3644
  );
3598
3645
  }
3599
3646
  const assetSymbol = resolveAssetSymbol(asset);
@@ -3667,6 +3714,16 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3667
3714
  );
3668
3715
  }
3669
3716
  }
3717
+ if (allowPermit && this.isPredeployed && this.isConnectedUser(userAddress)) {
3718
+ const sponsored = await this.sendFirstPermitDeposit({
3719
+ owner: getAddress2(userAddress),
3720
+ safe: safeAddress,
3721
+ chainId,
3722
+ token: getAddress2(token),
3723
+ amount: amountBigInt
3724
+ });
3725
+ if (sponsored) return sponsored;
3726
+ }
3670
3727
  const txHash = await walletClient.writeContract({
3671
3728
  address: token,
3672
3729
  abi: erc20TransferWriteAbi(assetSymbol),
@@ -3699,6 +3756,115 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3699
3756
  throw new Error(`Deposit failed: ${error.message}`);
3700
3757
  }
3701
3758
  }
3759
+ /**
3760
+ * Read the current first-deposit permit intent after a pending or interrupted deposit.
3761
+ *
3762
+ * @remarks
3763
+ * Uses the execution API and the SIWE session from {@link ZyfaiSDK.connectAccount}.
3764
+ * A registered intent provides the deposit id for {@link ZyfaiSDK.getDepositStatus}.
3765
+ *
3766
+ * @group Deposits and withdrawals
3767
+ *
3768
+ * @param userAddress - Authenticated EOA
3769
+ * @returns The latest permit intent, or null when no intent exists
3770
+ * @throws If the address differs from the authenticated EOA or the request fails
3771
+ *
3772
+ * @example
3773
+ * ```typescript
3774
+ * const intent = await sdk.getFirstPermitDepositStatus(eoa);
3775
+ * if (intent?.depositId) await sdk.waitForDepositCredit(intent.depositId, intent.chainId);
3776
+ * ```
3777
+ */
3778
+ async getFirstPermitDepositStatus(userAddress) {
3779
+ if (!this.sessionEoa || !isAddressEqual2(getAddress2(userAddress), this.sessionEoa)) {
3780
+ throw new Error("userAddress does not match authenticated session EOA");
3781
+ }
3782
+ return (await this.getFirstPermitDepositAvailability()).intent;
3783
+ }
3784
+ async getFirstPermitDepositAvailability(chainId) {
3785
+ try {
3786
+ return await this.httpClient.get(
3787
+ ENDPOINTS.FIRST_PERMIT_DEPOSIT,
3788
+ chainId != null ? { params: { chainId } } : void 0
3789
+ );
3790
+ } catch (error) {
3791
+ if (error instanceof Error && "status" in error && error.status === 404) {
3792
+ return { enabledTokens: [], intent: null };
3793
+ }
3794
+ throw error;
3795
+ }
3796
+ }
3797
+ async sendFirstPermitDeposit(request) {
3798
+ const { enabledTokens, intent, permitPreferred } = await this.getFirstPermitDepositAvailability(request.chainId);
3799
+ let id;
3800
+ let accepted;
3801
+ if (intent?.status === "queued" || intent?.status === "submitted") {
3802
+ if (!matchesFirstPermitDeposit(intent, request)) {
3803
+ throw new Error(`First permit deposit ${intent.id} is already pending for a different deposit`);
3804
+ }
3805
+ id = intent.id;
3806
+ accepted = intent;
3807
+ } else {
3808
+ const { owner, chainId, token, amount } = request;
3809
+ if (permitPreferred === false) return null;
3810
+ if (!enabledTokens.includes(`${chainId}:${token.toLowerCase()}`)) return null;
3811
+ const prepared = await this.httpClient.post(
3812
+ ENDPOINTS.FIRST_PERMIT_DEPOSIT_PREPARE,
3813
+ { owner, chainId, token, amount: amount.toString() }
3814
+ );
3815
+ if (!prepared) return null;
3816
+ const message = validateFirstPermit(prepared, request);
3817
+ const currentWallet = this.getWalletClient();
3818
+ const wallet = currentWallet.chain?.id === chainId ? currentWallet : await this.walletClientForOrigin(chainId);
3819
+ const signature = await wallet.signTypedData({
3820
+ account: wallet.account,
3821
+ domain: prepared.domain,
3822
+ types: firstPermitTypes,
3823
+ primaryType: "Permit",
3824
+ message
3825
+ });
3826
+ id = prepared.id;
3827
+ try {
3828
+ accepted = await this.httpClient.post(
3829
+ ENDPOINTS.FIRST_PERMIT_DEPOSIT_SUBMIT(id),
3830
+ { signature }
3831
+ );
3832
+ } catch (error) {
3833
+ accepted = await this.getFirstPermitDepositStatus(owner).catch(() => null);
3834
+ if (accepted?.id !== id || accepted.status === "prepared") {
3835
+ throw new Error(
3836
+ `Could not confirm first permit deposit ${id}. Check getFirstPermitDepositStatus before retrying: ${thrownMessage(error)}`
3837
+ );
3838
+ }
3839
+ }
3840
+ }
3841
+ let status = accepted;
3842
+ const { value: registered } = await pollUntil(async () => {
3843
+ const current = status ?? await this.getFirstPermitDepositStatus(request.owner);
3844
+ status = null;
3845
+ if (current?.id !== id || !matchesFirstPermitDeposit(current, request)) {
3846
+ throw new Error(`Unable to resolve first permit deposit ${id}. Check getFirstPermitDepositStatus before retrying.`);
3847
+ }
3848
+ if (current.status === "failed") {
3849
+ throw new Error(`First permit deposit ${id} failed`);
3850
+ }
3851
+ return current;
3852
+ }, (current) => current.status === "registered", {
3853
+ intervalMs: 3e3,
3854
+ label: `first permit deposit ${id} registration. Check getFirstPermitDepositStatus before retrying`
3855
+ });
3856
+ if (!registered.txHash || !registered.depositId) {
3857
+ throw new Error(`First permit deposit ${id} is missing its registration. Check getFirstPermitDepositStatus before retrying.`);
3858
+ }
3859
+ return {
3860
+ success: true,
3861
+ txHash: registered.txHash,
3862
+ smartWallet: request.safe,
3863
+ amount: registered.amount,
3864
+ route: "direct",
3865
+ registration: await this.getDepositStatus(registered.depositId)
3866
+ };
3867
+ }
3702
3868
  async sendDeposit(userAddressOrParams, chainId, amount, asset, strategy) {
3703
3869
  if (typeof userAddressOrParams !== "string") {
3704
3870
  return this.sendRoutedDeposit(userAddressOrParams);
@@ -3987,12 +4153,13 @@ var _ZyfaiSDK = class _ZyfaiSDK {
3987
4153
  BigInt(params.amount)
3988
4154
  );
3989
4155
  await this.wrapNativeEth(params.chainId, params.amount);
3990
- const sent = await this.sendDirectDeposit(
4156
+ const sent = await this.sendCollateralDeposit(
3991
4157
  params.userAddress,
3992
4158
  params.chainId,
3993
4159
  params.amount,
3994
4160
  "WETH",
3995
- params.strategy
4161
+ params.strategy,
4162
+ false
3996
4163
  );
3997
4164
  return { ...sent, route: "wrap" };
3998
4165
  }
@@ -4471,7 +4638,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
4471
4638
  async ensureFirstDepositSetup(strategy) {
4472
4639
  if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
4473
4640
  throw new Error(
4474
- `Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
4641
+ `Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
4475
4642
  );
4476
4643
  }
4477
4644
  await this.authenticateUser();
@@ -4504,7 +4671,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
4504
4671
  const { strategy, asset, chainId } = params;
4505
4672
  if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
4506
4673
  throw new Error(
4507
- `Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
4674
+ `Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
4508
4675
  );
4509
4676
  }
4510
4677
  await this.authenticateUser();
@@ -4887,7 +5054,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
4887
5054
  * Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
4888
5055
  * Funds are always withdrawn to the Safe owner's address (userAddress)
4889
5056
  *
4890
- * **Delayed withdrawals.** Positions held under the `"advanced"`
5057
+ * **Delayed withdrawals.** Positions held under the `"yieldmaxxing"`
4891
5058
  * strategy sit in protocols that cannot be exited on demand. For those the
4892
5059
  * backend transfers the immediately available portion, then queues a
4893
5060
  * redemption for the rest and forwards the funds to the EOA once the
@@ -5134,7 +5301,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
5134
5301
  * a snapshot, so net values can differ slightly from a fully live calc.
5135
5302
  *
5136
5303
  * **Total balance.** `portfolioByAssetType` sums deployed positions and idle
5137
- * Safe balances, and nothing else. Under the `"advanced"` strategy a
5304
+ * Safe balances, and nothing else. Under the `"yieldmaxxing"` strategy a
5138
5305
  * redemption in flight has already left its position and has not landed in
5139
5306
  * the Safe yet, so its funds appear in no balance field at all. That makes
5140
5307
  * two distinct numbers:
@@ -5159,7 +5326,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
5159
5326
  * @group Portfolio and execution
5160
5327
  *
5161
5328
  * @remarks Data API portfolio endpoint. See {@link PortfolioDetailed.pendingAsyncWithdrawals}
5162
- * when using {@link Strategy | grow}.
5329
+ * when using {@link Strategy | yieldmaxxing}.
5163
5330
  *
5164
5331
  * @param userAddress - User's EOA address
5165
5332
  * @returns Portfolio with optional fee-adjusted balance fields
@@ -5357,7 +5524,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
5357
5524
  *
5358
5525
  * @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
5359
5526
  * @param days - Time period: 7, 14, or 30
5360
- * @param strategy - Strategy type: "conservative" (default), "balanced" or "advanced"
5527
+ * @param strategy - Strategy type: "conservative" (default), "aggressive" or "yieldmaxxing"
5361
5528
  * @param chainId - Optional chain ID filter
5362
5529
  * @param tokenSymbol - Optional token symbol filter (e.g. "USDC", "WETH", "WBTC")
5363
5530
  * @returns APY per strategy for a specific chain
@@ -5812,19 +5979,19 @@ var _ZyfaiSDK = class _ZyfaiSDK {
5812
5979
  }
5813
5980
  }
5814
5981
  /**
5815
- * Get aggressive (high-risk, high-reward) yield opportunities
5982
+ * Get balanced (high-risk, high-reward) yield opportunities.
5816
5983
  *
5817
5984
  * @param chainId - Optional chain ID filter
5818
5985
  * @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
5819
- * @returns List of aggressive opportunities
5986
+ * @returns List of balanced opportunities
5820
5987
  *
5821
5988
  * @example
5822
5989
  * ```typescript
5823
- * const opportunities = await sdk.getAggressiveOpportunities(8453, "WETH");
5990
+ * const opportunities = await sdk.getBalancedOpportunities(8453, "WETH");
5824
5991
  * opportunities.data.forEach(o => console.log(o.protocolName, o.apy));
5825
5992
  * ```
5826
5993
  */
5827
- async getAggressiveOpportunities(chainId, asset, status) {
5994
+ async getBalancedOpportunities(chainId, asset, status) {
5828
5995
  try {
5829
5996
  const response = await this.httpClient.dataGet(
5830
5997
  DATA_ENDPOINTS.OPPORTUNITIES_DEGEN(chainId, asset, status)
@@ -5850,12 +6017,25 @@ var _ZyfaiSDK = class _ZyfaiSDK {
5850
6017
  };
5851
6018
  } catch (error) {
5852
6019
  throw new Error(
5853
- `Failed to get aggressive opportunities: ${error.message}`
6020
+ `Failed to get balanced opportunities: ${error.message}`
5854
6021
  );
5855
6022
  }
5856
6023
  }
5857
6024
  /**
5858
- * Get grow opportunities — pools reachable only with the
6025
+ * @deprecated Use {@link getBalancedOpportunities} instead. Retains the
6026
+ * pre-rename `getAggressiveOpportunities` entry point; same HTTP request as
6027
+ * balanced, with legacy `strategyType: "aggressive"` on the response and rows.
6028
+ */
6029
+ async getAggressiveOpportunities(chainId, asset, status) {
6030
+ const result = await this.getBalancedOpportunities(chainId, asset, status);
6031
+ return {
6032
+ ...result,
6033
+ strategyType: "aggressive",
6034
+ data: result.data.map((o) => ({ ...o, strategyType: "aggressive" }))
6035
+ };
6036
+ }
6037
+ /**
6038
+ * Get advanced yield opportunities — pools reachable only with the
5859
6039
  * `"advanced"` strategy, including protocols whose withdrawals are
5860
6040
  * asynchronous (Ipor, Superform). Exiting these pools takes about a day
5861
6041
  * on Ipor and three on Superform; track the redemption through
@@ -5863,15 +6043,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
5863
6043
  *
5864
6044
  * @param chainId - Optional chain ID filter
5865
6045
  * @param asset - Optional asset filter (e.g. "USDC", "WETH")
5866
- * @returns List of grow opportunities
6046
+ * @returns List of advanced opportunities
5867
6047
  *
5868
6048
  * @example
5869
6049
  * ```typescript
5870
- * const opportunities = await sdk.getAsyncOpportunities(8453);
6050
+ * const opportunities = await sdk.getAdvancedOpportunities(8453);
5871
6051
  * opportunities.data.forEach(o => console.log(o.protocolName, o.apy));
5872
6052
  * ```
5873
6053
  */
5874
- async getAsyncOpportunities(chainId, asset, status) {
6054
+ async getAdvancedOpportunities(chainId, asset, status) {
5875
6055
  try {
5876
6056
  const response = await this.httpClient.dataGet(
5877
6057
  DATA_ENDPOINTS.OPPORTUNITIES_ASYNC(chainId, asset, status)
@@ -5897,10 +6077,23 @@ var _ZyfaiSDK = class _ZyfaiSDK {
5897
6077
  };
5898
6078
  } catch (error) {
5899
6079
  throw new Error(
5900
- `Failed to get grow opportunities: ${error.message}`
6080
+ `Failed to get advanced opportunities: ${error.message}`
5901
6081
  );
5902
6082
  }
5903
6083
  }
6084
+ /**
6085
+ * @deprecated Use {@link getAdvancedOpportunities} instead. Retains the
6086
+ * pre-rename `getAsyncOpportunities` entry point; same HTTP request as
6087
+ * advanced, with legacy `strategyType: "yieldmaxxing"` on the response and rows.
6088
+ */
6089
+ async getAsyncOpportunities(chainId, asset, status) {
6090
+ const result = await this.getAdvancedOpportunities(chainId, asset, status);
6091
+ return {
6092
+ ...result,
6093
+ strategyType: "yieldmaxxing",
6094
+ data: result.data.map((o) => ({ ...o, strategyType: "yieldmaxxing" }))
6095
+ };
6096
+ }
5904
6097
  /**
5905
6098
  * Get active conservative opportunities (status = "live") with risk and utilization data
5906
6099
  * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
@@ -6422,7 +6615,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
6422
6615
  if (strategy) {
6423
6616
  if (!isValidPublicStrategy(strategy)) {
6424
6617
  throw new Error(
6425
- `Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
6618
+ `Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
6426
6619
  );
6427
6620
  }
6428
6621
  internalStrategy = toInternalStrategy(strategy);
@@ -6472,7 +6665,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
6472
6665
  try {
6473
6666
  if (!isValidPublicStrategy(params.strategy)) {
6474
6667
  throw new Error(
6475
- `Invalid strategy: ${params.strategy}. Must be "conservative", "balanced" or "advanced".`
6668
+ `Invalid strategy: ${params.strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
6476
6669
  );
6477
6670
  }
6478
6671
  const internalStrategy = toInternalStrategy(params.strategy);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.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",