@owney/sdk 0.7.16-beta.5 → 0.7.16-beta.7

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,4 +1,3 @@
1
- import { Hex } from 'viem';
2
1
  import { SIWXConfig } from '@reown/appkit-controllers';
3
2
 
4
3
  type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
@@ -9,8 +8,6 @@ interface OwneySDKConfig {
9
8
  * Example: { 8453: "https://...", 42161: "https://..." }
10
9
  */
11
10
  zyfaiRpcUrls?: ZyfaiRpcUrlsConfig;
12
- /** Optional Owney Yieldseeker proxy base URL override for integration tests. */
13
- yieldseekerApiBaseUrl?: string;
14
11
  /**
15
12
  * Optional override for the Owney routing API base URL used by all routing
16
13
  * calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
@@ -24,6 +21,16 @@ interface OwneySDKConfig {
24
21
  * for apps that don't use the AppKit SIWX modal.
25
22
  */
26
23
  referralSource?: string;
24
+ /**
25
+ * Optional override for the SurfLiquid API base URL (defaults to the
26
+ * SurfLiquid SDK's production URL). SurfLiquid auth is an httpOnly
27
+ * SameSite=None cookie set by api.surfliquid.com — a THIRD-PARTY cookie from
28
+ * the embedding app's origin, which WebKit (all iOS browsers) discards, so
29
+ * every authenticated SurfLiquid call 401s on iOS. Point this at a
30
+ * same-origin reverse proxy (e.g. "/api/surf") so the session cookie becomes
31
+ * first-party. Relative paths resolve against the page origin.
32
+ */
33
+ surfliquidApiBaseUrl?: string;
27
34
  /**
28
35
  * Turn on the SDK's debug logging (default false). Traces the decisions that
29
36
  * are otherwise invisible — notably how the organization's agent policy is
@@ -57,7 +64,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
57
64
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
58
65
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
59
66
 
60
- type AgentId = "zyfai" | "yieldseeker";
67
+ type AgentId = "zyfai" | "surfliquid";
61
68
  type Asset = string;
62
69
  type AgentSupportedAsset = {
63
70
  readonly symbol: string;
@@ -68,18 +75,6 @@ type AgentSupportedAssets = {
68
75
  readonly chain?: string;
69
76
  readonly assets: readonly AgentSupportedAsset[];
70
77
  };
71
- type AvailableAgent = {
72
- id: AgentId;
73
- isEnabled: boolean;
74
- supportedChainIds: readonly number[];
75
- supportedAssets: readonly AgentSupportedAssets[];
76
- };
77
- type AvailableAgentsOptions = {
78
- chainId?: number;
79
- asset?: Asset;
80
- /** Disabled agents are omitted by default because they cannot accept funds. */
81
- includeDisabled?: boolean;
82
- };
83
78
  type DailyApyDays = "7D" | "14D" | "30D";
