@owney/sdk 0.7.16-beta.4 → 0.7.16-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/README.md +0 -2
- package/dist/chunk-5LU2SHO7.js +50 -0
- package/dist/chunk-DBRXNDSB.js +87 -0
- package/dist/chunk-GMNQBWUB.js +55 -0
- package/dist/chunk-QA7JUSDB.js +92 -0
- package/dist/chunk-V2LNMTE6.js +222 -0
- package/dist/chunk-VHQ4VXY7.js +39 -0
- package/dist/index.cjs +3350 -3881
- package/dist/index.d.cts +33 -132
- package/dist/index.d.ts +33 -132
- package/dist/index.js +647 -2428
- package/dist/routing-api-KAILDWMD.js +11 -0
- package/dist/surfliquid.agent-5CWKYMRL.js +532 -0
- package/dist/surfliquid.smart-account-L3AWN52C.js +125 -0
- package/dist/surfliquid.sponsorship-BFAL2O3B.js +14 -0
- package/package.json +5 -2
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" | "
|
|
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
|
|
@@ -259,12 +258,6 @@ interface OwneyBalances {
|
|
|
259
258
|
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
260
259
|
totalBalanceAsset: string;
|
|
261
260
|
agentBalances: Record<AgentId, AgentBalance>;
|
|
262
|
-
/**
|
|
263
|
-
* Per-agent read failures when an aggregate balance request returned only a
|
|
264
|
-
* partial result. Callers may display the successful balances, but funding
|
|
265
|
-
* operations must not interpret a missing agent as having a zero balance.
|
|
266
|
-
*/
|
|
267
|
-
agentErrors?: Partial<Record<AgentId, string>>;
|
|
268
261
|
}
|
|
269
262
|
interface AgentEarnings {
|
|
270
263
|
smartWallet: `0x${string}`;
|
|
@@ -298,12 +291,6 @@ interface OwneyAccountApy {
|
|
|
298
291
|
totalApy: string;
|
|
299
292
|
agentApy: Record<AgentId, AccountAgentApy>;
|
|
300
293
|
apyByChainAndAsset: ApyByChainAndAsset;
|
|
301
|
-
/**
|
|
302
|
-
* Balance-weighted daily APY across the agents that returned a point for each
|
|
303
|
-
* date. The weights use the selected chain/asset balance when getAccountApy
|
|
304
|
-
* is asset-scoped, otherwise each agent's total balance.
|
|
305
|
-
*/
|
|
306
|
-
history?: ApyHistoryPoint[];
|
|
307
294
|
}
|
|
308
295
|
interface AllocationAgentApy {
|
|
309
296
|
/** Account-wide weighted APY for this agent, as a decimal string. */
|
|
@@ -402,15 +389,8 @@ interface IAgent {
|
|
|
402
389
|
readonly id: string;
|
|
403
390
|
readonly supportedChainIds: readonly OwneySupportedChainId[];
|
|
404
391
|
readonly supportedAssets: readonly AgentSupportedAssets[];
|
|
405
|
-
/**
|
|
406
|
-
* Describes how `AgentBalance.tokens` relates to `positions`.
|
|
407
|
-
* Most adapters expose token totals that already include deployed positions.
|
|
408
|
-
* Providers such as Yieldseeker expose idle wallet tokens separately, so
|
|
409
|
-
* withdrawal planning must add matching position amounts.
|
|
410
|
-
*/
|
|
411
|
-
readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
|
|
412
392
|
disconnect(): Promise<void>;
|
|
413
|
-
activateAgent(state: ConnectionState, chainId: number
|
|
393
|
+
activateAgent(state: ConnectionState, chainId: number): Promise<void>;
|
|
414
394
|
/**
|
|
415
395
|
* Apply the organization's agent policy to this user's account.
|
|
416
396
|
*
|
|
@@ -475,9 +455,9 @@ declare class OwneySDK {
|
|
|
475
455
|
private orgAgentConfig;
|
|
476
456
|
private orgAgentConfigPromise;
|
|
477
457
|
private zyfaiRpcUrls?;
|
|
478
|
-
private yieldseekerApiBaseUrl?;
|
|
479
458
|
private routingApiBaseUrl?;
|
|
480
459
|
private referralSource?;
|
|
460
|
+
private surfliquidApiBaseUrl?;
|
|
481
461
|
private cachedSponsoredCallback;
|
|
482
462
|
private cachedWethSponsoredCallback;
|
|
483
463
|
private paymasterServiceUrl?;
|
|
@@ -548,11 +528,6 @@ declare class OwneySDK {
|
|
|
548
528
|
private applyOrgPolicyTo;
|
|
549
529
|
private ensureAgentsInitialized;
|
|
550
530
|
private createAgent;
|
|
551
|
-
/**
|
|
552
|
-
* Discover the agents actually returned by routing for this organization.
|
|
553
|
-
* Consumers should use this instead of hardcoding a global agent roster.
|
|
554
|
-
*/
|
|
555
|
-
getAvailableAgents(options?: AvailableAgentsOptions): Promise<AvailableAgent[]>;
|
|
556
531
|
/**
|
|
557
532
|
* Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted.
|
|
558
533
|
* Deploys the Safe contract and creates a session key if not already set up.
|
|
@@ -563,7 +538,7 @@ declare class OwneySDK {
|
|
|
563
538
|
* If provided, ALL specified agents must support the chainId or the call
|
|
564
539
|
* throws before activating any agent.
|
|
565
540
|
*/
|
|
566
|
-
activateAgent(chainId: number, agentId?: AgentId[]
|
|
541
|
+
activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
|
|
567
542
|
/**
|
|
568
543
|
* Activate agents ONE AT A TIME, each followed by its org policy.
|
|
569
544
|
*
|
|
@@ -634,6 +609,17 @@ declare class OwneySDK {
|
|
|
634
609
|
private hasExistingBalance;
|
|
635
610
|
private validateAssetSupport;
|
|
636
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[]>;
|
|
637
623
|
/**
|
|
638
624
|
* Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
|
|
639
625
|
* Validates that the asset is supported by the target agent(s) on the active chain.
|
|
@@ -734,92 +720,7 @@ declare class OwneySDK {
|
|
|
734
720
|
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
735
721
|
}
|
|
736
722
|
|
|
737
|
-
type
|
|
738
|
-
now?: () => Date;
|
|
739
|
-
nonce?: () => string;
|
|
740
|
-
};
|
|
741
|
-
|
|
742
|
-
type YieldseekerFetch = typeof fetch;
|
|
743
|
-
|
|
744
|
-
type YieldseekerTransaction = {
|
|
745
|
-
from: `0x${string}`;
|
|
746
|
-
to: `0x${string}`;
|
|
747
|
-
data: `0x${string}`;
|
|
748
|
-
value: string;
|
|
749
|
-
chainId: number;
|
|
750
|
-
};
|
|
751
|
-
|
|
752
|
-
type YieldseekerAgentOptions = {
|
|
753
|
-
baseUrl?: string;
|
|
754
|
-
fetchFn?: YieldseekerFetch;
|
|
755
|
-
auth?: YieldseekerAuthDependencies;
|
|
756
|
-
/** Test seam for the wallet-submission/receipt boundary. */
|
|
757
|
-
transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
|
|
758
|
-
/** Test seam for transactions submitted outside transactionExecutor. */
|
|
759
|
-
unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
|
|
760
|
-
};
|
|
761
|
-
declare class YieldseekerAgent implements IAgent {
|
|
762
|
-
readonly id = "yieldseeker";
|
|
763
|
-
readonly balanceComposition: "tokens-plus-positions";
|
|
764
|
-
readonly supportedChainIds: readonly [8453];
|
|
765
|
-
readonly supportedAssets: readonly [{
|
|
766
|
-
readonly chainId: 8453;
|
|
767
|
-
readonly chain: "BASE";
|
|
768
|
-
readonly assets: readonly [{
|
|
769
|
-
readonly symbol: "USDC";
|
|
770
|
-
readonly minDepositAmount: "10000000";
|
|
771
|
-
}, {
|
|
772
|
-
readonly symbol: "WETH";
|
|
773
|
-
readonly minDepositAmount: "1";
|
|
774
|
-
}];
|
|
775
|
-
}];
|
|
776
|
-
private readonly api;
|
|
777
|
-
private readonly auth;
|
|
778
|
-
private readonly transactionExecutor?;
|
|
779
|
-
private readonly unwindReceiptWaiter?;
|
|
780
|
-
private readonly agentContexts;
|
|
781
|
-
private readonly users;
|
|
782
|
-
private readonly pendingAgents;
|
|
783
|
-
constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
|
|
784
|
-
disconnect(): Promise<void>;
|
|
785
|
-
activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
|
|
786
|
-
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
787
|
-
withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
|
|
788
|
-
getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
|
|
789
|
-
getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
|
|
790
|
-
getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
|
|
791
|
-
getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
|
|
792
|
-
getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
|
|
793
|
-
getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
|
|
794
|
-
private userKey;
|
|
795
|
-
private contextKey;
|
|
796
|
-
private resolveUser;
|
|
797
|
-
private forgetUser;
|
|
798
|
-
private ensureAgent;
|
|
799
|
-
private findAgent;
|
|
800
|
-
private resolveAgent;
|
|
801
|
-
private loadPortfolio;
|
|
802
|
-
private loadPortfolioContext;
|
|
803
|
-
private deployAfterFunding;
|
|
804
|
-
private refreshSnapshotAfterMovement;
|
|
805
|
-
private agentPath;
|
|
806
|
-
private walletRequest;
|
|
807
|
-
private providerRequest;
|
|
808
|
-
private mapApiError;
|
|
809
|
-
private submitTransaction;
|
|
810
|
-
private waitForReceipt;
|
|
811
|
-
private assertTransaction;
|
|
812
|
-
private assertAgent;
|
|
813
|
-
private isOwneyAgent;
|
|
814
|
-
private assetForAgent;
|
|
815
|
-
private isTransactionHash;
|
|
816
|
-
private assertChain;
|
|
817
|
-
private assertOptionalChain;
|
|
818
|
-
private assertAsset;
|
|
819
|
-
private invalidResponse;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
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_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";
|
|
823
724
|
declare class OwneyError extends Error {
|
|
824
725
|
readonly code: OwneyErrorCode;
|
|
825
726
|
readonly details?: Record<string, unknown>;
|
|
@@ -885,4 +786,4 @@ type OwneySIWXConfig = {
|
|
|
885
786
|
*/
|
|
886
787
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
887
788
|
|
|
888
|
-
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
|
|
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" | "
|
|
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
|
|
@@ -259,12 +258,6 @@ interface OwneyBalances {
|
|
|
259
258
|
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
260
259
|
totalBalanceAsset: string;
|
|
261
260
|
agentBalances: Record<AgentId, AgentBalance>;
|
|
262
|
-
/**
|
|
263
|
-
* Per-agent read failures when an aggregate balance request returned only a
|
|
264
|
-
* partial result. Callers may display the successful balances, but funding
|
|
265
|
-
* operations must not interpret a missing agent as having a zero balance.
|
|
266
|
-
*/
|
|
267
|
-
agentErrors?: Partial<Record<AgentId, string>>;
|
|
268
261
|
}
|
|
269
262
|
interface AgentEarnings {
|
|
270
263
|
smartWallet: `0x${string}`;
|
|
@@ -298,12 +291,6 @@ interface OwneyAccountApy {
|
|
|
298
291
|
totalApy: string;
|
|
299
292
|
agentApy: Record<AgentId, AccountAgentApy>;
|
|
300
293
|
apyByChainAndAsset: ApyByChainAndAsset;
|
|
301
|
-
/**
|
|
302
|
-
* Balance-weighted daily APY across the agents that returned a point for each
|
|
303
|
-
* date. The weights use the selected chain/asset balance when getAccountApy
|
|
304
|
-
* is asset-scoped, otherwise each agent's total balance.
|
|
305
|
-
*/
|
|
306
|
-
history?: ApyHistoryPoint[];
|
|
307
294
|
}
|
|
308
295
|
interface AllocationAgentApy {
|
|
309
296
|
/** Account-wide weighted APY for this agent, as a decimal string. */
|
|
@@ -402,15 +389,8 @@ interface IAgent {
|
|
|
402
389
|
readonly id: string;
|
|
403
390
|
readonly supportedChainIds: readonly OwneySupportedChainId[];
|
|
404
391
|
readonly supportedAssets: readonly AgentSupportedAssets[];
|
|
405
|
-
/**
|
|
406
|
-
* Describes how `AgentBalance.tokens` relates to `positions`.
|
|
407
|
-
* Most adapters expose token totals that already include deployed positions.
|
|
408
|
-
* Providers such as Yieldseeker expose idle wallet tokens separately, so
|
|
409
|
-
* withdrawal planning must add matching position amounts.
|
|
410
|
-
*/
|
|
411
|
-
readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
|
|
412
392
|
disconnect(): Promise<void>;
|
|
413
|
-
activateAgent(state: ConnectionState, chainId: number
|
|
393
|
+
activateAgent(state: ConnectionState, chainId: number): Promise<void>;
|
|
414
394
|
/**
|
|
415
395
|
* Apply the organization's agent policy to this user's account.
|
|
416
396
|
*
|
|
@@ -475,9 +455,9 @@ declare class OwneySDK {
|
|
|
475
455
|
private orgAgentConfig;
|
|
476
456
|
private orgAgentConfigPromise;
|
|
477
457
|
private zyfaiRpcUrls?;
|
|
478
|
-
private yieldseekerApiBaseUrl?;
|
|
479
458
|
private routingApiBaseUrl?;
|
|
480
459
|
private referralSource?;
|
|
460
|
+
private surfliquidApiBaseUrl?;
|
|
481
461
|
private cachedSponsoredCallback;
|
|
482
462
|
private cachedWethSponsoredCallback;
|
|
483
463
|
private paymasterServiceUrl?;
|
|
@@ -548,11 +528,6 @@ declare class OwneySDK {
|
|
|
548
528
|
private applyOrgPolicyTo;
|
|
549
529
|
private ensureAgentsInitialized;
|
|
550
530
|
private createAgent;
|
|
551
|
-
/**
|
|
552
|
-
* Discover the agents actually returned by routing for this organization.
|
|
553
|
-
* Consumers should use this instead of hardcoding a global agent roster.
|
|
554
|
-
*/
|
|
555
|
-
getAvailableAgents(options?: AvailableAgentsOptions): Promise<AvailableAgent[]>;
|
|
556
531
|
/**
|
|
557
532
|
* Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted.
|
|
558
533
|
* Deploys the Safe contract and creates a session key if not already set up.
|
|
@@ -563,7 +538,7 @@ declare class OwneySDK {
|
|
|
563
538
|
* If provided, ALL specified agents must support the chainId or the call
|
|
564
539
|
* throws before activating any agent.
|
|
565
540
|
*/
|
|
566
|
-
activateAgent(chainId: number, agentId?: AgentId[]
|
|
541
|
+
activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
|
|
567
542
|
/**
|
|
568
543
|
* Activate agents ONE AT A TIME, each followed by its org policy.
|
|
569
544
|
*
|
|
@@ -634,6 +609,17 @@ declare class OwneySDK {
|
|
|
634
609
|
private hasExistingBalance;
|
|
635
610
|
private validateAssetSupport;
|
|
636
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[]>;
|
|
637
623
|
/**
|
|
638
624
|
* Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
|
|
639
625
|
* Validates that the asset is supported by the target agent(s) on the active chain.
|
|
@@ -734,92 +720,7 @@ declare class OwneySDK {
|
|
|
734
720
|
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
735
721
|
}
|
|
736
722
|
|
|
737
|
-
type
|
|
738
|
-
now?: () => Date;
|
|
739
|
-
nonce?: () => string;
|
|
740
|
-
};
|
|
741
|
-
|
|
742
|
-
type YieldseekerFetch = typeof fetch;
|
|
743
|
-
|
|
744
|
-
type YieldseekerTransaction = {
|
|
745
|
-
from: `0x${string}`;
|
|
746
|
-
to: `0x${string}`;
|
|
747
|
-
data: `0x${string}`;
|
|
748
|
-
value: string;
|
|
749
|
-
chainId: number;
|
|
750
|
-
};
|
|
751
|
-
|
|
752
|
-
type YieldseekerAgentOptions = {
|
|
753
|
-
baseUrl?: string;
|
|
754
|
-
fetchFn?: YieldseekerFetch;
|
|
755
|
-
auth?: YieldseekerAuthDependencies;
|
|
756
|
-
/** Test seam for the wallet-submission/receipt boundary. */
|
|
757
|
-
transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
|
|
758
|
-
/** Test seam for transactions submitted outside transactionExecutor. */
|
|
759
|
-
unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
|
|
760
|
-
};
|
|
761
|
-
declare class YieldseekerAgent implements IAgent {
|
|
762
|
-
readonly id = "yieldseeker";
|
|
763
|
-
readonly balanceComposition: "tokens-plus-positions";
|
|
764
|
-
readonly supportedChainIds: readonly [8453];
|
|
765
|
-
readonly supportedAssets: readonly [{
|
|
766
|
-
readonly chainId: 8453;
|
|
767
|
-
readonly chain: "BASE";
|
|
768
|
-
readonly assets: readonly [{
|
|
769
|
-
readonly symbol: "USDC";
|
|
770
|
-
readonly minDepositAmount: "10000000";
|
|
771
|
-
}, {
|
|
772
|
-
readonly symbol: "WETH";
|
|
773
|
-
readonly minDepositAmount: "1";
|
|
774
|
-
}];
|
|
775
|
-
}];
|
|
776
|
-
private readonly api;
|
|
777
|
-
private readonly auth;
|
|
778
|
-
private readonly transactionExecutor?;
|
|
779
|
-
private readonly unwindReceiptWaiter?;
|
|
780
|
-
private readonly agentContexts;
|
|
781
|
-
private readonly users;
|
|
782
|
-
private readonly pendingAgents;
|
|
783
|
-
constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
|
|
784
|
-
disconnect(): Promise<void>;
|
|
785
|
-
activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
|
|
786
|
-
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
787
|
-
withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
|
|
788
|
-
getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
|
|
789
|
-
getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
|
|
790
|
-
getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
|
|
791
|
-
getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
|
|
792
|
-
getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
|
|
793
|
-
getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
|
|
794
|
-
private userKey;
|
|
795
|
-
private contextKey;
|
|
796
|
-
private resolveUser;
|
|
797
|
-
private forgetUser;
|
|
798
|
-
private ensureAgent;
|
|
799
|
-
private findAgent;
|
|
800
|
-
private resolveAgent;
|
|
801
|
-
private loadPortfolio;
|
|
802
|
-
private loadPortfolioContext;
|
|
803
|
-
private deployAfterFunding;
|
|
804
|
-
private refreshSnapshotAfterMovement;
|
|
805
|
-
private agentPath;
|
|
806
|
-
private walletRequest;
|
|
807
|
-
private providerRequest;
|
|
808
|
-
private mapApiError;
|
|
809
|
-
private submitTransaction;
|
|
810
|
-
private waitForReceipt;
|
|
811
|
-
private assertTransaction;
|
|
812
|
-
private assertAgent;
|
|
813
|
-
private isOwneyAgent;
|
|
814
|
-
private assetForAgent;
|
|
815
|
-
private isTransactionHash;
|
|
816
|
-
private assertChain;
|
|
817
|
-
private assertOptionalChain;
|
|
818
|
-
private assertAsset;
|
|
819
|
-
private invalidResponse;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
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_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";
|
|
823
724
|
declare class OwneyError extends Error {
|
|
824
725
|
readonly code: OwneyErrorCode;
|
|
825
726
|
readonly details?: Record<string, unknown>;
|
|
@@ -885,4 +786,4 @@ type OwneySIWXConfig = {
|
|
|
885
786
|
*/
|
|
886
787
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
887
788
|
|
|
888
|
-
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
|
|
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 };
|