@owney/sdk 0.7.7-beta.2 → 0.7.7-beta.4

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.d.cts CHANGED
@@ -180,6 +180,21 @@ interface OwneyPosition {
180
180
  * response later; undefined until then. */
181
181
  liquidity?: number;
182
182
  }
183
+ /**
184
+ * Funds that have landed in the agent's wallet but are not yet deployed into a
185
+ * protocol. Sourced from Zyfai `staleBalances[].isPending`. Absent when nothing
186
+ * is pending, and for agents that do not report it (sail).
187
+ */
188
+ interface OwneyPendingAllocation {
189
+ /** Deliberately loose (not OwneySupportedChainId) because Zyfai reports balances on unsupported chains. */
190
+ chainId: number;
191
+ /** Raw agent symbol, not normalized to OwneySupportedTokens; carries Zyfai's casing and "eth" alias for WETH. */
192
+ asset: string;
193
+ /** Decimal string, consistent with `OwneyToken.amount`. */
194
+ amount: string;
195
+ /** ISO timestamp from Zyfai's `updatedAt`, when the payload carries one. */
196
+ since?: string;
197
+ }
183
198
  interface AgentBalance {
184
199
  smartWallet?: `0x${string}`;
185
200
  totalBalance: string;
@@ -191,6 +206,8 @@ interface AgentBalance {
191
206
  * them (zyfai). Omitted for agents that don't expose positions (sail).
192
207
  */
193
208
  positions?: OwneyPosition[];
209
+ /** Funds received but not yet deployed. Omitted when nothing is pending. */
210
+ pendingAllocations?: OwneyPendingAllocation[];
194
211
  }
195
212
  interface OwneyBalances {
196
213
  totalBalance: string;
@@ -392,7 +409,7 @@ declare class OwneySDK {
392
409
  private routingApiBaseUrl?;
393
410
  private referralSource?;
394
411
  private cachedSponsoredCallback;
395
- private cachedPermit2Callbacks;
412
+ private cachedWethSponsoredCallback;
396
413
  private initializingAgentsPromise;
397
414
  constructor(config: OwneySDKConfig);
398
415
  /**
@@ -428,21 +445,12 @@ declare class OwneySDK {
428
445
  */
429
446
  private getDefaultSponsoredCallback;
430
447
  /**
431
- * Lazily builds (and caches) the Permit2 sponsored callback for one asset.
432
- * Used for WETH always, and for USDC when the connected owner is a smart
433
- * account — EIP-3009 verifies with ecrecover inside USDC and cannot accept a
434
- * contract signature, while Permit2 supports ERC-1271.
448
+ * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
449
+ * callback used when the caller omits `depositCallback` for a WETH
450
+ * deposit. Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
451
+ * `PermitTransferFrom` instead of an EIP-3009 authorization.
435
452
  */
436
- private getDefaultPermit2Callback;
437
- /**
438
- * True when the connected owner has bytecode — a deployed smart wallet, or an
439
- * EOA carrying an EIP-7702 delegation (the Base app's "Upgrade your wallet").
440
- * Such wallets sign via ERC-1271, which EIP-3009 cannot verify.
441
- *
442
- * Fails OPEN: an unreadable code check returns false so a working EOA deposit
443
- * is never blocked by a flaky provider.
444
- */
445
- private ownerHasCode;
453
+ private getDefaultWethSponsoredCallback;
446
454
  private getAgent;
447
455
  private getActiveAgents;
448
456
  /**
@@ -492,16 +500,13 @@ declare class OwneySDK {
492
500
  * 1. Missing Permit2 allowance: when the app did not supply its own
493
501
  * callback and the attempt fails with `PERMIT2_APPROVAL_REQUIRED` on a
494
502
  * WETH deposit, this is the wallet's first gasless WETH deposit. We send
495
- * the one-time (user-paid) Permit2 approval via `approvePermit2()`, wait
496
- * for the new allowance to actually be readable via
497
- * `waitForPermit2Allowance()` (the wallet's own RPC can lag a freshly
498
- * mined tx), then retry the SAME sponsored attempt once. Bounded to one
499
- * approval attempt per call so a wallet/agent that keeps reporting the
500
- * allowance as missing can't loop forever. If `approvePermit2()` itself
501
- * throws (e.g. the user rejects the wallet prompt), that error
502
- * propagates as-is — the user said no to a transaction, so we must not
503
- * turn around and ask them to pay for a different one via the fallback
504
- * below.
503
+ * the one-time (user-paid) Permit2 approval via `approvePermit2()` and
504
+ * retry the SAME sponsored attempt once. Bounded to one approval attempt
505
+ * per call so a wallet/agent that keeps reporting the allowance as
506
+ * missing can't loop forever. If `approvePermit2()` itself throws (e.g.
507
+ * the user rejects the wallet prompt), that error propagates as-is —
508
+ * the user said no to a transaction, so we must not turn around and ask
509
+ * them to pay for a different one via the fallback below.
505
510
  * 2. `shouldFallbackToUserPaid`: the SDK's own WETH sponsor path failed at
506
511
  * the infrastructure layer in a provably safe-to-retry way, so we warn
507
512
  * and retry once with `undefined`, falling through to a user-paid
@@ -513,18 +518,6 @@ declare class OwneySDK {
513
518
  * propagates unchanged. Scoped per agent invocation so one agent's failure
514
519
  * doesn't force a retry of sibling agents in a multi-agent split.
515
520
  */
516
- /**
517
- * Polls the owner's Permit2 allowance for `asset` until it covers `amount`
518
- * or the attempt budget runs out. Called right after `approvePermit2()`
519
- * resolves: the approval tx is mined, but the wallet's own RPC can still
520
- * serve a stale (zero) allowance on the very next read (replica lag), which
521
- * would otherwise make the immediate retry fail with the same
522
- * PERMIT2_APPROVAL_REQUIRED error the user just approved past. Never
523
- * throws — if the allowance still hasn't caught up after the budget, the
524
- * caller's retry will surface the honest PERMIT2_APPROVAL_REQUIRED error
525
- * rather than this helper inventing a different one.
526
- */
527
- private waitForPermit2Allowance;
528
521
  private depositWithFallback;
529
522
  private getMinDepositAmount;
530
523
  private splitDepositAmount;
@@ -602,16 +595,14 @@ declare class OwneySDK {
602
595
  */
603
596
  ensureAutoSelectProtocols(asset: "USDC" | "WETH", agentId?: AgentId): Promise<boolean>;
604
597
  /**
605
- * One-time, user-paid approval of Permit2 on the given sponsored token for
606
- * the active chain. Required once per wallet per chain per token before a
607
- * gasless deposit of that asset over Permit2; afterwards deposit() is
608
- * signature-only for it. This call itself is a real transaction the user
609
- * pays gas for. Resolves only after the approval transaction is mined (1
610
- * confirmation), so a subsequent deposit() will see the new allowance;
611
- * throws if the transaction reverted.
598
+ * One-time, user-paid approval of Permit2 on the sponsored WETH token for
599
+ * the active chain. Required once per wallet per chain before gasless WETH
600
+ * deposits; afterwards deposit() is signature-only. Resolves only after the
601
+ * approval transaction is mined (1 confirmation), so a subsequent deposit()
602
+ * will see the new allowance; throws if the transaction reverted.
612
603
  * @returns the approval transaction hash.
613
604
  */
614
- approvePermit2(asset?: "WETH" | "USDC"): Promise<`0x${string}`>;
605
+ approvePermit2(asset?: "WETH"): Promise<`0x${string}`>;
615
606
  /**
616
607
  * Get the agent's average APY performance over a time period. Does not require a wallet connection.
617
608
  * @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")
package/dist/index.d.ts CHANGED
@@ -180,6 +180,21 @@ interface OwneyPosition {
180
180
  * response later; undefined until then. */
181
181
  liquidity?: number;
182
182
  }
183
+ /**
184
+ * Funds that have landed in the agent's wallet but are not yet deployed into a
185
+ * protocol. Sourced from Zyfai `staleBalances[].isPending`. Absent when nothing
186
+ * is pending, and for agents that do not report it (sail).
187
+ */
188
+ interface OwneyPendingAllocation {
189
+ /** Deliberately loose (not OwneySupportedChainId) because Zyfai reports balances on unsupported chains. */
190
+ chainId: number;
191
+ /** Raw agent symbol, not normalized to OwneySupportedTokens; carries Zyfai's casing and "eth" alias for WETH. */
192
+ asset: string;
193
+ /** Decimal string, consistent with `OwneyToken.amount`. */
194
+ amount: string;
195
+ /** ISO timestamp from Zyfai's `updatedAt`, when the payload carries one. */
196
+ since?: string;
197
+ }
183
198
  interface AgentBalance {
184
199
  smartWallet?: `0x${string}`;
185
200
  totalBalance: string;
@@ -191,6 +206,8 @@ interface AgentBalance {
191
206
  * them (zyfai). Omitted for agents that don't expose positions (sail).
192
207
  */
193
208
  positions?: OwneyPosition[];
209
+ /** Funds received but not yet deployed. Omitted when nothing is pending. */
210
+ pendingAllocations?: OwneyPendingAllocation[];
194
211
  }
195
212
  interface OwneyBalances {
196
213
  totalBalance: string;
@@ -392,7 +409,7 @@ declare class OwneySDK {
392
409
  private routingApiBaseUrl?;
393
410
  private referralSource?;
394
411
  private cachedSponsoredCallback;
395
- private cachedPermit2Callbacks;
412
+ private cachedWethSponsoredCallback;
396
413
  private initializingAgentsPromise;
397
414
  constructor(config: OwneySDKConfig);
398
415
  /**
@@ -428,21 +445,12 @@ declare class OwneySDK {
428
445
  */
429
446
  private getDefaultSponsoredCallback;
430
447
  /**
431
- * Lazily builds (and caches) the Permit2 sponsored callback for one asset.
432
- * Used for WETH always, and for USDC when the connected owner is a smart
433
- * account — EIP-3009 verifies with ecrecover inside USDC and cannot accept a
434
- * contract signature, while Permit2 supports ERC-1271.
448
+ * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
449
+ * callback used when the caller omits `depositCallback` for a WETH
450
+ * deposit. Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
451
+ * `PermitTransferFrom` instead of an EIP-3009 authorization.
435
452
  */
436
- private getDefaultPermit2Callback;
437
- /**
438
- * True when the connected owner has bytecode — a deployed smart wallet, or an
439
- * EOA carrying an EIP-7702 delegation (the Base app's "Upgrade your wallet").
440
- * Such wallets sign via ERC-1271, which EIP-3009 cannot verify.
441
- *
442
- * Fails OPEN: an unreadable code check returns false so a working EOA deposit
443
- * is never blocked by a flaky provider.
444
- */
445
- private ownerHasCode;
453
+ private getDefaultWethSponsoredCallback;
446
454
  private getAgent;
447
455
  private getActiveAgents;
448
456
  /**
@@ -492,16 +500,13 @@ declare class OwneySDK {
492
500
  * 1. Missing Permit2 allowance: when the app did not supply its own
493
501
  * callback and the attempt fails with `PERMIT2_APPROVAL_REQUIRED` on a
494
502
  * WETH deposit, this is the wallet's first gasless WETH deposit. We send
495
- * the one-time (user-paid) Permit2 approval via `approvePermit2()`, wait
496
- * for the new allowance to actually be readable via
497
- * `waitForPermit2Allowance()` (the wallet's own RPC can lag a freshly
498
- * mined tx), then retry the SAME sponsored attempt once. Bounded to one
499
- * approval attempt per call so a wallet/agent that keeps reporting the
500
- * allowance as missing can't loop forever. If `approvePermit2()` itself
501
- * throws (e.g. the user rejects the wallet prompt), that error
502
- * propagates as-is — the user said no to a transaction, so we must not
503
- * turn around and ask them to pay for a different one via the fallback
504
- * below.
503
+ * the one-time (user-paid) Permit2 approval via `approvePermit2()` and
504
+ * retry the SAME sponsored attempt once. Bounded to one approval attempt
505
+ * per call so a wallet/agent that keeps reporting the allowance as
506
+ * missing can't loop forever. If `approvePermit2()` itself throws (e.g.
507
+ * the user rejects the wallet prompt), that error propagates as-is —
508
+ * the user said no to a transaction, so we must not turn around and ask
509
+ * them to pay for a different one via the fallback below.
505
510
  * 2. `shouldFallbackToUserPaid`: the SDK's own WETH sponsor path failed at
506
511
  * the infrastructure layer in a provably safe-to-retry way, so we warn
507
512
  * and retry once with `undefined`, falling through to a user-paid
@@ -513,18 +518,6 @@ declare class OwneySDK {
513
518
  * propagates unchanged. Scoped per agent invocation so one agent's failure
514
519
  * doesn't force a retry of sibling agents in a multi-agent split.
515
520
  */
516
- /**
517
- * Polls the owner's Permit2 allowance for `asset` until it covers `amount`
518
- * or the attempt budget runs out. Called right after `approvePermit2()`
519
- * resolves: the approval tx is mined, but the wallet's own RPC can still
520
- * serve a stale (zero) allowance on the very next read (replica lag), which
521
- * would otherwise make the immediate retry fail with the same
522
- * PERMIT2_APPROVAL_REQUIRED error the user just approved past. Never
523
- * throws — if the allowance still hasn't caught up after the budget, the
524
- * caller's retry will surface the honest PERMIT2_APPROVAL_REQUIRED error
525
- * rather than this helper inventing a different one.
526
- */
527
- private waitForPermit2Allowance;
528
521
  private depositWithFallback;
529
522
  private getMinDepositAmount;
530
523
  private splitDepositAmount;
@@ -602,16 +595,14 @@ declare class OwneySDK {
602
595
  */
603
596
  ensureAutoSelectProtocols(asset: "USDC" | "WETH", agentId?: AgentId): Promise<boolean>;
604
597
  /**
605
- * One-time, user-paid approval of Permit2 on the given sponsored token for
606
- * the active chain. Required once per wallet per chain per token before a
607
- * gasless deposit of that asset over Permit2; afterwards deposit() is
608
- * signature-only for it. This call itself is a real transaction the user
609
- * pays gas for. Resolves only after the approval transaction is mined (1
610
- * confirmation), so a subsequent deposit() will see the new allowance;
611
- * throws if the transaction reverted.
598
+ * One-time, user-paid approval of Permit2 on the sponsored WETH token for
599
+ * the active chain. Required once per wallet per chain before gasless WETH
600
+ * deposits; afterwards deposit() is signature-only. Resolves only after the
601
+ * approval transaction is mined (1 confirmation), so a subsequent deposit()
602
+ * will see the new allowance; throws if the transaction reverted.
612
603
  * @returns the approval transaction hash.
613
604
  */
614
- approvePermit2(asset?: "WETH" | "USDC"): Promise<`0x${string}`>;
605
+ approvePermit2(asset?: "WETH"): Promise<`0x${string}`>;
615
606
  /**
616
607
  * Get the agent's average APY performance over a time period. Does not require a wallet connection.
617
608
  * @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")