@owney/sdk 0.7.25-beta.6 → 0.7.25-beta.8
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 +17 -23
- package/dist/index.cjs +356 -153
- package/dist/index.d.cts +166 -147
- package/dist/index.d.ts +166 -147
- package/dist/index.js +356 -153
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ interface OwneySDKConfig {
|
|
|
8
8
|
apiKey: string;
|
|
9
9
|
/**
|
|
10
10
|
* Optional per-chain RPC overrides used for application-owned reads and
|
|
11
|
-
* transaction receipt polling. Missing chains use Owney
|
|
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.
|
|
12
13
|
* Wallet providers remain responsible for account access, chain switching,
|
|
13
14
|
* signatures, and transaction submission.
|
|
14
15
|
*/
|
|
@@ -25,9 +26,9 @@ interface OwneySDKConfig {
|
|
|
25
26
|
yieldseekerSiweOrigin?: string;
|
|
26
27
|
/**
|
|
27
28
|
* Optional override for the Owney routing API base URL used by all routing
|
|
28
|
-
* calls
|
|
29
|
-
*
|
|
30
|
-
*
|
|
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.
|
|
31
32
|
*/
|
|
32
33
|
routingApiBaseUrl?: string;
|
|
33
34
|
/**
|
|
@@ -69,148 +70,6 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
|
69
70
|
type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
|
|
70
71
|
type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
|
|
71
72
|
|
|
72
|
-
type AgentId = "zyfai" | "yieldseeker";
|
|
73
|
-
type Asset = string;
|
|
74
|
-
type AgentSupportedAsset = {
|
|
75
|
-
readonly symbol: string;
|
|
76
|
-
readonly minDepositAmount: string;
|
|
77
|
-
};
|
|
78
|
-
type AgentSupportedAssets = {
|
|
79
|
-
readonly chainId: number;
|
|
80
|
-
readonly chain?: string;
|
|
81
|
-
readonly assets: readonly AgentSupportedAsset[];
|
|
82
|
-
};
|
|
83
|
-
type AvailableAgent = {
|
|
84
|
-
id: AgentId;
|
|
85
|
-
isEnabled: boolean;
|
|
86
|
-
supportedChainIds: readonly number[];
|
|
87
|
-
supportedAssets: readonly AgentSupportedAssets[];
|
|
88
|
-
};
|
|
89
|
-
type AvailableAgentsOptions = {
|
|
90
|
-
chainId?: number;
|
|
91
|
-
asset?: Asset;
|
|
92
|
-
/** Disabled agents are omitted by default because they cannot accept funds. */
|
|
93
|
-
includeDisabled?: boolean;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* A lookback window for any "last N days" read — the APY series, the daily
|
|
97
|
-
* earnings series. Named for the window itself, so nothing borrows the APY's
|
|
98
|
-
* name to ask for something else.
|
|
99
|
-
*/
|
|
100
|
-
type LookbackDays = "7D" | "14D" | "30D";
|
|
101
|
-
/** Kept so existing callers keep compiling. Prefer `LookbackDays`. */
|
|
102
|
-
type DailyApyDays = LookbackDays;
|
|
103
|
-
type HistoryFilters = {
|
|
104
|
-
fromDate?: string;
|
|
105
|
-
toDate?: string;
|
|
106
|
-
/** Max entries returned per call. Defaults to 10. */
|
|
107
|
-
limit?: number;
|
|
108
|
-
/** Opaque cursor returned by a previous getHistory call. */
|
|
109
|
-
cursor?: string;
|
|
110
|
-
/**
|
|
111
|
-
* Optional asset symbol (e.g. "USDC", "WETH") to scope the history to a
|
|
112
|
-
* single asset. Without it the page blends every asset on the chain, so a
|
|
113
|
-
* consumer showing one asset at a time has to filter client-side — and a
|
|
114
|
-
* page whose entries all belong to the *other* asset then renders empty
|
|
115
|
-
* even though matching entries exist further back. Agents whose backends
|
|
116
|
-
* cannot filter by asset ignore this and return the whole chain's history.
|
|
117
|
-
*/
|
|
118
|
-
tokenSymbol?: string;
|
|
119
|
-
};
|
|
120
|
-
type HistoryOptions = {
|
|
121
|
-
agentId?: AgentId;
|
|
122
|
-
filters?: HistoryFilters;
|
|
123
|
-
};
|
|
124
|
-
type WithdrawOptions = {
|
|
125
|
-
asset: Asset;
|
|
126
|
-
amount?: string;
|
|
127
|
-
agentId?: AgentId;
|
|
128
|
-
};
|
|
129
|
-
type AccountApyOptions = {
|
|
130
|
-
agentId?: AgentId;
|
|
131
|
-
days: LookbackDays;
|
|
132
|
-
/**
|
|
133
|
-
* Optional asset symbol (e.g. "USDC", "WETH") to scope the daily APY series
|
|
134
|
-
* to a specific asset on the active chain. Without it the series blends every
|
|
135
|
-
* position on the chain, so two assets sharing a chain (USDC and WETH on
|
|
136
|
-
* Base/Arbitrum) would render one merged line. Agents whose backends do not
|
|
137
|
-
* expose per-asset positions ignore this. (ROUT-186)
|
|
138
|
-
*/
|
|
139
|
-
tokenSymbol?: string;
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* Options for the daily earnings series. Same shape as `AccountApyOptions` and
|
|
143
|
-
* deliberately its own type: the two reads answer different questions and are
|
|
144
|
-
* free to diverge.
|
|
145
|
-
*/
|
|
146
|
-
type DailyEarningsOptions = {
|
|
147
|
-
agentId?: AgentId;
|
|
148
|
-
days: LookbackDays;
|
|
149
|
-
/**
|
|
150
|
-
* Optional asset symbol (e.g. "USDC", "WETH") scoping the series to one
|
|
151
|
-
* asset on the active chain.
|
|
152
|
-
*/
|
|
153
|
-
tokenSymbol?: string;
|
|
154
|
-
};
|
|
155
|
-
type AllocationApyOptions = {
|
|
156
|
-
agentId?: AgentId;
|
|
157
|
-
};
|
|
158
|
-
type AgentsApyOptions = {
|
|
159
|
-
agentId?: AgentId;
|
|
160
|
-
days: DailyApyDays;
|
|
161
|
-
/**
|
|
162
|
-
* Optional asset symbol (e.g. "USDC", "WETH") to scope the APY to a
|
|
163
|
-
* specific asset+chain. Ignored by agents whose backends do not yet
|
|
164
|
-
* support per-asset APY.
|
|
165
|
-
*/
|
|
166
|
-
tokenSymbol?: string;
|
|
167
|
-
/**
|
|
168
|
-
* Optional chain id for per-asset APY lookups. Typically paired with
|
|
169
|
-
* `tokenSymbol`.
|
|
170
|
-
*/
|
|
171
|
-
chainId?: number;
|
|
172
|
-
};
|
|
173
|
-
type DepositOptions = {
|
|
174
|
-
amount: string;
|
|
175
|
-
asset: Asset;
|
|
176
|
-
depositCallback?: DepositCallback;
|
|
177
|
-
agentId?: AgentId;
|
|
178
|
-
onApproved?: () => void;
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
|
|
183
|
-
* verbatim — matched case-sensitively by customizeBatch, and an unrecognised
|
|
184
|
-
* name makes Zyfai's rebalance engine skip the whole protocol, so these strings
|
|
185
|
-
* must not be normalised anywhere.
|
|
186
|
-
*
|
|
187
|
-
* An empty array means "no usable pools on this chain".
|
|
188
|
-
*/
|
|
189
|
-
type OrgPoolSelection = {
|
|
190
|
-
protocolId: string;
|
|
191
|
-
chainId: number;
|
|
192
|
-
pools: string[];
|
|
193
|
-
};
|
|
194
|
-
/**
|
|
195
|
-
* The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
|
|
196
|
-
* narrowed appear. Optional so an older routing API, which does not return the
|
|
197
|
-
* field, still parses; undefined and null both mean "change nothing".
|
|
198
|
-
*/
|
|
199
|
-
type OrgPoolPolicy = {
|
|
200
|
-
autoApproveProtocols: boolean;
|
|
201
|
-
autoApprovePools: boolean;
|
|
202
|
-
selections: OrgPoolSelection[];
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* The organization's agent execution policy, or null when the partner has never
|
|
206
|
-
* configured one — in which case the agents leave the user's profile alone.
|
|
207
|
-
*/
|
|
208
|
-
type OrgAgentConfig = {
|
|
209
|
-
splittingMode: "none" | "automatic" | "force";
|
|
210
|
-
minSplits: number | null;
|
|
211
|
-
poolPolicy?: OrgPoolPolicy | null;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
73
|
interface OwneyDepositResult {
|
|
215
74
|
txHash: string;
|
|
216
75
|
smartWallet: string;
|
|
@@ -247,8 +106,10 @@ interface OwneyPosition {
|
|
|
247
106
|
pool?: string;
|
|
248
107
|
asset: string;
|
|
249
108
|
amount: string;
|
|
250
|
-
/**
|
|
109
|
+
/** Provider-native raw quantity; may represent vault shares, not the underlying asset. */
|
|
251
110
|
amountRaw?: string;
|
|
111
|
+
/** Withdrawable underlying asset amount in that asset's smallest units. */
|
|
112
|
+
withdrawableAmountRaw?: string;
|
|
252
113
|
apy?: number;
|
|
253
114
|
tvl?: number;
|
|
254
115
|
/** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
|
|
@@ -481,6 +342,150 @@ interface AccountDailyEarnings {
|
|
|
481
342
|
assets: AssetDailyEarnings[];
|
|
482
343
|
}
|
|
483
344
|
|
|
345
|
+
type AgentId = "zyfai" | "yieldseeker";
|
|
346
|
+
type Asset = string;
|
|
347
|
+
type AgentSupportedAsset = {
|
|
348
|
+
readonly symbol: string;
|
|
349
|
+
readonly minDepositAmount: string;
|
|
350
|
+
};
|
|
351
|
+
type AgentSupportedAssets = {
|
|
352
|
+
readonly chainId: number;
|
|
353
|
+
readonly chain?: string;
|
|
354
|
+
readonly assets: readonly AgentSupportedAsset[];
|
|
355
|
+
};
|
|
356
|
+
type AvailableAgent = {
|
|
357
|
+
id: AgentId;
|
|
358
|
+
isEnabled: boolean;
|
|
359
|
+
supportedChainIds: readonly number[];
|
|
360
|
+
supportedAssets: readonly AgentSupportedAssets[];
|
|
361
|
+
};
|
|
362
|
+
type AvailableAgentsOptions = {
|
|
363
|
+
chainId?: number;
|
|
364
|
+
asset?: Asset;
|
|
365
|
+
/** Disabled agents are omitted by default because they cannot accept funds. */
|
|
366
|
+
includeDisabled?: boolean;
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* A lookback window for any "last N days" read — the APY series, the daily
|
|
370
|
+
* earnings series. Named for the window itself, so nothing borrows the APY's
|
|
371
|
+
* name to ask for something else.
|
|
372
|
+
*/
|
|
373
|
+
type LookbackDays = "7D" | "14D" | "30D";
|
|
374
|
+
/** Kept so existing callers keep compiling. Prefer `LookbackDays`. */
|
|
375
|
+
type DailyApyDays = LookbackDays;
|
|
376
|
+
type HistoryFilters = {
|
|
377
|
+
fromDate?: string;
|
|
378
|
+
toDate?: string;
|
|
379
|
+
/** Max entries returned per call. Defaults to 10. */
|
|
380
|
+
limit?: number;
|
|
381
|
+
/** Opaque cursor returned by a previous getHistory call. */
|
|
382
|
+
cursor?: string;
|
|
383
|
+
/**
|
|
384
|
+
* Optional asset symbol (e.g. "USDC", "WETH") to scope the history to a
|
|
385
|
+
* single asset. Without it the page blends every asset on the chain, so a
|
|
386
|
+
* consumer showing one asset at a time has to filter client-side — and a
|
|
387
|
+
* page whose entries all belong to the *other* asset then renders empty
|
|
388
|
+
* even though matching entries exist further back. Agents whose backends
|
|
389
|
+
* cannot filter by asset ignore this and return the whole chain's history.
|
|
390
|
+
*/
|
|
391
|
+
tokenSymbol?: string;
|
|
392
|
+
};
|
|
393
|
+
type HistoryOptions = {
|
|
394
|
+
agentId?: AgentId;
|
|
395
|
+
filters?: HistoryFilters;
|
|
396
|
+
};
|
|
397
|
+
type WithdrawOptions = {
|
|
398
|
+
asset: Asset;
|
|
399
|
+
amount?: string;
|
|
400
|
+
agentId?: AgentId;
|
|
401
|
+
/** Called after each agent returns; callback failures never change a financial result. */
|
|
402
|
+
onAgentResult?: (agentId: AgentId, result: AgentWithdrawResult) => void;
|
|
403
|
+
};
|
|
404
|
+
type AccountApyOptions = {
|
|
405
|
+
agentId?: AgentId;
|
|
406
|
+
days: LookbackDays;
|
|
407
|
+
/**
|
|
408
|
+
* Optional asset symbol (e.g. "USDC", "WETH") to scope the daily APY series
|
|
409
|
+
* to a specific asset on the active chain. Without it the series blends every
|
|
410
|
+
* position on the chain, so two assets sharing a chain (USDC and WETH on
|
|
411
|
+
* Base/Arbitrum) would render one merged line. Agents whose backends do not
|
|
412
|
+
* expose per-asset positions ignore this. (ROUT-186)
|
|
413
|
+
*/
|
|
414
|
+
tokenSymbol?: string;
|
|
415
|
+
};
|
|
416
|
+
/**
|
|
417
|
+
* Options for the daily earnings series. Same shape as `AccountApyOptions` and
|
|
418
|
+
* deliberately its own type: the two reads answer different questions and are
|
|
419
|
+
* free to diverge.
|
|
420
|
+
*/
|
|
421
|
+
type DailyEarningsOptions = {
|
|
422
|
+
agentId?: AgentId;
|
|
423
|
+
days: LookbackDays;
|
|
424
|
+
/**
|
|
425
|
+
* Optional asset symbol (e.g. "USDC", "WETH") scoping the series to one
|
|
426
|
+
* asset on the active chain.
|
|
427
|
+
*/
|
|
428
|
+
tokenSymbol?: string;
|
|
429
|
+
};
|
|
430
|
+
type AllocationApyOptions = {
|
|
431
|
+
agentId?: AgentId;
|
|
432
|
+
};
|
|
433
|
+
type AgentsApyOptions = {
|
|
434
|
+
agentId?: AgentId;
|
|
435
|
+
days: DailyApyDays;
|
|
436
|
+
/**
|
|
437
|
+
* Optional asset symbol (e.g. "USDC", "WETH") to scope the APY to a
|
|
438
|
+
* specific asset+chain. Ignored by agents whose backends do not yet
|
|
439
|
+
* support per-asset APY.
|
|
440
|
+
*/
|
|
441
|
+
tokenSymbol?: string;
|
|
442
|
+
/**
|
|
443
|
+
* Optional chain id for per-asset APY lookups. Typically paired with
|
|
444
|
+
* `tokenSymbol`.
|
|
445
|
+
*/
|
|
446
|
+
chainId?: number;
|
|
447
|
+
};
|
|
448
|
+
type DepositOptions = {
|
|
449
|
+
amount: string;
|
|
450
|
+
asset: Asset;
|
|
451
|
+
depositCallback?: DepositCallback;
|
|
452
|
+
agentId?: AgentId;
|
|
453
|
+
onApproved?: () => void;
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
|
|
458
|
+
* verbatim — matched case-sensitively by customizeBatch, and an unrecognised
|
|
459
|
+
* name makes Zyfai's rebalance engine skip the whole protocol, so these strings
|
|
460
|
+
* must not be normalised anywhere.
|
|
461
|
+
*
|
|
462
|
+
* An empty array means "no usable pools on this chain".
|
|
463
|
+
*/
|
|
464
|
+
type OrgPoolSelection = {
|
|
465
|
+
protocolId: string;
|
|
466
|
+
chainId: number;
|
|
467
|
+
pools: string[];
|
|
468
|
+
};
|
|
469
|
+
/**
|
|
470
|
+
* The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
|
|
471
|
+
* narrowed appear. Optional so an older routing API, which does not return the
|
|
472
|
+
* field, still parses; undefined and null both mean "change nothing".
|
|
473
|
+
*/
|
|
474
|
+
type OrgPoolPolicy = {
|
|
475
|
+
autoApproveProtocols: boolean;
|
|
476
|
+
autoApprovePools: boolean;
|
|
477
|
+
selections: OrgPoolSelection[];
|
|
478
|
+
};
|
|
479
|
+
/**
|
|
480
|
+
* The organization's agent execution policy, or null when the partner has never
|
|
481
|
+
* configured one — in which case the agents leave the user's profile alone.
|
|
482
|
+
*/
|
|
483
|
+
type OrgAgentConfig = {
|
|
484
|
+
splittingMode: "none" | "automatic" | "force";
|
|
485
|
+
minSplits: number | null;
|
|
486
|
+
poolPolicy?: OrgPoolPolicy | null;
|
|
487
|
+
};
|
|
488
|
+
|
|
484
489
|
type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
|
|
485
490
|
interface IAgent {
|
|
486
491
|
readonly id: string;
|
|
@@ -909,6 +914,13 @@ declare class YieldseekerAgent implements IAgent {
|
|
|
909
914
|
private readonly readCache;
|
|
910
915
|
private readonly pendingReads;
|
|
911
916
|
private readGeneration;
|
|
917
|
+
private readonly portfolioVersions;
|
|
918
|
+
private readonly snapshotFailures;
|
|
919
|
+
private readonly standardReadFailures;
|
|
920
|
+
private readonly reconcileUntil;
|
|
921
|
+
private readonly activityRefreshUntil;
|
|
922
|
+
private readonly snapshotMovements;
|
|
923
|
+
private readonly movementEpochs;
|
|
912
924
|
private readonly yieldOptions;
|
|
913
925
|
private readonly pendingYieldOptions;
|
|
914
926
|
constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
|
|
@@ -926,6 +938,7 @@ declare class YieldseekerAgent implements IAgent {
|
|
|
926
938
|
private loadYieldOptions;
|
|
927
939
|
private userKey;
|
|
928
940
|
private contextKey;
|
|
941
|
+
private assertSession;
|
|
929
942
|
private cachedRead;
|
|
930
943
|
private agentListKey;
|
|
931
944
|
private listAgents;
|
|
@@ -936,6 +949,12 @@ declare class YieldseekerAgent implements IAgent {
|
|
|
936
949
|
private findAgent;
|
|
937
950
|
private resolveAgent;
|
|
938
951
|
private loadPortfolio;
|
|
952
|
+
private portfolioVersion;
|
|
953
|
+
private portfolioCacheMs;
|
|
954
|
+
private snapshotMovement;
|
|
955
|
+
private advancePortfolioVersion;
|
|
956
|
+
private requestPortfolioSnapshot;
|
|
957
|
+
private portfolioSnapshot;
|
|
939
958
|
private loadPortfolioContext;
|
|
940
959
|
private deployAgent;
|
|
941
960
|
private refreshSnapshotAfterMovement;
|