@owney/sdk 0.7.25-beta.8 → 0.7.25
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 +26 -74
- package/dist/index.cjs +698 -3255
- package/dist/index.d.cts +181 -354
- package/dist/index.d.ts +181 -354
- package/dist/index.js +694 -3270
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,34 +1,18 @@
|
|
|
1
|
-
import { Hex } from 'viem';
|
|
2
1
|
import { SIWXConfig } from '@reown/appkit-controllers';
|
|
3
2
|
|
|
4
|
-
type
|
|
5
|
-
/** @deprecated Use RpcUrlsConfig. */
|
|
6
|
-
type ZyfaiRpcUrlsConfig = RpcUrlsConfig;
|
|
3
|
+
type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
|
|
7
4
|
interface OwneySDKConfig {
|
|
8
5
|
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;
|
|
17
6
|
/**
|
|
18
7
|
* Optional per-chain RPC overrides for Zyfai SDK network calls.
|
|
19
8
|
* Example: { 8453: "https://...", 42161: "https://..." }
|
|
20
|
-
* @deprecated Use rpcUrls so every agent shares the same read transport.
|
|
21
9
|
*/
|
|
22
10
|
zyfaiRpcUrls?: ZyfaiRpcUrlsConfig;
|
|
23
|
-
/** Optional Owney Yieldseeker proxy base URL override for integration tests. */
|
|
24
|
-
yieldseekerApiBaseUrl?: string;
|
|
25
|
-
/** Optional SIWE origin override. Defaults to the requesting browser origin. */
|
|
26
|
-
yieldseekerSiweOrigin?: string;
|
|
27
11
|
/**
|
|
28
12
|
* Optional override for the Owney routing API base URL used by all routing
|
|
29
|
-
* calls
|
|
30
|
-
*
|
|
31
|
-
*
|
|
13
|
+
* calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
|
|
14
|
+
* production URL). Set this to point at a local/staging routing API,
|
|
15
|
+
* e.g. "http://localhost:3000", when testing sponsor changes.
|
|
32
16
|
*/
|
|
33
17
|
routingApiBaseUrl?: string;
|
|
34
18
|
/**
|
|
@@ -70,6 +54,148 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
|
70
54
|
type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
|
|
71
55
|
type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
|
|
72
56
|
|
|
57
|
+
type AgentId = "zyfai";
|
|
58
|
+
type Asset = string;
|
|
59
|
+
type AgentSupportedAsset = {
|
|
60
|
+
readonly symbol: string;
|
|
61
|
+
readonly minDepositAmount: string;
|
|
62
|
+
};
|
|
63
|
+
type AgentSupportedAssets = {
|
|
64
|
+
readonly chainId: number;
|
|
65
|
+
readonly chain?: string;
|
|
66
|
+
readonly assets: readonly AgentSupportedAsset[];
|
|
67
|
+
};
|
|
68
|
+
type AvailableAgent = {
|
|
69
|
+
id: AgentId;
|
|
70
|
+
isEnabled: boolean;
|
|
71
|
+
supportedChainIds: readonly number[];
|
|
72
|
+
supportedAssets: readonly AgentSupportedAssets[];
|
|
73
|
+
};
|
|
74
|
+
type AvailableAgentsOptions = {
|
|
75
|
+
chainId?: number;
|
|
76
|
+
asset?: Asset;
|
|
77
|
+
/** Disabled agents are omitted by default because they cannot accept funds. */
|
|
78
|
+
includeDisabled?: boolean;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* A lookback window for any "last N days" read — the APY series, the daily
|
|
82
|
+
* earnings series. Named for the window itself, so nothing borrows the APY's
|
|
83
|
+
* name to ask for something else.
|
|
84
|
+
*/
|
|
85
|
+
type LookbackDays = "7D" | "14D" | "30D";
|
|
86
|
+
/** Kept so existing callers keep compiling. Prefer `LookbackDays`. */
|
|
87
|
+
type DailyApyDays = LookbackDays;
|
|
88
|
+
type HistoryFilters = {
|
|
89
|
+
fromDate?: string;
|
|
90
|
+
toDate?: string;
|
|
91
|
+
/** Max entries returned per call. Defaults to 10. */
|
|
92
|
+
limit?: number;
|
|
93
|
+
/** Opaque cursor returned by a previous getHistory call. */
|
|
94
|
+
cursor?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Optional asset symbol (e.g. "USDC", "WETH") to scope the history to a
|
|
97
|
+
* single asset. Without it the page blends every asset on the chain, so a
|
|
98
|
+
* consumer showing one asset at a time has to filter client-side — and a
|
|
99
|
+
* page whose entries all belong to the *other* asset then renders empty
|
|
100
|
+
* even though matching entries exist further back. Agents whose backends
|
|
101
|
+
* cannot filter by asset ignore this and return the whole chain's history.
|
|
102
|
+
*/
|
|
103
|
+
tokenSymbol?: string;
|
|
104
|
+
};
|
|
105
|
+
type HistoryOptions = {
|
|
106
|
+
agentId?: AgentId;
|
|
107
|
+
filters?: HistoryFilters;
|
|
108
|
+
};
|
|
109
|
+
type WithdrawOptions = {
|
|
110
|
+
asset: Asset;
|
|
111
|
+
amount?: string;
|
|
112
|
+
agentId?: AgentId;
|
|
113
|
+
};
|
|
114
|
+
type AccountApyOptions = {
|
|
115
|
+
agentId?: AgentId;
|
|
116
|
+
days: LookbackDays;
|
|
117
|
+
/**
|
|
118
|
+
* Optional asset symbol (e.g. "USDC", "WETH") to scope the daily APY series
|
|
119
|
+
* to a specific asset on the active chain. Without it the series blends every
|
|
120
|
+
* position on the chain, so two assets sharing a chain (USDC and WETH on
|
|
121
|
+
* Base/Arbitrum) would render one merged line. Agents whose backends do not
|
|
122
|
+
* expose per-asset positions ignore this. (ROUT-186)
|
|
123
|
+
*/
|
|
124
|
+
tokenSymbol?: string;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Options for the daily earnings series. Same shape as `AccountApyOptions` and
|
|
128
|
+
* deliberately its own type: the two reads answer different questions and are
|
|
129
|
+
* free to diverge.
|
|
130
|
+
*/
|
|
131
|
+
type DailyEarningsOptions = {
|
|
132
|
+
agentId?: AgentId;
|
|
133
|
+
days: LookbackDays;
|
|
134
|
+
/**
|
|
135
|
+
* Optional asset symbol (e.g. "USDC", "WETH") scoping the series to one
|
|
136
|
+
* asset on the active chain.
|
|
137
|
+
*/
|
|
138
|
+
tokenSymbol?: string;
|
|
139
|
+
};
|
|
140
|
+
type AllocationApyOptions = {
|
|
141
|
+
agentId?: AgentId;
|
|
142
|
+
};
|
|
143
|
+
type AgentsApyOptions = {
|
|
144
|
+
agentId?: AgentId;
|
|
145
|
+
days: DailyApyDays;
|
|
146
|
+
/**
|
|
147
|
+
* Optional asset symbol (e.g. "USDC", "WETH") to scope the APY to a
|
|
148
|
+
* specific asset+chain. Ignored by agents whose backends do not yet
|
|
149
|
+
* support per-asset APY.
|
|
150
|
+
*/
|
|
151
|
+
tokenSymbol?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Optional chain id for per-asset APY lookups. Typically paired with
|
|
154
|
+
* `tokenSymbol`.
|
|
155
|
+
*/
|
|
156
|
+
chainId?: number;
|
|
157
|
+
};
|
|
158
|
+
type DepositOptions = {
|
|
159
|
+
amount: string;
|
|
160
|
+
asset: Asset;
|
|
161
|
+
depositCallback?: DepositCallback;
|
|
162
|
+
agentId?: AgentId;
|
|
163
|
+
onApproved?: () => void;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
|
|
168
|
+
* verbatim — matched case-sensitively by customizeBatch, and an unrecognised
|
|
169
|
+
* name makes Zyfai's rebalance engine skip the whole protocol, so these strings
|
|
170
|
+
* must not be normalised anywhere.
|
|
171
|
+
*
|
|
172
|
+
* An empty array means "no usable pools on this chain".
|
|
173
|
+
*/
|
|
174
|
+
type OrgPoolSelection = {
|
|
175
|
+
protocolId: string;
|
|
176
|
+
chainId: number;
|
|
177
|
+
pools: string[];
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
|
|
181
|
+
* narrowed appear. Optional so an older routing API, which does not return the
|
|
182
|
+
* field, still parses; undefined and null both mean "change nothing".
|
|
183
|
+
*/
|
|
184
|
+
type OrgPoolPolicy = {
|
|
185
|
+
autoApproveProtocols: boolean;
|
|
186
|
+
autoApprovePools: boolean;
|
|
187
|
+
selections: OrgPoolSelection[];
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* The organization's agent execution policy, or null when the partner has never
|
|
191
|
+
* configured one — in which case the agents leave the user's profile alone.
|
|
192
|
+
*/
|
|
193
|
+
type OrgAgentConfig = {
|
|
194
|
+
splittingMode: "none" | "automatic" | "force";
|
|
195
|
+
minSplits: number | null;
|
|
196
|
+
poolPolicy?: OrgPoolPolicy | null;
|
|
197
|
+
};
|
|
198
|
+
|
|
73
199
|
interface OwneyDepositResult {
|
|
74
200
|
txHash: string;
|
|
75
201
|
smartWallet: string;
|
|
@@ -106,10 +232,6 @@ interface OwneyPosition {
|
|
|
106
232
|
pool?: string;
|
|
107
233
|
asset: string;
|
|
108
234
|
amount: string;
|
|
109
|
-
/** Provider-native raw quantity; may represent vault shares, not the underlying asset. */
|
|
110
|
-
amountRaw?: string;
|
|
111
|
-
/** Withdrawable underlying asset amount in that asset's smallest units. */
|
|
112
|
-
withdrawableAmountRaw?: string;
|
|
113
235
|
apy?: number;
|
|
114
236
|
tvl?: number;
|
|
115
237
|
/** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
|
|
@@ -140,19 +262,10 @@ interface OwneyPendingAllocation {
|
|
|
140
262
|
since?: string;
|
|
141
263
|
}
|
|
142
264
|
interface AgentBalance {
|
|
143
|
-
/** Authoritative native balances per asset/network, including idle and invested funds. */
|
|
144
|
-
assetBalances?: OwneyToken[];
|
|
145
265
|
smartWallet?: `0x${string}`;
|
|
146
266
|
totalBalance: string;
|
|
147
267
|
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
148
268
|
totalBalanceAsset: string;
|
|
149
|
-
/**
|
|
150
|
-
* Describes whether `tokens` already includes deployed `positions`.
|
|
151
|
-
* Consumers must add matching positions only for `tokens-plus-positions`;
|
|
152
|
-
* doing so for Zyfai would double-count, while omitting it for Yieldseeker
|
|
153
|
-
* makes its balance disappear as soon as idle funds enter a vault.
|
|
154
|
-
*/
|
|
155
|
-
balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
|
|
156
269
|
tokens: OwneyToken[];
|
|
157
270
|
/**
|
|
158
271
|
* Per-protocol/pool positions when the agent's portfolio payload includes
|
|
@@ -167,14 +280,10 @@ interface OwneyBalances {
|
|
|
167
280
|
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
168
281
|
totalBalanceAsset: string;
|
|
169
282
|
agentBalances: Record<AgentId, AgentBalance>;
|
|
170
|
-
/**
|
|
171
|
-
|
|
172
|
-
* partial result. Callers may display the successful balances, but funding
|
|
173
|
-
* operations must not interpret a missing agent as having a zero balance.
|
|
174
|
-
*/
|
|
175
|
-
agentErrors?: Partial<Record<AgentId, string>>;
|
|
283
|
+
/** Omitted agents failed to load; they must not be interpreted as zero. */
|
|
284
|
+
agentErrors?: Record<AgentId, string>;
|
|
176
285
|
/** Absolute provider cooldown deadlines (Unix milliseconds). */
|
|
177
|
-
agentRetryAt?:
|
|
286
|
+
agentRetryAt?: Record<AgentId, number>;
|
|
178
287
|
}
|
|
179
288
|
interface AgentEarnings {
|
|
180
289
|
smartWallet: `0x${string}`;
|
|
@@ -342,170 +451,13 @@ interface AccountDailyEarnings {
|
|
|
342
451
|
assets: AssetDailyEarnings[];
|
|
343
452
|
}
|
|
344
453
|
|
|
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
|
-
|
|
489
454
|
type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
|
|
490
455
|
interface IAgent {
|
|
491
456
|
readonly id: string;
|
|
492
457
|
readonly supportedChainIds: readonly OwneySupportedChainId[];
|
|
493
458
|
readonly supportedAssets: readonly AgentSupportedAssets[];
|
|
494
|
-
/**
|
|
495
|
-
* Describes how `AgentBalance.tokens` relates to `positions`.
|
|
496
|
-
* Most adapters expose token totals that already include deployed positions.
|
|
497
|
-
* Providers such as Yieldseeker expose idle wallet tokens separately, so
|
|
498
|
-
* withdrawal planning must add matching position amounts.
|
|
499
|
-
*/
|
|
500
|
-
readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
|
|
501
|
-
/**
|
|
502
|
-
* Whether a withdrawal requires an owner-approved wallet transaction.
|
|
503
|
-
* Aggregate withdrawals run these agents before relayer-only agents so a
|
|
504
|
-
* rejected wallet request cannot happen after another leg has committed.
|
|
505
|
-
*/
|
|
506
|
-
readonly withdrawalRequiresWalletApproval?: boolean;
|
|
507
459
|
disconnect(): Promise<void>;
|
|
508
|
-
activateAgent(state: ConnectionState, chainId: number
|
|
460
|
+
activateAgent(state: ConnectionState, chainId: number): Promise<void>;
|
|
509
461
|
/**
|
|
510
462
|
* Apply the organization's agent policy to this user's account.
|
|
511
463
|
*
|
|
@@ -575,10 +527,7 @@ declare class OwneySDK {
|
|
|
575
527
|
private apiKey;
|
|
576
528
|
private orgAgentConfig;
|
|
577
529
|
private orgAgentConfigPromise;
|
|
578
|
-
private rpcUrls?;
|
|
579
530
|
private zyfaiRpcUrls?;
|
|
580
|
-
private yieldseekerApiBaseUrl?;
|
|
581
|
-
private yieldseekerSiweOrigin?;
|
|
582
531
|
private routingApiBaseUrl?;
|
|
583
532
|
private referralSource?;
|
|
584
533
|
private cachedSponsoredCallback;
|
|
@@ -615,16 +564,25 @@ declare class OwneySDK {
|
|
|
615
564
|
private requireState;
|
|
616
565
|
private requireChainId;
|
|
617
566
|
private requireConnectedProvider;
|
|
618
|
-
|
|
619
|
-
|
|
567
|
+
/**
|
|
568
|
+
* Lazily builds (and caches) the default EIP-3009 sponsored deposit callback
|
|
569
|
+
* used when the caller omits `depositCallback`. Wraps the connected EIP-1193
|
|
570
|
+
* provider with viem `custom(provider)` to read token meta and sign the
|
|
571
|
+
* `TransferWithAuthorization`, then POSTs to the sponsor API.
|
|
572
|
+
*/
|
|
620
573
|
private getDefaultSponsoredCallback;
|
|
621
|
-
/**
|
|
574
|
+
/**
|
|
575
|
+
* Lazily builds (and caches) the default Permit2 sponsored WETH deposit
|
|
576
|
+
* callback used when the caller omits `depositCallback` for a WETH
|
|
577
|
+
* deposit. Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
|
|
578
|
+
* `PermitTransferFrom` instead of an EIP-3009 authorization.
|
|
579
|
+
*/
|
|
622
580
|
private getDefaultSponsoredCallsCallback;
|
|
623
581
|
/**
|
|
624
582
|
* Lazily builds (and caches) the default Permit2 sponsored WETH deposit
|
|
625
583
|
* callback used when the caller omits `depositCallback` for a WETH deposit.
|
|
626
584
|
* Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
|
|
627
|
-
*
|
|
585
|
+
* `PermitTransferFrom` instead of an EIP-3009 authorization.
|
|
628
586
|
*/
|
|
629
587
|
private getDefaultWethSponsoredCallback;
|
|
630
588
|
private getAgent;
|
|
@@ -660,8 +618,7 @@ declare class OwneySDK {
|
|
|
660
618
|
* If provided, ALL specified agents must support the chainId or the call
|
|
661
619
|
* throws before activating any agent.
|
|
662
620
|
*/
|
|
663
|
-
activateAgent(chainId: number, agentId?: AgentId[]
|
|
664
|
-
private assertActivationSession;
|
|
621
|
+
activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
|
|
665
622
|
/**
|
|
666
623
|
* Activate agents ONE AT A TIME, each followed by its org policy.
|
|
667
624
|
*
|
|
@@ -675,9 +632,10 @@ declare class OwneySDK {
|
|
|
675
632
|
* Serializing costs no real wall-clock: the user can only approve one prompt
|
|
676
633
|
* at a time anyway.
|
|
677
634
|
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
635
|
+
* Every agent is attempted even if an earlier one fails, so one declined
|
|
636
|
+
* signature can't deny the remaining agents their turn. The first failure is
|
|
637
|
+
* rethrown (matching the previous `Promise.all` rejection) once all agents
|
|
638
|
+
* have had a chance to activate.
|
|
681
639
|
*/
|
|
682
640
|
private activateAgentsInTurn;
|
|
683
641
|
/**
|
|
@@ -688,8 +646,7 @@ declare class OwneySDK {
|
|
|
688
646
|
* @param options.asset - Asset symbol to deposit (e.g. "USDC")
|
|
689
647
|
* @param options.depositCallback - Callback that performs the token transfer and returns a tx hash.
|
|
690
648
|
* When agentId is omitted, this callback is invoked once per eligible agent with that agent's
|
|
691
|
-
* split amount and smart wallet address
|
|
692
|
-
* all shares into one signature; custom callbacks still run once per agent.
|
|
649
|
+
* split amount and smart wallet address — expect multiple wallet prompts.
|
|
693
650
|
* @param options.agentId - Optional explicit target. Otherwise split equally,
|
|
694
651
|
* or fund remaining agents when a recovery deposit cannot meet every minimum.
|
|
695
652
|
* @returns {OwneyDepositResult} for a single agent, or {OwneyMultiDepositResult} with per-agent results
|
|
@@ -699,12 +656,10 @@ declare class OwneySDK {
|
|
|
699
656
|
* Invokes `agent.deposit` with the resolved sponsored callback, composing
|
|
700
657
|
* two independent auto-recovery mechanisms:
|
|
701
658
|
*
|
|
702
|
-
* 1. Missing Permit2 allowance
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
* its sponsored deposit and never reaches this branch. Other tokens send
|
|
707
|
-
* the one-time user-paid Permit2 approval via `approvePermit2()` and
|
|
659
|
+
* 1. Missing Permit2 allowance: when the app did not supply its own
|
|
660
|
+
* callback and the attempt fails with `PERMIT2_APPROVAL_REQUIRED` on a
|
|
661
|
+
* WETH deposit, this is the wallet's first gasless WETH deposit. We send
|
|
662
|
+
* the one-time (user-paid) Permit2 approval via `approvePermit2()` and
|
|
708
663
|
* retry the SAME sponsored attempt once. Bounded to one approval attempt
|
|
709
664
|
* per call so a wallet/agent that keeps reporting the allowance as
|
|
710
665
|
* missing can't loop forever. If `approvePermit2()` itself throws (e.g.
|
|
@@ -725,7 +680,6 @@ declare class OwneySDK {
|
|
|
725
680
|
private depositWithFallback;
|
|
726
681
|
private getMinDepositAmount;
|
|
727
682
|
private splitDepositAmount;
|
|
728
|
-
private formatAgentName;
|
|
729
683
|
private validateMinDepositAmount;
|
|
730
684
|
/**
|
|
731
685
|
* Whether the user already holds a non-zero balance with `agent` for the
|
|
@@ -736,13 +690,6 @@ declare class OwneySDK {
|
|
|
736
690
|
private hasExistingBalance;
|
|
737
691
|
private validateAssetSupport;
|
|
738
692
|
private getEligibleAgents;
|
|
739
|
-
/**
|
|
740
|
-
* Run owner-approved withdrawals before relayer-only withdrawals. Wallet
|
|
741
|
-
* approval is the only point at which the user can cancel the aggregate
|
|
742
|
-
* operation, so no relayer leg should commit before it has completed.
|
|
743
|
-
*/
|
|
744
|
-
private orderAgentsForWithdrawal;
|
|
745
|
-
private isUserRejectedWithdrawal;
|
|
746
693
|
/**
|
|
747
694
|
* Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
|
|
748
695
|
* Validates that the asset is supported by the target agent(s) on the active chain.
|
|
@@ -824,17 +771,14 @@ declare class OwneySDK {
|
|
|
824
771
|
*/
|
|
825
772
|
ensureAutoSelectProtocols(asset: "USDC" | "WETH", agentId?: AgentId): Promise<boolean>;
|
|
826
773
|
/**
|
|
827
|
-
*
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
* @param requiredAmount Raw base-unit amount the pending deposit must cover.
|
|
834
|
-
* @param expectedChainId Chain captured by the deposit that requested approval.
|
|
774
|
+
* One-time, user-paid approval of Permit2 on the sponsored WETH token for
|
|
775
|
+
* the active chain. Required once per wallet per chain before gasless WETH
|
|
776
|
+
* deposits; afterwards deposit() is signature-only. Resolves only after the
|
|
777
|
+
* approval transaction is mined (1 confirmation), so a subsequent deposit()
|
|
778
|
+
* will see the new allowance; throws if the transaction reverted.
|
|
835
779
|
* @returns the approval transaction hash.
|
|
836
780
|
*/
|
|
837
|
-
approvePermit2(asset?:
|
|
781
|
+
approvePermit2(asset?: "WETH"): Promise<`0x${string}`>;
|
|
838
782
|
/**
|
|
839
783
|
* Get the agent's average APY performance over a time period. Does not require a wallet connection.
|
|
840
784
|
* @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")
|
|
@@ -858,124 +802,7 @@ declare class OwneySDK {
|
|
|
858
802
|
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
859
803
|
}
|
|
860
804
|
|
|
861
|
-
type
|
|
862
|
-
origin?: string;
|
|
863
|
-
now?: () => Date;
|
|
864
|
-
nonce?: () => string;
|
|
865
|
-
};
|
|
866
|
-
|
|
867
|
-
type YieldseekerFetch = typeof fetch;
|
|
868
|
-
|
|
869
|
-
type YieldseekerTransaction = {
|
|
870
|
-
from: `0x${string}`;
|
|
871
|
-
to: `0x${string}`;
|
|
872
|
-
data: `0x${string}`;
|
|
873
|
-
value: string;
|
|
874
|
-
chainId: number;
|
|
875
|
-
};
|
|
876
|
-
|
|
877
|
-
type YieldseekerAgentOptions = {
|
|
878
|
-
baseUrl?: string;
|
|
879
|
-
fetchFn?: YieldseekerFetch;
|
|
880
|
-
auth?: YieldseekerAuthDependencies;
|
|
881
|
-
/** Dedicated read transport; Base is used for receipt polling. */
|
|
882
|
-
rpcUrls?: RpcUrlsConfig;
|
|
883
|
-
/** Test seam for the wallet-submission/receipt boundary. */
|
|
884
|
-
transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
|
|
885
|
-
/** Test seam for transactions submitted outside transactionExecutor. */
|
|
886
|
-
unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
|
|
887
|
-
};
|
|
888
|
-
declare class YieldseekerAgent implements IAgent {
|
|
889
|
-
readonly id = "yieldseeker";
|
|
890
|
-
readonly balanceComposition: "tokens-plus-positions";
|
|
891
|
-
readonly withdrawalRequiresWalletApproval = true;
|
|
892
|
-
readonly supportedChainIds: readonly [8453];
|
|
893
|
-
readonly supportedAssets: readonly [{
|
|
894
|
-
readonly chainId: 8453;
|
|
895
|
-
readonly chain: "BASE";
|
|
896
|
-
readonly assets: readonly [{
|
|
897
|
-
readonly symbol: "USDC";
|
|
898
|
-
readonly minDepositAmount: "10000000";
|
|
899
|
-
}, {
|
|
900
|
-
readonly symbol: "WETH";
|
|
901
|
-
readonly minDepositAmount: "1";
|
|
902
|
-
}];
|
|
903
|
-
}];
|
|
904
|
-
private readonly api;
|
|
905
|
-
private readonly auth;
|
|
906
|
-
private readonly rpcUrls?;
|
|
907
|
-
private receiptClient?;
|
|
908
|
-
private readonly transactionExecutor?;
|
|
909
|
-
private readonly unwindReceiptWaiter?;
|
|
910
|
-
private readonly agentContexts;
|
|
911
|
-
private readonly users;
|
|
912
|
-
private readonly pendingAgents;
|
|
913
|
-
private readonly pendingWalletContexts;
|
|
914
|
-
private readonly readCache;
|
|
915
|
-
private readonly pendingReads;
|
|
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;
|
|
924
|
-
private readonly yieldOptions;
|
|
925
|
-
private readonly pendingYieldOptions;
|
|
926
|
-
constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
|
|
927
|
-
private getReceiptClient;
|
|
928
|
-
disconnect(): Promise<void>;
|
|
929
|
-
activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
|
|
930
|
-
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
931
|
-
withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
|
|
932
|
-
getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
|
|
933
|
-
getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
|
|
934
|
-
getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
|
|
935
|
-
getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
|
|
936
|
-
getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
|
|
937
|
-
getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
|
|
938
|
-
private loadYieldOptions;
|
|
939
|
-
private userKey;
|
|
940
|
-
private contextKey;
|
|
941
|
-
private assertSession;
|
|
942
|
-
private cachedRead;
|
|
943
|
-
private agentListKey;
|
|
944
|
-
private listAgents;
|
|
945
|
-
private contextForAgent;
|
|
946
|
-
private resolveUser;
|
|
947
|
-
private forgetUser;
|
|
948
|
-
private ensureAgent;
|
|
949
|
-
private findAgent;
|
|
950
|
-
private resolveAgent;
|
|
951
|
-
private loadPortfolio;
|
|
952
|
-
private portfolioVersion;
|
|
953
|
-
private portfolioCacheMs;
|
|
954
|
-
private snapshotMovement;
|
|
955
|
-
private advancePortfolioVersion;
|
|
956
|
-
private requestPortfolioSnapshot;
|
|
957
|
-
private portfolioSnapshot;
|
|
958
|
-
private loadPortfolioContext;
|
|
959
|
-
private deployAgent;
|
|
960
|
-
private refreshSnapshotAfterMovement;
|
|
961
|
-
private agentPath;
|
|
962
|
-
private walletRequest;
|
|
963
|
-
private providerRequest;
|
|
964
|
-
private mapApiError;
|
|
965
|
-
private submitTransaction;
|
|
966
|
-
private waitForReceipt;
|
|
967
|
-
private assertTransaction;
|
|
968
|
-
private assertAgent;
|
|
969
|
-
private isOwneyAgent;
|
|
970
|
-
private assetForAgent;
|
|
971
|
-
private isTransactionHash;
|
|
972
|
-
private assertChain;
|
|
973
|
-
private assertOptionalChain;
|
|
974
|
-
private assertAsset;
|
|
975
|
-
private invalidResponse;
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
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";
|
|
805
|
+
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_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_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "AGENT_RATE_LIMITED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
979
806
|
declare class OwneyError extends Error {
|
|
980
807
|
readonly code: OwneyErrorCode;
|
|
981
808
|
readonly details?: Record<string, unknown>;
|
|
@@ -1041,4 +868,4 @@ type OwneySIWXConfig = {
|
|
|
1041
868
|
*/
|
|
1042
869
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
1043
870
|
|
|
1044
|
-
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
|
|
871
|
+
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, createOwneySIWX, setOwneyDebug };
|