84
79
  type HistoryFilters = {
85
80
  fromDate?: string;
@@ -185,6 +180,12 @@ interface OwneyDepositResult {
185
180
  }
186
181
  interface OwneyMultiDepositResult {
187
182
  agentResults: Record<string, OwneyDepositResult>;
183
+ /**
184
+ * Per-agent failure messages for agents that errored during a diversified
185
+ * deposit. Present only when at least one (but not all) agents failed —
186
+ * the deposit is partial, not total. Omitted when every agent succeeded.
187
+ */
188
+ agentErrors?: Record<string, string>;
188
189
  }
189
190
  interface AgentWithdrawResult {
190
191
  txHash?: string;
@@ -209,8 +210,6 @@ interface OwneyPosition {
209
210
  pool?: string;
210
211
  asset: string;
211
212
  amount: string;
212
- /** Smallest-unit amount when the provider exposes it alongside `amount`. */
213
- amountRaw?: string;
214
213
  apy?: number;
215
214
  tvl?: number;
216
215
  /** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
@@ -245,13 +244,6 @@ interface AgentBalance {
245
244
  totalBalance: string;
246
245
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
247
246
  totalBalanceAsset: string;
248
- /**
249
- * Describes whether `tokens` already includes deployed `positions`.
250
- * Consumers must add matching positions only for `tokens-plus-positions`;
251
- * doing so for Zyfai would double-count, while omitting it for Yieldseeker
252
- * makes its balance disappear as soon as idle funds enter a vault.
253
- */
254
- balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
255
247
  tokens: OwneyToken[];
256
248
  /**
257
249
  * Per-protocol/pool positions when the agent's portfolio payload includes
@@ -266,12 +258,6 @@ interface OwneyBalances {
266
258
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
267
259
  totalBalanceAsset: string;
268
260
  agentBalances: Record<AgentId, AgentBalance>;
269
- /**
270
- * Per-agent read failures when an aggregate balance request returned only a
271
- * partial result. Callers may display the successful balances, but funding
272
- * operations must not interpret a missing agent as having a zero balance.
273
- */
274
- agentErrors?: Partial<Record<AgentId, string>>;
275
261
  }
276
262
  interface AgentEarnings {
277
263
  smartWallet: `0x${string}`;
@@ -305,12 +291,6 @@ interface OwneyAccountApy {
305
291
  totalApy: string;
306
292
  agentApy: Record<AgentId, AccountAgentApy>;
307
293
  apyByChainAndAsset: ApyByChainAndAsset;
308
- /**
309
- * Balance-weighted daily APY across the agents that returned a point for each
310
- * date. The weights use the selected chain/asset balance when getAccountApy
311
- * is asset-scoped, otherwise each agent's total balance.
312
- */
313
- history?: ApyHistoryPoint[];
314
294
  }
315
295
  interface AllocationAgentApy {
316
296
  /** Account-wide weighted APY for this agent, as a decimal string. */
@@ -409,15 +389,8 @@ interface IAgent {
409
389
  readonly id: string;
410
390
  readonly supportedChainIds: readonly OwneySupportedChainId[];
411
391
  readonly supportedAssets: readonly AgentSupportedAssets[];
412
- /**
413
- * Describes how `AgentBalance.tokens` relates to `positions`.
414
- * Most adapters expose token totals that already include deployed positions.
415
- * Providers such as Yieldseeker expose idle wallet tokens separately, so
416
- * withdrawal planning must add matching position amounts.
417
- */
418
- readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
419
392
  disconnect(): Promise<void>;
420
- activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
393
+ activateAgent(state: ConnectionState, chainId: number): Promise<void>;
421
394
  /**
422
395
  * Apply the organization's agent policy to this user's account.
423
396
  *
@@ -482,9 +455,9 @@ declare class OwneySDK {
482
455
  private orgAgentConfig;
483
456
  private orgAgentConfigPromise;
484
457
  private zyfaiRpcUrls?;
485
- private yieldseekerApiBaseUrl?;
486
458
  private routingApiBaseUrl?;
487
459
  private referralSource?;
460
+ private surfliquidApiBaseUrl?;
488
461
  private cachedSponsoredCallback;
489
462
  private cachedWethSponsoredCallback;
490
463
  private paymasterServiceUrl?;
@@ -555,11 +528,6 @@ declare class OwneySDK {
555
528
  private applyOrgPolicyTo;
556
529
  private ensureAgentsInitialized;
557
530
  private createAgent;
558
- /**
559
- * Discover the agents actually returned by routing for this organization.
560
- * Consumers should use this instead of hardcoding a global agent roster.
561
- */
562
- getAvailableAgents(options?: AvailableAgentsOptions): Promise<AvailableAgent[]>;
563
531
  /**
564
532
  * Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted.
565
533
  * Deploys the Safe contract and creates a session key if not already set up.
@@ -570,7 +538,7 @@ declare class OwneySDK {
570
538
  * If provided, ALL specified agents must support the chainId or the call
571
539
  * throws before activating any agent.
572
540
  */
573
- activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
541
+ activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
574
542
  /**
575
543
  * Activate agents ONE AT A TIME, each followed by its org policy.
576
544
  *
@@ -585,13 +553,13 @@ declare class OwneySDK {
585
553
  * at a time anyway.
586
554
  *
587
555
  * Every agent is attempted even if an earlier one fails, so one declined
588
- * signature can't deny the remaining agents their turn. Once all agents have
589
- * had a chance, a partial failure identifies the agents that still need a
590
- * retry; if none activated, the original provider error is preserved.
556
+ * signature can't deny the remaining agents their turn. The first failure is
557
+ * rethrown (matching the previous `Promise.all` rejection) once all agents
558
+ * have had a chance to activate.
591
559
  */
592
560
  private activateAgentsInTurn;
593
561
  /**
594
- * Deposit funds into a specific agent, or distribute across all agents if agentId is omitted.
562
+ * Deposit funds into a specific agent, or split equally across all agents if agentId is omitted.
595
563
  * Validates that the asset is supported and amount meets minimums for the target agent(s).
596
564
  * @param options - Deposit parameters
597
565
  * @param options.amount - Amount to deposit in smallest unit (e.g. "100000000" for 100 USDC)
@@ -599,8 +567,7 @@ declare class OwneySDK {
599
567
  * @param options.depositCallback - Callback that performs the token transfer and returns a tx hash.
600
568
  * When agentId is omitted, this callback is invoked once per eligible agent with that agent's
601
569
  * split amount and smart wallet address — expect multiple wallet prompts.
602
- * @param options.agentId - Optional. Target agent. Omit to fund all eligible agents. Deposits
603
- * are equal once every agent is funded; first/recovery deposits also honor each agent's floor.
570
+ * @param options.agentId - Optional. Target agent. Omit to split equally across all agents.
604
571
  * @returns {OwneyDepositResult} for a single agent, or {OwneyMultiDepositResult} with per-agent results
605
572
  */
606
573
  deposit(options: DepositOptions): Promise<OwneyDepositResult | OwneyMultiDepositResult>;
@@ -632,7 +599,6 @@ declare class OwneySDK {
632
599
  private depositWithFallback;
633
600
  private getMinDepositAmount;
634
601
  private splitDepositAmount;
635
- private formatAgentName;
636
602
  private validateMinDepositAmount;
637
603
  /**
638
604
  * Whether the user already holds a non-zero balance with `agent` for the
@@ -643,6 +609,17 @@ declare class OwneySDK {
643
609
  private hasExistingBalance;
644
610
  private validateAssetSupport;
645
611
  private getEligibleAgents;
612
+ /**
613
+ * Agent ids the routing API provisioned for this org that support the given
614
+ * chain + asset, ordered by preference ({@link AGENT_ELIGIBILITY_ORDER},
615
+ * surfliquid first). Returns `[]` when the org has no compatible agent — never
616
+ * throws on an empty org. Loads agent keys on first call (apiKey only, no
617
+ * wallet), so the UI can resolve which agent to use before the user connects.
618
+ *
619
+ * This is the source of truth for agent availability: an agent appears here
620
+ * iff the routing API returned its key. No per-app feature flags.
621
+ */
622
+ getEligibleAgentIds(chainId: number, asset: string): Promise<AgentId[]>;
646
623
  /**
647
624
  * Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
648
625
  * Validates that the asset is supported by the target agent(s) on the active chain.
@@ -743,92 +720,7 @@ declare class OwneySDK {
743
720
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
744
721
  }
745
722
 
746
- type YieldseekerAuthDependencies = {
747
- now?: () => Date;
748
- nonce?: () => string;
749
- };
750
-
751
- type YieldseekerFetch = typeof fetch;
752
-
753
- type YieldseekerTransaction = {
754
- from: `0x${string}`;
755
- to: `0x${string}`;
756
- data: `0x${string}`;
757
- value: string;
758
- chainId: number;
759
- };
760
-
761
- type YieldseekerAgentOptions = {
762
- baseUrl?: string;
763
- fetchFn?: YieldseekerFetch;
764
- auth?: YieldseekerAuthDependencies;
765
- /** Test seam for the wallet-submission/receipt boundary. */
766
- transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
767
- /** Test seam for transactions submitted outside transactionExecutor. */
768
- unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
769
- };
770
- declare class YieldseekerAgent implements IAgent {
771
- readonly id = "yieldseeker";
772
- readonly balanceComposition: "tokens-plus-positions";
773
- readonly supportedChainIds: readonly [8453];
774
- readonly supportedAssets: readonly [{
775
- readonly chainId: 8453;
776
- readonly chain: "BASE";
777
- readonly assets: readonly [{
778
- readonly symbol: "USDC";
779
- readonly minDepositAmount: "10000000";
780
- }, {
781
- readonly symbol: "WETH";
782
- readonly minDepositAmount: "1";
783
- }];
784
- }];
785
- private readonly api;
786
- private readonly auth;
787
- private readonly transactionExecutor?;
788
- private readonly unwindReceiptWaiter?;
789
- private readonly agentContexts;
790
- private readonly users;
791
- private readonly pendingAgents;
792
- constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
793
- disconnect(): Promise<void>;
794
- activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
795
- deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
796
- withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
797
- getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
798
- getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
799
- getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
800
- getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
801
- getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
802
- getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
803
- private userKey;
804
- private contextKey;
805
- private resolveUser;
806
- private forgetUser;
807
- private ensureAgent;
808
- private findAgent;
809
- private resolveAgent;
810
- private loadPortfolio;
811
- private loadPortfolioContext;
812
- private deployAfterFunding;
813
- private refreshSnapshotAfterMovement;
814
- private agentPath;
815
- private walletRequest;
816
- private providerRequest;
817
- private mapApiError;
818
- private submitTransaction;
819
- private waitForReceipt;
820
- private assertTransaction;
821
- private assertAgent;
822
- private isOwneyAgent;
823
- private assetForAgent;
824
- private isTransactionHash;
825
- private assertChain;
826
- private assertOptionalChain;
827
- private assertAsset;
828
- private invalidResponse;
829
- }
830
-
831
- type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "AGENT_ACTIVATION_PARTIAL_FAILURE" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_BALANCE_UNAVAILABLE" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "AGENT_API_ERROR" | "AGENT_AUTH_FAILED" | "AGENT_INVALID_RESPONSE" | "AGENT_TIMEOUT" | "AGENT_TRANSACTION_REVERTED" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
723
+ type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_ALL_FAILED" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
832
724
  declare class OwneyError extends Error {
833
725
  readonly code: OwneyErrorCode;
834
726
  readonly details?: Record<string, unknown>;
@@ -894,4 +786,4 @@ type OwneySIWXConfig = {
894
786
  */
895
787
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
896
788
 
897
- export { type AccountAgentApy, type AccountApyOptions, 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 AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, 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 };
789
+ export { type AccountAgentApy, type AccountApyOptions, 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 ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, 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, createOwneySIWX, setOwneyDebug };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { Hex } from 'viem';
2
1
  import { SIWXConfig } from '@reown/appkit-controllers';
3
2
 
4
3
  type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
@@ -9,8 +8,6 @@ interface OwneySDKConfig {
9
8
  * Example: { 8453: "https://...", 42161: "https://..." }
10
9
  */
11
10
  zyfaiRpcUrls?: ZyfaiRpcUrlsConfig;
12
- /** Optional Owney Yieldseeker proxy base URL override for integration tests. */
13
- yieldseekerApiBaseUrl?: string;
14
11
  /**
15
12
  * Optional override for the Owney routing API base URL used by all routing
16
13
  * calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
@@ -24,6 +21,16 @@ interface OwneySDKConfig {
24
21
  * for apps that don't use the AppKit SIWX modal.
25
22
  */
26
23
  referralSource?: string;
24
+ /**
25
+ * Optional override for the SurfLiquid API base URL (defaults to the
26
+ * SurfLiquid SDK's production URL). SurfLiquid auth is an httpOnly
27
+ * SameSite=None cookie set by api.surfliquid.com — a THIRD-PARTY cookie from
28
+ * the embedding app's origin, which WebKit (all iOS browsers) discards, so
29
+ * every authenticated SurfLiquid call 401s on iOS. Point this at a
30
+ * same-origin reverse proxy (e.g. "/api/surf") so the session cookie becomes
31
+ * first-party. Relative paths resolve against the page origin.
32
+ */
33
+ surfliquidApiBaseUrl?: string;
27
34
  /**
28
35
  * Turn on the SDK's debug logging (default false). Traces the decisions that
29
36
  * are otherwise invisible — notably how the organization's agent policy is
@@ -57,7 +64,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
57
64
  type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
58
65
  type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
59
66
 
60
- type AgentId = "zyfai" | "yieldseeker";
67
+ type AgentId = "zyfai" | "surfliquid";
61
68
  type Asset = string;
62
69
  type AgentSupportedAsset = {
63
70
  readonly symbol: string;
@@ -68,18 +75,6 @@ type AgentSupportedAssets = {
68
75
  readonly chain?: string;
69
76
  readonly assets: readonly AgentSupportedAsset[];
70
77
  };
71
- type AvailableAgent = {
72
- id: AgentId;
73
- isEnabled: boolean;
74
- supportedChainIds: readonly number[];
75
- supportedAssets: readonly AgentSupportedAssets[];
76
- };
77
- type AvailableAgentsOptions = {
78
- chainId?: number;
79
- asset?: Asset;
80
- /** Disabled agents are omitted by default because they cannot accept funds. */
81
- includeDisabled?: boolean;
82
- };
83
78
  type DailyApyDays = "7D" | "14D" | "30D";
84
79
  type HistoryFilters = {
85
80
  fromDate?: string;
@@ -185,6 +180,12 @@ interface OwneyDepositResult {
185
180
  }
186
181
  interface OwneyMultiDepositResult {
187
182
  agentResults: Record<string, OwneyDepositResult>;
183
+ /**
184
+ * Per-agent failure messages for agents that errored during a diversified
185
+ * deposit. Present only when at least one (but not all) agents failed —
186
+ * the deposit is partial, not total. Omitted when every agent succeeded.
187
+ */
188
+ agentErrors?: Record<string, string>;
188
189
  }
189
190
  interface AgentWithdrawResult {
190
191
  txHash?: string;
@@ -209,8 +210,6 @@ interface OwneyPosition {
209
210
  pool?: string;
210
211
  asset: string;
211
212
  amount: string;
212
- /** Smallest-unit amount when the provider exposes it alongside `amount`. */
213
- amountRaw?: string;
214
213
  apy?: number;
215
214
  tvl?: number;
216
215
  /** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
@@ -245,13 +244,6 @@ interface AgentBalance {
245
244
  totalBalance: string;
246
245
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
247
246
  totalBalanceAsset: string;
248
- /**
249
- * Describes whether `tokens` already includes deployed `positions`.
250
- * Consumers must add matching positions only for `tokens-plus-positions`;
251
- * doing so for Zyfai would double-count, while omitting it for Yieldseeker
252
- * makes its balance disappear as soon as idle funds enter a vault.
253
- */
254
- balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
255
247
  tokens: OwneyToken[];
256
248
  /**
257
249
  * Per-protocol/pool positions when the agent's portfolio payload includes
@@ -266,12 +258,6 @@ interface OwneyBalances {
266
258
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
267
259
  totalBalanceAsset: string;
268
260
  agentBalances: Record<AgentId, AgentBalance>;
269
- /**
270
- * Per-agent read failures when an aggregate balance request returned only a
271
- * partial result. Callers may display the successful balances, but funding
272
- * operations must not interpret a missing agent as having a zero balance.
273
- */
274
- agentErrors?: Partial<Record<AgentId, string>>;
275
261
  }
276
262
  interface AgentEarnings {
277
263
  smartWallet: `0x${string}`;
@@ -305,12 +291,6 @@ interface OwneyAccountApy {
305
291
  totalApy: string;
306
292
  agentApy: Record<AgentId, AccountAgentApy>;
307
293
  apyByChainAndAsset: ApyByChainAndAsset;
308
- /**
309
- * Balance-weighted daily APY across the agents that returned a point for each
310
- * date. The weights use the selected chain/asset balance when getAccountApy
311
- * is asset-scoped, otherwise each agent's total balance.
312
- */
313
- history?: ApyHistoryPoint[];
314
294
  }
315
295
  interface AllocationAgentApy {
316
296
  /** Account-wide weighted APY for this agent, as a decimal string. */
@@ -409,15 +389,8 @@ interface IAgent {
409
389
  readonly id: string;
410
390
  readonly supportedChainIds: readonly OwneySupportedChainId[];
411
391
  readonly supportedAssets: readonly AgentSupportedAssets[];
412
- /**
413
- * Describes how `AgentBalance.tokens` relates to `positions`.
414
- * Most adapters expose token totals that already include deployed positions.
415
- * Providers such as Yieldseeker expose idle wallet tokens separately, so
416
- * withdrawal planning must add matching position amounts.
417
- */
418
- readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
419
392
  disconnect(): Promise<void>;
420
- activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
393
+ activateAgent(state: ConnectionState, chainId: number): Promise<void>;
421
394
  /**
422
395
  * Apply the organization's agent policy to this user's account.
423
396
  *
@@ -482,9 +455,9 @@ declare class OwneySDK {
482
455
  private orgAgentConfig;
483
456
  private orgAgentConfigPromise;
484
457
  private zyfaiRpcUrls?;
485
- private yieldseekerApiBaseUrl?;
486
458
  private routingApiBaseUrl?;
487
459
  private referralSource?;
460
+ private surfliquidApiBaseUrl?;
488
461
  private cachedSponsoredCallback;
489
462
  private cachedWethSponsoredCallback;
490
463
  private paymasterServiceUrl?;
@@ -555,11 +528,6 @@ declare class OwneySDK {
555
528
  private applyOrgPolicyTo;
556
529
  private ensureAgentsInitialized;
557
530
  private createAgent;
558
- /**
559
- * Discover the agents actually returned by routing for this organization.
560
- * Consumers should use this instead of hardcoding a global agent roster.
561
- */
562
- getAvailableAgents(options?: AvailableAgentsOptions): Promise<AvailableAgent[]>;
563
531
  /**
564
532
  * Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted.
565
533
  * Deploys the Safe contract and creates a session key if not already set up.
@@ -570,7 +538,7 @@ declare class OwneySDK {
570
538
  * If provided, ALL specified agents must support the chainId or the call
571
539
  * throws before activating any agent.
572
540
  */
573
- activateAgent(chainId: number, agentId?: AgentId[], asset?: OwneySupportedTokens): Promise<void>;
541
+ activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
574
542
  /**
575
543
  * Activate agents ONE AT A TIME, each followed by its org policy.
576
544
  *
@@ -585,13 +553,13 @@ declare class OwneySDK {
585
553
  * at a time anyway.
586
554
  *
587
555
  * Every agent is attempted even if an earlier one fails, so one declined
588
- * signature can't deny the remaining agents their turn. Once all agents have
589
- * had a chance, a partial failure identifies the agents that still need a
590
- * retry; if none activated, the original provider error is preserved.
556
+ * signature can't deny the remaining agents their turn. The first failure is
557
+ * rethrown (matching the previous `Promise.all` rejection) once all agents
558
+ * have had a chance to activate.
591
559
  */
592
560
  private activateAgentsInTurn;
593
561
  /**
594
- * Deposit funds into a specific agent, or distribute across all agents if agentId is omitted.
562
+ * Deposit funds into a specific agent, or split equally across all agents if agentId is omitted.
595
563
  * Validates that the asset is supported and amount meets minimums for the target agent(s).
596
564
  * @param options - Deposit parameters
597
565
  * @param options.amount - Amount to deposit in smallest unit (e.g. "100000000" for 100 USDC)
@@ -599,8 +567,7 @@ declare class OwneySDK {
599
567
  * @param options.depositCallback - Callback that performs the token transfer and returns a tx hash.
600
568
  * When agentId is omitted, this callback is invoked once per eligible agent with that agent's
601
569
  * split amount and smart wallet address — expect multiple wallet prompts.
602
- * @param options.agentId - Optional. Target agent. Omit to fund all eligible agents. Deposits
603
- * are equal once every agent is funded; first/recovery deposits also honor each agent's floor.
570
+ * @param options.agentId - Optional. Target agent. Omit to split equally across all agents.
604
571
  * @returns {OwneyDepositResult} for a single agent, or {OwneyMultiDepositResult} with per-agent results
605
572
  */
606
573
  deposit(options: DepositOptions): Promise<OwneyDepositResult | OwneyMultiDepositResult>;
@@ -632,7 +599,6 @@ declare class OwneySDK {
632
599
  private depositWithFallback;
633
600
  private getMinDepositAmount;
634
601
  private splitDepositAmount;
635
- private formatAgentName;
636
602
  private validateMinDepositAmount;
637
603
  /**
638
604
  * Whether the user already holds a non-zero balance with `agent` for the
@@ -643,6 +609,17 @@ declare class OwneySDK {
643
609
  private hasExistingBalance;
644
610
  private validateAssetSupport;
645
611
  private getEligibleAgents;
612
+ /**
613
+ * Agent ids the routing API provisioned for this org that support the given
614
+ * chain + asset, ordered by preference ({@link AGENT_ELIGIBILITY_ORDER},
615
+ * surfliquid first). Returns `[]` when the org has no compatible agent — never
616
+ * throws on an empty org. Loads agent keys on first call (apiKey only, no
617
+ * wallet), so the UI can resolve which agent to use before the user connects.
618
+ *
619
+ * This is the source of truth for agent availability: an agent appears here
620
+ * iff the routing API returned its key. No per-app feature flags.
621
+ */
622
+ getEligibleAgentIds(chainId: number, asset: string): Promise<AgentId[]>;
646
623
  /**
647
624
  * Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
648
625
  * Validates that the asset is supported by the target agent(s) on the active chain.
@@ -743,92 +720,7 @@ declare class OwneySDK {
743
720
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
744
721
  }
745
722
 
746
- type YieldseekerAuthDependencies = {
747
- now?: () => Date;
748
- nonce?: () => string;
749
- };
750
-
751
- type YieldseekerFetch = typeof fetch;
752
-
753
- type YieldseekerTransaction = {
754
- from: `0x${string}`;
755
- to: `0x${string}`;
756
- data: `0x${string}`;
757
- value: string;
758
- chainId: number;
759
- };
760
-
761
- type YieldseekerAgentOptions = {
762
- baseUrl?: string;
763
- fetchFn?: YieldseekerFetch;
764
- auth?: YieldseekerAuthDependencies;
765
- /** Test seam for the wallet-submission/receipt boundary. */
766
- transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
767
- /** Test seam for transactions submitted outside transactionExecutor. */
768
- unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
769
- };
770
- declare class YieldseekerAgent implements IAgent {
771
- readonly id = "yieldseeker";
772
- readonly balanceComposition: "tokens-plus-positions";
773
- readonly supportedChainIds: readonly [8453];
774
- readonly supportedAssets: readonly [{
775
- readonly chainId: 8453;
776
- readonly chain: "BASE";
777
- readonly assets: readonly [{
778
- readonly symbol: "USDC";
779
- readonly minDepositAmount: "10000000";
780
- }, {
781
- readonly symbol: "WETH";
782
- readonly minDepositAmount: "1";
783
- }];
784
- }];
785
- private readonly api;
786
- private readonly auth;
787
- private readonly transactionExecutor?;
788
- private readonly unwindReceiptWaiter?;
789
- private readonly agentContexts;
790
- private readonly users;
791
- private readonly pendingAgents;
792
- constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
793
- disconnect(): Promise<void>;
794
- activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
795
- deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
796
- withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
797
- getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
798
- getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
799
- getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
800
- getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
801
- getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
802
- getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
803
- private userKey;
804
- private contextKey;
805
- private resolveUser;
806
- private forgetUser;
807
- private ensureAgent;
808
- private findAgent;
809
- private resolveAgent;
810
- private loadPortfolio;
811
- private loadPortfolioContext;
812
- private deployAfterFunding;
813
- private refreshSnapshotAfterMovement;
814
- private agentPath;
815
- private walletRequest;
816
- private providerRequest;
817
- private mapApiError;
818
- private submitTransaction;
819
- private waitForReceipt;
820
- private assertTransaction;
821
- private assertAgent;
822
- private isOwneyAgent;
823
- private assetForAgent;
824
- private isTransactionHash;
825
- private assertChain;
826
- private assertOptionalChain;
827
- private assertAsset;
828
- private invalidResponse;
829
- }
830
-
831
- type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "AGENT_ACTIVATION_PARTIAL_FAILURE" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_BALANCE_UNAVAILABLE" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "AGENT_API_ERROR" | "AGENT_AUTH_FAILED" | "AGENT_INVALID_RESPONSE" | "AGENT_TIMEOUT" | "AGENT_TRANSACTION_REVERTED" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
723
+ type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_ALL_FAILED" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
832
724
  declare class OwneyError extends Error {
833
725
  readonly code: OwneyErrorCode;
834
726
  readonly details?: Record<string, unknown>;
@@ -894,4 +786,4 @@ type OwneySIWXConfig = {
894
786
  */
895
787
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
896
788
 
897
- export { type AccountAgentApy, type AccountApyOptions, 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 AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, 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 };
789
+ export { type AccountAgentApy, type AccountApyOptions, 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 ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, 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, createOwneySIWX, setOwneyDebug };