@owney/sdk 0.7.32-beta.1 → 0.7.32-beta.2

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.cjs CHANGED
@@ -1548,7 +1548,7 @@ var SnapshotHistory = class {
1548
1548
  };
1549
1549
 
1550
1550
  // src/lib/funding-ledger.ts
1551
- var SDK_VERSION = "0.7.32-beta.1";
1551
+ var SDK_VERSION = "0.7.32-beta.2";
1552
1552
  var SCOPE2 = "funding-ledger";
1553
1553
  var REQUEST_TIMEOUT_MS2 = 5e3;
1554
1554
  var RETRY_DELAYS_MS = [1e3, 4e3, 16e3];
@@ -2158,6 +2158,8 @@ function ledgerLegFromEvidence(e, kind) {
2158
2158
  if (e.callsId && e.callsId.length <= 200) leg.callsId = e.callsId;
2159
2159
  if (isUint(e.confirmedAmount)) leg.confirmedAmountRaw = e.confirmedAmount;
2160
2160
  if (e.blockNumber && /^\d{1,19}$/.test(e.blockNumber)) leg.blockNumber = e.blockNumber;
2161
+ const providerRef = e.withdrawalRequest?.providerWithdrawalId;
2162
+ if (typeof providerRef === "string" && providerRef.length >= 1 && providerRef.length <= 128) leg.providerRef = providerRef;
2161
2163
  const failure = e.withdrawalRequest?.failure;
2162
2164
  if (failure) leg.errorCode = failure.toUpperCase().replace(/-/g, "_");
2163
2165
  return leg;
@@ -2824,6 +2826,7 @@ var AgentReads = class {
2824
2826
  // src/agents/zyfai/zyfai.withdraw-submission.ts
2825
2827
  var BELOW_MINIMUM = /^Idle balance (\d+(?:\.\d+)?) (USDC|WETH|ETH|EURC) is below the minimum withdrawal of (\d+(?:\.\d+)?) \2\.?$/;
2826
2828
  var listenersByClient = /* @__PURE__ */ new WeakMap();
2829
+ var MAX_WITHDRAWAL_ID_LENGTH = 128;
2827
2830
  function observeWithdrawalSubmission(sdk, chainId, token, assertCurrent) {
2828
2831
  const client = sdk.httpClient;
2829
2832
  if (!client || typeof client.get !== "function" || typeof client.post !== "function")
@@ -2854,6 +2857,7 @@ function observeWithdrawalSubmission(sdk, chainId, token, assertCurrent) {
2854
2857
  method: method === "get" ? "GET" : "POST",
2855
2858
  path: method === "get" ? "/users/withdraw" : "/users/partial-withdraw"
2856
2859
  };
2860
+ if (withdrawal) request3.path = `${request3.path}/v2`;
2857
2861
  let belowMinimum2;
2858
2862
  const notify2 = (outcome) => {
2859
2863
  if (outcome === "rejected" && matching.length !== 1) return;
@@ -2886,8 +2890,26 @@ function observeWithdrawalSubmission(sdk, chainId, token, assertCurrent) {
2886
2890
  captureStatus
2887
2891
  ] };
2888
2892
  }
2893
+ const send = (route) => original.apply(this, [route, ...callArgs.slice(1)]);
2889
2894
  try {
2890
- return await original.apply(this, callArgs);
2895
+ let result;
2896
+ if (!withdrawal) result = await send(url);
2897
+ else {
2898
+ try {
2899
+ result = await send(`${url}/v2`);
2900
+ } catch (error) {
2901
+ const status = request3.httpStatus ?? error?.response?.status;
2902
+ if (status !== 404) throw error;
2903
+ for (const observer of matching) observer.assertCurrent?.();
2904
+ request3.path = url;
2905
+ delete request3.httpStatus;
2906
+ result = await send(url);
2907
+ }
2908
+ const id = result?.id;
2909
+ if (request3.path?.endsWith("/v2") && typeof id === "string" && id.length >= 1 && id.length <= MAX_WITHDRAWAL_ID_LENGTH)
2910
+ request3.providerWithdrawalId = id;
2911
+ }
2912
+ return result;
2891
2913
  } catch (error) {
2892
2914
  const message = error instanceof Error ? error.message : "";
2893
2915
  const minimum = BELOW_MINIMUM.exec(message);
@@ -5514,6 +5536,22 @@ var ZyfaiAgent = class _ZyfaiAgent {
5514
5536
  this.ledgerReads.clear();
5515
5537
  return { ...evidence, registration: "confirmed" };
5516
5538
  }
5539
+ /** Reads a withdrawal's lifecycle by its id. Never signs, prompts or authenticates:
5540
+ * it uses only a session the vendor client already holds, and any failure is `null`. */
5541
+ async getWithdrawalLifecycle(state, withdrawalId) {
5542
+ const internals = this.sdk;
5543
+ const client = internals.httpClient;
5544
+ if (!client?.authToken || typeof client.get !== "function" || this.connectedAddress?.toLowerCase() !== state.walletAddress.toLowerCase()) return null;
5545
+ try {
5546
+ const body = await client.get(`/users/withdrawals/${encodeURIComponent(withdrawalId)}`);
5547
+ if (!body || typeof body !== "object" || typeof body.status !== "string" || typeof body.syncSettled !== "boolean")
5548
+ return null;
5549
+ const hash2 = typeof body.syncTxHash === "string" && /^0x[0-9a-fA-F]{64}$/.test(body.syncTxHash) ? body.syncTxHash : void 0;
5550
+ return { status: body.status, syncSettled: body.syncSettled, ...hash2 ? { syncTxHash: hash2 } : {} };
5551
+ } catch {
5552
+ return null;
5553
+ }
5554
+ }
5517
5555
  // --- IAgent: Portfolio reads ---
5518
5556
  async getFundingWallet(state, chainId) {
5519
5557
  return this.readSmartWallet(state.walletAddress, isValidChainId(chainId));
@@ -8971,7 +9009,8 @@ var YieldseekerAgent = class {
8971
9009
  );
8972
9010
  const confirmedAmount = evidence.confirmedAmount && /^\d+$/.test(evidence.confirmedAmount) ? BigInt(evidence.confirmedAmount) : void 0;
8973
9011
  const feeIncrease = ownerFunds.fees - initialFunds.fees;
8974
- const feeAdjustment = amount !== void 0 && receipt && initialFunds.blockNumber !== void 0 && latestUnwindBlock !== void 0 && initialFunds.blockNumber <= latestUnwindBlock && receipt.blockNumber >= latestUnwindBlock && evidence.transfer === "confirmed" && evidence.delivery === "confirmed" && confirmedAmount === payout && feeIncrease > 0n && feeIncrease <= maxFee && requested - payout === feeIncrease ? { grossAmount: requested.toString(), feeAmount: feeIncrease.toString() } : void 0;
9012
+ const feeShortfall = requested - payout;
9013
+ const feeAdjustment = amount !== void 0 && receipt && initialFunds.blockNumber !== void 0 && latestUnwindBlock !== void 0 && initialFunds.blockNumber <= latestUnwindBlock && receipt.blockNumber >= latestUnwindBlock && evidence.transfer === "confirmed" && evidence.delivery === "confirmed" && confirmedAmount === payout && feeIncrease > 0n && feeIncrease <= maxFee && feeShortfall > 0n && feeShortfall <= feeIncrease ? { grossAmount: requested.toString(), feeAmount: feeShortfall.toString() } : void 0;
8975
9014
  return {
8976
9015
  txHash,
8977
9016
  type: amount === void 0 && !completion ? "full" : "partial",
@@ -10805,7 +10844,7 @@ var YieldseekerAgent = class {
10805
10844
  }
10806
10845
  const ttl = this.portfolioCacheMs(contextKey);
10807
10846
  this.settlementChecks.set(contextKey, 1);
10808
- const force = !this.deferredToLedger(contextKey);
10847
+ const force = movement === "withdrawal" || !this.deferredToLedger(contextKey);
10809
10848
  await this.cachedRead(
10810
10849
  `snapshot:${contextKey}`,
10811
10850
  ttl,
@@ -15443,6 +15482,14 @@ var OwneySDK = class {
15443
15482
  if (verified.agentId !== "zyfai") return verified;
15444
15483
  return this.getAgent("zyfai").retryDepositRegistration(state, verified);
15445
15484
  }
15485
+ /** A Zyfai withdrawal's lifecycle by the id recorded on its evidence. Never signs,
15486
+ * prompts or authenticates; `null` when unavailable or not this wallet's Zyfai withdrawal. */
15487
+ async getZyfaiWithdrawal(evidence) {
15488
+ const state = this.state;
15489
+ const id = evidence.withdrawalRequest?.providerWithdrawalId;
15490
+ if (evidence.agentId !== "zyfai" || !id || !state || state.walletAddress.toLowerCase() !== evidence.walletAddress.toLowerCase()) return null;
15491
+ return this.getAgent("zyfai").getWithdrawalLifecycle(state, id);
15492
+ }
15446
15493
  // --- Fund operations ---
15447
15494
  /** On-chain version and ownership status for this owner's Yieldseeker agent. */
15448
15495
  async getYieldseekerWalletStatus(asset) {
package/dist/index.d.cts CHANGED
@@ -777,13 +777,16 @@ interface FundingEvidence {
777
777
  withdrawalRequest?: {
778
778
  attempted: boolean;
779
779
  method?: "GET" | "POST";
780
- path?: "/users/withdraw" | "/users/partial-withdraw";
780
+ /** The route that answered; a v2 path may fall back to v1 after an HTTP 404. */
781
+ path?: "/users/withdraw" | "/users/partial-withdraw" | "/users/withdraw/v2" | "/users/partial-withdraw/v2";
781
782
  elapsedMs?: number;
782
783
  /** Actual response status captured before the vendor replaces the HTTP error. */
783
784
  httpStatus?: number;
784
785
  failure?: "network" | "unauthorized" | "forbidden" | "rate-limited" | "insufficient-balance" | "session-key-missing" | "withdrawal-in-progress" | "other";
785
786
  /** When the provider accepted the request without a hash (ms since epoch). */
786
787
  acceptedAt?: number;
788
+ /** Zyfai's v2 withdrawal id, for the lifecycle lookup (1-128 chars). */
789
+ providerWithdrawalId?: string;
787
790
  };
788
791
  /** Where an on-chain payout search may start, for a hashless acceptance.
789
792
  * `fromBlock` is the chain head read just before the request (decimal string). */
@@ -795,6 +798,14 @@ interface FundingEvidence {
795
798
  delivery: FundingStage;
796
799
  }
797
800
  type FundingProgress = (evidence: FundingEvidence) => void;
801
+ /** The part of Zyfai's withdrawal lifecycle (`GET /users/withdrawals/{id}`) that Owney acts on. */
802
+ type ZyfaiWithdrawalLifecycle = {
803
+ status: string;
804
+ /** The synchronous payout leg has settled. */
805
+ syncSettled: boolean;
806
+ /** Hash of the synchronous payout transaction; present only when well formed. */
807
+ syncTxHash?: `0x${string}`;
808
+ };
798
809
  interface AssetReadMetadata {
799
810
  chainId: number;
800
811
  asset: string;
@@ -1621,6 +1632,9 @@ declare class OwneySDK {
1621
1632
  /** History lookup for receipt recovery; adapters may not authenticate or sign here. */
1622
1633
  getFundingHistory(evidence: FundingEvidence, fromDate: string, options?: Pick<HistoryFilters, "cursor" | "toDate">): Promise<OwneyAgentHistory>;
1623
1634
  recoverDepositRegistration(evidence: FundingEvidence): Promise<FundingEvidence>;
1635
+ /** A Zyfai withdrawal's lifecycle by the id recorded on its evidence. Never signs,
1636
+ * prompts or authenticates; `null` when unavailable or not this wallet's Zyfai withdrawal. */
1637
+ getZyfaiWithdrawal(evidence: FundingEvidence): Promise<ZyfaiWithdrawalLifecycle | null>;
1624
1638
  /** On-chain version and ownership status for this owner's Yieldseeker agent. */
1625
1639
  getYieldseekerWalletStatus(asset: OwneySupportedTokens): Promise<YieldseekerWalletStatus | null>;
1626
1640
  /** Deployment gate; an unavailable response keeps the current paid path. */
@@ -2642,6 +2656,8 @@ type LedgerLegReport = {
2642
2656
  userOpHash?: string;
2643
2657
  callsId?: string;
2644
2658
  orderHash?: string;
2659
+ /** The provider's own id for this leg's request (Zyfai's v2 withdrawal id). */
2660
+ providerRef?: string;
2645
2661
  confirmedAmountRaw?: string;
2646
2662
  blockNumber?: string;
2647
2663
  errorCode?: string;
@@ -2660,4 +2676,4 @@ type LedgerLegReport = {
2660
2676
  };
2661
2677
  };
2662
2678
 
2663
- export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type PendingDeposit, type ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YieldseekerAgent, type YieldseekerWalletStatus, type ZyfaiRpcUrlsConfig, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };
2679
+ export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type PendingDeposit, type ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YieldseekerAgent, type YieldseekerWalletStatus, type ZyfaiRpcUrlsConfig, type ZyfaiWithdrawalLifecycle, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };
package/dist/index.d.ts CHANGED
@@ -777,13 +777,16 @@ interface FundingEvidence {
777
777
  withdrawalRequest?: {
778
778
  attempted: boolean;
779
779
  method?: "GET" | "POST";
780
- path?: "/users/withdraw" | "/users/partial-withdraw";
780
+ /** The route that answered; a v2 path may fall back to v1 after an HTTP 404. */
781
+ path?: "/users/withdraw" | "/users/partial-withdraw" | "/users/withdraw/v2" | "/users/partial-withdraw/v2";
781
782
  elapsedMs?: number;
782
783
  /** Actual response status captured before the vendor replaces the HTTP error. */
783
784
  httpStatus?: number;
784
785
  failure?: "network" | "unauthorized" | "forbidden" | "rate-limited" | "insufficient-balance" | "session-key-missing" | "withdrawal-in-progress" | "other";
785
786
  /** When the provider accepted the request without a hash (ms since epoch). */
786
787
  acceptedAt?: number;
788
+ /** Zyfai's v2 withdrawal id, for the lifecycle lookup (1-128 chars). */
789
+ providerWithdrawalId?: string;
787
790
  };
788
791
  /** Where an on-chain payout search may start, for a hashless acceptance.
789
792
  * `fromBlock` is the chain head read just before the request (decimal string). */
@@ -795,6 +798,14 @@ interface FundingEvidence {
795
798
  delivery: FundingStage;
796
799
  }
797
800
  type FundingProgress = (evidence: FundingEvidence) => void;
801
+ /** The part of Zyfai's withdrawal lifecycle (`GET /users/withdrawals/{id}`) that Owney acts on. */
802
+ type ZyfaiWithdrawalLifecycle = {
803
+ status: string;
804
+ /** The synchronous payout leg has settled. */
805
+ syncSettled: boolean;
806
+ /** Hash of the synchronous payout transaction; present only when well formed. */
807
+ syncTxHash?: `0x${string}`;
808
+ };
798
809
  interface AssetReadMetadata {
799
810
  chainId: number;
800
811
  asset: string;
@@ -1621,6 +1632,9 @@ declare class OwneySDK {
1621
1632
  /** History lookup for receipt recovery; adapters may not authenticate or sign here. */
1622
1633
  getFundingHistory(evidence: FundingEvidence, fromDate: string, options?: Pick<HistoryFilters, "cursor" | "toDate">): Promise<OwneyAgentHistory>;
1623
1634
  recoverDepositRegistration(evidence: FundingEvidence): Promise<FundingEvidence>;
1635
+ /** A Zyfai withdrawal's lifecycle by the id recorded on its evidence. Never signs,
1636
+ * prompts or authenticates; `null` when unavailable or not this wallet's Zyfai withdrawal. */
1637
+ getZyfaiWithdrawal(evidence: FundingEvidence): Promise<ZyfaiWithdrawalLifecycle | null>;
1624
1638
  /** On-chain version and ownership status for this owner's Yieldseeker agent. */
1625
1639
  getYieldseekerWalletStatus(asset: OwneySupportedTokens): Promise<YieldseekerWalletStatus | null>;
1626
1640
  /** Deployment gate; an unavailable response keeps the current paid path. */
@@ -2642,6 +2656,8 @@ type LedgerLegReport = {
2642
2656
  userOpHash?: string;
2643
2657
  callsId?: string;
2644
2658
  orderHash?: string;
2659
+ /** The provider's own id for this leg's request (Zyfai's v2 withdrawal id). */
2660
+ providerRef?: string;
2645
2661
  confirmedAmountRaw?: string;
2646
2662
  blockNumber?: string;
2647
2663
  errorCode?: string;
@@ -2660,4 +2676,4 @@ type LedgerLegReport = {
2660
2676
  };
2661
2677
  };
2662
2678
 
2663
- export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type PendingDeposit, type ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YieldseekerAgent, type YieldseekerWalletStatus, type ZyfaiRpcUrlsConfig, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };
2679
+ export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type PendingDeposit, type ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YieldseekerAgent, type YieldseekerWalletStatus, type ZyfaiRpcUrlsConfig, type ZyfaiWithdrawalLifecycle, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };
package/dist/index.js CHANGED
@@ -960,7 +960,7 @@ var SnapshotHistory = class {
960
960
  };
961
961
 
962
962
  // src/lib/funding-ledger.ts
963
- var SDK_VERSION = "0.7.32-beta.1";
963
+ var SDK_VERSION = "0.7.32-beta.2";
964
964
  var SCOPE2 = "funding-ledger";
965
965
  var REQUEST_TIMEOUT_MS2 = 5e3;
966
966
  var RETRY_DELAYS_MS = [1e3, 4e3, 16e3];
@@ -1570,6 +1570,8 @@ function ledgerLegFromEvidence(e, kind) {
1570
1570
  if (e.callsId && e.callsId.length <= 200) leg.callsId = e.callsId;
1571
1571
  if (isUint(e.confirmedAmount)) leg.confirmedAmountRaw = e.confirmedAmount;
1572
1572
  if (e.blockNumber && /^\d{1,19}$/.test(e.blockNumber)) leg.blockNumber = e.blockNumber;
1573
+ const providerRef = e.withdrawalRequest?.providerWithdrawalId;
1574
+ if (typeof providerRef === "string" && providerRef.length >= 1 && providerRef.length <= 128) leg.providerRef = providerRef;
1573
1575
  const failure = e.withdrawalRequest?.failure;
1574
1576
  if (failure) leg.errorCode = failure.toUpperCase().replace(/-/g, "_");
1575
1577
  return leg;
@@ -2228,6 +2230,7 @@ var AgentReads = class {
2228
2230
  // src/agents/zyfai/zyfai.withdraw-submission.ts
2229
2231
  var BELOW_MINIMUM = /^Idle balance (\d+(?:\.\d+)?) (USDC|WETH|ETH|EURC) is below the minimum withdrawal of (\d+(?:\.\d+)?) \2\.?$/;
2230
2232
  var listenersByClient = /* @__PURE__ */ new WeakMap();
2233
+ var MAX_WITHDRAWAL_ID_LENGTH = 128;
2231
2234
  function observeWithdrawalSubmission(sdk, chainId, token, assertCurrent) {
2232
2235
  const client = sdk.httpClient;
2233
2236
  if (!client || typeof client.get !== "function" || typeof client.post !== "function")
@@ -2258,6 +2261,7 @@ function observeWithdrawalSubmission(sdk, chainId, token, assertCurrent) {
2258
2261
  method: method === "get" ? "GET" : "POST",
2259
2262
  path: method === "get" ? "/users/withdraw" : "/users/partial-withdraw"
2260
2263
  };
2264
+ if (withdrawal) request3.path = `${request3.path}/v2`;
2261
2265
  let belowMinimum2;
2262
2266
  const notify2 = (outcome) => {
2263
2267
  if (outcome === "rejected" && matching.length !== 1) return;
@@ -2290,8 +2294,26 @@ function observeWithdrawalSubmission(sdk, chainId, token, assertCurrent) {
2290
2294
  captureStatus
2291
2295
  ] };
2292
2296
  }
2297
+ const send = (route) => original.apply(this, [route, ...callArgs.slice(1)]);
2293
2298
  try {
2294
- return await original.apply(this, callArgs);
2299
+ let result;
2300
+ if (!withdrawal) result = await send(url);
2301
+ else {
2302
+ try {
2303
+ result = await send(`${url}/v2`);
2304
+ } catch (error) {
2305
+ const status = request3.httpStatus ?? error?.response?.status;
2306
+ if (status !== 404) throw error;
2307
+ for (const observer of matching) observer.assertCurrent?.();
2308
+ request3.path = url;
2309
+ delete request3.httpStatus;
2310
+ result = await send(url);
2311
+ }
2312
+ const id = result?.id;
2313
+ if (request3.path?.endsWith("/v2") && typeof id === "string" && id.length >= 1 && id.length <= MAX_WITHDRAWAL_ID_LENGTH)
2314
+ request3.providerWithdrawalId = id;
2315
+ }
2316
+ return result;
2295
2317
  } catch (error) {
2296
2318
  const message = error instanceof Error ? error.message : "";
2297
2319
  const minimum = BELOW_MINIMUM.exec(message);
@@ -4915,6 +4937,22 @@ var ZyfaiAgent = class _ZyfaiAgent {
4915
4937
  this.ledgerReads.clear();
4916
4938
  return { ...evidence, registration: "confirmed" };
4917
4939
  }
4940
+ /** Reads a withdrawal's lifecycle by its id. Never signs, prompts or authenticates:
4941
+ * it uses only a session the vendor client already holds, and any failure is `null`. */
4942
+ async getWithdrawalLifecycle(state, withdrawalId) {
4943
+ const internals = this.sdk;
4944
+ const client = internals.httpClient;
4945
+ if (!client?.authToken || typeof client.get !== "function" || this.connectedAddress?.toLowerCase() !== state.walletAddress.toLowerCase()) return null;
4946
+ try {
4947
+ const body = await client.get(`/users/withdrawals/${encodeURIComponent(withdrawalId)}`);
4948
+ if (!body || typeof body !== "object" || typeof body.status !== "string" || typeof body.syncSettled !== "boolean")
4949
+ return null;
4950
+ const hash2 = typeof body.syncTxHash === "string" && /^0x[0-9a-fA-F]{64}$/.test(body.syncTxHash) ? body.syncTxHash : void 0;
4951
+ return { status: body.status, syncSettled: body.syncSettled, ...hash2 ? { syncTxHash: hash2 } : {} };
4952
+ } catch {
4953
+ return null;
4954
+ }
4955
+ }
4918
4956
  // --- IAgent: Portfolio reads ---
4919
4957
  async getFundingWallet(state, chainId) {
4920
4958
  return this.readSmartWallet(state.walletAddress, isValidChainId(chainId));
@@ -8395,7 +8433,8 @@ var YieldseekerAgent = class {
8395
8433
  );
8396
8434
  const confirmedAmount = evidence.confirmedAmount && /^\d+$/.test(evidence.confirmedAmount) ? BigInt(evidence.confirmedAmount) : void 0;
8397
8435
  const feeIncrease = ownerFunds.fees - initialFunds.fees;
8398
- const feeAdjustment = amount !== void 0 && receipt && initialFunds.blockNumber !== void 0 && latestUnwindBlock !== void 0 && initialFunds.blockNumber <= latestUnwindBlock && receipt.blockNumber >= latestUnwindBlock && evidence.transfer === "confirmed" && evidence.delivery === "confirmed" && confirmedAmount === payout && feeIncrease > 0n && feeIncrease <= maxFee && requested - payout === feeIncrease ? { grossAmount: requested.toString(), feeAmount: feeIncrease.toString() } : void 0;
8436
+ const feeShortfall = requested - payout;
8437
+ const feeAdjustment = amount !== void 0 && receipt && initialFunds.blockNumber !== void 0 && latestUnwindBlock !== void 0 && initialFunds.blockNumber <= latestUnwindBlock && receipt.blockNumber >= latestUnwindBlock && evidence.transfer === "confirmed" && evidence.delivery === "confirmed" && confirmedAmount === payout && feeIncrease > 0n && feeIncrease <= maxFee && feeShortfall > 0n && feeShortfall <= feeIncrease ? { grossAmount: requested.toString(), feeAmount: feeShortfall.toString() } : void 0;
8399
8438
  return {
8400
8439
  txHash,
8401
8440
  type: amount === void 0 && !completion ? "full" : "partial",
@@ -10229,7 +10268,7 @@ var YieldseekerAgent = class {
10229
10268
  }
10230
10269
  const ttl = this.portfolioCacheMs(contextKey);
10231
10270
  this.settlementChecks.set(contextKey, 1);
10232
- const force = !this.deferredToLedger(contextKey);
10271
+ const force = movement === "withdrawal" || !this.deferredToLedger(contextKey);
10233
10272
  await this.cachedRead(
10234
10273
  `snapshot:${contextKey}`,
10235
10274
  ttl,
@@ -14872,6 +14911,14 @@ var OwneySDK = class {
14872
14911
  if (verified.agentId !== "zyfai") return verified;
14873
14912
  return this.getAgent("zyfai").retryDepositRegistration(state, verified);
14874
14913
  }
14914
+ /** A Zyfai withdrawal's lifecycle by the id recorded on its evidence. Never signs,
14915
+ * prompts or authenticates; `null` when unavailable or not this wallet's Zyfai withdrawal. */
14916
+ async getZyfaiWithdrawal(evidence) {
14917
+ const state = this.state;
14918
+ const id = evidence.withdrawalRequest?.providerWithdrawalId;
14919
+ if (evidence.agentId !== "zyfai" || !id || !state || state.walletAddress.toLowerCase() !== evidence.walletAddress.toLowerCase()) return null;
14920
+ return this.getAgent("zyfai").getWithdrawalLifecycle(state, id);
14921
+ }
14875
14922
  // --- Fund operations ---
14876
14923
  /** On-chain version and ownership status for this owner's Yieldseeker agent. */
14877
14924
  async getYieldseekerWalletStatus(asset) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owney/sdk",
3
- "version": "0.7.32-beta.1",
3
+ "version": "0.7.32-beta.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",