@owney/sdk 0.7.25-beta.4 → 0.7.25-beta.6

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
@@ -1,12 +1,22 @@
1
1
  import { Hex } from 'viem';
2
2
  import { SIWXConfig } from '@reown/appkit-controllers';
3
3
 
4
- type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
4
+ type RpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
5
+ /** @deprecated Use RpcUrlsConfig. */
6
+ type ZyfaiRpcUrlsConfig = RpcUrlsConfig;
5
7
  interface OwneySDKConfig {
6
8
  apiKey: string;
9
+ /**
10
+ * Optional per-chain RPC overrides used for application-owned reads and
11
+ * transaction receipt polling. Missing chains use Owney SDK defaults.
12
+ * Wallet providers remain responsible for account access, chain switching,
13
+ * signatures, and transaction submission.
14
+ */
15
+ rpcUrls?: RpcUrlsConfig;
7
16
  /**
8
17
  * Optional per-chain RPC overrides for Zyfai SDK network calls.
9
18
  * Example: { 8453: "https://...", 42161: "https://..." }
19
+ * @deprecated Use rpcUrls so every agent shares the same read transport.
10
20
  */
11
21
  zyfaiRpcUrls?: ZyfaiRpcUrlsConfig;
12
22
  /** Optional Owney Yieldseeker proxy base URL override for integration tests. */
@@ -483,6 +493,12 @@ interface IAgent {
483
493
  * withdrawal planning must add matching position amounts.
484
494
  */
485
495
  readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
496
+ /**
497
+ * Whether a withdrawal requires an owner-approved wallet transaction.
498
+ * Aggregate withdrawals run these agents before relayer-only agents so a
499
+ * rejected wallet request cannot happen after another leg has committed.
500
+ */
501
+ readonly withdrawalRequiresWalletApproval?: boolean;
486
502
  disconnect(): Promise<void>;
487
503
  activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
488
504
  /**
@@ -554,6 +570,7 @@ declare class OwneySDK {
554
570
  private apiKey;
555
571
  private orgAgentConfig;
556
572
  private orgAgentConfigPromise;
573
+ private rpcUrls?;
557
574
  private zyfaiRpcUrls?;
558
575
  private yieldseekerApiBaseUrl?;
559
576
  private yieldseekerSiweOrigin?;
@@ -593,6 +610,7 @@ declare class OwneySDK {
593
610
  private requireState;
594
611
  private requireChainId;
595
612
  private requireConnectedProvider;
613
+ private getPaidRpcClient;
596
614
  /** Builds the default USDC batch callback for the connected wallet. */
597
615
  private getDefaultSponsoredCallback;
598
616
  /** Builds the wallet-native sponsored calls callback for compatible paymasters. */
@@ -676,10 +694,12 @@ declare class OwneySDK {
676
694
  * Invokes `agent.deposit` with the resolved sponsored callback, composing
677
695
  * two independent auto-recovery mechanisms:
678
696
  *
679
- * 1. Missing Permit2 allowance: when the app did not supply its own
680
- * callback and the attempt fails with `PERMIT2_APPROVAL_REQUIRED` on a
681
- * token deposit, this is the wallet's first Permit2 deposit for that token. We send
682
- * the one-time (user-paid) Permit2 approval via `approvePermit2()` and
697
+ * 1. Missing Permit2 allowance outside the atomic Base-USDC path: when the
698
+ * app did not supply its own callback and the attempt fails with
699
+ * `PERMIT2_APPROVAL_REQUIRED`, this is the wallet's first Permit2 deposit
700
+ * for that token. Base USDC bundles a gasless ERC-2612 approval inside
701
+ * its sponsored deposit and never reaches this branch. Other tokens send
702
+ * the one-time user-paid Permit2 approval via `approvePermit2()` and
683
703
  * retry the SAME sponsored attempt once. Bounded to one approval attempt
684
704
  * per call so a wallet/agent that keeps reporting the allowance as
685
705
  * missing can't loop forever. If `approvePermit2()` itself throws (e.g.
@@ -711,6 +731,13 @@ declare class OwneySDK {
711
731
  private hasExistingBalance;
712
732
  private validateAssetSupport;
713
733
  private getEligibleAgents;
734
+ /**
735
+ * Run owner-approved withdrawals before relayer-only withdrawals. Wallet
736
+ * approval is the only point at which the user can cancel the aggregate
737
+ * operation, so no relayer leg should commit before it has completed.
738
+ */
739
+ private orderAgentsForWithdrawal;
740
+ private isUserRejectedWithdrawal;
714
741
  /**
715
742
  * Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
716
743
  * Validates that the asset is supported by the target agent(s) on the active chain.
@@ -846,6 +873,8 @@ type YieldseekerAgentOptions = {
846
873
  baseUrl?: string;
847
874
  fetchFn?: YieldseekerFetch;
848
875
  auth?: YieldseekerAuthDependencies;
876
+ /** Dedicated read transport; Base is used for receipt polling. */
877
+ rpcUrls?: RpcUrlsConfig;
849
878
  /** Test seam for the wallet-submission/receipt boundary. */
850
879
  transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
851
880
  /** Test seam for transactions submitted outside transactionExecutor. */
@@ -854,6 +883,7 @@ type YieldseekerAgentOptions = {
854
883
  declare class YieldseekerAgent implements IAgent {
855
884
  readonly id = "yieldseeker";
856
885
  readonly balanceComposition: "tokens-plus-positions";
886
+ readonly withdrawalRequiresWalletApproval = true;
857
887
  readonly supportedChainIds: readonly [8453];
858
888
  readonly supportedAssets: readonly [{
859
889
  readonly chainId: 8453;
@@ -868,14 +898,21 @@ declare class YieldseekerAgent implements IAgent {
868
898
  }];
869
899
  private readonly api;
870
900
  private readonly auth;
901
+ private readonly rpcUrls?;
902
+ private receiptClient?;
871
903
  private readonly transactionExecutor?;
872
904
  private readonly unwindReceiptWaiter?;
873
905
  private readonly agentContexts;
874
906
  private readonly users;
875
907
  private readonly pendingAgents;
908
+ private readonly pendingWalletContexts;
909
+ private readonly readCache;
910
+ private readonly pendingReads;
911
+ private readGeneration;
876
912
  private readonly yieldOptions;
877
913
  private readonly pendingYieldOptions;
878
914
  constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
915
+ private getReceiptClient;
879
916
  disconnect(): Promise<void>;
880
917
  activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
881
918
  deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
@@ -889,6 +926,10 @@ declare class YieldseekerAgent implements IAgent {
889
926
  private loadYieldOptions;
890
927
  private userKey;
891
928
  private contextKey;
929
+ private cachedRead;
930
+ private agentListKey;
931
+ private listAgents;
932
+ private contextForAgent;
892
933
  private resolveUser;
893
934
  private forgetUser;
894
935
  private ensureAgent;
@@ -981,4 +1022,4 @@ type OwneySIWXConfig = {
981
1022
  */
982
1023
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
983
1024
 
984
- export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, 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 AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, 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 RebalanceLog, type WithdrawOptions, YieldseekerAgent, createOwneySIWX, setOwneyDebug };
1025
+ export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, 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 AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, 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 RebalanceLog, type RpcUrlsConfig, type WithdrawOptions, YieldseekerAgent, type ZyfaiRpcUrlsConfig, createOwneySIWX, setOwneyDebug };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,22 @@
1
1
  import { Hex } from 'viem';
2
2
  import { SIWXConfig } from '@reown/appkit-controllers';
3
3
 
4
- type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
4
+ type RpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
5
+ /** @deprecated Use RpcUrlsConfig. */
6
+ type ZyfaiRpcUrlsConfig = RpcUrlsConfig;
5
7
  interface OwneySDKConfig {
6
8
  apiKey: string;
9
+ /**
10
+ * Optional per-chain RPC overrides used for application-owned reads and
11
+ * transaction receipt polling. Missing chains use Owney SDK defaults.
12
+ * Wallet providers remain responsible for account access, chain switching,
13
+ * signatures, and transaction submission.
14
+ */
15
+ rpcUrls?: RpcUrlsConfig;
7
16
  /**
8
17
  * Optional per-chain RPC overrides for Zyfai SDK network calls.
9
18
  * Example: { 8453: "https://...", 42161: "https://..." }
19
+ * @deprecated Use rpcUrls so every agent shares the same read transport.
10
20
  */
11
21
  zyfaiRpcUrls?: ZyfaiRpcUrlsConfig;
12
22
  /** Optional Owney Yieldseeker proxy base URL override for integration tests. */
@@ -483,6 +493,12 @@ interface IAgent {
483
493
  * withdrawal planning must add matching position amounts.
484
494
  */
485
495
  readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
496
+ /**
497
+ * Whether a withdrawal requires an owner-approved wallet transaction.
498
+ * Aggregate withdrawals run these agents before relayer-only agents so a
499
+ * rejected wallet request cannot happen after another leg has committed.
500
+ */
501
+ readonly withdrawalRequiresWalletApproval?: boolean;
486
502
  disconnect(): Promise<void>;
487
503
  activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
488
504
  /**
@@ -554,6 +570,7 @@ declare class OwneySDK {
554
570
  private apiKey;
555
571
  private orgAgentConfig;
556
572
  private orgAgentConfigPromise;
573
+ private rpcUrls?;
557
574
  private zyfaiRpcUrls?;
558
575
  private yieldseekerApiBaseUrl?;
559
576
  private yieldseekerSiweOrigin?;
@@ -593,6 +610,7 @@ declare class OwneySDK {
593
610
  private requireState;
594
611
  private requireChainId;
595
612
  private requireConnectedProvider;
613
+ private getPaidRpcClient;
596
614
  /** Builds the default USDC batch callback for the connected wallet. */
597
615
  private getDefaultSponsoredCallback;
598
616
  /** Builds the wallet-native sponsored calls callback for compatible paymasters. */
@@ -676,10 +694,12 @@ declare class OwneySDK {
676
694
  * Invokes `agent.deposit` with the resolved sponsored callback, composing
677
695
  * two independent auto-recovery mechanisms:
678
696
  *
679
- * 1. Missing Permit2 allowance: when the app did not supply its own
680
- * callback and the attempt fails with `PERMIT2_APPROVAL_REQUIRED` on a
681
- * token deposit, this is the wallet's first Permit2 deposit for that token. We send
682
- * the one-time (user-paid) Permit2 approval via `approvePermit2()` and
697
+ * 1. Missing Permit2 allowance outside the atomic Base-USDC path: when the
698
+ * app did not supply its own callback and the attempt fails with
699
+ * `PERMIT2_APPROVAL_REQUIRED`, this is the wallet's first Permit2 deposit
700
+ * for that token. Base USDC bundles a gasless ERC-2612 approval inside
701
+ * its sponsored deposit and never reaches this branch. Other tokens send
702
+ * the one-time user-paid Permit2 approval via `approvePermit2()` and
683
703
  * retry the SAME sponsored attempt once. Bounded to one approval attempt
684
704
  * per call so a wallet/agent that keeps reporting the allowance as
685
705
  * missing can't loop forever. If `approvePermit2()` itself throws (e.g.
@@ -711,6 +731,13 @@ declare class OwneySDK {
711
731
  private hasExistingBalance;
712
732
  private validateAssetSupport;
713
733
  private getEligibleAgents;
734
+ /**
735
+ * Run owner-approved withdrawals before relayer-only withdrawals. Wallet
736
+ * approval is the only point at which the user can cancel the aggregate
737
+ * operation, so no relayer leg should commit before it has completed.
738
+ */
739
+ private orderAgentsForWithdrawal;
740
+ private isUserRejectedWithdrawal;
714
741
  /**
715
742
  * Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
716
743
  * Validates that the asset is supported by the target agent(s) on the active chain.
@@ -846,6 +873,8 @@ type YieldseekerAgentOptions = {
846
873
  baseUrl?: string;
847
874
  fetchFn?: YieldseekerFetch;
848
875
  auth?: YieldseekerAuthDependencies;
876
+ /** Dedicated read transport; Base is used for receipt polling. */
877
+ rpcUrls?: RpcUrlsConfig;
849
878
  /** Test seam for the wallet-submission/receipt boundary. */
850
879
  transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
851
880
  /** Test seam for transactions submitted outside transactionExecutor. */
@@ -854,6 +883,7 @@ type YieldseekerAgentOptions = {
854
883
  declare class YieldseekerAgent implements IAgent {
855
884
  readonly id = "yieldseeker";
856
885
  readonly balanceComposition: "tokens-plus-positions";
886
+ readonly withdrawalRequiresWalletApproval = true;
857
887
  readonly supportedChainIds: readonly [8453];
858
888
  readonly supportedAssets: readonly [{
859
889
  readonly chainId: 8453;
@@ -868,14 +898,21 @@ declare class YieldseekerAgent implements IAgent {
868
898
  }];
869
899
  private readonly api;
870
900
  private readonly auth;
901
+ private readonly rpcUrls?;
902
+ private receiptClient?;
871
903
  private readonly transactionExecutor?;
872
904
  private readonly unwindReceiptWaiter?;
873
905
  private readonly agentContexts;
874
906
  private readonly users;
875
907
  private readonly pendingAgents;
908
+ private readonly pendingWalletContexts;
909
+ private readonly readCache;
910
+ private readonly pendingReads;
911
+ private readGeneration;
876
912
  private readonly yieldOptions;
877
913
  private readonly pendingYieldOptions;
878
914
  constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
915
+ private getReceiptClient;
879
916
  disconnect(): Promise<void>;
880
917
  activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
881
918
  deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
@@ -889,6 +926,10 @@ declare class YieldseekerAgent implements IAgent {
889
926
  private loadYieldOptions;
890
927
  private userKey;
891
928
  private contextKey;
929
+ private cachedRead;
930
+ private agentListKey;
931
+ private listAgents;
932
+ private contextForAgent;
892
933
  private resolveUser;
893
934
  private forgetUser;
894
935
  private ensureAgent;
@@ -981,4 +1022,4 @@ type OwneySIWXConfig = {
981
1022
  */
982
1023
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
983
1024
 
984
- export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, 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 AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, 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 RebalanceLog, type WithdrawOptions, YieldseekerAgent, createOwneySIWX, setOwneyDebug };
1025
+ export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, 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 AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, 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 RebalanceLog, type RpcUrlsConfig, type WithdrawOptions, YieldseekerAgent, type ZyfaiRpcUrlsConfig, createOwneySIWX, setOwneyDebug };