@owney/sdk 0.7.25-beta.1 → 0.7.25-beta.10
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 +79 -14
- package/dist/index.cjs +971 -290
- package/dist/index.d.cts +228 -157
- package/dist/index.d.ts +228 -157
- package/dist/index.js +917 -233
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { Hex } from 'viem';
|
|
2
2
|
import { SIWXConfig } from '@reown/appkit-controllers';
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
type RpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
|
|
5
|
+
/** @deprecated Use RpcUrlsConfig. */
|
|
6
|
+
type ZyfaiRpcUrlsConfig = RpcUrlsConfig;
|
|
5
7
|
interface OwneySDKConfig {
|
|
6
8
|
apiKey: string;
|
|
9
|
+
/**
|
|
10
|
+
* Optional per-chain RPC overrides used for application-owned reads and
|
|
11
|
+
* transaction receipt polling. Missing chains use the Owney routing API's
|
|
12
|
+
* read-only RPC proxy. No upstream RPC credentials are included in the SDK.
|
|
13
|
+
* Wallet providers remain responsible for account access, chain switching,
|
|
14
|
+
* signatures, and transaction submission.
|
|
15
|
+
*/
|
|
16
|
+
rpcUrls?: RpcUrlsConfig;
|
|
7
17
|
/**
|
|
8
18
|
* Optional per-chain RPC overrides for Zyfai SDK network calls.
|
|
9
19
|
* Example: { 8453: "https://...", 42161: "https://..." }
|
|
20
|
+
* @deprecated Use rpcUrls so every agent shares the same read transport.
|
|
10
21
|
*/
|
|
11
22
|
zyfaiRpcUrls?: ZyfaiRpcUrlsConfig;
|
|
12
23
|
/** Optional Owney Yieldseeker proxy base URL override for integration tests. */
|
|
@@ -15,9 +26,9 @@ interface OwneySDKConfig {
|
|
|
15
26
|
yieldseekerSiweOrigin?: string;
|
|
16
27
|
/**
|
|
17
28
|
* Optional override for the Owney routing API base URL used by all routing
|
|
18
|
-
* calls
|
|
19
|
-
*
|
|
20
|
-
*
|
|
29
|
+
* calls. RPC proxy requests use OWNEY_ROUTING_API_BASE_URL when this is
|
|
30
|
+
* omitted; without either value, all rpcUrls must be configured.
|
|
31
|
+
* Set this to a local/staging routing API when testing sponsor changes.
|
|
21
32
|
*/
|
|
22
33
|
routingApiBaseUrl?: string;
|
|
23
34
|
/**
|
|
@@ -59,148 +70,6 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
|
59
70
|
type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
|
|
60
71
|
type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
|
|
61
72
|
|
|
62
|
-
type AgentId = "zyfai" | "yieldseeker";
|
|
63
|
-
type Asset = string;
|
|
64
|
-
type AgentSupportedAsset = {
|
|
65
|
-
readonly symbol: string;
|
|
66
|
-
readonly minDepositAmount: string;
|
|
67
|
-
};
|
|
68
|
-
type AgentSupportedAssets = {
|
|
69
|
-
readonly chainId: number;
|
|
70
|
-
readonly chain?: string;
|
|
71
|
-
readonly assets: readonly AgentSupportedAsset[];
|
|
72
|
-
};
|
|
73
|
-
type AvailableAgent = {
|
|
74
|
-
id: AgentId;
|
|
75
|
-
isEnabled: boolean;
|
|
76
|
-
supportedChainIds: readonly number[];
|
|
77
|
-
supportedAssets: readonly AgentSupportedAssets[];
|
|
78
|
-
};
|
|
79
|
-
type AvailableAgentsOptions = {
|
|
80
|
-
chainId?: number;
|
|
81
|
-
asset?: Asset;
|
|
82
|
-
/** Disabled agents are omitted by default because they cannot accept funds. */
|
|
83
|
-
includeDisabled?: boolean;
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* A lookback window for any "last N days" read — the APY series, the daily
|
|
87
|
-
* earnings series. Named for the window itself, so nothing borrows the APY's
|
|
88
|
-
* name to ask for something else.
|
|
89
|
-
*/
|
|
90
|
-
type LookbackDays = "7D" | "14D" | "30D";
|
|
91
|
-
/** Kept so existing callers keep compiling. Prefer `LookbackDays`. */
|
|
92
|
-
type DailyApyDays = LookbackDays;
|
|
93
|
-
type HistoryFilters = {
|
|
94
|
-
fromDate?: string;
|
|
95
|
-
toDate?: string;
|
|
96
|
-
/** Max entries returned per call. Defaults to 10. */
|
|
97
|
-
limit?: number;
|
|
98
|
-
/** Opaque cursor returned by a previous getHistory call. */
|
|
99
|
-
cursor?: string;
|
|
100
|
-
/**
|
|
101
|
-
* Optional asset symbol (e.g. "USDC", "WETH") to scope the history to a
|
|
102
|
-
* single asset. Without it the page blends every asset on the chain, so a
|
|
103
|
-
* consumer showing one asset at a time has to filter client-side — and a
|
|
104
|
-
* page whose entries all belong to the *other* asset then renders empty
|
|
105
|
-
* even though matching entries exist further back. Agents whose backends
|
|
106
|
-
* cannot filter by asset ignore this and return the whole chain's history.
|
|
107
|
-
*/
|
|
108
|
-
tokenSymbol?: string;
|
|
109
|
-
};
|
|
110
|
-
type HistoryOptions = {
|
|
111
|
-
agentId?: AgentId;
|
|
112
|
-
filters?: HistoryFilters;
|
|
113
|
-
};
|
|
114
|
-
type WithdrawOptions = {
|
|
115
|
-
asset: Asset;
|
|
116
|
-
amount?: string;
|
|
117
|
-
agentId?: AgentId;
|
|
118
|
-
};
|
|
119
|
-
type AccountApyOptions = {
|
|
120
|
-
agentId?: AgentId;
|
|
121
|
-
days: LookbackDays;
|
|
122
|
-
/**
|
|
123
|
-
* Optional asset symbol (e.g. "USDC", "WETH") to scope the daily APY series
|
|
124
|
-
* to a specific asset on the active chain. Without it the series blends every
|
|
125
|
-
* position on the chain, so two assets sharing a chain (USDC and WETH on
|
|
126
|
-
* Base/Arbitrum) would render one merged line. Agents whose backends do not
|
|
127
|
-
* expose per-asset positions ignore this. (ROUT-186)
|
|
128
|
-
*/
|
|
129
|
-
tokenSymbol?: string;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Options for the daily earnings series. Same shape as `AccountApyOptions` and
|
|
133
|
-
* deliberately its own type: the two reads answer different questions and are
|
|
134
|
-
* free to diverge.
|
|
135
|
-
*/
|
|
136
|
-
type DailyEarningsOptions = {
|
|
137
|
-
agentId?: AgentId;
|
|
138
|
-
days: LookbackDays;
|
|
139
|
-
/**
|
|
140
|
-
* Optional asset symbol (e.g. "USDC", "WETH") scoping the series to one
|
|
141
|
-
* asset on the active chain.
|
|
142
|
-
*/
|
|
143
|
-
tokenSymbol?: string;
|
|
144
|
-
};
|
|
145
|
-
type AllocationApyOptions = {
|
|
146
|
-
agentId?: AgentId;
|
|
147
|
-
};
|
|
148
|
-
type AgentsApyOptions = {
|
|
149
|
-
agentId?: AgentId;
|
|
150
|
-
days: DailyApyDays;
|
|
151
|
-
/**
|
|
152
|
-
* Optional asset symbol (e.g. "USDC", "WETH") to scope the APY to a
|
|
153
|
-
* specific asset+chain. Ignored by agents whose backends do not yet
|
|
154
|
-
* support per-asset APY.
|
|
155
|
-
*/
|
|
156
|
-
tokenSymbol?: string;
|
|
157
|
-
/**
|
|
158
|
-
* Optional chain id for per-asset APY lookups. Typically paired with
|
|
159
|
-
* `tokenSymbol`.
|
|
160
|
-
*/
|
|
161
|
-
chainId?: number;
|
|
162
|
-
};
|
|
163
|
-
type DepositOptions = {
|
|
164
|
-
amount: string;
|
|
165
|
-
asset: Asset;
|
|
166
|
-
depositCallback?: DepositCallback;
|
|
167
|
-
agentId?: AgentId;
|
|
168
|
-
onApproved?: () => void;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
|
|
173
|
-
* verbatim — matched case-sensitively by customizeBatch, and an unrecognised
|
|
174
|
-
* name makes Zyfai's rebalance engine skip the whole protocol, so these strings
|
|
175
|
-
* must not be normalised anywhere.
|
|
176
|
-
*
|
|
177
|
-
* An empty array means "no usable pools on this chain".
|
|
178
|
-
*/
|
|
179
|
-
type OrgPoolSelection = {
|
|
180
|
-
protocolId: string;
|
|
181
|
-
chainId: number;
|
|
182
|
-
pools: string[];
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
|
|
186
|
-
* narrowed appear. Optional so an older routing API, which does not return the
|
|
187
|
-
* field, still parses; undefined and null both mean "change nothing".
|
|
188
|
-
*/
|
|
189
|
-
type OrgPoolPolicy = {
|
|
190
|
-
autoApproveProtocols: boolean;
|
|
191
|
-
autoApprovePools: boolean;
|
|
192
|
-
selections: OrgPoolSelection[];
|
|
193
|
-
};
|
|
194
|
-
/**
|
|
195
|
-
* The organization's agent execution policy, or null when the partner has never
|
|
196
|
-
* configured one — in which case the agents leave the user's profile alone.
|
|
197
|
-
*/
|
|
198
|
-
type OrgAgentConfig = {
|
|
199
|
-
splittingMode: "none" | "automatic" | "force";
|
|
200
|
-
minSplits: number | null;
|
|
201
|
-
poolPolicy?: OrgPoolPolicy | null;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
73
|
interface OwneyDepositResult {
|
|
205
74
|
txHash: string;
|
|
206
75
|
smartWallet: string;
|
|
@@ -237,8 +106,10 @@ interface OwneyPosition {
|
|
|
237
106
|
pool?: string;
|
|
238
107
|
asset: string;
|
|
239
108
|
amount: string;
|
|
240
|
-
/**
|
|
109
|
+
/** Provider-native raw quantity; may represent vault shares, not the underlying asset. */
|
|
241
110
|
amountRaw?: string;
|
|
111
|
+
/** Withdrawable underlying asset amount in that asset's smallest units. */
|
|
112
|
+
withdrawableAmountRaw?: string;
|
|
242
113
|
apy?: number;
|
|
243
114
|
tvl?: number;
|
|
244
115
|
/** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
|
|
@@ -313,6 +184,10 @@ interface AgentEarnings {
|
|
|
313
184
|
interface OwneyEarnings {
|
|
314
185
|
totalEarnings: string;
|
|
315
186
|
agentEarnings: Record<AgentId, AgentEarnings>;
|
|
187
|
+
/** Per-agent failures when an aggregate read returned a partial result. */
|
|
188
|
+
agentErrors?: Partial<Record<AgentId, string>>;
|
|
189
|
+
/** Absolute provider cooldown deadlines (Unix milliseconds). */
|
|
190
|
+
agentRetryAt?: Partial<Record<AgentId, number>>;
|
|
316
191
|
}
|
|
317
192
|
type ApyByChainAndAsset = Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
|
|
318
193
|
/** A single day's net APY for the connected account, as a percentage number. */
|
|
@@ -471,6 +346,150 @@ interface AccountDailyEarnings {
|
|
|
471
346
|
assets: AssetDailyEarnings[];
|
|
472
347
|
}
|
|
473
348
|
|
|
349
|
+
type AgentId = "zyfai" | "yieldseeker";
|
|
350
|
+
type Asset = string;
|
|
351
|
+
type AgentSupportedAsset = {
|
|
352
|
+
readonly symbol: string;
|
|
353
|
+
readonly minDepositAmount: string;
|
|
354
|
+
};
|
|
355
|
+
type AgentSupportedAssets = {
|
|
356
|
+
readonly chainId: number;
|
|
357
|
+
readonly chain?: string;
|
|
358
|
+
readonly assets: readonly AgentSupportedAsset[];
|
|
359
|
+
};
|
|
360
|
+
type AvailableAgent = {
|
|
361
|
+
id: AgentId;
|
|
362
|
+
isEnabled: boolean;
|
|
363
|
+
supportedChainIds: readonly number[];
|
|
364
|
+
supportedAssets: readonly AgentSupportedAssets[];
|
|
365
|
+
};
|
|
366
|
+
type AvailableAgentsOptions = {
|
|
367
|
+
chainId?: number;
|
|
368
|
+
asset?: Asset;
|
|
369
|
+
/** Disabled agents are omitted by default because they cannot accept funds. */
|
|
370
|
+
includeDisabled?: boolean;
|
|
371
|
+
};
|
|
372
|
+
/**
|
|
373
|
+
* A lookback window for any "last N days" read — the APY series, the daily
|
|
374
|
+
* earnings series. Named for the window itself, so nothing borrows the APY's
|
|
375
|
+
* name to ask for something else.
|
|
376
|
+
*/
|
|
377
|
+
type LookbackDays = "7D" | "14D" | "30D";
|
|
378
|
+
/** Kept so existing callers keep compiling. Prefer `LookbackDays`. */
|
|
379
|
+
type DailyApyDays = LookbackDays;
|
|
380
|
+
type HistoryFilters = {
|
|
381
|
+
fromDate?: string;
|
|
382
|
+
toDate?: string;
|
|
383
|
+
/** Max entries returned per call. Defaults to 10. */
|
|
384
|
+
limit?: number;
|
|
385
|
+
/** Opaque cursor returned by a previous getHistory call. */
|
|
386
|
+
cursor?: string;
|
|
387
|
+
/**
|
|
388
|
+
* Optional asset symbol (e.g. "USDC", "WETH") to scope the history to a
|
|
389
|
+
* single asset. Without it the page blends every asset on the chain, so a
|
|
390
|
+
* consumer showing one asset at a time has to filter client-side — and a
|
|
391
|
+
* page whose entries all belong to the *other* asset then renders empty
|
|
392
|
+
* even though matching entries exist further back. Agents whose backends
|
|
393
|
+
* cannot filter by asset ignore this and return the whole chain's history.
|
|
394
|
+
*/
|
|
395
|
+
tokenSymbol?: string;
|
|
396
|
+
};
|
|
397
|
+
type HistoryOptions = {
|
|
398
|
+
agentId?: AgentId;
|
|
399
|
+
filters?: HistoryFilters;
|
|
400
|
+
};
|
|
401
|
+
type WithdrawOptions = {
|
|
402
|
+
asset: Asset;
|
|
403
|
+
amount?: string;
|
|
404
|
+
agentId?: AgentId;
|
|
405
|
+
/** Called after each agent returns; callback failures never change a financial result. */
|
|
406
|
+
onAgentResult?: (agentId: AgentId, result: AgentWithdrawResult) => void;
|
|
407
|
+
};
|
|
408
|
+
type AccountApyOptions = {
|
|
409
|
+
agentId?: AgentId;
|
|
410
|
+
days: LookbackDays;
|
|
411
|
+
/**
|
|
412
|
+
* Optional asset symbol (e.g. "USDC", "WETH") to scope the daily APY series
|
|
413
|
+
* to a specific asset on the active chain. Without it the series blends every
|
|
414
|
+
* position on the chain, so two assets sharing a chain (USDC and WETH on
|
|
415
|
+
* Base/Arbitrum) would render one merged line. Agents whose backends do not
|
|
416
|
+
* expose per-asset positions ignore this. (ROUT-186)
|
|
417
|
+
*/
|
|
418
|
+
tokenSymbol?: string;
|
|
419
|
+
};
|
|
420
|
+
/**
|
|
421
|
+
* Options for the daily earnings series. Same shape as `AccountApyOptions` and
|
|
422
|
+
* deliberately its own type: the two reads answer different questions and are
|
|
423
|
+
* free to diverge.
|
|
424
|
+
*/
|
|
425
|
+
type DailyEarningsOptions = {
|
|
426
|
+
agentId?: AgentId;
|
|
427
|
+
days: LookbackDays;
|
|
428
|
+
/**
|
|
429
|
+
* Optional asset symbol (e.g. "USDC", "WETH") scoping the series to one
|
|
430
|
+
* asset on the active chain.
|
|
431
|
+
*/
|
|
432
|
+
tokenSymbol?: string;
|
|
433
|
+
};
|
|
434
|
+
type AllocationApyOptions = {
|
|
435
|
+
agentId?: AgentId;
|
|
436
|
+
};
|
|
437
|
+
type AgentsApyOptions = {
|
|
438
|
+
agentId?: AgentId;
|
|
439
|
+
days: DailyApyDays;
|
|
440
|
+
/**
|
|
441
|
+
* Optional asset symbol (e.g. "USDC", "WETH") to scope the APY to a
|
|
442
|
+
* specific asset+chain. Ignored by agents whose backends do not yet
|
|
443
|
+
* support per-asset APY.
|
|
444
|
+
*/
|
|
445
|
+
tokenSymbol?: string;
|
|
446
|
+
/**
|
|
447
|
+
* Optional chain id for per-asset APY lookups. Typically paired with
|
|
448
|
+
* `tokenSymbol`.
|
|
449
|
+
*/
|
|
450
|
+
chainId?: number;
|
|
451
|
+
};
|
|
452
|
+
type DepositOptions = {
|
|
453
|
+
amount: string;
|
|
454
|
+
asset: Asset;
|
|
455
|
+
depositCallback?: DepositCallback;
|
|
456
|
+
agentId?: AgentId;
|
|
457
|
+
onApproved?: () => void;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
|
|
462
|
+
* verbatim — matched case-sensitively by customizeBatch, and an unrecognised
|
|
463
|
+
* name makes Zyfai's rebalance engine skip the whole protocol, so these strings
|
|
464
|
+
* must not be normalised anywhere.
|
|
465
|
+
*
|
|
466
|
+
* An empty array means "no usable pools on this chain".
|
|
467
|
+
*/
|
|
468
|
+
type OrgPoolSelection = {
|
|
469
|
+
protocolId: string;
|
|
470
|
+
chainId: number;
|
|
471
|
+
pools: string[];
|
|
472
|
+
};
|
|
473
|
+
/**
|
|
474
|
+
* The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
|
|
475
|
+
* narrowed appear. Optional so an older routing API, which does not return the
|
|
476
|
+
* field, still parses; undefined and null both mean "change nothing".
|
|
477
|
+
*/
|
|
478
|
+
type OrgPoolPolicy = {
|
|
479
|
+
autoApproveProtocols: boolean;
|
|
480
|
+
autoApprovePools: boolean;
|
|
481
|
+
selections: OrgPoolSelection[];
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
* The organization's agent execution policy, or null when the partner has never
|
|
485
|
+
* configured one — in which case the agents leave the user's profile alone.
|
|
486
|
+
*/
|
|
487
|
+
type OrgAgentConfig = {
|
|
488
|
+
splittingMode: "none" | "automatic" | "force";
|
|
489
|
+
minSplits: number | null;
|
|
490
|
+
poolPolicy?: OrgPoolPolicy | null;
|
|
491
|
+
};
|
|
492
|
+
|
|
474
493
|
type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
|
|
475
494
|
interface IAgent {
|
|
476
495
|
readonly id: string;
|
|
@@ -483,6 +502,12 @@ interface IAgent {
|
|
|
483
502
|
* withdrawal planning must add matching position amounts.
|
|
484
503
|
*/
|
|
485
504
|
readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
|
|
505
|
+
/**
|
|
506
|
+
* Whether a withdrawal requires an owner-approved wallet transaction.
|
|
507
|
+
* Aggregate withdrawals run these agents before relayer-only agents so a
|
|
508
|
+
* rejected wallet request cannot happen after another leg has committed.
|
|
509
|
+
*/
|
|
510
|
+
readonly withdrawalRequiresWalletApproval?: boolean;
|
|
486
511
|
disconnect(): Promise<void>;
|
|
487
512
|
activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
|
|
488
513
|
/**
|
|
@@ -554,6 +579,7 @@ declare class OwneySDK {
|
|
|
554
579
|
private apiKey;
|
|
555
580
|
private orgAgentConfig;
|
|
556
581
|
private orgAgentConfigPromise;
|
|
582
|
+
private rpcUrls?;
|
|
557
583
|
private zyfaiRpcUrls?;
|
|
558
584
|
private yieldseekerApiBaseUrl?;
|
|
559
585
|
private yieldseekerSiweOrigin?;
|
|
@@ -593,6 +619,7 @@ declare class OwneySDK {
|
|
|
593
619
|
private requireState;
|
|
594
620
|
private requireChainId;
|
|
595
621
|
private requireConnectedProvider;
|
|
622
|
+
private getPaidRpcClient;
|
|
596
623
|
/** Builds the default USDC batch callback for the connected wallet. */
|
|
597
624
|
private getDefaultSponsoredCallback;
|
|
598
625
|
/** Builds the wallet-native sponsored calls callback for compatible paymasters. */
|
|
@@ -676,10 +703,12 @@ declare class OwneySDK {
|
|
|
676
703
|
* Invokes `agent.deposit` with the resolved sponsored callback, composing
|
|
677
704
|
* two independent auto-recovery mechanisms:
|
|
678
705
|
*
|
|
679
|
-
* 1. Missing Permit2 allowance
|
|
680
|
-
* callback and the attempt fails with
|
|
681
|
-
*
|
|
682
|
-
*
|
|
706
|
+
* 1. Missing Permit2 allowance outside the atomic Base-USDC path: when the
|
|
707
|
+
* app did not supply its own callback and the attempt fails with
|
|
708
|
+
* `PERMIT2_APPROVAL_REQUIRED`, this is the wallet's first Permit2 deposit
|
|
709
|
+
* for that token. Base USDC bundles a gasless ERC-2612 approval inside
|
|
710
|
+
* its sponsored deposit and never reaches this branch. Other tokens send
|
|
711
|
+
* the one-time user-paid Permit2 approval via `approvePermit2()` and
|
|
683
712
|
* retry the SAME sponsored attempt once. Bounded to one approval attempt
|
|
684
713
|
* per call so a wallet/agent that keeps reporting the allowance as
|
|
685
714
|
* missing can't loop forever. If `approvePermit2()` itself throws (e.g.
|
|
@@ -711,6 +740,13 @@ declare class OwneySDK {
|
|
|
711
740
|
private hasExistingBalance;
|
|
712
741
|
private validateAssetSupport;
|
|
713
742
|
private getEligibleAgents;
|
|
743
|
+
/**
|
|
744
|
+
* Run owner-approved withdrawals before relayer-only withdrawals. Wallet
|
|
745
|
+
* approval is the only point at which the user can cancel the aggregate
|
|
746
|
+
* operation, so no relayer leg should commit before it has completed.
|
|
747
|
+
*/
|
|
748
|
+
private orderAgentsForWithdrawal;
|
|
749
|
+
private isUserRejectedWithdrawal;
|
|
714
750
|
/**
|
|
715
751
|
* Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
|
|
716
752
|
* Validates that the asset is supported by the target agent(s) on the active chain.
|
|
@@ -738,6 +774,7 @@ declare class OwneySDK {
|
|
|
738
774
|
* Agents without a refresh capability fall back to their current snapshot.
|
|
739
775
|
*/
|
|
740
776
|
refreshEarnings(agentId?: AgentId): Promise<OwneyEarnings | AgentEarnings>;
|
|
777
|
+
private aggregateEarnings;
|
|
741
778
|
/**
|
|
742
779
|
* Get the weighted APY for the user's account over a time period.
|
|
743
780
|
* When querying all agents, the total APY is a balance-weighted average.
|
|
@@ -793,14 +830,16 @@ declare class OwneySDK {
|
|
|
793
830
|
ensureAutoSelectProtocols(asset: "USDC" | "WETH", agentId?: AgentId): Promise<boolean>;
|
|
794
831
|
/**
|
|
795
832
|
* User-paid approval of Permit2 on the selected token for the active chain.
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
833
|
+
* Grants the maximum ERC20 allowance so later deposits do not require another
|
|
834
|
+
* approval. Resolves after one confirmation so the subsequent deposit attempt
|
|
835
|
+
* sees the new allowance. Deposit retries pass their captured chain id so a
|
|
836
|
+
* concurrent activation cannot redirect the approval to another network.
|
|
799
837
|
*
|
|
800
838
|
* @param requiredAmount Raw base-unit amount the pending deposit must cover.
|
|
839
|
+
* @param expectedChainId Chain captured by the deposit that requested approval.
|
|
801
840
|
* @returns the approval transaction hash.
|
|
802
841
|
*/
|
|
803
|
-
approvePermit2(asset?: OwneySupportedTokens, requiredAmount?: bigint): Promise<`0x${string}`>;
|
|
842
|
+
approvePermit2(asset?: OwneySupportedTokens, requiredAmount?: bigint, expectedChainId?: OwneySupportedChainId): Promise<`0x${string}`>;
|
|
804
843
|
/**
|
|
805
844
|
* Get the agent's average APY performance over a time period. Does not require a wallet connection.
|
|
806
845
|
* @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")
|
|
@@ -844,6 +883,8 @@ type YieldseekerAgentOptions = {
|
|
|
844
883
|
baseUrl?: string;
|
|
845
884
|
fetchFn?: YieldseekerFetch;
|
|
846
885
|
auth?: YieldseekerAuthDependencies;
|
|
886
|
+
/** Dedicated read transport; Base is used for receipt polling. */
|
|
887
|
+
rpcUrls?: RpcUrlsConfig;
|
|
847
888
|
/** Test seam for the wallet-submission/receipt boundary. */
|
|
848
889
|
transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
|
|
849
890
|
/** Test seam for transactions submitted outside transactionExecutor. */
|
|
@@ -852,6 +893,7 @@ type YieldseekerAgentOptions = {
|
|
|
852
893
|
declare class YieldseekerAgent implements IAgent {
|
|
853
894
|
readonly id = "yieldseeker";
|
|
854
895
|
readonly balanceComposition: "tokens-plus-positions";
|
|
896
|
+
readonly withdrawalRequiresWalletApproval = true;
|
|
855
897
|
readonly supportedChainIds: readonly [8453];
|
|
856
898
|
readonly supportedAssets: readonly [{
|
|
857
899
|
readonly chainId: 8453;
|
|
@@ -866,14 +908,28 @@ declare class YieldseekerAgent implements IAgent {
|
|
|
866
908
|
}];
|
|
867
909
|
private readonly api;
|
|
868
910
|
private readonly auth;
|
|
911
|
+
private readonly rpcUrls?;
|
|
912
|
+
private receiptClient?;
|
|
869
913
|
private readonly transactionExecutor?;
|
|
870
914
|
private readonly unwindReceiptWaiter?;
|
|
871
915
|
private readonly agentContexts;
|
|
872
916
|
private readonly users;
|
|
873
917
|
private readonly pendingAgents;
|
|
918
|
+
private readonly pendingWalletContexts;
|
|
919
|
+
private readonly readCache;
|
|
920
|
+
private readonly pendingReads;
|
|
921
|
+
private readGeneration;
|
|
922
|
+
private readonly portfolioVersions;
|
|
923
|
+
private readonly snapshotFailures;
|
|
924
|
+
private readonly standardReadFailures;
|
|
925
|
+
private readonly reconcileUntil;
|
|
926
|
+
private readonly activityRefreshUntil;
|
|
927
|
+
private readonly snapshotMovements;
|
|
928
|
+
private readonly movementEpochs;
|
|
874
929
|
private readonly yieldOptions;
|
|
875
930
|
private readonly pendingYieldOptions;
|
|
876
931
|
constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
|
|
932
|
+
private getReceiptClient;
|
|
877
933
|
disconnect(): Promise<void>;
|
|
878
934
|
activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
|
|
879
935
|
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
@@ -887,13 +943,28 @@ declare class YieldseekerAgent implements IAgent {
|
|
|
887
943
|
private loadYieldOptions;
|
|
888
944
|
private userKey;
|
|
889
945
|
private contextKey;
|
|
946
|
+
private assertSession;
|
|
947
|
+
private cachedRead;
|
|
948
|
+
private agentListKey;
|
|
949
|
+
private listAgents;
|
|
950
|
+
private contextForAgent;
|
|
890
951
|
private resolveUser;
|
|
891
952
|
private forgetUser;
|
|
892
953
|
private ensureAgent;
|
|
893
954
|
private findAgent;
|
|
894
955
|
private resolveAgent;
|
|
895
956
|
private loadPortfolio;
|
|
957
|
+
private loadActivityPortfolio;
|
|
958
|
+
private resolvePortfolioContexts;
|
|
959
|
+
private portfolioVersion;
|
|
960
|
+
private portfolioCacheMs;
|
|
961
|
+
private snapshotMovement;
|
|
962
|
+
private advancePortfolioVersion;
|
|
963
|
+
private requestPortfolioSnapshot;
|
|
964
|
+
private portfolioSnapshot;
|
|
896
965
|
private loadPortfolioContext;
|
|
966
|
+
private loadActivityContext;
|
|
967
|
+
private loadPortfolioParts;
|
|
897
968
|
private deployAgent;
|
|
898
969
|
private refreshSnapshotAfterMovement;
|
|
899
970
|
private agentPath;
|
|
@@ -913,7 +984,7 @@ declare class YieldseekerAgent implements IAgent {
|
|
|
913
984
|
private invalidResponse;
|
|
914
985
|
}
|
|
915
986
|
|
|
916
|
-
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_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "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" | "AGENT_RATE_LIMITED" | "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";
|
|
987
|
+
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_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "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" | "AGENT_RATE_LIMITED" | "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" | "EARNINGS_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
917
988
|
declare class OwneyError extends Error {
|
|
918
989
|
readonly code: OwneyErrorCode;
|
|
919
990
|
readonly details?: Record<string, unknown>;
|
|
@@ -979,4 +1050,4 @@ type OwneySIWXConfig = {
|
|
|
979
1050
|
*/
|
|
980
1051
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
981
1052
|
|
|
982
|
-
export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions, YieldseekerAgent, createOwneySIWX, setOwneyDebug };
|
|
1053
|
+
export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type RpcUrlsConfig, type WithdrawOptions, YieldseekerAgent, type ZyfaiRpcUrlsConfig, createOwneySIWX, setOwneyDebug };
|