@owney/sdk 0.6.9-beta.7 → 0.7.0-beta.1
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 +1 -1
- package/dist/index.cjs +243 -1292
- package/dist/index.d.cts +3 -138
- package/dist/index.d.ts +3 -138
- package/dist/index.js +214 -634
- package/package.json +3 -5
- package/dist/chunk-PWIKIQOX.js +0 -140
- package/dist/surfliquid.agent-JOJJ3C5Y.js +0 -448
package/dist/index.d.cts
CHANGED
|
@@ -21,25 +21,6 @@ interface OwneySDKConfig {
|
|
|
21
21
|
* `createOwneySIWX` for apps that don't use the AppKit SIWX modal.
|
|
22
22
|
*/
|
|
23
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;
|
|
34
|
-
/**
|
|
35
|
-
* Turn on the SDK's debug logging (default false). Traces the decisions that
|
|
36
|
-
* are otherwise invisible — notably how the organization's agent policy is
|
|
37
|
-
* compared against each user's Zyfai profile and whether it writes.
|
|
38
|
-
*
|
|
39
|
-
* Also switchable at runtime without a rebuild, which is what you want on an
|
|
40
|
-
* already-deployed app: set `globalThis.__OWNEY_DEBUG__ = true` in devtools.
|
|
41
|
-
*/
|
|
42
|
-
debug?: boolean;
|
|
43
24
|
}
|
|
44
25
|
interface ConnectionState {
|
|
45
26
|
provider: any;
|
|
@@ -53,7 +34,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
|
53
34
|
type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
|
|
54
35
|
type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
|
|
55
36
|
|
|
56
|
-
type AgentId = "zyfai" | "sail"
|
|
37
|
+
type AgentId = "zyfai" | "sail";
|
|
57
38
|
type Asset = string;
|
|
58
39
|
type AgentSupportedAsset = {
|
|
59
40
|
readonly symbol: string;
|
|
@@ -120,39 +101,6 @@ type DepositOptions = {
|
|
|
120
101
|
onApproved?: () => void;
|
|
121
102
|
};
|
|
122
103
|
|
|
123
|
-
/**
|
|
124
|
-
* One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
|
|
125
|
-
* verbatim — matched case-sensitively by customizeBatch, and an unrecognised
|
|
126
|
-
* name makes Zyfai's rebalance engine skip the whole protocol, so these strings
|
|
127
|
-
* must not be normalised anywhere.
|
|
128
|
-
*
|
|
129
|
-
* An empty array means "no usable pools on this chain".
|
|
130
|
-
*/
|
|
131
|
-
type OrgPoolSelection = {
|
|
132
|
-
protocolId: string;
|
|
133
|
-
chainId: number;
|
|
134
|
-
pools: string[];
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
|
|
138
|
-
* narrowed appear. Optional so an older routing API, which does not return the
|
|
139
|
-
* field, still parses; undefined and null both mean "change nothing".
|
|
140
|
-
*/
|
|
141
|
-
type OrgPoolPolicy = {
|
|
142
|
-
autoApproveProtocols: boolean;
|
|
143
|
-
autoApprovePools: boolean;
|
|
144
|
-
selections: OrgPoolSelection[];
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
* The organization's agent execution policy, or null when the partner has never
|
|
148
|
-
* configured one — in which case the agents leave the user's profile alone.
|
|
149
|
-
*/
|
|
150
|
-
type OrgAgentConfig = {
|
|
151
|
-
splittingMode: "none" | "automatic" | "force";
|
|
152
|
-
minSplits: number | null;
|
|
153
|
-
poolPolicy?: OrgPoolPolicy | null;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
104
|
interface OwneyDepositResult {
|
|
157
105
|
txHash: string;
|
|
158
106
|
smartWallet: string;
|
|
@@ -160,12 +108,6 @@ interface OwneyDepositResult {
|
|
|
160
108
|
}
|
|
161
109
|
interface OwneyMultiDepositResult {
|
|
162
110
|
agentResults: Record<string, OwneyDepositResult>;
|
|
163
|
-
/**
|
|
164
|
-
* Per-agent failure messages for agents that errored during a diversified
|
|
165
|
-
* deposit. Present only when at least one (but not all) agents failed —
|
|
166
|
-
* the deposit is partial, not total. Omitted when every agent succeeded.
|
|
167
|
-
*/
|
|
168
|
-
agentErrors?: Record<string, string>;
|
|
169
111
|
}
|
|
170
112
|
interface AgentWithdrawResult {
|
|
171
113
|
txHash?: string;
|
|
@@ -311,19 +253,6 @@ interface AgentUserProfile {
|
|
|
311
253
|
strategy?: string;
|
|
312
254
|
hasActiveSessionKey: boolean;
|
|
313
255
|
protocols: string[];
|
|
314
|
-
/**
|
|
315
|
-
* Capital splitting, as the agent currently has it (ROUT-229). Optional
|
|
316
|
-
* because not every agent has the concept — Sail omits both.
|
|
317
|
-
*
|
|
318
|
-
* `minSplits` is the field that carries the meaning: 1 means "split only when
|
|
319
|
-
* it beats a single pool", 2-4 means "force a split for diversification".
|
|
320
|
-
*
|
|
321
|
-
* Zyfai stores these PER ASSET. This profile read does not pass an asset, so
|
|
322
|
-
* these reflect the USDC bucket; a WETH-only user's real setting is not shown
|
|
323
|
-
* here.
|
|
324
|
-
*/
|
|
325
|
-
splitting?: boolean;
|
|
326
|
-
minSplits?: number;
|
|
327
256
|
}
|
|
328
257
|
interface OwneyUserProfile {
|
|
329
258
|
agentUserProfile: Record<AgentId, AgentUserProfile>;
|
|
@@ -346,19 +275,6 @@ interface IAgent {
|
|
|
346
275
|
readonly supportedAssets: readonly AgentSupportedAssets[];
|
|
347
276
|
disconnect(): Promise<void>;
|
|
348
277
|
activateAgent(state: ConnectionState, chainId: number): Promise<void>;
|
|
349
|
-
/**
|
|
350
|
-
* Apply the organization's agent policy to this user's account.
|
|
351
|
-
*
|
|
352
|
-
* Optional: an agent that has no equivalent knob simply omits it, which is why
|
|
353
|
-
* this is not part of `activateAgent`'s signature. Declared on the interface
|
|
354
|
-
* rather than only on ZyfaiAgent so the contract stays agent-neutral — the
|
|
355
|
-
* ticket asks for a design that can also cover Surf, which has no adapter yet.
|
|
356
|
-
*
|
|
357
|
-
* Implementations must be **non-fatal**: this runs during activation as a side
|
|
358
|
-
* effect, so a failure has to leave the user connected and their profile
|
|
359
|
-
* unchanged rather than break the connect.
|
|
360
|
-
*/
|
|
361
|
-
applyOrgPolicy?(state: ConnectionState, chainId: number, policy: OrgAgentConfig): Promise<void>;
|
|
362
278
|
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
363
279
|
withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
|
|
364
280
|
getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
|
|
@@ -402,12 +318,9 @@ declare class OwneySDK {
|
|
|
402
318
|
private disabledAgents;
|
|
403
319
|
private state;
|
|
404
320
|
private apiKey;
|
|
405
|
-
private orgAgentConfig;
|
|
406
|
-
private orgAgentConfigPromise;
|
|
407
321
|
private zyfaiRpcUrls?;
|
|
408
322
|
private routingApiBaseUrl?;
|
|
409
323
|
private referralSource?;
|
|
410
|
-
private surfliquidApiBaseUrl?;
|
|
411
324
|
private cachedSponsoredCallback;
|
|
412
325
|
private cachedWethSponsoredCallback;
|
|
413
326
|
private initializingAgentsPromise;
|
|
@@ -453,20 +366,6 @@ declare class OwneySDK {
|
|
|
453
366
|
private getDefaultWethSponsoredCallback;
|
|
454
367
|
private getAgent;
|
|
455
368
|
private getActiveAgents;
|
|
456
|
-
/**
|
|
457
|
-
* Read the org's agent policy once and reuse it. fetchOrgAgentConfig never
|
|
458
|
-
* throws — it degrades to null — so this cannot break activation.
|
|
459
|
-
*/
|
|
460
|
-
private getOrgAgentConfig;
|
|
461
|
-
/**
|
|
462
|
-
* Apply the org policy to one agent, after it has activated.
|
|
463
|
-
*
|
|
464
|
-
* Sequenced after activation rather than alongside it because applying the
|
|
465
|
-
* policy needs the authenticated session activation establishes. Every failure
|
|
466
|
-
* mode is swallowed: a partner's splitting preference is not worth failing a
|
|
467
|
-
* user's connect over.
|
|
468
|
-
*/
|
|
469
|
-
private applyOrgPolicyTo;
|
|
470
369
|
private ensureAgentsInitialized;
|
|
471
370
|
private createAgent;
|
|
472
371
|
/**
|
|
@@ -531,17 +430,6 @@ declare class OwneySDK {
|
|
|
531
430
|
private hasExistingBalance;
|
|
532
431
|
private validateAssetSupport;
|
|
533
432
|
private getEligibleAgents;
|
|
534
|
-
/**
|
|
535
|
-
* Agent ids the routing API provisioned for this org that support the given
|
|
536
|
-
* chain + asset, ordered by preference ({@link AGENT_ELIGIBILITY_ORDER},
|
|
537
|
-
* surfliquid first). Returns `[]` when the org has no compatible agent — never
|
|
538
|
-
* throws on an empty org. Loads agent keys on first call (apiKey only, no
|
|
539
|
-
* wallet), so the UI can resolve which agent to use before the user connects.
|
|
540
|
-
*
|
|
541
|
-
* This is the source of truth for agent availability: an agent appears here
|
|
542
|
-
* iff the routing API returned its key. No per-app feature flags.
|
|
543
|
-
*/
|
|
544
|
-
getEligibleAgentIds(chainId: number, asset: string): Promise<AgentId[]>;
|
|
545
433
|
/**
|
|
546
434
|
* Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
|
|
547
435
|
* Validates that the asset is supported by the target agent(s) on the active chain.
|
|
@@ -637,7 +525,7 @@ declare class OwneySDK {
|
|
|
637
525
|
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
638
526
|
}
|
|
639
527
|
|
|
640
|
-
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "
|
|
528
|
+
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "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_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
641
529
|
declare class OwneyError extends Error {
|
|
642
530
|
readonly code: OwneyErrorCode;
|
|
643
531
|
readonly details?: Record<string, unknown>;
|
|
@@ -667,29 +555,6 @@ declare class InvalidHistoryCursorError extends Error {
|
|
|
667
555
|
constructor(message: string);
|
|
668
556
|
}
|
|
669
557
|
|
|
670
|
-
/**
|
|
671
|
-
* Opt-in debug logging.
|
|
672
|
-
*
|
|
673
|
-
* The SDK is deliberately quiet: before this, `src/` contained no `console.log`
|
|
674
|
-
* at all, only `console.warn`/`console.error` for genuine faults. That is worth
|
|
675
|
-
* preserving — this runs inside every partner's app, on every user's connect, so
|
|
676
|
-
* unconditional chatter would land in end users' consoles forever.
|
|
677
|
-
*
|
|
678
|
-
* Two ways to turn it on:
|
|
679
|
-
*
|
|
680
|
-
* 1. From the app: new OwneySDK({ apiKey, debug: true })
|
|
681
|
-
* 2. From devtools, live: globalThis.__OWNEY_DEBUG__ = true
|
|
682
|
-
*
|
|
683
|
-
* (2) is the useful one when diagnosing something on an already-deployed app:
|
|
684
|
-
* the flag is read on every call, not captured once, so flipping it in the
|
|
685
|
-
* console takes effect on the next action without a rebuild or a republish.
|
|
686
|
-
*/
|
|
687
|
-
declare global {
|
|
688
|
-
var __OWNEY_DEBUG__: boolean | undefined;
|
|
689
|
-
}
|
|
690
|
-
/** Enable/disable debug logging programmatically. */
|
|
691
|
-
declare function setOwneyDebug(enabled: boolean): void;
|
|
692
|
-
|
|
693
558
|
type OwneySIWXConfig = {
|
|
694
559
|
/** Owney/Zyfai API key — same value passed to `new OwneySDK({ apiKey })`. */
|
|
695
560
|
apiKey: string;
|
|
@@ -703,4 +568,4 @@ type OwneySIWXConfig = {
|
|
|
703
568
|
*/
|
|
704
569
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
705
570
|
|
|
706
|
-
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, AllocationApyOptions, ApyByChainAndAsset, ApyHistoryPoint, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, InvalidHistoryCursorError, NotConnectedError, OwneyAccountApy, OwneyAgentApy, OwneyAgentHistory, OwneyAllocationApy, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneyPosition, OwneySDK, OwneySDKConfig, OwneySIWXConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions, createOwneySIWX
|
|
571
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -21,25 +21,6 @@ interface OwneySDKConfig {
|
|
|
21
21
|
* `createOwneySIWX` for apps that don't use the AppKit SIWX modal.
|
|
22
22
|
*/
|
|
23
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;
|
|
34
|
-
/**
|
|
35
|
-
* Turn on the SDK's debug logging (default false). Traces the decisions that
|
|
36
|
-
* are otherwise invisible — notably how the organization's agent policy is
|
|
37
|
-
* compared against each user's Zyfai profile and whether it writes.
|
|
38
|
-
*
|
|
39
|
-
* Also switchable at runtime without a rebuild, which is what you want on an
|
|
40
|
-
* already-deployed app: set `globalThis.__OWNEY_DEBUG__ = true` in devtools.
|
|
41
|
-
*/
|
|
42
|
-
debug?: boolean;
|
|
43
24
|
}
|
|
44
25
|
interface ConnectionState {
|
|
45
26
|
provider: any;
|
|
@@ -53,7 +34,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
|
53
34
|
type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
|
|
54
35
|
type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
|
|
55
36
|
|
|
56
|
-
type AgentId = "zyfai" | "sail"
|
|
37
|
+
type AgentId = "zyfai" | "sail";
|
|
57
38
|
type Asset = string;
|
|
58
39
|
type AgentSupportedAsset = {
|
|
59
40
|
readonly symbol: string;
|
|
@@ -120,39 +101,6 @@ type DepositOptions = {
|
|
|
120
101
|
onApproved?: () => void;
|
|
121
102
|
};
|
|
122
103
|
|
|
123
|
-
/**
|
|
124
|
-
* One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
|
|
125
|
-
* verbatim — matched case-sensitively by customizeBatch, and an unrecognised
|
|
126
|
-
* name makes Zyfai's rebalance engine skip the whole protocol, so these strings
|
|
127
|
-
* must not be normalised anywhere.
|
|
128
|
-
*
|
|
129
|
-
* An empty array means "no usable pools on this chain".
|
|
130
|
-
*/
|
|
131
|
-
type OrgPoolSelection = {
|
|
132
|
-
protocolId: string;
|
|
133
|
-
chainId: number;
|
|
134
|
-
pools: string[];
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
|
|
138
|
-
* narrowed appear. Optional so an older routing API, which does not return the
|
|
139
|
-
* field, still parses; undefined and null both mean "change nothing".
|
|
140
|
-
*/
|
|
141
|
-
type OrgPoolPolicy = {
|
|
142
|
-
autoApproveProtocols: boolean;
|
|
143
|
-
autoApprovePools: boolean;
|
|
144
|
-
selections: OrgPoolSelection[];
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
* The organization's agent execution policy, or null when the partner has never
|
|
148
|
-
* configured one — in which case the agents leave the user's profile alone.
|
|
149
|
-
*/
|
|
150
|
-
type OrgAgentConfig = {
|
|
151
|
-
splittingMode: "none" | "automatic" | "force";
|
|
152
|
-
minSplits: number | null;
|
|
153
|
-
poolPolicy?: OrgPoolPolicy | null;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
104
|
interface OwneyDepositResult {
|
|
157
105
|
txHash: string;
|
|
158
106
|
smartWallet: string;
|
|
@@ -160,12 +108,6 @@ interface OwneyDepositResult {
|
|
|
160
108
|
}
|
|
161
109
|
interface OwneyMultiDepositResult {
|
|
162
110
|
agentResults: Record<string, OwneyDepositResult>;
|
|
163
|
-
/**
|
|
164
|
-
* Per-agent failure messages for agents that errored during a diversified
|
|
165
|
-
* deposit. Present only when at least one (but not all) agents failed —
|
|
166
|
-
* the deposit is partial, not total. Omitted when every agent succeeded.
|
|
167
|
-
*/
|
|
168
|
-
agentErrors?: Record<string, string>;
|
|
169
111
|
}
|
|
170
112
|
interface AgentWithdrawResult {
|
|
171
113
|
txHash?: string;
|
|
@@ -311,19 +253,6 @@ interface AgentUserProfile {
|
|
|
311
253
|
strategy?: string;
|
|
312
254
|
hasActiveSessionKey: boolean;
|
|
313
255
|
protocols: string[];
|
|
314
|
-
/**
|
|
315
|
-
* Capital splitting, as the agent currently has it (ROUT-229). Optional
|
|
316
|
-
* because not every agent has the concept — Sail omits both.
|
|
317
|
-
*
|
|
318
|
-
* `minSplits` is the field that carries the meaning: 1 means "split only when
|
|
319
|
-
* it beats a single pool", 2-4 means "force a split for diversification".
|
|
320
|
-
*
|
|
321
|
-
* Zyfai stores these PER ASSET. This profile read does not pass an asset, so
|
|
322
|
-
* these reflect the USDC bucket; a WETH-only user's real setting is not shown
|
|
323
|
-
* here.
|
|
324
|
-
*/
|
|
325
|
-
splitting?: boolean;
|
|
326
|
-
minSplits?: number;
|
|
327
256
|
}
|
|
328
257
|
interface OwneyUserProfile {
|
|
329
258
|
agentUserProfile: Record<AgentId, AgentUserProfile>;
|
|
@@ -346,19 +275,6 @@ interface IAgent {
|
|
|
346
275
|
readonly supportedAssets: readonly AgentSupportedAssets[];
|
|
347
276
|
disconnect(): Promise<void>;
|
|
348
277
|
activateAgent(state: ConnectionState, chainId: number): Promise<void>;
|
|
349
|
-
/**
|
|
350
|
-
* Apply the organization's agent policy to this user's account.
|
|
351
|
-
*
|
|
352
|
-
* Optional: an agent that has no equivalent knob simply omits it, which is why
|
|
353
|
-
* this is not part of `activateAgent`'s signature. Declared on the interface
|
|
354
|
-
* rather than only on ZyfaiAgent so the contract stays agent-neutral — the
|
|
355
|
-
* ticket asks for a design that can also cover Surf, which has no adapter yet.
|
|
356
|
-
*
|
|
357
|
-
* Implementations must be **non-fatal**: this runs during activation as a side
|
|
358
|
-
* effect, so a failure has to leave the user connected and their profile
|
|
359
|
-
* unchanged rather than break the connect.
|
|
360
|
-
*/
|
|
361
|
-
applyOrgPolicy?(state: ConnectionState, chainId: number, policy: OrgAgentConfig): Promise<void>;
|
|
362
278
|
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
363
279
|
withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
|
|
364
280
|
getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
|
|
@@ -402,12 +318,9 @@ declare class OwneySDK {
|
|
|
402
318
|
private disabledAgents;
|
|
403
319
|
private state;
|
|
404
320
|
private apiKey;
|
|
405
|
-
private orgAgentConfig;
|
|
406
|
-
private orgAgentConfigPromise;
|
|
407
321
|
private zyfaiRpcUrls?;
|
|
408
322
|
private routingApiBaseUrl?;
|
|
409
323
|
private referralSource?;
|
|
410
|
-
private surfliquidApiBaseUrl?;
|
|
411
324
|
private cachedSponsoredCallback;
|
|
412
325
|
private cachedWethSponsoredCallback;
|
|
413
326
|
private initializingAgentsPromise;
|
|
@@ -453,20 +366,6 @@ declare class OwneySDK {
|
|
|
453
366
|
private getDefaultWethSponsoredCallback;
|
|
454
367
|
private getAgent;
|
|
455
368
|
private getActiveAgents;
|
|
456
|
-
/**
|
|
457
|
-
* Read the org's agent policy once and reuse it. fetchOrgAgentConfig never
|
|
458
|
-
* throws — it degrades to null — so this cannot break activation.
|
|
459
|
-
*/
|
|
460
|
-
private getOrgAgentConfig;
|
|
461
|
-
/**
|
|
462
|
-
* Apply the org policy to one agent, after it has activated.
|
|
463
|
-
*
|
|
464
|
-
* Sequenced after activation rather than alongside it because applying the
|
|
465
|
-
* policy needs the authenticated session activation establishes. Every failure
|
|
466
|
-
* mode is swallowed: a partner's splitting preference is not worth failing a
|
|
467
|
-
* user's connect over.
|
|
468
|
-
*/
|
|
469
|
-
private applyOrgPolicyTo;
|
|
470
369
|
private ensureAgentsInitialized;
|
|
471
370
|
private createAgent;
|
|
472
371
|
/**
|
|
@@ -531,17 +430,6 @@ declare class OwneySDK {
|
|
|
531
430
|
private hasExistingBalance;
|
|
532
431
|
private validateAssetSupport;
|
|
533
432
|
private getEligibleAgents;
|
|
534
|
-
/**
|
|
535
|
-
* Agent ids the routing API provisioned for this org that support the given
|
|
536
|
-
* chain + asset, ordered by preference ({@link AGENT_ELIGIBILITY_ORDER},
|
|
537
|
-
* surfliquid first). Returns `[]` when the org has no compatible agent — never
|
|
538
|
-
* throws on an empty org. Loads agent keys on first call (apiKey only, no
|
|
539
|
-
* wallet), so the UI can resolve which agent to use before the user connects.
|
|
540
|
-
*
|
|
541
|
-
* This is the source of truth for agent availability: an agent appears here
|
|
542
|
-
* iff the routing API returned its key. No per-app feature flags.
|
|
543
|
-
*/
|
|
544
|
-
getEligibleAgentIds(chainId: number, asset: string): Promise<AgentId[]>;
|
|
545
433
|
/**
|
|
546
434
|
* Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
|
|
547
435
|
* Validates that the asset is supported by the target agent(s) on the active chain.
|
|
@@ -637,7 +525,7 @@ declare class OwneySDK {
|
|
|
637
525
|
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
638
526
|
}
|
|
639
527
|
|
|
640
|
-
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "
|
|
528
|
+
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "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_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
641
529
|
declare class OwneyError extends Error {
|
|
642
530
|
readonly code: OwneyErrorCode;
|
|
643
531
|
readonly details?: Record<string, unknown>;
|
|
@@ -667,29 +555,6 @@ declare class InvalidHistoryCursorError extends Error {
|
|
|
667
555
|
constructor(message: string);
|
|
668
556
|
}
|
|
669
557
|
|
|
670
|
-
/**
|
|
671
|
-
* Opt-in debug logging.
|
|
672
|
-
*
|
|
673
|
-
* The SDK is deliberately quiet: before this, `src/` contained no `console.log`
|
|
674
|
-
* at all, only `console.warn`/`console.error` for genuine faults. That is worth
|
|
675
|
-
* preserving — this runs inside every partner's app, on every user's connect, so
|
|
676
|
-
* unconditional chatter would land in end users' consoles forever.
|
|
677
|
-
*
|
|
678
|
-
* Two ways to turn it on:
|
|
679
|
-
*
|
|
680
|
-
* 1. From the app: new OwneySDK({ apiKey, debug: true })
|
|
681
|
-
* 2. From devtools, live: globalThis.__OWNEY_DEBUG__ = true
|
|
682
|
-
*
|
|
683
|
-
* (2) is the useful one when diagnosing something on an already-deployed app:
|
|
684
|
-
* the flag is read on every call, not captured once, so flipping it in the
|
|
685
|
-
* console takes effect on the next action without a rebuild or a republish.
|
|
686
|
-
*/
|
|
687
|
-
declare global {
|
|
688
|
-
var __OWNEY_DEBUG__: boolean | undefined;
|
|
689
|
-
}
|
|
690
|
-
/** Enable/disable debug logging programmatically. */
|
|
691
|
-
declare function setOwneyDebug(enabled: boolean): void;
|
|
692
|
-
|
|
693
558
|
type OwneySIWXConfig = {
|
|
694
559
|
/** Owney/Zyfai API key — same value passed to `new OwneySDK({ apiKey })`. */
|
|
695
560
|
apiKey: string;
|
|
@@ -703,4 +568,4 @@ type OwneySIWXConfig = {
|
|
|
703
568
|
*/
|
|
704
569
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
705
570
|
|
|
706
|
-
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, AllocationApyOptions, ApyByChainAndAsset, ApyHistoryPoint, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, InvalidHistoryCursorError, NotConnectedError, OwneyAccountApy, OwneyAgentApy, OwneyAgentHistory, OwneyAllocationApy, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneyPosition, OwneySDK, OwneySDKConfig, OwneySIWXConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions, createOwneySIWX
|
|
571
|
+
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 };
|