@owney/sdk 0.6.9-beta.0 → 0.6.9-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/dist/index.cjs +239 -606
- package/dist/index.d.cts +41 -19
- package/dist/index.d.ts +41 -19
- package/dist/index.js +224 -101
- package/package.json +1 -3
- package/dist/chunk-GMNQBWUB.js +0 -55
- package/dist/surfliquid.agent-OMOYXWLP.js +0 -385
package/dist/index.d.cts
CHANGED
|
@@ -34,7 +34,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
|
34
34
|
type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
|
|
35
35
|
type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
|
|
36
36
|
|
|
37
|
-
type AgentId = "zyfai" | "sail"
|
|
37
|
+
type AgentId = "zyfai" | "sail";
|
|
38
38
|
type Asset = string;
|
|
39
39
|
type AgentSupportedAsset = {
|
|
40
40
|
readonly symbol: string;
|
|
@@ -101,6 +101,16 @@ type DepositOptions = {
|
|
|
101
101
|
onApproved?: () => void;
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* The organization's agent execution policy, or null when the partner has never
|
|
106
|
+
* configured one — in which case the agents leave the user's profile alone.
|
|
107
|
+
* Currently capital splitting only (ROUT-229).
|
|
108
|
+
*/
|
|
109
|
+
type OrgAgentConfig = {
|
|
110
|
+
splittingMode: "none" | "automatic" | "force";
|
|
111
|
+
minSplits: number | null;
|
|
112
|
+
};
|
|
113
|
+
|
|
104
114
|
interface OwneyDepositResult {
|
|
105
115
|
txHash: string;
|
|
106
116
|
smartWallet: string;
|
|
@@ -108,12 +118,6 @@ interface OwneyDepositResult {
|
|
|
108
118
|
}
|
|
109
119
|
interface OwneyMultiDepositResult {
|
|
110
120
|
agentResults: Record<string, OwneyDepositResult>;
|
|
111
|
-
/**
|
|
112
|
-
* Per-agent failure messages for agents that errored during a diversified
|
|
113
|
-
* deposit. Present only when at least one (but not all) agents failed —
|
|
114
|
-
* the deposit is partial, not total. Omitted when every agent succeeded.
|
|
115
|
-
*/
|
|
116
|
-
agentErrors?: Record<string, string>;
|
|
117
121
|
}
|
|
118
122
|
interface AgentWithdrawResult {
|
|
119
123
|
txHash?: string;
|
|
@@ -281,6 +285,19 @@ interface IAgent {
|
|
|
281
285
|
readonly supportedAssets: readonly AgentSupportedAssets[];
|
|
282
286
|
disconnect(): Promise<void>;
|
|
283
287
|
activateAgent(state: ConnectionState, chainId: number): Promise<void>;
|
|
288
|
+
/**
|
|
289
|
+
* Apply the organization's agent policy to this user's account.
|
|
290
|
+
*
|
|
291
|
+
* Optional: an agent that has no equivalent knob simply omits it, which is why
|
|
292
|
+
* this is not part of `activateAgent`'s signature. Declared on the interface
|
|
293
|
+
* rather than only on ZyfaiAgent so the contract stays agent-neutral — the
|
|
294
|
+
* ticket asks for a design that can also cover Surf, which has no adapter yet.
|
|
295
|
+
*
|
|
296
|
+
* Implementations must be **non-fatal**: this runs during activation as a side
|
|
297
|
+
* effect, so a failure has to leave the user connected and their profile
|
|
298
|
+
* unchanged rather than break the connect.
|
|
299
|
+
*/
|
|
300
|
+
applyOrgPolicy?(state: ConnectionState, chainId: number, policy: OrgAgentConfig): Promise<void>;
|
|
284
301
|
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
285
302
|
withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
|
|
286
303
|
getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
|
|
@@ -324,6 +341,8 @@ declare class OwneySDK {
|
|
|
324
341
|
private disabledAgents;
|
|
325
342
|
private state;
|
|
326
343
|
private apiKey;
|
|
344
|
+
private orgAgentConfig;
|
|
345
|
+
private orgAgentConfigPromise;
|
|
327
346
|
private zyfaiRpcUrls?;
|
|
328
347
|
private routingApiBaseUrl?;
|
|
329
348
|
private referralSource?;
|
|
@@ -372,6 +391,20 @@ declare class OwneySDK {
|
|
|
372
391
|
private getDefaultWethSponsoredCallback;
|
|
373
392
|
private getAgent;
|
|
374
393
|
private getActiveAgents;
|
|
394
|
+
/**
|
|
395
|
+
* Read the org's agent policy once and reuse it. fetchOrgAgentConfig never
|
|
396
|
+
* throws — it degrades to null — so this cannot break activation.
|
|
397
|
+
*/
|
|
398
|
+
private getOrgAgentConfig;
|
|
399
|
+
/**
|
|
400
|
+
* Apply the org policy to one agent, after it has activated.
|
|
401
|
+
*
|
|
402
|
+
* Sequenced after activation rather than alongside it because applying the
|
|
403
|
+
* policy needs the authenticated session activation establishes. Every failure
|
|
404
|
+
* mode is swallowed: a partner's splitting preference is not worth failing a
|
|
405
|
+
* user's connect over.
|
|
406
|
+
*/
|
|
407
|
+
private applyOrgPolicyTo;
|
|
375
408
|
private ensureAgentsInitialized;
|
|
376
409
|
private createAgent;
|
|
377
410
|
/**
|
|
@@ -436,17 +469,6 @@ declare class OwneySDK {
|
|
|
436
469
|
private hasExistingBalance;
|
|
437
470
|
private validateAssetSupport;
|
|
438
471
|
private getEligibleAgents;
|
|
439
|
-
/**
|
|
440
|
-
* Agent ids the routing API provisioned for this org that support the given
|
|
441
|
-
* chain + asset, ordered by preference ({@link AGENT_ELIGIBILITY_ORDER},
|
|
442
|
-
* surfliquid first). Returns `[]` when the org has no compatible agent — never
|
|
443
|
-
* throws on an empty org. Loads agent keys on first call (apiKey only, no
|
|
444
|
-
* wallet), so the UI can resolve which agent to use before the user connects.
|
|
445
|
-
*
|
|
446
|
-
* This is the source of truth for agent availability: an agent appears here
|
|
447
|
-
* iff the routing API returned its key. No per-app feature flags.
|
|
448
|
-
*/
|
|
449
|
-
getEligibleAgentIds(chainId: number, asset: string): Promise<AgentId[]>;
|
|
450
472
|
/**
|
|
451
473
|
* Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
|
|
452
474
|
* Validates that the asset is supported by the target agent(s) on the active chain.
|
|
@@ -542,7 +564,7 @@ declare class OwneySDK {
|
|
|
542
564
|
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
543
565
|
}
|
|
544
566
|
|
|
545
|
-
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" | "
|
|
567
|
+
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";
|
|
546
568
|
declare class OwneyError extends Error {
|
|
547
569
|
readonly code: OwneyErrorCode;
|
|
548
570
|
readonly details?: Record<string, unknown>;
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
|
34
34
|
type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
|
|
35
35
|
type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
|
|
36
36
|
|
|
37
|
-
type AgentId = "zyfai" | "sail"
|
|
37
|
+
type AgentId = "zyfai" | "sail";
|
|
38
38
|
type Asset = string;
|
|
39
39
|
type AgentSupportedAsset = {
|
|
40
40
|
readonly symbol: string;
|
|
@@ -101,6 +101,16 @@ type DepositOptions = {
|
|
|
101
101
|
onApproved?: () => void;
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* The organization's agent execution policy, or null when the partner has never
|
|
106
|
+
* configured one — in which case the agents leave the user's profile alone.
|
|
107
|
+
* Currently capital splitting only (ROUT-229).
|
|
108
|
+
*/
|
|
109
|
+
type OrgAgentConfig = {
|
|
110
|
+
splittingMode: "none" | "automatic" | "force";
|
|
111
|
+
minSplits: number | null;
|
|
112
|
+
};
|
|
113
|
+
|
|
104
114
|
interface OwneyDepositResult {
|
|
105
115
|
txHash: string;
|
|
106
116
|
smartWallet: string;
|
|
@@ -108,12 +118,6 @@ interface OwneyDepositResult {
|
|
|
108
118
|
}
|
|
109
119
|
interface OwneyMultiDepositResult {
|
|
110
120
|
agentResults: Record<string, OwneyDepositResult>;
|
|
111
|
-
/**
|
|
112
|
-
* Per-agent failure messages for agents that errored during a diversified
|
|
113
|
-
* deposit. Present only when at least one (but not all) agents failed —
|
|
114
|
-
* the deposit is partial, not total. Omitted when every agent succeeded.
|
|
115
|
-
*/
|
|
116
|
-
agentErrors?: Record<string, string>;
|
|
117
121
|
}
|
|
118
122
|
interface AgentWithdrawResult {
|
|
119
123
|
txHash?: string;
|
|
@@ -281,6 +285,19 @@ interface IAgent {
|
|
|
281
285
|
readonly supportedAssets: readonly AgentSupportedAssets[];
|
|
282
286
|
disconnect(): Promise<void>;
|
|
283
287
|
activateAgent(state: ConnectionState, chainId: number): Promise<void>;
|
|
288
|
+
/**
|
|
289
|
+
* Apply the organization's agent policy to this user's account.
|
|
290
|
+
*
|
|
291
|
+
* Optional: an agent that has no equivalent knob simply omits it, which is why
|
|
292
|
+
* this is not part of `activateAgent`'s signature. Declared on the interface
|
|
293
|
+
* rather than only on ZyfaiAgent so the contract stays agent-neutral — the
|
|
294
|
+
* ticket asks for a design that can also cover Surf, which has no adapter yet.
|
|
295
|
+
*
|
|
296
|
+
* Implementations must be **non-fatal**: this runs during activation as a side
|
|
297
|
+
* effect, so a failure has to leave the user connected and their profile
|
|
298
|
+
* unchanged rather than break the connect.
|
|
299
|
+
*/
|
|
300
|
+
applyOrgPolicy?(state: ConnectionState, chainId: number, policy: OrgAgentConfig): Promise<void>;
|
|
284
301
|
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
285
302
|
withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
|
|
286
303
|
getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
|
|
@@ -324,6 +341,8 @@ declare class OwneySDK {
|
|
|
324
341
|
private disabledAgents;
|
|
325
342
|
private state;
|
|
326
343
|
private apiKey;
|
|
344
|
+
private orgAgentConfig;
|
|
345
|
+
private orgAgentConfigPromise;
|
|
327
346
|
private zyfaiRpcUrls?;
|
|
328
347
|
private routingApiBaseUrl?;
|
|
329
348
|
private referralSource?;
|
|
@@ -372,6 +391,20 @@ declare class OwneySDK {
|
|
|
372
391
|
private getDefaultWethSponsoredCallback;
|
|
373
392
|
private getAgent;
|
|
374
393
|
private getActiveAgents;
|
|
394
|
+
/**
|
|
395
|
+
* Read the org's agent policy once and reuse it. fetchOrgAgentConfig never
|
|
396
|
+
* throws — it degrades to null — so this cannot break activation.
|
|
397
|
+
*/
|
|
398
|
+
private getOrgAgentConfig;
|
|
399
|
+
/**
|
|
400
|
+
* Apply the org policy to one agent, after it has activated.
|
|
401
|
+
*
|
|
402
|
+
* Sequenced after activation rather than alongside it because applying the
|
|
403
|
+
* policy needs the authenticated session activation establishes. Every failure
|
|
404
|
+
* mode is swallowed: a partner's splitting preference is not worth failing a
|
|
405
|
+
* user's connect over.
|
|
406
|
+
*/
|
|
407
|
+
private applyOrgPolicyTo;
|
|
375
408
|
private ensureAgentsInitialized;
|
|
376
409
|
private createAgent;
|
|
377
410
|
/**
|
|
@@ -436,17 +469,6 @@ declare class OwneySDK {
|
|
|
436
469
|
private hasExistingBalance;
|
|
437
470
|
private validateAssetSupport;
|
|
438
471
|
private getEligibleAgents;
|
|
439
|
-
/**
|
|
440
|
-
* Agent ids the routing API provisioned for this org that support the given
|
|
441
|
-
* chain + asset, ordered by preference ({@link AGENT_ELIGIBILITY_ORDER},
|
|
442
|
-
* surfliquid first). Returns `[]` when the org has no compatible agent — never
|
|
443
|
-
* throws on an empty org. Loads agent keys on first call (apiKey only, no
|
|
444
|
-
* wallet), so the UI can resolve which agent to use before the user connects.
|
|
445
|
-
*
|
|
446
|
-
* This is the source of truth for agent availability: an agent appears here
|
|
447
|
-
* iff the routing API returned its key. No per-app feature flags.
|
|
448
|
-
*/
|
|
449
|
-
getEligibleAgentIds(chainId: number, asset: string): Promise<AgentId[]>;
|
|
450
472
|
/**
|
|
451
473
|
* Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
|
|
452
474
|
* Validates that the asset is supported by the target agent(s) on the active chain.
|
|
@@ -542,7 +564,7 @@ declare class OwneySDK {
|
|
|
542
564
|
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
543
565
|
}
|
|
544
566
|
|
|
545
|
-
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" | "
|
|
567
|
+
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";
|
|
546
568
|
declare class OwneyError extends Error {
|
|
547
569
|
readonly code: OwneyErrorCode;
|
|
548
570
|
readonly details?: Record<string, unknown>;
|