@owney/sdk 0.7.31 → 0.7.32-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 +109 -20
- package/dist/chunk-CW55W2WO.js +622 -0
- package/dist/index.cjs +19232 -3856
- package/dist/index.d.cts +2327 -338
- package/dist/index.d.ts +2327 -338
- package/dist/index.js +18575 -3837
- package/dist/token-batch-family-TUGZWETV.js +32 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as viem from 'viem';
|
|
2
|
+
import { Hex, Address } from 'viem';
|
|
1
3
|
import { SIWXConfig } from '@reown/appkit-controllers';
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -220,7 +222,9 @@ type SwapOrderStatus = "pending" | "executed" | "expired" | "cancelled" | "refun
|
|
|
220
222
|
* of the flow and the one place a user would otherwise think nothing is
|
|
221
223
|
* happening.
|
|
222
224
|
*/
|
|
223
|
-
type SwapStage = "withdrawing" | "withdrawn"
|
|
225
|
+
type SwapStage = "withdrawing" | "withdrawn"
|
|
226
|
+
/** Withdrawal incomplete or unconfirmed; no swap was submitted. */
|
|
227
|
+
| "withdrawal-incomplete" | "swap-unknown" | "swap-partial" | "swap-not-started" | "quoting" | "wrapping" | "wrapped" | "approving" | "building" | "signing" | "swapping" | "swapped" | "depositing" | "refunding" | "refunded";
|
|
224
228
|
/**
|
|
225
229
|
* Which way the funds travel, which decides what each side may be.
|
|
226
230
|
*
|
|
@@ -246,19 +250,95 @@ type SwapQuoteParams = {
|
|
|
246
250
|
direction?: SwapDirection;
|
|
247
251
|
};
|
|
248
252
|
|
|
249
|
-
type
|
|
253
|
+
type FundingOperationKind = "deposit" | "withdraw" | "swap_deposit" | "withdraw_swap";
|
|
254
|
+
/** One leg of a ledger operation, as the API returns it. */
|
|
255
|
+
type FundingOperationLeg = {
|
|
256
|
+
/** e.g. `agent:zyfai`, `swap`, `approval`. */
|
|
257
|
+
legKey: string;
|
|
258
|
+
agentType: string | null;
|
|
259
|
+
/** created | submitted | unknown | failed | confirmed */
|
|
260
|
+
status: string;
|
|
261
|
+
/** uint256 decimal string. */
|
|
262
|
+
confirmedAmountRaw: string | null;
|
|
263
|
+
/** bigint decimal string. */
|
|
264
|
+
blockNumber: string | null;
|
|
265
|
+
txHash: string | null;
|
|
266
|
+
/** ISO. Kept as stored: a confirmed -> failed leg keeps its value, so key off `status`. */
|
|
267
|
+
confirmedAt: string | null;
|
|
268
|
+
/** Lowercase agent wallet the leg moved funds to or from; null when unknown. */
|
|
269
|
+
agentWallet: string | null;
|
|
270
|
+
/** ISO. First time the provider's proxied history listed this leg's tx hash (Yieldseeker). Never cleared. */
|
|
271
|
+
providerIndexedAt: string | null;
|
|
272
|
+
/**
|
|
273
|
+
* ISO. When a proxied provider snapshot first showed this leg in net deposits
|
|
274
|
+
* (Yieldseeker). Never cleared. Null means "not booked or undecidable", never
|
|
275
|
+
* "definitely not booked".
|
|
276
|
+
*/
|
|
277
|
+
providerBookedAt: string | null;
|
|
278
|
+
/** The provider's own id for this leg (e.g. a withdrawal or deposit id), as stored; null when none. */
|
|
279
|
+
providerRef: string | null;
|
|
280
|
+
/**
|
|
281
|
+
* The server stopped checking this in-flight leg (no outcome was proven).
|
|
282
|
+
* Present only when true; a new fact reported for the leg reopens it.
|
|
283
|
+
*/
|
|
284
|
+
closed?: true;
|
|
285
|
+
};
|
|
286
|
+
/** One ledger operation, as the API returns it. */
|
|
287
|
+
type FundingOperationRow = {
|
|
288
|
+
/** First 8 hex chars of the client operation id, lowercase. */
|
|
289
|
+
reference: string;
|
|
290
|
+
/** Present only for operations whose id the caller passed in `ids`. */
|
|
291
|
+
clientOperationId?: string;
|
|
292
|
+
kind: FundingOperationKind;
|
|
293
|
+
/** created | submitted | unknown | failed | confirmed | partial */
|
|
294
|
+
status: string;
|
|
295
|
+
/** ISO. */
|
|
296
|
+
createdAt: string;
|
|
297
|
+
/** ISO. */
|
|
298
|
+
settledAt: string | null;
|
|
299
|
+
stuck: boolean;
|
|
300
|
+
legs: FundingOperationLeg[];
|
|
301
|
+
};
|
|
302
|
+
/** The newest server-side provider snapshot sample at or before a time. */
|
|
303
|
+
type ProviderSnapshotSample = {
|
|
304
|
+
/** Signed decimal strings in the asset's base units, or null. */
|
|
305
|
+
netDepositsRaw: string | null;
|
|
306
|
+
cumulativeYieldRaw: string | null;
|
|
307
|
+
totalValueRaw: string | null;
|
|
308
|
+
/** ISO or null. */
|
|
309
|
+
providerUpdatedAt: string | null;
|
|
310
|
+
/** ISO. */
|
|
311
|
+
observedAt: string;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
type RpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
|
|
315
|
+
/** @deprecated Use RpcUrlsConfig. */
|
|
316
|
+
type ZyfaiRpcUrlsConfig = RpcUrlsConfig;
|
|
250
317
|
interface OwneySDKConfig {
|
|
251
318
|
apiKey: string;
|
|
319
|
+
/**
|
|
320
|
+
* Optional per-chain RPC overrides used for application-owned reads and
|
|
321
|
+
* transaction receipt polling. Missing chains use the Owney routing API's
|
|
322
|
+
* read-only RPC proxy. No upstream RPC credentials are included in the SDK.
|
|
323
|
+
* Wallet providers remain responsible for account access, chain switching,
|
|
324
|
+
* signatures, and transaction submission.
|
|
325
|
+
*/
|
|
326
|
+
rpcUrls?: RpcUrlsConfig;
|
|
252
327
|
/**
|
|
253
328
|
* Optional per-chain RPC overrides for Zyfai SDK network calls.
|
|
254
329
|
* Example: { 8453: "https://...", 42161: "https://..." }
|
|
330
|
+
* @deprecated Use rpcUrls so every agent shares the same read transport.
|
|
255
331
|
*/
|
|
256
332
|
zyfaiRpcUrls?: ZyfaiRpcUrlsConfig;
|
|
333
|
+
/** Optional Owney Yieldseeker proxy base URL override for integration tests. */
|
|
334
|
+
yieldseekerApiBaseUrl?: string;
|
|
335
|
+
/** Optional SIWE origin override. Defaults to the requesting browser origin. */
|
|
336
|
+
yieldseekerSiweOrigin?: string;
|
|
257
337
|
/**
|
|
258
338
|
* Optional override for the Owney routing API base URL used by all routing
|
|
259
|
-
* calls
|
|
260
|
-
*
|
|
261
|
-
*
|
|
339
|
+
* calls. RPC proxy requests use OWNEY_ROUTING_API_BASE_URL when this is
|
|
340
|
+
* omitted; without either value, all rpcUrls must be configured.
|
|
341
|
+
* Set this to a local/staging routing API when testing sponsor changes.
|
|
262
342
|
*/
|
|
263
343
|
routingApiBaseUrl?: string;
|
|
264
344
|
/**
|
|
@@ -267,6 +347,13 @@ interface OwneySDKConfig {
|
|
|
267
347
|
* for apps that don't use the AppKit SIWX modal.
|
|
268
348
|
*/
|
|
269
349
|
referralSource?: string;
|
|
350
|
+
/**
|
|
351
|
+
* Mini-app identifier (`web`, `base`, `ellipal` …) recorded on funding ledger
|
|
352
|
+
* operations. Not `referralSource`, which is a Zyfai attribution tag. The
|
|
353
|
+
* ledger records `unknown` when this is omitted. Lowercased before sending;
|
|
354
|
+
* a value that is not 1-32 of `a-z 0-9 _ -` after that is left out.
|
|
355
|
+
*/
|
|
356
|
+
appName?: string;
|
|
270
357
|
/**
|
|
271
358
|
* Turn on the SDK's debug logging (default false). Traces the decisions that
|
|
272
359
|
* are otherwise invisible — notably how the organization's agent policy is
|
|
@@ -296,11 +383,58 @@ interface OwneySDKConfig {
|
|
|
296
383
|
* unresolvable. Omit it and every rail behaves exactly as before.
|
|
297
384
|
*/
|
|
298
385
|
paymasterServiceUrl?: string;
|
|
386
|
+
/**
|
|
387
|
+
* Cross-device withdrawal reservation (default `"fail-open"`). `withdraw()`
|
|
388
|
+
* claims a hold on the owner's funds before any provider call; a hold held by
|
|
389
|
+
* another device or app rejects with `WITHDRAW_IN_PROGRESS` /
|
|
390
|
+
* `details.reason === "RESERVED_ELSEWHERE"`.
|
|
391
|
+
* - `"fail-open"`: when the reservation API cannot answer (network error,
|
|
392
|
+
* timeout, 5xx, 404, 429, ...) the withdrawal proceeds as before.
|
|
393
|
+
* - `"fail-closed"`: it rejects with `WITHDRAW_RESERVATION_UNAVAILABLE`
|
|
394
|
+
* before anything is submitted.
|
|
395
|
+
* - `"off"`: never calls the reservation API.
|
|
396
|
+
* `OWNEY_WITHDRAWAL_RESERVATION_DISABLED=1` in the environment acts as `"off"`.
|
|
397
|
+
*/
|
|
398
|
+
withdrawalReservation?: "fail-open" | "fail-closed" | "off";
|
|
399
|
+
/**
|
|
400
|
+
* Hand Zyfai withdrawals and deposit registrations, with the user's Zyfai
|
|
401
|
+
* session, to the Owney routing API, which then sends them itself (default
|
|
402
|
+
* off). Only `true`, or a function that returns `true`, opts in.
|
|
403
|
+
*
|
|
404
|
+
* A function is called for each operation, at the moment it would first
|
|
405
|
+
* hand a withdrawal or a registration off, so an app can turn the handoff on
|
|
406
|
+
* or off in open tabs without a reload. A function that throws counts as
|
|
407
|
+
* off.
|
|
408
|
+
*
|
|
409
|
+
* Off, the SDK hands no new operation off, never sends the Zyfai session to
|
|
410
|
+
* Owney for it, and behaves as before. Turning it off never makes the
|
|
411
|
+
* browser send what the server may already hold: an operation this SDK
|
|
412
|
+
* instance already handed off keeps going through the server (its nudges,
|
|
413
|
+
* re-runs, retries and registration recovery). Recovery of a deposit handed
|
|
414
|
+
* off by an earlier page waits until it is on again.
|
|
415
|
+
*/
|
|
416
|
+
zyfaiServerTasks?: boolean | (() => boolean);
|
|
417
|
+
/**
|
|
418
|
+
* Hand each signed cross-chain (Fusion+) order's secrets to the Owney
|
|
419
|
+
* routing API, which publishes them once 1inch is ready, so the swap
|
|
420
|
+
* completes even if the tab closes (default false). Only `true` opts in.
|
|
421
|
+
* Off, the secrets never leave the browser and swaps behave as before. On,
|
|
422
|
+
* the browser still publishes them too.
|
|
423
|
+
*/
|
|
424
|
+
fusionSecretHandoff?: boolean;
|
|
299
425
|
}
|
|
300
426
|
interface ConnectionState {
|
|
301
427
|
provider: any;
|
|
302
428
|
walletAddress: `0x${string}`;
|
|
303
429
|
chainId: number | null;
|
|
430
|
+
/**
|
|
431
|
+
* Reads under this state use a saved sign-in only: an agent never opens a
|
|
432
|
+
* wallet prompt for them and fails instead. Set by the whole-portfolio reads
|
|
433
|
+
* of an agent that is not active on the connection chain, and by every read
|
|
434
|
+
* of an agent that did not sign in this session (it failed while another
|
|
435
|
+
* agent signed in, or the user cancelled its sign-in).
|
|
436
|
+
*/
|
|
437
|
+
promptless?: boolean;
|
|
304
438
|
}
|
|
305
439
|
declare const SUPPORTED_TOKENS: readonly ["USDC", "WETH"];
|
|
306
440
|
declare const SUPPORTED_CHAIN_IDS: readonly [8453, 42161, 1];
|
|
@@ -309,7 +443,462 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
|
309
443
|
type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
|
|
310
444
|
type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
|
|
311
445
|
|
|
312
|
-
|
|
446
|
+
/** Capability flag: this SDK can hand Zyfai withdrawals and deposit
|
|
447
|
+
* registrations to the server, and marks such legs with evidence `serverTask`.
|
|
448
|
+
* Older builds do not export this. */
|
|
449
|
+
declare const ZYFAI_SERVER_TASKS: 1;
|
|
450
|
+
/** A `zyfai_withdrawal` task that failed with one of these codes never sent
|
|
451
|
+
* the withdrawal to Zyfai. */
|
|
452
|
+
declare const ZYFAI_WITHDRAWAL_NOT_SENT_CODES: ReadonlySet<string>;
|
|
453
|
+
/** A `zyfai_deposit_registration` task that failed with one of these codes
|
|
454
|
+
* never registered the deposit with Zyfai, so the browser may register it. */
|
|
455
|
+
declare const ZYFAI_REGISTRATION_NOT_SENT_CODES: ReadonlySet<string>;
|
|
456
|
+
type ZyfaiTaskResult = {
|
|
457
|
+
providerWithdrawalId?: string;
|
|
458
|
+
providerDepositId?: string;
|
|
459
|
+
txHash?: string;
|
|
460
|
+
asyncPending?: true;
|
|
461
|
+
handedOff?: "reconciler";
|
|
462
|
+
lifecycle?: "failed";
|
|
463
|
+
};
|
|
464
|
+
/**
|
|
465
|
+
* - accepted: the server has a task for this leg (its state and code);
|
|
466
|
+
* - declined: the server proved no task was created (a 200 decline, or a 400,
|
|
467
|
+
* 401, 403, 404, 409 or 429; or `ZYFAI_SERVER_TASKS_OFF_CODE` without the
|
|
468
|
+
* opt-in);
|
|
469
|
+
* - unknown: anything else. The server may have a task.
|
|
470
|
+
*/
|
|
471
|
+
type ZyfaiHandoffAnswer = {
|
|
472
|
+
type: "accepted";
|
|
473
|
+
taskId: string;
|
|
474
|
+
state: string;
|
|
475
|
+
code?: string;
|
|
476
|
+
result: ZyfaiTaskResult;
|
|
477
|
+
} | {
|
|
478
|
+
type: "declined";
|
|
479
|
+
code: string;
|
|
480
|
+
} | {
|
|
481
|
+
type: "unknown";
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* One protocol's pool selection on one chain. `pools` holds Zyfai pool NAMES
|
|
486
|
+
* verbatim — matched case-sensitively by customizeBatch, and an unrecognised
|
|
487
|
+
* name makes Zyfai's rebalance engine skip the whole protocol, so these strings
|
|
488
|
+
* must not be normalised anywhere.
|
|
489
|
+
*
|
|
490
|
+
* An empty array means "no usable pools on this chain".
|
|
491
|
+
*/
|
|
492
|
+
type OrgPoolSelection = {
|
|
493
|
+
protocolId: string;
|
|
494
|
+
chainId: number;
|
|
495
|
+
pools: string[];
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* The partner's protocol/pool policy (ROUT-224). Sparse — only protocols they
|
|
499
|
+
* narrowed appear. Optional so an older routing API, which does not return the
|
|
500
|
+
* field, still parses; undefined and null both mean "change nothing".
|
|
501
|
+
*/
|
|
502
|
+
type OrgPoolPolicy = {
|
|
503
|
+
autoApproveProtocols: boolean;
|
|
504
|
+
autoApprovePools: boolean;
|
|
505
|
+
selections: OrgPoolSelection[];
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* The organization's agent execution policy, or null when the partner has never
|
|
509
|
+
* configured one — in which case the agents leave the user's profile alone.
|
|
510
|
+
*/
|
|
511
|
+
type OrgAgentConfig = {
|
|
512
|
+
splittingMode: "none" | "automatic" | "force";
|
|
513
|
+
minSplits: number | null;
|
|
514
|
+
poolPolicy?: OrgPoolPolicy | null;
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Pool policy: Owney's org-level protocol/pool policy -> Zyfai's two mismatched
|
|
519
|
+
* write shapes.
|
|
520
|
+
*
|
|
521
|
+
* Zyfai splits "which protocols and pools may this user's funds sit in" across
|
|
522
|
+
* two calls that do not share an axis:
|
|
523
|
+
*
|
|
524
|
+
* updateUserProfile({ protocols }) per ASSET, chain-agnostic
|
|
525
|
+
* customizeBatch([{ protocolId, per (PROTOCOL, CHAIN), asset-agnostic
|
|
526
|
+
* chainId, pools, autoselect }])
|
|
527
|
+
*
|
|
528
|
+
* `protocols` is an explicit ALLOW-LIST: a protocol left out of it is disabled
|
|
529
|
+
* for that asset, on every chain, immediately. `customizeBatch` is the opposite
|
|
530
|
+
* shape — one record per (protocol, chain) pair, asset-agnostic, and per
|
|
531
|
+
* docs.zyf.ai it "creates or updates a record for the (user, protocol, chain)
|
|
532
|
+
* combination"; "previous customizations for the same combination are
|
|
533
|
+
* overwritten".
|
|
534
|
+
*
|
|
535
|
+
* That second property is the reason this file exists rather than a single
|
|
536
|
+
* flat translation: customizeBatch overwrites only the combinations it is
|
|
537
|
+
* GIVEN. The partner's stored policy (`OrgPoolPolicy.selections`) is sparse —
|
|
538
|
+
* only the protocols they actually narrowed appear — but the payload we send
|
|
539
|
+
* must be EXHAUSTIVE over every (protocol, chain) pair Zyfai offers this user.
|
|
540
|
+
* If we only sent the narrowed pairs, a partner who restricts Morpho, saves,
|
|
541
|
+
* then later re-ticks every pool box would never be able to undo it: nothing
|
|
542
|
+
* in the (sparse) policy would tell us to send a record clearing it, and the
|
|
543
|
+
* old restrictive record would stay live on the user's profile forever.
|
|
544
|
+
*
|
|
545
|
+
* Pure functions, kept out of the agent so the mapping is testable without a
|
|
546
|
+
* Zyfai client. See splitting.ts for the same pattern on the other lever.
|
|
547
|
+
*/
|
|
548
|
+
|
|
549
|
+
/** One selectable pool, with the figures the deposit-time Pools step shows. */
|
|
550
|
+
type AvailablePool = {
|
|
551
|
+
chainId: number;
|
|
552
|
+
token: string;
|
|
553
|
+
name: string;
|
|
554
|
+
/** combined_apy (pool + rewards), already a percent. null when absent. */
|
|
555
|
+
apy: number | null;
|
|
556
|
+
/** TVL in USD. null when absent. See ZyfCustomizationPoolInfo: `tvl` is in
|
|
557
|
+
* the pool's own token, `tvlUsd` is the dollar figure — only the latter is
|
|
558
|
+
* safe to show with a currency symbol. */
|
|
559
|
+
tvlUsd: number | null;
|
|
560
|
+
/** Per-pool deep link (e.g. the Morpho vault page). null when absent. */
|
|
561
|
+
link: string | null;
|
|
562
|
+
/**
|
|
563
|
+
* The pool's on-chain vault address. Yieldseeker identifies its pools by it.
|
|
564
|
+
* Zyfai identifies its pools by name and sends no address, so for Zyfai it is
|
|
565
|
+
* read from the pool's link where that names a vault (Morpho and Euler
|
|
566
|
+
* vaults) and is unset otherwise. It is how the same vault offered by two
|
|
567
|
+
* agents is recognised.
|
|
568
|
+
*/
|
|
569
|
+
address?: string;
|
|
570
|
+
};
|
|
571
|
+
/** Public Zyfai strategies used by deposit-time pool customization. */
|
|
572
|
+
type PoolSelectionStrategy = "aggressive" | "yieldmaxxing";
|
|
573
|
+
/** One asset's explicit choice for a protocol on one chain. */
|
|
574
|
+
type UserPoolSelection = {
|
|
575
|
+
asset: "USDC" | "WETH";
|
|
576
|
+
protocolId: string;
|
|
577
|
+
chainId: number;
|
|
578
|
+
/**
|
|
579
|
+
* Names enabled by the user for this asset/protocol/chain. Empty, with
|
|
580
|
+
* `availablePools` not empty, means the user chose none of them.
|
|
581
|
+
*/
|
|
582
|
+
pools: string[];
|
|
583
|
+
/** Every name shown for this asset/protocol/chain in the superset catalog. */
|
|
584
|
+
availablePools: string[];
|
|
585
|
+
};
|
|
586
|
+
/**
|
|
587
|
+
* The complete saved draft for the asset/chain legs selected in the deposit.
|
|
588
|
+
*
|
|
589
|
+
* Every agent keeps at least one pool (2026-11-11): a request whose every
|
|
590
|
+
* entry for an asset and chain has empty `pools` (with pools shown) is
|
|
591
|
+
* refused with POOL_SELECTION_REQUIRED before anything is written, unless
|
|
592
|
+
* (Zyfai) a protocol the request does not touch keeps a pool there. A "none
|
|
593
|
+
* chosen" saved before that rule is still read back as none. Entries that
|
|
594
|
+
* showed nothing (`availablePools` empty) change nothing.
|
|
595
|
+
*/
|
|
596
|
+
type UserPoolSelectionRequest = {
|
|
597
|
+
strategies: Array<{
|
|
598
|
+
asset: "USDC" | "WETH";
|
|
599
|
+
strategy: PoolSelectionStrategy;
|
|
600
|
+
}>;
|
|
601
|
+
selections: UserPoolSelection[];
|
|
602
|
+
};
|
|
603
|
+
/**
|
|
604
|
+
* What a user's account currently has saved (ROUT-650): each asset's strategy,
|
|
605
|
+
* plus the pool list of every protocol/chain pair frozen by an earlier Save.
|
|
606
|
+
* Pairs Zyfai still autoselects are left out, so "no entry" means "default"
|
|
607
|
+
* (nothing saved). A pair that is present with empty `pools` means none
|
|
608
|
+
* chosen: the user picked none of that pair's pools.
|
|
609
|
+
*/
|
|
610
|
+
type SavedPoolSelection = {
|
|
611
|
+
strategies: Array<{
|
|
612
|
+
asset: "USDC" | "WETH";
|
|
613
|
+
strategy: string;
|
|
614
|
+
}>;
|
|
615
|
+
pairs: Array<{
|
|
616
|
+
protocolId: string;
|
|
617
|
+
chainId: number;
|
|
618
|
+
pools: string[];
|
|
619
|
+
}>;
|
|
620
|
+
};
|
|
621
|
+
/** One protocol with its pools for the deposit asset — what the Pools step
|
|
622
|
+
* renders: a protocol row that opens to a list of selectable pools. */
|
|
623
|
+
type PoolCatalogProtocol = {
|
|
624
|
+
protocolId: string;
|
|
625
|
+
name: string;
|
|
626
|
+
logo: string | null;
|
|
627
|
+
pools: AvailablePool[];
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
|
|
631
|
+
/**
|
|
632
|
+
* Read access to the funding ledger, given to agents by the client so they can
|
|
633
|
+
* hold earnings while a provider lags (spec B2). Both reads never throw:
|
|
634
|
+
* null means "no ledger information", and callers then behave as before.
|
|
635
|
+
*/
|
|
636
|
+
type AgentFundingLedgerAccess = {
|
|
637
|
+
/** `sdk.listFundingOperations` for this owner; null when the owner is not the connected one or on failure. */
|
|
638
|
+
listOperations(input: {
|
|
639
|
+
owner: string;
|
|
640
|
+
chainId: number;
|
|
641
|
+
asset: string;
|
|
642
|
+
since?: Date;
|
|
643
|
+
}): Promise<FundingOperationRow[] | null>;
|
|
644
|
+
/** The newest server provider-snapshot sample at or before `before`; null when none or on failure. */
|
|
645
|
+
providerSnapshot?(input: {
|
|
646
|
+
owner: string;
|
|
647
|
+
chainId: number;
|
|
648
|
+
asset: string;
|
|
649
|
+
agentWallet: string;
|
|
650
|
+
before: Date;
|
|
651
|
+
}): Promise<ProviderSnapshotSample | null>;
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
654
|
+
* What an agent did with a confirmed-deposit notice (`IAgent.depositConfirmed`).
|
|
655
|
+
* `attempts` counts the provider calls made. `allocated` is set when the agent
|
|
656
|
+
* checked whether the deposit was put to work; `allocatesAfter` (ISO) is when
|
|
657
|
+
* the provider will act on it at the earliest, when it said so.
|
|
658
|
+
*/
|
|
659
|
+
type DepositNotice = {
|
|
660
|
+
notified: true;
|
|
661
|
+
attempts?: number;
|
|
662
|
+
allocated?: boolean;
|
|
663
|
+
reason?: string;
|
|
664
|
+
allocatesAfter?: string;
|
|
665
|
+
} | {
|
|
666
|
+
notified: false;
|
|
667
|
+
reason: string;
|
|
668
|
+
attempts?: number;
|
|
669
|
+
};
|
|
670
|
+
interface IAgent {
|
|
671
|
+
readonly id: string;
|
|
672
|
+
readonly supportedChainIds: readonly OwneySupportedChainId[];
|
|
673
|
+
readonly supportedAssets: readonly AgentSupportedAssets[];
|
|
674
|
+
/**
|
|
675
|
+
* Describes how `AgentBalance.tokens` relates to `positions`.
|
|
676
|
+
* Most adapters expose token totals that already include deployed positions.
|
|
677
|
+
* Providers such as Yieldseeker expose idle wallet tokens separately, so
|
|
678
|
+
* withdrawal planning must add matching position amounts.
|
|
679
|
+
*/
|
|
680
|
+
readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
|
|
681
|
+
/**
|
|
682
|
+
* Whether a withdrawal requires an owner-approved wallet transaction.
|
|
683
|
+
* Aggregate withdrawals run these agents before relayer-only agents so a
|
|
684
|
+
* rejected wallet request cannot happen after another leg has committed.
|
|
685
|
+
*/
|
|
686
|
+
readonly withdrawalRequiresWalletApproval?: boolean;
|
|
687
|
+
/**
|
|
688
|
+
* Settles this agent's own wallet prompts (a login, a session key) so that a
|
|
689
|
+
* following `withdraw` needs none. A multi-agent withdrawal calls it before a
|
|
690
|
+
* wallet-approval agent's owner signature, so two prompts never overlap and
|
|
691
|
+
* this agent can start as soon as that signature was accepted. Never submits
|
|
692
|
+
* a withdrawal. A rejected prompt throws; other failures are left to `withdraw`.
|
|
693
|
+
*/
|
|
694
|
+
prepareWithdrawal?(state: ConnectionState, chainId: number, token: OwneySupportedTokens): Promise<void>;
|
|
695
|
+
/**
|
|
696
|
+
* The adapter can hand its withdrawal to our server (part 4, Zyfai). Only
|
|
697
|
+
* such agents get the plan-time handoff and a `planned` withdraw context;
|
|
698
|
+
* every other agent keeps today's calls.
|
|
699
|
+
*/
|
|
700
|
+
readonly supportsServerTasks?: true;
|
|
701
|
+
/**
|
|
702
|
+
* Hands a planned withdrawal leg to our server before an earlier
|
|
703
|
+
* wallet-approval leg is signed (`after`: those legs' keys). The server sends
|
|
704
|
+
* it once those legs are accepted. Never throws; never withdraws locally.
|
|
705
|
+
* `amount` is the leg's planned share, or "MAX". `beforeRequest` runs right
|
|
706
|
+
* before the request leaves (never when none is sent), so the caller can
|
|
707
|
+
* save the leg's server mark first.
|
|
708
|
+
*/
|
|
709
|
+
handOffPlannedWithdrawal?(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount: string, ctx: {
|
|
710
|
+
operationId: string;
|
|
711
|
+
after: string[];
|
|
712
|
+
beforeRequest?: () => void;
|
|
713
|
+
}): Promise<ZyfaiHandoffAnswer>;
|
|
714
|
+
disconnect(): Promise<void>;
|
|
715
|
+
/**
|
|
716
|
+
* Ready the user's account for every asset the agent supports on `chainId`,
|
|
717
|
+
* `asset` first. A failure the provider says will not go away (the user can
|
|
718
|
+
* never have this agent) carries `details.permanent: true`, and the client
|
|
719
|
+
* then refuses the whole connect (`AGENT_ACTIVATION_BLOCKED`).
|
|
720
|
+
*/
|
|
721
|
+
activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
|
|
722
|
+
/**
|
|
723
|
+
* True when the provider reported this session that the user cannot have an
|
|
724
|
+
* agent for this chain and asset (Yieldseeker's active-agent limit). Callers
|
|
725
|
+
* leave the slot out of deposits. Optional: an agent without such a limit
|
|
726
|
+
* omits it.
|
|
727
|
+
*/
|
|
728
|
+
isSlotUnavailable?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): boolean;
|
|
729
|
+
/**
|
|
730
|
+
* Apply the organization's agent policy to this user's account.
|
|
731
|
+
*
|
|
732
|
+
* Optional: an agent that has no equivalent knob simply omits it, which is why
|
|
733
|
+
* this is not part of `activateAgent`'s signature. Declared on the interface
|
|
734
|
+
* rather than only on ZyfaiAgent so the contract stays agent-neutral — the
|
|
735
|
+
* ticket asks for a design that can also cover Surf, which has no adapter yet.
|
|
736
|
+
*
|
|
737
|
+
* Implementations must be **non-fatal**: this runs during activation as a side
|
|
738
|
+
* effect, so a failure has to leave the user connected and their profile
|
|
739
|
+
* unchanged rather than break the connect.
|
|
740
|
+
*/
|
|
741
|
+
applyOrgPolicy?(state: ConnectionState, chainId: number, policy: OrgAgentConfig): Promise<void>;
|
|
742
|
+
/**
|
|
743
|
+
* The deposit-time pool catalogue for one asset and strategy: protocols with
|
|
744
|
+
* their selectable pools and figures. Optional — an agent with no pool
|
|
745
|
+
* customization omits it. (ROUT-569)
|
|
746
|
+
*/
|
|
747
|
+
getPoolCatalog?(params: {
|
|
748
|
+
asset: string;
|
|
749
|
+
strategy: "conservative" | "aggressive" | "yieldmaxxing";
|
|
750
|
+
}): Promise<PoolCatalogProtocol[]>;
|
|
751
|
+
/**
|
|
752
|
+
* Apply a user's own pool selection to their account, driven by the
|
|
753
|
+
* deposit-time Pools step. Optional. A failure throws, and the caller
|
|
754
|
+
* must not start the deposit. A save must also reach money already
|
|
755
|
+
* invested: Zyfai rebalances on its own, Yieldseeker is told with
|
|
756
|
+
* `deposit-made`. Every agent keeps at least one pool: a selection that
|
|
757
|
+
* would leave the agent with no pool for an asset on a chain it offers pools
|
|
758
|
+
* for throws POOL_SELECTION_REQUIRED before anything is written.
|
|
759
|
+
* `state` is the client's connection, or undefined when there is none; an
|
|
760
|
+
* agent that signs in per call (Yieldseeker) needs it, and one that is
|
|
761
|
+
* already connected (Zyfai) ignores it. (ROUT-569)
|
|
762
|
+
*/
|
|
763
|
+
setPoolSelection?(selection: UserPoolSelectionRequest, state?: ConnectionState): Promise<void>;
|
|
764
|
+
/**
|
|
765
|
+
* Read back what `setPoolSelection` saved, for the pairs and assets given,
|
|
766
|
+
* so the Pools step can open on the user's own choices. Optional. (ROUT-650)
|
|
767
|
+
*/
|
|
768
|
+
getPoolSelection?(state: ConnectionState, chainId: number, params: {
|
|
769
|
+
pairs: Array<{
|
|
770
|
+
protocolId: string;
|
|
771
|
+
chainId: number;
|
|
772
|
+
}>;
|
|
773
|
+
assets: Array<"USDC" | "WETH">;
|
|
774
|
+
}): Promise<SavedPoolSelection>;
|
|
775
|
+
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback, onProgress?: FundingProgress, onBeforeSubmission?: (evidence: FundingEvidence) => void | Promise<void>,
|
|
776
|
+
/** `operationId`: the funding ledger operation. Zyfai hands the deposit's
|
|
777
|
+
* registration to the server with it (only agents with
|
|
778
|
+
* `supportsServerTasks` get it; every other agent keeps today's call). */
|
|
779
|
+
context?: {
|
|
780
|
+
operationId?: string;
|
|
781
|
+
}): Promise<OwneyDepositResult>;
|
|
782
|
+
withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress, gasMode?: "auto" | "sponsored" | "paid", onBeforeSubmission?: FundingProgress, assertCurrent?: () => void,
|
|
783
|
+
/** `operationId`: the funding ledger operation (Yieldseeker opts in to the
|
|
784
|
+
* server-owned send of its sponsored userOp with it; Zyfai hands its
|
|
785
|
+
* withdrawal to the server with it). `planned`: the leg was handed to the
|
|
786
|
+
* server at plan time, so this call nudges that task (only for agents with
|
|
787
|
+
* `supportsServerTasks`). */
|
|
788
|
+
context?: {
|
|
789
|
+
operationId?: string;
|
|
790
|
+
planned?: true;
|
|
791
|
+
}): Promise<AgentWithdrawResult>;
|
|
792
|
+
/** Read-only MAX proof at the owner payout block; never sends another withdrawal. */
|
|
793
|
+
verifyWithdrawalCompletion?(state: ConnectionState, evidence: FundingEvidence): Promise<WithdrawalCompletion>;
|
|
794
|
+
/** A newly observed pool allocation invalidates this asset's portfolio cache only. */
|
|
795
|
+
invalidateAllocationRead?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): void;
|
|
796
|
+
/**
|
|
797
|
+
* A deposit into this agent just confirmed on-chain. An agent whose provider
|
|
798
|
+
* can act on a deposit at once tells it here (Yieldseeker then allocates it
|
|
799
|
+
* instead of waiting for its next scheduled check). The client calls it once
|
|
800
|
+
* per confirmed transfer, in the background: it must never prompt the wallet
|
|
801
|
+
* and never throw. Agents without it rely on their provider's own discovery.
|
|
802
|
+
* An agent that calls its provider more than once, or checks the outcome,
|
|
803
|
+
* reports each call through `onNotice` and resolves with the final outcome.
|
|
804
|
+
*/
|
|
805
|
+
depositConfirmed?(state: ConnectionState, chainId: number, evidence: FundingEvidence, onNotice?: (notice: DepositNotice & {
|
|
806
|
+
attempt: number;
|
|
807
|
+
}) => void): Promise<DepositNotice>;
|
|
808
|
+
/** Invalidate only the confirmed asset. This hook must not sign or submit transactions. */
|
|
809
|
+
invalidateFundingRead?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, refreshUntil?: number, txHash?: string): void;
|
|
810
|
+
/** End accelerated balance reads only for the exact snapshot the caller displayed. */
|
|
811
|
+
endFundingBalanceRefresh?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, read: AssetReadMetadata): boolean;
|
|
812
|
+
getFundingHistory?(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
|
|
813
|
+
getFundingWallet?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<string>;
|
|
814
|
+
/** Verify the displayed remaining balance after a receipt-confirmed payout.
|
|
815
|
+
* Undefined means unknown; never substitute a failed read with zero. */
|
|
816
|
+
verifyWithdrawalBalance?(state: ConnectionState, evidence: FundingEvidence, balance: AgentBalance): Promise<AssetReadMetadata | undefined>;
|
|
817
|
+
/** Read-only chain proof when indexed withdrawal components are incomplete.
|
|
818
|
+
* Returns raw owner-withdrawable units; unavailable proof must throw.
|
|
819
|
+
* minimumAmount is the raw liquidity required from this agent for a typed
|
|
820
|
+
* plan, so adapters can expand discovery when known positions fall short. */
|
|
821
|
+
getWithdrawableBalance?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, minimumAmount?: bigint): Promise<bigint>;
|
|
822
|
+
/** Optional positive proof for a repeat deposit; unknown must fall back to portfolio validation. */
|
|
823
|
+
hasExistingDepositFunds?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<true | undefined>;
|
|
824
|
+
getBalances(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<AgentBalance>;
|
|
825
|
+
/**
|
|
826
|
+
* Whether this wallet can be read on `chainId` from a saved sign-in, with no
|
|
827
|
+
* wallet prompt. Lets the whole-portfolio reads include an agent that does
|
|
828
|
+
* not run on the connection chain (Yieldseeker on Base while the wallet is
|
|
829
|
+
* on Arbitrum); agents without it are read only while active.
|
|
830
|
+
*/
|
|
831
|
+
hasReadSession?(state: ConnectionState, chainId: number): boolean;
|
|
832
|
+
getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
|
|
833
|
+
/** Funding-ledger read access for earnings holds. Optional; without it an agent behaves as before. */
|
|
834
|
+
setFundingLedgerAccess?(access: AgentFundingLedgerAccess | undefined): void;
|
|
835
|
+
/**
|
|
836
|
+
* Called each time the agent maps a provider refusal for a wallet whose
|
|
837
|
+
* account was not created through Owney (AGENT_ACCOUNT_NOT_OWNEY). Optional.
|
|
838
|
+
*/
|
|
839
|
+
setAccountRefusedListener?(listener: (() => void) | undefined): void;
|
|
840
|
+
/**
|
|
841
|
+
* May this wallet's account use Owney with this agent? Run at connect for
|
|
842
|
+
* every agent about to activate, before any agent activates or is read.
|
|
843
|
+
* Throws a permanent OwneyError (`details.permanent: true`) when it never
|
|
844
|
+
* can, any other error when it cannot tell now. It may sign in; it must not
|
|
845
|
+
* create agents or read balances. Optional; without it the agent is not
|
|
846
|
+
* checked.
|
|
847
|
+
*/
|
|
848
|
+
checkAccount?(state: ConnectionState, chainId: number): Promise<void>;
|
|
849
|
+
/**
|
|
850
|
+
* A small, never-prompting read of the provider's earnings bookkeeping for a
|
|
851
|
+
* `provider.sample` ledger event (Zyfai). Null when unavailable; never throws.
|
|
852
|
+
*/
|
|
853
|
+
providerEarningsSample?(state: ConnectionState, chainId: number): Promise<Record<string, unknown> | null>;
|
|
854
|
+
/**
|
|
855
|
+
* Refresh the agent's earnings snapshot when its backend supports doing so.
|
|
856
|
+
* Implementations own freshness and request-deduplication policy.
|
|
857
|
+
*/
|
|
858
|
+
refreshEarnings?(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
|
|
859
|
+
getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays,
|
|
860
|
+
/**
|
|
861
|
+
* Optional asset symbol ("USDC" / "WETH") scoping the daily series to a
|
|
862
|
+
* single asset on the chain. Agents without per-asset positions ignore it.
|
|
863
|
+
*/
|
|
864
|
+
tokenSymbol?: string,
|
|
865
|
+
/**
|
|
866
|
+
* Chain the series is scoped to, when that differs from the chain the
|
|
867
|
+
* connection is on. `null` spans every chain the wallet held (ROUT-479);
|
|
868
|
+
* omitted means `chainId`. Kept apart from `chainId` because that one
|
|
869
|
+
* still resolves the wallet and must stay a real, connected chain.
|
|
870
|
+
*/
|
|
871
|
+
scopeChainId?: number | null): Promise<AccountAgentApy>;
|
|
872
|
+
/**
|
|
873
|
+
* Daily cumulative earnings in token units, scoped to a chain/asset, using
|
|
874
|
+
* the provider's earnings basis. Include an opening snapshot when available
|
|
875
|
+
* so the "recent earnings" subline can difference the endpoints. (ROUT-452)
|
|
876
|
+
*/
|
|
877
|
+
getDailyEarnings?(state: ConnectionState, chainId: number, days: LookbackDays, tokenSymbol?: string): Promise<AccountDailyEarnings>;
|
|
878
|
+
getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
|
|
879
|
+
getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
|
|
880
|
+
/**
|
|
881
|
+
* Ensure the given asset uses backend protocol auto-selection
|
|
882
|
+
* (`autoSelectProtocols: true`). Optional capability — only agents whose
|
|
883
|
+
* backend models per-asset protocol selection implement it. Returns whether
|
|
884
|
+
* a write occurred (`false` = already enabled / not supported).
|
|
885
|
+
*/
|
|
886
|
+
ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
|
|
887
|
+
supportsAgentApyPeriod?(days: DailyApyDays): boolean;
|
|
888
|
+
getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Optional filters for per-agent APY lookups.
|
|
892
|
+
* - `tokenSymbol` / `chainId` scope the APY to a specific asset+chain when
|
|
893
|
+
* the underlying provider supports it (Zyfai). Agents whose backends do
|
|
894
|
+
* not yet support per-asset APY will ignore these options.
|
|
895
|
+
*/
|
|
896
|
+
type AgentApyOptions = {
|
|
897
|
+
tokenSymbol?: string;
|
|
898
|
+
chainId?: number;
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
type AgentId = "zyfai" | "yieldseeker";
|
|
313
902
|
type Asset = string;
|
|
314
903
|
type AgentSupportedAsset = {
|
|
315
904
|
readonly symbol: string;
|
|
@@ -327,19 +916,28 @@ type AvailableAgent = {
|
|
|
327
916
|
supportedAssets: readonly AgentSupportedAssets[];
|
|
328
917
|
};
|
|
329
918
|
type ActivateAgentOptions = {
|
|
919
|
+
/** Limits agent setup to what this asset needs. Omit for every asset. */
|
|
920
|
+
asset?: OwneySupportedTokens;
|
|
330
921
|
/**
|
|
331
|
-
* Called once the chain and agents are registered
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
922
|
+
* Called once the chain and agents are registered and every agent's account
|
|
923
|
+
* check has passed (an agent's check may sign it in), before any agent runs
|
|
924
|
+
* its setup. Not called when a check fails. From then on reads such as
|
|
925
|
+
* `getBalances` are safe to start: each agent's reads wait on that agent's
|
|
926
|
+
* own sign-in, so they share the activation's one wallet prompt instead of
|
|
927
|
+
* waiting for all of setup.
|
|
335
928
|
*/
|
|
336
929
|
onAgentsSelected?: () => void;
|
|
337
930
|
};
|
|
338
931
|
type AvailableAgentsOptions = {
|
|
339
932
|
chainId?: number;
|
|
340
933
|
asset?: Asset;
|
|
341
|
-
/** Disabled agents are omitted by default because they cannot accept funds.
|
|
934
|
+
/** Disabled agents are omitted by default because they cannot accept funds.
|
|
935
|
+
* Listing them also lists unavailable agents: both may still hold funds. */
|
|
342
936
|
includeDisabled?: boolean;
|
|
937
|
+
/** Agents unavailable on `chainId` and `asset` this session are omitted by
|
|
938
|
+
* default because they get no deposits: their provider has no agent for the
|
|
939
|
+
* slot. See `OwneySDK.getUnavailableAgentIds`. */
|
|
940
|
+
includeUnavailable?: boolean;
|
|
343
941
|
};
|
|
344
942
|
/**
|
|
345
943
|
* A lookback window for any "last N days" read — the APY series, the daily
|
|
@@ -367,6 +965,7 @@ type HistoryFilters = {
|
|
|
367
965
|
tokenSymbol?: string;
|
|
368
966
|
};
|
|
369
967
|
type HistoryOptions = {
|
|
968
|
+
chainId?: number;
|
|
370
969
|
agentId?: AgentId;
|
|
371
970
|
filters?: HistoryFilters;
|
|
372
971
|
/**
|
|
@@ -380,15 +979,54 @@ type HistoryOptions = {
|
|
|
380
979
|
chainIds?: OwneySupportedChainId[];
|
|
381
980
|
};
|
|
382
981
|
type WithdrawOptions = {
|
|
982
|
+
/** Internal orchestration observation deadline; never retries a send. */
|
|
983
|
+
observationDeadline?: number;
|
|
984
|
+
assertCurrent?: () => void;
|
|
985
|
+
/** Yieldseeker V2 only. "auto" requests sponsorship for a verified V2 wallet. */
|
|
986
|
+
gasMode?: "auto" | "sponsored" | "paid";
|
|
987
|
+
/** Exclude unresolved providers from aggregate withdrawals; direct agent requests are unchanged. */
|
|
988
|
+
excludeAgentIds?: AgentId[];
|
|
989
|
+
onProgress?: FundingProgress;
|
|
990
|
+
/**
|
|
991
|
+
* Durable pre-dispatch checkpoint for adapters with a recoverable operation ID.
|
|
992
|
+
* Rejection prevents submission; progress observers remain non-fatal.
|
|
993
|
+
*/
|
|
994
|
+
onBeforeSubmission?: FundingProgress;
|
|
383
995
|
asset: Asset;
|
|
384
996
|
amount?: string;
|
|
385
997
|
agentId?: AgentId;
|
|
998
|
+
/** Called after each agent returns; callback failures never change a financial result. */
|
|
999
|
+
onAgentResult?: (agentId: AgentId, result: AgentWithdrawResult) => void;
|
|
1000
|
+
/** Funding ledger reference (a UUID). Defaults to a new random UUID; apps pass
|
|
1001
|
+
* their own so the app record and the ledger share one reference. It is also
|
|
1002
|
+
* the withdrawal reservation's operationId. */
|
|
1003
|
+
operationId?: string;
|
|
1004
|
+
/**
|
|
1005
|
+
* Groups this withdrawal with the others started by one user action (a
|
|
1006
|
+
* "withdraw all" sends one per asset). A UUID, recorded on the funding
|
|
1007
|
+
* ledger's operation; a value that is not a UUID is ignored.
|
|
1008
|
+
*/
|
|
1009
|
+
batchId?: string;
|
|
1010
|
+
/**
|
|
1011
|
+
* Cross-device withdrawal reservation options.
|
|
1012
|
+
* - `override`: the `reference` from an overridable `RESERVED_ELSEWHERE`
|
|
1013
|
+
* error, sent after the user chose "Withdraw anyway".
|
|
1014
|
+
* - `supersedesOperationId`: an earlier operation of this SDK (for example
|
|
1015
|
+
* the sponsored attempt a paid retry replaces). Its hold is released when
|
|
1016
|
+
* this SDK still has that operation's holder token; otherwise ignored.
|
|
1017
|
+
*/
|
|
1018
|
+
reservation?: WithdrawalReservationOptions;
|
|
386
1019
|
/**
|
|
387
1020
|
* Chain to withdraw from. Defaults to the chain `activateAgent` last set.
|
|
388
1021
|
* See `DepositOptions.chainId` — the same rules apply.
|
|
389
1022
|
*/
|
|
390
1023
|
chainId?: number;
|
|
391
1024
|
};
|
|
1025
|
+
/** `WithdrawOptions.reservation`: see there. */
|
|
1026
|
+
type WithdrawalReservationOptions = {
|
|
1027
|
+
override?: string;
|
|
1028
|
+
supersedesOperationId?: string;
|
|
1029
|
+
};
|
|
392
1030
|
type AccountApyOptions = {
|
|
393
1031
|
agentId?: AgentId;
|
|
394
1032
|
days: LookbackDays;
|
|
@@ -454,11 +1092,44 @@ type AgentsApyOptions = {
|
|
|
454
1092
|
chainId?: number;
|
|
455
1093
|
};
|
|
456
1094
|
type DepositOptions = {
|
|
1095
|
+
/** Optional synchronous foreground ownership fence for the default Permit2 rail.
|
|
1096
|
+
* Throw to stop preparation/dispatch and late journal writes after lease/session loss. */
|
|
1097
|
+
assertSubmissionCurrent?: () => void;
|
|
1098
|
+
/** Resume only these already signed relayer bytes; never create a new authorization. */
|
|
1099
|
+
resumeTxHash?: `0x${string}`;
|
|
1100
|
+
/** Resume only the saved signed batch of a deposit the server may be sending
|
|
1101
|
+
* (its prepare got no answer, so no transaction hash is known); never create
|
|
1102
|
+
* a new authorization. Check it first with `canResumePendingDeposit`. */
|
|
1103
|
+
resumeSavedBatch?: true;
|
|
1104
|
+
onProgress?: FundingProgress;
|
|
1105
|
+
/** Awaited immediately before dispatch. Throwing prevents submission.
|
|
1106
|
+
* All legs of an atomic batch are checkpointed together. */
|
|
1107
|
+
onBeforeSubmission?: (evidence: FundingEvidence[]) => void | Promise<void>;
|
|
457
1108
|
amount: string;
|
|
458
1109
|
asset: Asset;
|
|
459
1110
|
depositCallback?: DepositCallback;
|
|
460
1111
|
agentId?: AgentId;
|
|
1112
|
+
/**
|
|
1113
|
+
* Agents that must receive nothing from this deposit. The rest split the
|
|
1114
|
+
* whole amount, and only their minimums apply; an excluded agent is not read,
|
|
1115
|
+
* not prioritized as unfunded and not reported on.
|
|
1116
|
+
*
|
|
1117
|
+
* Throws `ALL_AGENTS_EXCLUDED` (before anything is read or sent) when no
|
|
1118
|
+
* agent is left, or when `agentId` itself is listed. Unknown ids are ignored.
|
|
1119
|
+
* Ignored by `resumeTxHash` and `resumeSavedBatch`: a signed batch is already
|
|
1120
|
+
* committed to its wallets and must be finished as signed.
|
|
1121
|
+
*/
|
|
1122
|
+
excludeAgentIds?: AgentId[];
|
|
461
1123
|
onApproved?: () => void;
|
|
1124
|
+
/** Funding ledger reference (a UUID). Defaults to a new random UUID; apps pass
|
|
1125
|
+
* their own so the app record and the ledger share one reference. */
|
|
1126
|
+
operationId?: string;
|
|
1127
|
+
/**
|
|
1128
|
+
* Groups this deposit with the others started by one user action (a spread
|
|
1129
|
+
* deposit sends one per position). A UUID, recorded on the funding ledger's
|
|
1130
|
+
* operation; a value that is not a UUID is ignored.
|
|
1131
|
+
*/
|
|
1132
|
+
batchId?: string;
|
|
462
1133
|
/**
|
|
463
1134
|
* Chain to deposit on. Defaults to the chain `activateAgent` last set, so
|
|
464
1135
|
* omitting it behaves exactly as before.
|
|
@@ -473,151 +1144,235 @@ type DepositOptions = {
|
|
|
473
1144
|
chainId?: number;
|
|
474
1145
|
};
|
|
475
1146
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
*/
|
|
484
|
-
type OrgPoolSelection = {
|
|
485
|
-
protocolId: string;
|
|
486
|
-
chainId: number;
|
|
487
|
-
pools: string[];
|
|
1147
|
+
type FundingStage = "pending" | "confirmed" | "unknown" | "failed" | "not-applicable";
|
|
1148
|
+
/** Vault inventory retained before the MAX payout. No signatures or secrets. */
|
|
1149
|
+
type WithdrawalCompletionContext = {
|
|
1150
|
+
vaults: string[];
|
|
1151
|
+
userId: string;
|
|
1152
|
+
agentId: string;
|
|
1153
|
+
inventoryComplete: boolean;
|
|
488
1154
|
};
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
*/
|
|
494
|
-
type OrgPoolPolicy = {
|
|
495
|
-
autoApproveProtocols: boolean;
|
|
496
|
-
autoApprovePools: boolean;
|
|
497
|
-
selections: OrgPoolSelection[];
|
|
1155
|
+
type WithdrawalCompletion = {
|
|
1156
|
+
status: "complete" | "remaining" | "unavailable";
|
|
1157
|
+
reason?: string;
|
|
1158
|
+
checkedVaults?: number;
|
|
498
1159
|
};
|
|
499
|
-
/**
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
1160
|
+
/** Hash-bound v0.6 recovery metadata. Deliberately excludes the owner signature. */
|
|
1161
|
+
type UnsignedUserOperationEvidence = {
|
|
1162
|
+
sender: string;
|
|
1163
|
+
nonce: string;
|
|
1164
|
+
initCode: string;
|
|
1165
|
+
callData: string;
|
|
1166
|
+
callGasLimit: string;
|
|
1167
|
+
verificationGasLimit: string;
|
|
1168
|
+
preVerificationGas: string;
|
|
1169
|
+
maxFeePerGas: string;
|
|
1170
|
+
maxPriorityFeePerGas: string;
|
|
1171
|
+
paymasterAndData: string;
|
|
507
1172
|
};
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
* write shapes.
|
|
512
|
-
*
|
|
513
|
-
* Zyfai splits "which protocols and pools may this user's funds sit in" across
|
|
514
|
-
* two calls that do not share an axis:
|
|
515
|
-
*
|
|
516
|
-
* updateUserProfile({ protocols }) per ASSET, chain-agnostic
|
|
517
|
-
* customizeBatch([{ protocolId, per (PROTOCOL, CHAIN), asset-agnostic
|
|
518
|
-
* chainId, pools, autoselect }])
|
|
519
|
-
*
|
|
520
|
-
* `protocols` is an explicit ALLOW-LIST: a protocol left out of it is disabled
|
|
521
|
-
* for that asset, on every chain, immediately. `customizeBatch` is the opposite
|
|
522
|
-
* shape — one record per (protocol, chain) pair, asset-agnostic, and per
|
|
523
|
-
* docs.zyf.ai it "creates or updates a record for the (user, protocol, chain)
|
|
524
|
-
* combination"; "previous customizations for the same combination are
|
|
525
|
-
* overwritten".
|
|
526
|
-
*
|
|
527
|
-
* That second property is the reason this file exists rather than a single
|
|
528
|
-
* flat translation: customizeBatch overwrites only the combinations it is
|
|
529
|
-
* GIVEN. The partner's stored policy (`OrgPoolPolicy.selections`) is sparse —
|
|
530
|
-
* only the protocols they actually narrowed appear — but the payload we send
|
|
531
|
-
* must be EXHAUSTIVE over every (protocol, chain) pair Zyfai offers this user.
|
|
532
|
-
* If we only sent the narrowed pairs, a partner who restricts Morpho, saves,
|
|
533
|
-
* then later re-ticks every pool box would never be able to undo it: nothing
|
|
534
|
-
* in the (sparse) policy would tell us to send a record clearing it, and the
|
|
535
|
-
* old restrictive record would stay live on the user's profile forever.
|
|
536
|
-
*
|
|
537
|
-
* Pure functions, kept out of the agent so the mapping is testable without a
|
|
538
|
-
* Zyfai client. See splitting.ts for the same pattern on the other lever.
|
|
539
|
-
*/
|
|
540
|
-
|
|
541
|
-
/** One selectable pool, with the figures the deposit-time Pools step shows. */
|
|
542
|
-
type AvailablePool = {
|
|
543
|
-
chainId: number;
|
|
544
|
-
token: string;
|
|
545
|
-
name: string;
|
|
546
|
-
/** combined_apy (pool + rewards), already a percent. null when absent. */
|
|
547
|
-
apy: number | null;
|
|
548
|
-
/** TVL in USD. null when absent. See ZyfCustomizationPoolInfo: `tvl` is in
|
|
549
|
-
* the pool's own token, `tvlUsd` is the dollar figure — only the latter is
|
|
550
|
-
* safe to show with a currency symbol. */
|
|
551
|
-
tvlUsd: number | null;
|
|
552
|
-
/** Per-pool deep link (e.g. the Morpho vault page). null when absent. */
|
|
553
|
-
link: string | null;
|
|
1173
|
+
type DepositAuthorizationReference = {
|
|
1174
|
+
authorizationId: `0x${string}`;
|
|
1175
|
+
predecessorTxHash?: `0x${string}`;
|
|
554
1176
|
};
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
asset: "USDC" | "WETH";
|
|
560
|
-
protocolId: string;
|
|
561
|
-
chainId: number;
|
|
562
|
-
/** Names enabled by the user for this asset/protocol/chain. */
|
|
563
|
-
pools: string[];
|
|
564
|
-
/** Every name shown for this asset/protocol/chain in the superset catalog. */
|
|
565
|
-
availablePools: string[];
|
|
566
|
-
};
|
|
567
|
-
/** The complete saved draft for the asset/chain legs selected in the deposit. */
|
|
568
|
-
type UserPoolSelectionRequest = {
|
|
569
|
-
strategies: Array<{
|
|
570
|
-
asset: "USDC" | "WETH";
|
|
571
|
-
strategy: PoolSelectionStrategy;
|
|
572
|
-
}>;
|
|
573
|
-
selections: UserPoolSelection[];
|
|
1177
|
+
type DepositReplacementValidation = {
|
|
1178
|
+
authorizationId: `0x${string}`;
|
|
1179
|
+
predecessorTxHash: `0x${string}`;
|
|
1180
|
+
replacementTxHash: `0x${string}`;
|
|
574
1181
|
};
|
|
575
|
-
/**
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
1182
|
+
/** Evidence about one provider leg. Amounts are token base units, never USD. */
|
|
1183
|
+
interface FundingEvidence {
|
|
1184
|
+
agentId: AgentId;
|
|
1185
|
+
chainId: number;
|
|
1186
|
+
token: OwneySupportedTokens;
|
|
1187
|
+
walletAddress: string;
|
|
1188
|
+
agentWallet?: string;
|
|
1189
|
+
maxCompletion?: WithdrawalCompletionContext;
|
|
1190
|
+
maxCompletionCheck?: WithdrawalCompletion;
|
|
1191
|
+
intendedAmount: string;
|
|
1192
|
+
/** A multi-agent withdrawal recorded this leg's planned amount (`intendedAmount`:
|
|
1193
|
+
* the leg's share, or "MAX") before any agent was dispatched. A plan, not a
|
|
1194
|
+
* submission: it never says the leg was sent. */
|
|
1195
|
+
planned?: true;
|
|
1196
|
+
/** The owner-authorized call of a wallet-approval withdrawal was accepted: the
|
|
1197
|
+
* bundler accepted the signed userOp (`userOpHash`), the wallet returned a
|
|
1198
|
+
* calls ID (`callsId`), or `eth_sendTransaction` returned a hash (`txHash`).
|
|
1199
|
+
* Not confirmation: the call can still revert. */
|
|
1200
|
+
ownerAuthorization?: "accepted";
|
|
1201
|
+
confirmedAmount?: string;
|
|
1202
|
+
/** Receipt delivery and fulfillment of a typed requested amount are separate facts. */
|
|
1203
|
+
amountCompletion?: "complete" | "shortfall";
|
|
1204
|
+
/** Verified difference between the typed request and the actual owner payout. */
|
|
1205
|
+
shortfallAmount?: string;
|
|
1206
|
+
txHash?: string;
|
|
1207
|
+
/** Zyfai's id for this deposit, from its registration (1-128 chars); reads its placement status. */
|
|
1208
|
+
providerDepositId?: string;
|
|
1209
|
+
/** Persisted before a sponsored EOA operation is sent. */
|
|
1210
|
+
userOpHash?: string;
|
|
1211
|
+
/** Lets recovery verify a consumed nonce even if a bundler forgets the operation. */
|
|
1212
|
+
userOperation?: UnsignedUserOperationEvidence;
|
|
1213
|
+
/** Base Account calls ID used to recover an uncertain wallet submission. */
|
|
1214
|
+
callsId?: string;
|
|
1215
|
+
/** The server owns this sponsored Yieldseeker userOp's send (true), or may
|
|
1216
|
+
* own it ("unknown": the opted-in send got no definitive answer). Either way
|
|
1217
|
+
* the leg is never "not sent". Not acceptance, not confirmation. Never sent
|
|
1218
|
+
* to the ledger. */
|
|
1219
|
+
serverSubmit?: true | "unknown";
|
|
1220
|
+
/** Zyfai server tasks. On a withdrawal leg: the server sends this withdrawal
|
|
1221
|
+
* (true), or may send it ("unknown": the handoff got no definitive answer),
|
|
1222
|
+
* so the browser never sends it. `false`: the server proved it has no task
|
|
1223
|
+
* for this leg, so the browser sends it; it clears an earlier mark (a
|
|
1224
|
+
* handoff checkpoint), and a merge must let it win over true and "unknown".
|
|
1225
|
+
* On a deposit leg: the server registers this deposit. Not acceptance, not
|
|
1226
|
+
* confirmation. Never sent to the ledger. */
|
|
1227
|
+
serverTask?: true | "unknown" | false;
|
|
1228
|
+
/** With `serverTask` on a Zyfai deposit leg: the client operation id of the
|
|
1229
|
+
* server's registration task, so registration recovery can nudge that task
|
|
1230
|
+
* after a reload. Not a secret. Never sent to the ledger. */
|
|
1231
|
+
serverTaskOperationId?: string;
|
|
1232
|
+
/** With `serverTask: "unknown"` on a Zyfai deposit leg: what the server
|
|
1233
|
+
* answered to the registration handoff. "lost": no answer (the server may
|
|
1234
|
+
* or may not have a task), so a later proof of no task lets the browser
|
|
1235
|
+
* register it. "declined": the server declined it with a code that does not
|
|
1236
|
+
* prove no task (e.g. ALREADY_REGISTERED), so the browser never registers
|
|
1237
|
+
* it. Local only: never sent to the ledger. */
|
|
1238
|
+
serverTaskCreate?: "declined" | "lost";
|
|
1239
|
+
/** Deposit execution was attempted, rather than only prepared. Not confirmation. */
|
|
1240
|
+
depositSubmission?: "started";
|
|
1241
|
+
depositAuthorization?: DepositAuthorizationReference;
|
|
1242
|
+
/** The server accepted this sponsored deposit and sends it itself if the
|
|
1243
|
+
* browser does not (true), or may have accepted it ("unknown": the prepare
|
|
1244
|
+
* got no definitive answer, no hash is known yet). Either way it is never
|
|
1245
|
+
* "not sent". Not confirmation. */
|
|
1246
|
+
serverBroadcast?: true | "unknown";
|
|
1247
|
+
/** With `serverBroadcast: "unknown"`: the deposit authorization's Permit2
|
|
1248
|
+
* deadline (unix seconds). After it no deposit of that authorization can
|
|
1249
|
+
* execute. */
|
|
1250
|
+
authorizationDeadline?: number;
|
|
1251
|
+
/** With `serverBroadcast`: the deposit authorization's Permit2 nonce
|
|
1252
|
+
* (decimal); see `checkDepositAuthorization`. */
|
|
1253
|
+
permit2Nonce?: string;
|
|
1254
|
+
blockNumber?: string;
|
|
1255
|
+
logIndexes?: number[];
|
|
1256
|
+
transferLogs?: {
|
|
1257
|
+
logIndex: number;
|
|
1258
|
+
amountRaw: string;
|
|
1259
|
+
}[];
|
|
1260
|
+
/** Sanitized execution-request evidence. Attempted does not prove server acceptance. */
|
|
1261
|
+
withdrawalRequest?: {
|
|
1262
|
+
attempted: boolean;
|
|
1263
|
+
method?: "GET" | "POST";
|
|
1264
|
+
/** The route that answered. v1 paths appear only in evidence saved before @zyfai/sdk 0.10.0. */
|
|
1265
|
+
path?: "/users/withdraw" | "/users/partial-withdraw" | "/users/withdraw/v2" | "/users/partial-withdraw/v2";
|
|
1266
|
+
elapsedMs?: number;
|
|
1267
|
+
/** Actual response status captured before the vendor replaces the HTTP error. */
|
|
1268
|
+
httpStatus?: number;
|
|
1269
|
+
failure?: "network" | "unauthorized" | "forbidden" | "rate-limited" | "insufficient-balance" | "session-key-missing" | "withdrawal-in-progress" | "other";
|
|
1270
|
+
/** When the provider accepted the request without a hash (ms since epoch). */
|
|
1271
|
+
acceptedAt?: number;
|
|
1272
|
+
/** Zyfai's v2 withdrawal id, for the lifecycle lookup (1-128 chars). */
|
|
1273
|
+
providerWithdrawalId?: string;
|
|
1274
|
+
};
|
|
1275
|
+
/** Where an on-chain payout search may start, for a hashless acceptance.
|
|
1276
|
+
* `fromBlock` is the chain head read just before the request (decimal string). */
|
|
1277
|
+
payoutSearch?: {
|
|
1278
|
+
fromBlock?: string;
|
|
1279
|
+
};
|
|
1280
|
+
transfer: FundingStage;
|
|
1281
|
+
registration: FundingStage;
|
|
1282
|
+
delivery: FundingStage;
|
|
1283
|
+
}
|
|
1284
|
+
type FundingProgress = (evidence: FundingEvidence) => void;
|
|
1285
|
+
/** The part of Zyfai's withdrawal lifecycle (`GET /users/withdrawals/{id}`) that Owney acts on. */
|
|
1286
|
+
type ZyfaiWithdrawalLifecycle = {
|
|
1287
|
+
status: string;
|
|
1288
|
+
/** The synchronous payout leg has settled. */
|
|
1289
|
+
syncSettled: boolean;
|
|
1290
|
+
/** Hash of the synchronous payout transaction; present only when well formed. */
|
|
1291
|
+
syncTxHash?: `0x${string}`;
|
|
1292
|
+
/** Delayed (protocol-cooldown) redemption legs; empty when none or unreadable. */
|
|
1293
|
+
asyncLegs: {
|
|
1294
|
+
id: string;
|
|
1295
|
+
status: string;
|
|
1296
|
+
estimatedClaimAt?: string;
|
|
1297
|
+
claimTxHash?: `0x${string}`;
|
|
1298
|
+
}[];
|
|
1299
|
+
/** Ids of delayed legs Zyfai reports as failed. */
|
|
1300
|
+
failedAsyncIds: string[];
|
|
1301
|
+
/** When the delayed part is expected to arrive; present only when a valid date. */
|
|
1302
|
+
estimatedClaimAt?: string;
|
|
1303
|
+
/** Zyfai recorded an error for this withdrawal. Its text is never carried. */
|
|
1304
|
+
hasError: boolean;
|
|
590
1305
|
};
|
|
591
|
-
/**
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
pools: AvailablePool[];
|
|
1306
|
+
/** The part of Zyfai's deposit status (`GET /users/deposits/{id}/v2`) that Owney acts on. */
|
|
1307
|
+
type ZyfaiDepositPlacement = {
|
|
1308
|
+
/** `handover_pending | credited | position_pending | positioned | recovered_to_eoa`. */
|
|
1309
|
+
status: string;
|
|
1310
|
+
/** `pending | positioned | skipped | failed`. */
|
|
1311
|
+
positionOutcome?: string;
|
|
598
1312
|
};
|
|
599
|
-
|
|
1313
|
+
interface AssetReadMetadata {
|
|
1314
|
+
chainId: number;
|
|
1315
|
+
asset: string;
|
|
1316
|
+
fetchedAt?: number;
|
|
1317
|
+
/** When the underlying provider request started; preserved on cached reads. */
|
|
1318
|
+
requestedAt?: number;
|
|
1319
|
+
/** SDK cache generation, not an onchain block or provider timestamp. */
|
|
1320
|
+
readVersion?: number;
|
|
1321
|
+
providerUpdatedAt?: string;
|
|
1322
|
+
snapshotId?: string;
|
|
1323
|
+
blockNumber?: string;
|
|
1324
|
+
netDepositsRaw?: string;
|
|
1325
|
+
/** Display-only agreement with a post-payout read. Does not prove that
|
|
1326
|
+
* provider accounting, history or allocations include the transaction. */
|
|
1327
|
+
withdrawalCheck?: {
|
|
1328
|
+
txHash: string;
|
|
1329
|
+
blockNumber: string;
|
|
1330
|
+
};
|
|
1331
|
+
positionsStatus: "available" | "unavailable";
|
|
1332
|
+
}
|
|
600
1333
|
interface OwneyDepositResult {
|
|
1334
|
+
evidence?: FundingEvidence;
|
|
601
1335
|
txHash: string;
|
|
602
1336
|
smartWallet: string;
|
|
603
1337
|
amount: string;
|
|
1338
|
+
/** Funding ledger reference for this deposit (quote it in support tickets). */
|
|
1339
|
+
operationId?: string;
|
|
604
1340
|
}
|
|
605
1341
|
interface OwneyMultiDepositResult {
|
|
606
1342
|
agentResults: Record<string, OwneyDepositResult>;
|
|
1343
|
+
/** Funding ledger reference for this deposit (quote it in support tickets). */
|
|
1344
|
+
operationId?: string;
|
|
607
1345
|
}
|
|
608
1346
|
interface AgentWithdrawResult {
|
|
1347
|
+
evidence?: FundingEvidence;
|
|
609
1348
|
txHash?: string;
|
|
610
1349
|
type: "full" | "partial";
|
|
611
|
-
/**
|
|
1350
|
+
/** Owner payout or clearing all MAX positions still needs verification. */
|
|
1351
|
+
completion?: "unverified";
|
|
1352
|
+
/** Confirmed smallest-unit amount; "0" when no owner payout is verified.
|
|
1353
|
+
* Legacy providers may return a sentinel such as "all" for a full request. */
|
|
612
1354
|
amount: string;
|
|
1355
|
+
/** Yieldseeker typed withdrawal fulfilled after an exactly verified fee
|
|
1356
|
+
* deduction. Amount remains the confirmed net owner payout, and the gross
|
|
1357
|
+
* amount must equal that payout plus the fee, all in token base units. */
|
|
1358
|
+
feeAdjustment?: {
|
|
1359
|
+
grossAmount: string;
|
|
1360
|
+
feeAmount: string;
|
|
1361
|
+
};
|
|
1362
|
+
/** Funding ledger reference for this withdrawal (quote it in support tickets).
|
|
1363
|
+
* Set on the result of a single-agent `withdraw()`, not on per-agent entries. */
|
|
1364
|
+
operationId?: string;
|
|
613
1365
|
}
|
|
614
1366
|
interface OwneyWithdrawResult {
|
|
615
1367
|
agentResult: Record<AgentId, AgentWithdrawResult>;
|
|
616
1368
|
/**
|
|
617
|
-
* Sum of
|
|
618
|
-
*
|
|
1369
|
+
* Sum of confirmed smallest-unit amounts; null while any returned leg's
|
|
1370
|
+
* payout is not yet known, including typed requests accepted asynchronously.
|
|
1371
|
+
* Evidence-less custom adapters retain their confirmed-amount contract.
|
|
619
1372
|
*/
|
|
620
1373
|
totalWithdrawn: string | null;
|
|
1374
|
+
/** Funding ledger reference for this withdrawal (quote it in support tickets). */
|
|
1375
|
+
operationId?: string;
|
|
621
1376
|
}
|
|
622
1377
|
interface OwneyToken {
|
|
623
1378
|
chain: OwneySupportedChains;
|
|
@@ -633,6 +1388,10 @@ interface OwneyPosition {
|
|
|
633
1388
|
pool?: string;
|
|
634
1389
|
asset: string;
|
|
635
1390
|
amount: string;
|
|
1391
|
+
/** Provider-native raw quantity; may represent vault shares, not the underlying asset. */
|
|
1392
|
+
amountRaw?: string;
|
|
1393
|
+
/** Withdrawable underlying asset amount in that asset's smallest units. */
|
|
1394
|
+
withdrawableAmountRaw?: string;
|
|
636
1395
|
apy?: number;
|
|
637
1396
|
tvl?: number;
|
|
638
1397
|
/** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
|
|
@@ -662,11 +1421,34 @@ interface OwneyPendingAllocation {
|
|
|
662
1421
|
/** ISO timestamp from Zyfai's `updatedAt`, when the payload carries one. */
|
|
663
1422
|
since?: string;
|
|
664
1423
|
}
|
|
1424
|
+
/**
|
|
1425
|
+
* A Zyfai delayed redemption in flight (`REQUESTED` or `CLAIMABLE`). Its funds
|
|
1426
|
+
* are in neither `positions` nor `tokens`; display-only, never added to a total.
|
|
1427
|
+
*/
|
|
1428
|
+
interface OwneyPendingWithdrawal {
|
|
1429
|
+
id: string;
|
|
1430
|
+
status: string;
|
|
1431
|
+
chainId: number;
|
|
1432
|
+
/** Token symbol as Zyfai reports it. */
|
|
1433
|
+
asset: string;
|
|
1434
|
+
/** Redeemed amount in least units, as a decimal string. */
|
|
1435
|
+
amountRaw: string;
|
|
1436
|
+
}
|
|
665
1437
|
interface AgentBalance {
|
|
1438
|
+
readMetadata?: AssetReadMetadata[];
|
|
1439
|
+
/** Authoritative native balances per asset/network, including idle and invested funds. */
|
|
1440
|
+
assetBalances?: OwneyToken[];
|
|
666
1441
|
smartWallet?: `0x${string}`;
|
|
667
1442
|
totalBalance: string;
|
|
668
1443
|
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
669
1444
|
totalBalanceAsset: string;
|
|
1445
|
+
/**
|
|
1446
|
+
* Describes whether `tokens` already includes deployed `positions`.
|
|
1447
|
+
* Consumers must add matching positions only for `tokens-plus-positions`;
|
|
1448
|
+
* doing so for Zyfai would double-count, while omitting it for Yieldseeker
|
|
1449
|
+
* makes its balance disappear as soon as idle funds enter a vault.
|
|
1450
|
+
*/
|
|
1451
|
+
balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
|
|
670
1452
|
tokens: OwneyToken[];
|
|
671
1453
|
/**
|
|
672
1454
|
* Per-protocol/pool positions when the agent's portfolio payload includes
|
|
@@ -675,7 +1457,23 @@ interface AgentBalance {
|
|
|
675
1457
|
positions?: OwneyPosition[];
|
|
676
1458
|
/** Funds received but not yet deployed. Omitted when nothing is pending. */
|
|
677
1459
|
pendingAllocations?: OwneyPendingAllocation[];
|
|
1460
|
+
/** Zyfai only: delayed redemptions still in flight. Omitted when none. Never part of a total. */
|
|
1461
|
+
pendingWithdrawals?: OwneyPendingWithdrawal[];
|
|
1462
|
+
/**
|
|
1463
|
+
* Zyfai only: every delayed redemption Zyfai lists except FAILED, recently
|
|
1464
|
+
* CLAIMED ones included (Zyfai keeps them about a day). Present, possibly
|
|
1465
|
+
* empty, whenever Zyfai sent the list; absent when it did not. Empty means no
|
|
1466
|
+
* older delayed payout can be landing now. Never part of a total.
|
|
1467
|
+
*/
|
|
1468
|
+
recentAsyncWithdrawals?: OwneyRecentAsyncWithdrawal[];
|
|
678
1469
|
}
|
|
1470
|
+
/** A delayed Zyfai redemption by status, for telling a new payout from an older remainder. */
|
|
1471
|
+
type OwneyRecentAsyncWithdrawal = {
|
|
1472
|
+
id: string;
|
|
1473
|
+
status: string;
|
|
1474
|
+
chainId: number;
|
|
1475
|
+
asset: string;
|
|
1476
|
+
};
|
|
679
1477
|
/**
|
|
680
1478
|
* One position drained by `withdrawAll()` — a chain and asset pair.
|
|
681
1479
|
*
|
|
@@ -700,10 +1498,14 @@ interface OwneyBalances {
|
|
|
700
1498
|
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
701
1499
|
totalBalanceAsset: string;
|
|
702
1500
|
agentBalances: Record<AgentId, AgentBalance>;
|
|
703
|
-
/**
|
|
704
|
-
|
|
1501
|
+
/**
|
|
1502
|
+
* Per-agent read failures when an aggregate balance request returned only a
|
|
1503
|
+
* partial result. Callers may display the successful balances, but funding
|
|
1504
|
+
* operations must not interpret a missing agent as having a zero balance.
|
|
1505
|
+
*/
|
|
1506
|
+
agentErrors?: Partial<Record<AgentId, string>>;
|
|
705
1507
|
/** Absolute provider cooldown deadlines (Unix milliseconds). */
|
|
706
|
-
agentRetryAt?: Record<AgentId, number
|
|
1508
|
+
agentRetryAt?: Partial<Record<AgentId, number>>;
|
|
707
1509
|
}
|
|
708
1510
|
interface AgentEarnings {
|
|
709
1511
|
smartWallet: `0x${string}`;
|
|
@@ -713,19 +1515,37 @@ interface AgentEarnings {
|
|
|
713
1515
|
interface OwneyEarnings {
|
|
714
1516
|
totalEarnings: string;
|
|
715
1517
|
agentEarnings: Record<AgentId, AgentEarnings>;
|
|
1518
|
+
/** Per-agent failures when an aggregate read returned a partial result. */
|
|
1519
|
+
agentErrors?: Partial<Record<AgentId, string>>;
|
|
1520
|
+
/** Absolute provider cooldown deadlines (Unix milliseconds). */
|
|
1521
|
+
agentRetryAt?: Partial<Record<AgentId, number>>;
|
|
716
1522
|
}
|
|
717
1523
|
type ApyByChainAndAsset = Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
|
|
1524
|
+
/** One external reward program contributing percentage points to a day. */
|
|
1525
|
+
interface ApyIncentive {
|
|
1526
|
+
source: "merkl";
|
|
1527
|
+
agentId: AgentId;
|
|
1528
|
+
opportunityId: string;
|
|
1529
|
+
/** All on-chain campaigns represented by the opportunity APR that day. */
|
|
1530
|
+
campaignIds: string[];
|
|
1531
|
+
/** Source APR before portfolio weighting, expressed as a percentage. */
|
|
1532
|
+
apr: number;
|
|
1533
|
+
/** Percentage points to add to this point's native/provider `apy`. */
|
|
1534
|
+
apyContribution: number;
|
|
1535
|
+
}
|
|
718
1536
|
/** A single day's net APY for the connected account, as a percentage number. */
|
|
719
1537
|
interface ApyHistoryPoint {
|
|
720
1538
|
/** ISO date string for the day, e.g. "2026-06-20". */
|
|
721
1539
|
date: string;
|
|
722
|
-
/**
|
|
1540
|
+
/** Native/provider net APY. External incentives are deliberately excluded. */
|
|
723
1541
|
apy: number;
|
|
724
1542
|
/** Balance on this date, in the explicitly named unit; never today's balance. */
|
|
725
1543
|
historicalBalance?: {
|
|
726
1544
|
amount: number;
|
|
727
1545
|
unit: string;
|
|
728
1546
|
};
|
|
1547
|
+
/** Best-effort external rewards. Absent when none apply or cannot be read. */
|
|
1548
|
+
incentives?: ApyIncentive[];
|
|
729
1549
|
}
|
|
730
1550
|
/**
|
|
731
1551
|
* What the APY chart's chain/asset menus are allowed to offer, and how far
|
|
@@ -790,6 +1610,15 @@ interface OwneyAllocationApy {
|
|
|
790
1610
|
}
|
|
791
1611
|
type HistoryAction = "Rebalance" | "Deposit" | "Top up" | "Withdraw" | "Earned";
|
|
792
1612
|
interface HistoryTransaction {
|
|
1613
|
+
tokenAddress?: string;
|
|
1614
|
+
agentWallet?: string;
|
|
1615
|
+
logIndexes?: number[];
|
|
1616
|
+
transferLogs?: {
|
|
1617
|
+
logIndex: number;
|
|
1618
|
+
amountRaw: string;
|
|
1619
|
+
}[];
|
|
1620
|
+
amountRaw?: string;
|
|
1621
|
+
blockNumber?: string;
|
|
793
1622
|
txHashes: string[];
|
|
794
1623
|
chainId?: number;
|
|
795
1624
|
tokenSymbol?: string;
|
|
@@ -810,14 +1639,27 @@ interface RebalanceLog {
|
|
|
810
1639
|
tokenSymbol: string;
|
|
811
1640
|
amount: string;
|
|
812
1641
|
status: "success" | "failed";
|
|
1642
|
+
/** Fee-net APY at execution time for the source leg, in percentage points. */
|
|
1643
|
+
fromApy?: string;
|
|
1644
|
+
/** Fee-net APY at execution time for the destination leg, in percentage points. */
|
|
1645
|
+
toApy?: string;
|
|
813
1646
|
}
|
|
814
1647
|
interface AgentHistoryPosition {
|
|
815
1648
|
protocol: string;
|
|
816
1649
|
pool?: string;
|
|
817
1650
|
tokenSymbol?: string;
|
|
1651
|
+
/** The position balance after the action (decimal string, token units). */
|
|
818
1652
|
amount?: string;
|
|
1653
|
+
/**
|
|
1654
|
+
* The amount the action actually moved (decimal string, token units), as
|
|
1655
|
+
* opposed to `amount`, the resulting position balance. Present only when the
|
|
1656
|
+
* provider reports it; withheld on withdrawals.
|
|
1657
|
+
*/
|
|
1658
|
+
deltaAmount?: string;
|
|
819
1659
|
}
|
|
820
1660
|
interface AgentHistoryEntry {
|
|
1661
|
+
/** Stable provider/transfer identity, independent of row order. */
|
|
1662
|
+
id?: string;
|
|
821
1663
|
agent: AgentId;
|
|
822
1664
|
action: HistoryAction;
|
|
823
1665
|
/**
|
|
@@ -844,6 +1686,8 @@ interface AgentHistoryEntry {
|
|
|
844
1686
|
asyncRequest?: true;
|
|
845
1687
|
}
|
|
846
1688
|
interface OwneyAgentHistory {
|
|
1689
|
+
agentErrors?: Partial<Record<AgentId, string>>;
|
|
1690
|
+
agentRetryAt?: Partial<Record<AgentId, number>>;
|
|
847
1691
|
data: AgentHistoryEntry[];
|
|
848
1692
|
/** True iff a subsequent page exists; pair with `nextCursor`. */
|
|
849
1693
|
hasMore: boolean;
|
|
@@ -882,17 +1726,18 @@ interface AgentApy {
|
|
|
882
1726
|
detailedApys?: AgentApyDetails;
|
|
883
1727
|
}
|
|
884
1728
|
interface OwneyAgentApy {
|
|
885
|
-
|
|
1729
|
+
/** Agents without data for the requested period are omitted. */
|
|
1730
|
+
agentApy: Partial<Record<AgentId, AgentApy>>;
|
|
886
1731
|
}
|
|
887
|
-
/** One day's cumulative
|
|
1732
|
+
/** One day's cumulative earnings for a single asset. */
|
|
888
1733
|
interface DailyEarningsPoint {
|
|
889
1734
|
/** ISO date string for the day, e.g. "2026-09-01". */
|
|
890
1735
|
date: string;
|
|
891
1736
|
/**
|
|
892
|
-
*
|
|
893
|
-
*
|
|
894
|
-
*
|
|
895
|
-
*
|
|
1737
|
+
* Cumulative earnings in the asset's own units, using the provider's earnings
|
|
1738
|
+
* basis. A provider may return lifetime totals or a running window total;
|
|
1739
|
+
* difference the last and opening points to measure earnings over the window.
|
|
1740
|
+
* Aggregate series normalize each component's opening value before summing.
|
|
896
1741
|
*/
|
|
897
1742
|
amount: number;
|
|
898
1743
|
}
|
|
@@ -901,8 +1746,9 @@ interface AssetDailyEarnings {
|
|
|
901
1746
|
/** Asset symbol, e.g. "USDC" / "WETH". */
|
|
902
1747
|
asset: string;
|
|
903
1748
|
/**
|
|
904
|
-
* Ascending by date
|
|
905
|
-
*
|
|
1749
|
+
* Ascending by date, including an opening snapshot before the requested
|
|
1750
|
+
* window when available. Provider gaps remain absent; aggregates carry the
|
|
1751
|
+
* most recent cumulative value across dates reported by other providers.
|
|
906
1752
|
*/
|
|
907
1753
|
points: DailyEarningsPoint[];
|
|
908
1754
|
}
|
|
@@ -919,107 +1765,53 @@ interface AccountDailyEarnings {
|
|
|
919
1765
|
assets: AssetDailyEarnings[];
|
|
920
1766
|
}
|
|
921
1767
|
|
|
922
|
-
type
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
* Implementations must be **non-fatal**: this runs during activation as a side
|
|
938
|
-
* effect, so a failure has to leave the user connected and their profile
|
|
939
|
-
* unchanged rather than break the connect.
|
|
940
|
-
*/
|
|
941
|
-
applyOrgPolicy?(state: ConnectionState, chainId: number, policy: OrgAgentConfig): Promise<void>;
|
|
942
|
-
/**
|
|
943
|
-
* The deposit-time pool catalogue for one asset and strategy: protocols with
|
|
944
|
-
* their selectable pools and figures. Optional — an agent with no pool
|
|
945
|
-
* customization omits it. (ROUT-569)
|
|
946
|
-
*/
|
|
947
|
-
getPoolCatalog?(params: {
|
|
948
|
-
asset: string;
|
|
949
|
-
strategy: "conservative" | "aggressive" | "yieldmaxxing";
|
|
950
|
-
}): Promise<PoolCatalogProtocol[]>;
|
|
951
|
-
/**
|
|
952
|
-
* Apply a user's own pool selection to their account, driven by the
|
|
953
|
-
* deposit-time Pools step. Optional, and non-fatal like `applyOrgPolicy`.
|
|
954
|
-
* (ROUT-569)
|
|
955
|
-
*/
|
|
956
|
-
setPoolSelection?(selection: UserPoolSelectionRequest): Promise<void>;
|
|
957
|
-
/**
|
|
958
|
-
* Read back what `setPoolSelection` saved, for the pairs and assets given,
|
|
959
|
-
* so the Pools step can open on the user's own choices. Optional. (ROUT-650)
|
|
960
|
-
*/
|
|
961
|
-
getPoolSelection?(state: ConnectionState, chainId: number, params: {
|
|
962
|
-
pairs: Array<{
|
|
963
|
-
protocolId: string;
|
|
964
|
-
chainId: number;
|
|
965
|
-
}>;
|
|
966
|
-
assets: Array<"USDC" | "WETH">;
|
|
967
|
-
}): Promise<SavedPoolSelection>;
|
|
968
|
-
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
969
|
-
withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
|
|
970
|
-
getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
|
|
971
|
-
getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
|
|
972
|
-
/**
|
|
973
|
-
* Refresh the agent's earnings snapshot when its backend supports doing so.
|
|
974
|
-
* Implementations own freshness and request-deduplication policy.
|
|
975
|
-
*/
|
|
976
|
-
refreshEarnings?(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
|
|
977
|
-
getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays,
|
|
978
|
-
/**
|
|
979
|
-
* Optional asset symbol ("USDC" / "WETH") scoping the daily series to a
|
|
980
|
-
* single asset on the chain. Agents without per-asset positions ignore it.
|
|
981
|
-
*/
|
|
982
|
-
tokenSymbol?: string,
|
|
983
|
-
/**
|
|
984
|
-
* Chain the series is scoped to, when that differs from the chain the
|
|
985
|
-
* connection is on. `null` spans every chain the wallet held (ROUT-479);
|
|
986
|
-
* omitted means `chainId`. Kept apart from `chainId` because that one
|
|
987
|
-
* still resolves the wallet and must stay a real, connected chain.
|
|
988
|
-
*/
|
|
989
|
-
scopeChainId?: number | null): Promise<AccountAgentApy>;
|
|
990
|
-
/**
|
|
991
|
-
* Daily cumulative NET earnings for the window, scoped to a chain/asset.
|
|
992
|
-
* Backs the "recent earnings" subline, whose figure must reconcile with the
|
|
993
|
-
* balance headline directly above it. (ROUT-452)
|
|
994
|
-
*/
|
|
995
|
-
getDailyEarnings?(state: ConnectionState, chainId: number, days: LookbackDays, tokenSymbol?: string): Promise<AccountDailyEarnings>;
|
|
996
|
-
getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
|
|
997
|
-
getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
|
|
998
|
-
/**
|
|
999
|
-
* Ensure the given asset uses backend protocol auto-selection
|
|
1000
|
-
* (`autoSelectProtocols: true`). Optional capability — only agents whose
|
|
1001
|
-
* backend models per-asset protocol selection implement it. Returns whether
|
|
1002
|
-
* a write occurred (`false` = already enabled / not supported).
|
|
1003
|
-
*/
|
|
1004
|
-
ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
|
|
1005
|
-
getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
|
|
1006
|
-
}
|
|
1768
|
+
type ReservationAgent = "zyfai" | "surfliquid" | "yieldseeker";
|
|
1769
|
+
type WithdrawalReservationMode = "fail-open" | "fail-closed" | "off";
|
|
1770
|
+
type ReservationReleaseReason = "confirmed" | "failed" | "not_submitted";
|
|
1771
|
+
/** What the 409 tells the app. The holding operation's id and token are never returned. */
|
|
1772
|
+
type WithdrawalReservationConflict = {
|
|
1773
|
+
/** First 8 hex characters of the holding operation's id. */
|
|
1774
|
+
reference: string;
|
|
1775
|
+
ageSec: number;
|
|
1776
|
+
expiresInSec: number;
|
|
1777
|
+
agents: ReservationAgent[];
|
|
1778
|
+
state: "preparing" | "dispatched";
|
|
1779
|
+
/** True for an unproven hold: the app may resend with `override: reference`. */
|
|
1780
|
+
overridable: boolean;
|
|
1781
|
+
};
|
|
1782
|
+
|
|
1007
1783
|
/**
|
|
1008
|
-
*
|
|
1009
|
-
*
|
|
1010
|
-
*
|
|
1011
|
-
*
|
|
1784
|
+
* On-chain discovery of a hashless withdrawal's payout.
|
|
1785
|
+
*
|
|
1786
|
+
* Lists ERC-20 `Transfer` logs on the operation's token that reach the owner.
|
|
1787
|
+
* The sender is never filtered: routed payouts hop through intermediaries.
|
|
1788
|
+
* This only finds candidates; each one must still be proven with the receipt
|
|
1789
|
+
* inspection (`inspectFunding(candidate, "withdraw", { requireAmountMatch: true })`).
|
|
1012
1790
|
*/
|
|
1013
|
-
type
|
|
1014
|
-
|
|
1015
|
-
|
|
1791
|
+
type WithdrawalPayoutCandidate = {
|
|
1792
|
+
txHash: string;
|
|
1793
|
+
/** Decimal block number. */
|
|
1794
|
+
blockNumber: string;
|
|
1795
|
+
logIndex: number;
|
|
1796
|
+
/** Transferred amount in token base units. */
|
|
1797
|
+
amountRaw: string;
|
|
1798
|
+
};
|
|
1799
|
+
type WithdrawalPayoutScan = {
|
|
1800
|
+
candidates: WithdrawalPayoutCandidate[];
|
|
1801
|
+
/** Last block scanned (inclusive, decimal). Pass it back as the next `cursor`. */
|
|
1802
|
+
scannedTo: string;
|
|
1803
|
+
/** False when the call stopped at its request limit before the scan end (the
|
|
1804
|
+
* head minus the reorg margin), so more blocks are already waiting. */
|
|
1805
|
+
caughtUp: boolean;
|
|
1016
1806
|
};
|
|
1017
1807
|
|
|
1018
|
-
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_NOTHING_TO_WITHDRAW" | "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" | "SWAP_DISABLED" | "SWAP_RATE_LIMITED" | "SWAP_REQUEST_FAILED" | "SWAP_QUOTE_FAILED" | "SWAP_UNSUPPORTED_PAIR" | "SWAP_APPROVAL_REQUIRED" | "SWAP_BELOW_DEPOSIT_MINIMUM" | "SWAP_DEPOSIT_PENDING" | "SWAP_WALLET_PROMPT_TIMEOUT" | "SWAP_INSUFFICIENT_GAS" | "SWAP_NATIVE_UNSUPPORTED" | "SWAP_ORDER_EXPIRED" | "SWAP_ORDER_REFUNDED" | "SWAP_ORDER_CANCELLED" | "SWAP_ORDER_NOT_FOUND" | "WITHDRAW_ARRIVAL_TIMEOUT" | "WITHDRAW_SWAP_FAILED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "POOL_CATALOG_UNSUPPORTED" | "POOL_SELECTION_UNSUPPORTED" | "VALIDATION_INVALID_DAYS";
|
|
1808
|
+
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" | "AGENT_ACTIVATION_BLOCKED" | "AGENT_ACCOUNT_NOT_OWNEY" | "YIELDSEEKER_AGENT_MISSING" | "YIELDSEEKER_AGENT_CLOSED" | "YIELDSEEKER_SLOT_UNAVAILABLE" | "YIELDSEEKER_WALLET_UNVERIFIED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "DEPOSIT_IN_PROGRESS" | "DEPOSIT_CHECKPOINT_FAILED" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_INVALID_AMOUNT" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "ALL_AGENTS_EXCLUDED" | "WITHDRAW_IN_PROGRESS" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_BALANCE_UNAVAILABLE" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_UNCONFIRMED" | "WITHDRAW_NOTHING_TO_WITHDRAW" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_SWAP_INCOMPLETE" | "WITHDRAW_FAILED" | "WITHDRAW_INVALID_AMOUNT" | "WITHDRAW_RESERVATION_UNAVAILABLE" | "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" | "AGENT_APY_PERIOD_UNSUPPORTED" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "SWAP_DISABLED" | "SWAP_RATE_LIMITED" | "SWAP_REQUEST_FAILED" | "SWAP_QUOTE_FAILED" | "SWAP_UNSUPPORTED_PAIR" | "SWAP_APPROVAL_REQUIRED" | "SWAP_BELOW_DEPOSIT_MINIMUM" | "SWAP_DEPOSIT_PENDING" | "SWAP_WALLET_PROMPT_TIMEOUT" | "SWAP_INSUFFICIENT_GAS" | "SWAP_NATIVE_UNSUPPORTED" | "SWAP_ORDER_EXPIRED" | "SWAP_ORDER_REFUNDED" | "SWAP_ORDER_CANCELLED" | "SWAP_ORDER_NOT_FOUND" | "WITHDRAW_ARRIVAL_TIMEOUT" | "WITHDRAW_SWAP_FAILED" | "BALANCE_ALL_FAILED" | "EARNINGS_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "POOL_CATALOG_UNSUPPORTED" | "POOL_SELECTION_UNSUPPORTED" | "POOL_SELECTION_NOT_APPLIED" | "POOL_SELECTION_RULE_LIMIT" | "POOL_SELECTION_REQUIRED" | "VALIDATION_INVALID_DAYS";
|
|
1019
1809
|
declare class OwneyError extends Error {
|
|
1020
1810
|
readonly code: OwneyErrorCode;
|
|
1021
1811
|
readonly details?: Record<string, unknown>;
|
|
1022
1812
|
readonly agentId?: string;
|
|
1813
|
+
/** Funding ledger reference, set when a funding operation fails. */
|
|
1814
|
+
operationId?: string;
|
|
1023
1815
|
constructor(code: OwneyErrorCode, message: string, details?: Record<string, unknown>, agentId?: string);
|
|
1024
1816
|
}
|
|
1025
1817
|
declare class AgentNotFoundError extends OwneyError {
|
|
@@ -1040,41 +1832,41 @@ declare class AgentChainIncompatibleError extends OwneyError {
|
|
|
1040
1832
|
}>, connectedChainId: number);
|
|
1041
1833
|
}
|
|
1042
1834
|
|
|
1043
|
-
/**
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
* transaction and resolves in seconds; a same-chain fusion order has no stored
|
|
1060
|
-
* preimages, so there would be nothing for a reloaded session to resume and
|
|
1061
|
-
* the record would sit at `swapping` for ever.
|
|
1062
|
-
*
|
|
1063
|
-
* Kept deliberately separate from the secret store. Secrets are retired the
|
|
1064
|
-
* moment an order reaches a verdict — that is a safety property, not a display
|
|
1065
|
-
* one — and the record has to outlive them so the user can still be told what
|
|
1066
|
-
* happened after they come back.
|
|
1067
|
-
*/
|
|
1068
|
-
/**
|
|
1069
|
-
* `swapping` is the only non-terminal state. `unknown` is what a watch that
|
|
1070
|
-
* gave up looks like: we stopped polling before the order spoke, so the order
|
|
1071
|
-
* may well have filled. It is not a failure, and it must never be shown as
|
|
1072
|
-
* one.
|
|
1073
|
-
*/
|
|
1074
|
-
type WithdrawSwapStatus = "swapping" | "landed" | "refunded" | "unknown";
|
|
1835
|
+
/** Durable intent and evidence, including the gap before an order exists. */
|
|
1836
|
+
type WithdrawalSwapRecovery = {
|
|
1837
|
+
attemptId: string;
|
|
1838
|
+
phase: "withdrawing" | "verifying" | "ready" | "submitted" | "incomplete";
|
|
1839
|
+
baseline: string;
|
|
1840
|
+
baselineBlock: string;
|
|
1841
|
+
submittedAt: number;
|
|
1842
|
+
deadline: number;
|
|
1843
|
+
requested?: string;
|
|
1844
|
+
agentId?: AgentId;
|
|
1845
|
+
results?: Record<string, AgentWithdrawResult>;
|
|
1846
|
+
evidence: Record<string, FundingEvidence>;
|
|
1847
|
+
reason?: string;
|
|
1848
|
+
};
|
|
1849
|
+
/** Unknown and partial outcomes remain recoverable until settlement is verified. */
|
|
1850
|
+
type WithdrawSwapStatus = "swapping" | "landed" | "refunded" | "unknown" | "refund-pending" | "partially-filled" | "withdrawal-pending" | "withdrawal-incomplete" | "ready" | "not-swapped";
|
|
1075
1851
|
type WithdrawSwapRecord = {
|
|
1076
1852
|
/** Identity. One record per Fusion+ order. */
|
|
1077
1853
|
orderHash: string;
|
|
1854
|
+
walletAddress?: string;
|
|
1855
|
+
txHash?: string;
|
|
1856
|
+
/**
|
|
1857
|
+
* The funding-ledger operation of this withdrawal and swap, reused when it
|
|
1858
|
+
* is continued or rechecked. Absent on records written by an older SDK.
|
|
1859
|
+
*/
|
|
1860
|
+
operationId?: string;
|
|
1861
|
+
/**
|
|
1862
|
+
* The batch this withdrawal belongs to (see `WithdrawOptions.batchId`), kept
|
|
1863
|
+
* so a continuation or recheck reports into the same batch. Absent when the
|
|
1864
|
+
* withdrawal was not part of one.
|
|
1865
|
+
*/
|
|
1866
|
+
batchId?: string;
|
|
1867
|
+
recovery?: WithdrawalSwapRecovery;
|
|
1868
|
+
spent?: string;
|
|
1869
|
+
dismissed?: boolean;
|
|
1078
1870
|
status: WithdrawSwapStatus;
|
|
1079
1871
|
/**
|
|
1080
1872
|
* What actually left the agent, smallest unit of the SOURCE asset.
|
|
@@ -1111,7 +1903,7 @@ declare function subscribeWithdrawSwaps(listener: () => void): () => void;
|
|
|
1111
1903
|
* Not after the swap resolves: the point is to survive the gap between submit
|
|
1112
1904
|
* and settle, which is exactly when the user closes the tab.
|
|
1113
1905
|
*/
|
|
1114
|
-
declare function saveWithdrawSwap(record: WithdrawSwapRecord):
|
|
1906
|
+
declare function saveWithdrawSwap(record: WithdrawSwapRecord): boolean;
|
|
1115
1907
|
/**
|
|
1116
1908
|
* Move a record to its outcome.
|
|
1117
1909
|
*
|
|
@@ -1125,8 +1917,8 @@ declare function saveWithdrawSwap(record: WithdrawSwapRecord): void;
|
|
|
1125
1917
|
declare function updateWithdrawSwap(orderHash: string, patch: Partial<Omit<WithdrawSwapRecord, "orderHash">>): void;
|
|
1126
1918
|
/** The user has read the outcome. Only they do this. */
|
|
1127
1919
|
declare function clearWithdrawSwap(orderHash: string): void;
|
|
1128
|
-
/**
|
|
1129
|
-
declare function listWithdrawSwaps(now?: number): WithdrawSwapRecord[];
|
|
1920
|
+
/** Visible records, newest first. Only verified terminal records expire by age. */
|
|
1921
|
+
declare function listWithdrawSwaps(now?: number, includeDismissed?: boolean): WithdrawSwapRecord[];
|
|
1130
1922
|
|
|
1131
1923
|
/**
|
|
1132
1924
|
* Swaps that landed but were never deposited.
|
|
@@ -1161,6 +1953,16 @@ type PendingDeposit = {
|
|
|
1161
1953
|
agentId?: string;
|
|
1162
1954
|
/** Epoch ms, for the sweep. */
|
|
1163
1955
|
createdAt: number;
|
|
1956
|
+
/**
|
|
1957
|
+
* The swap's funding-ledger operation, so finishing the deposit reports into
|
|
1958
|
+
* it. Absent on records written by an older SDK.
|
|
1959
|
+
*/
|
|
1960
|
+
operationId?: string;
|
|
1961
|
+
/**
|
|
1962
|
+
* The user action's batch (see `DepositOptions.batchId`), so finishing the
|
|
1963
|
+
* deposit later reports under it. Absent when the swap had none.
|
|
1964
|
+
*/
|
|
1965
|
+
batchId?: string;
|
|
1164
1966
|
};
|
|
1165
1967
|
/** Every record, dismissed ones included, newest first. Sweeps as it goes. */
|
|
1166
1968
|
declare function listPendingDeposits(now?: number): PendingDeposit[];
|
|
@@ -1174,23 +1976,117 @@ declare class OwneySDK {
|
|
|
1174
1976
|
* withdraw, but they are excluded from new deposits / activations.
|
|
1175
1977
|
*/
|
|
1176
1978
|
private disabledAgents;
|
|
1979
|
+
private readonly accountRefusedListeners;
|
|
1980
|
+
/**
|
|
1981
|
+
* Agents whose sign-in the user cancelled this session (the wallet rejected
|
|
1982
|
+
* the prompt), keyed by chain. Until the app ends the session they are read
|
|
1983
|
+
* from a saved sign-in only (`readStateFor`), so no read reopens the prompt
|
|
1984
|
+
* the user cancelled. A later successful activation of the agent removes
|
|
1985
|
+
* it, and `disconnect()` or a different wallet's `connect()` clears the map.
|
|
1986
|
+
*/
|
|
1987
|
+
private declinedSignIns;
|
|
1177
1988
|
private state;
|
|
1989
|
+
private connectionRevision;
|
|
1990
|
+
private disconnectingAgents;
|
|
1178
1991
|
private apiKey;
|
|
1179
1992
|
private orgAgentConfig;
|
|
1180
1993
|
private orgAgentConfigPromise;
|
|
1994
|
+
private rpcUrls?;
|
|
1181
1995
|
private zyfaiRpcUrls?;
|
|
1996
|
+
private yieldseekerApiBaseUrl?;
|
|
1997
|
+
private yieldseekerSiweOrigin?;
|
|
1182
1998
|
private userPoolCustomization;
|
|
1183
1999
|
private routingApiBaseUrl?;
|
|
1184
2000
|
private referralSource?;
|
|
2001
|
+
private readonly ledger;
|
|
2002
|
+
private readonly reservationMode;
|
|
2003
|
+
private readonly reservationTransport;
|
|
2004
|
+
/** The caller's Zyfai server tasks opt-in: `true`, a function read each
|
|
2005
|
+
* time a handoff would start (F-I2(iii)), or undefined (off). */
|
|
2006
|
+
private readonly zyfaiServerTasks;
|
|
2007
|
+
/** The caller opted in to the Fusion+ secret handoff (`fusionSecretHandoff: true`). */
|
|
2008
|
+
private readonly fusionSecretHandoff;
|
|
1185
2009
|
private cachedSponsoredCallback;
|
|
1186
2010
|
private cachedWethSponsoredCallback;
|
|
1187
2011
|
private paymasterServiceUrl?;
|
|
1188
2012
|
private cachedSponsoredCallsCallbacks;
|
|
1189
2013
|
private readonly agentReads;
|
|
2014
|
+
private readonly depositFamilyReads;
|
|
2015
|
+
/** Movements (owner, chain, agent, token, tx hash) whose balance refresh this
|
|
2016
|
+
* session started: true when it armed the refresh, false when its deadline
|
|
2017
|
+
* had passed (it only dropped the cache and forced one snapshot read). */
|
|
2018
|
+
private readonly recoveredFundingReads;
|
|
2019
|
+
/** Confirmed deposits already announced to their agent (`depositConfirmed`), bounded. */
|
|
2020
|
+
private readonly announcedDeposits;
|
|
2021
|
+
private fundingBalanceChecks;
|
|
1190
2022
|
private readonly activationChecks;
|
|
2023
|
+
private readonly withdrawalSubmissions;
|
|
2024
|
+
private readonly withdrawalSwapSubmissions;
|
|
1191
2025
|
private readAgent;
|
|
1192
2026
|
private initializingAgentsPromise;
|
|
1193
2027
|
constructor(config: OwneySDKConfig);
|
|
2028
|
+
/** Finishes a funding-ledger operation on success and adds its reference to
|
|
2029
|
+
* the result. The result object is copied, never mutated or replaced.
|
|
2030
|
+
* `OK` replaces any failure code an earlier attempt of the same operation
|
|
2031
|
+
* recorded (a resumed pending deposit, a continuation). */
|
|
2032
|
+
private ledgerSucceeded;
|
|
2033
|
+
/** Tags a failure with its funding-ledger reference and finishes the
|
|
2034
|
+
* operation. The error is never wrapped or replaced. */
|
|
2035
|
+
private ledgerFailed;
|
|
2036
|
+
/**
|
|
2037
|
+
* Swap operations running right now, by operationId. A deposit or withdrawal
|
|
2038
|
+
* started with one of these ids is the inner half of that swap and joins its
|
|
2039
|
+
* operation instead of starting its own (see `startLedger`).
|
|
2040
|
+
*/
|
|
2041
|
+
private readonly openSwapLedgers;
|
|
2042
|
+
/**
|
|
2043
|
+
* Starts a funding-ledger operation, or joins the open swap operation with
|
|
2044
|
+
* the same id. A joined call reports its legs into the swap's operation and
|
|
2045
|
+
* leaves finishing to the swap, so the operation gets one outcome, sent on
|
|
2046
|
+
* one ordered request chain.
|
|
2047
|
+
*/
|
|
2048
|
+
private startLedger;
|
|
2049
|
+
/** Starts a swap's operation and opens it to the swap's inner deposit or
|
|
2050
|
+
* withdrawal. Never throws: reporting never blocks a swap. */
|
|
2051
|
+
private openSwapLedger;
|
|
2052
|
+
/**
|
|
2053
|
+
* Part 5: the swap's ledger identity, for the executor's Fusion+ secret
|
|
2054
|
+
* handoff. Only with the `fusionSecretHandoff` opt-in and an open operation;
|
|
2055
|
+
* otherwise undefined, and the executor sends nothing. Owner and token are
|
|
2056
|
+
* lowercased, as the ledger reports them.
|
|
2057
|
+
*/
|
|
2058
|
+
private secretHandoffFor;
|
|
2059
|
+
private closeSwapLedger;
|
|
2060
|
+
/** Reports one agent's withdrawal evidence as its leg (with `errorCode`, when
|
|
2061
|
+
* given). Never throws. */
|
|
2062
|
+
private ledgerWithdrawalLeg;
|
|
2063
|
+
/** Operation/leg/tx keys whose provider samples are already scheduled. */
|
|
2064
|
+
private readonly providerSampleKeys;
|
|
2065
|
+
/**
|
|
2066
|
+
* For a confirmed leg of an operation this SDK reported, records the agent's
|
|
2067
|
+
* own earnings bookkeeping as `provider.sample` events at confirmation, +5
|
|
2068
|
+
* and +30 min (Zyfai; evidence for provider lag). Only agents that expose a
|
|
2069
|
+
* never-prompting sample read take part. Fire-and-forget, never throws;
|
|
2070
|
+
* a later sample is skipped once the wallet disconnects or changes.
|
|
2071
|
+
*/
|
|
2072
|
+
private ledgerProviderSamples;
|
|
2073
|
+
/**
|
|
2074
|
+
* Listens for an agent refusing the connected wallet because its provider
|
|
2075
|
+
* account was not created through Owney (`AGENT_ACCOUNT_NOT_OWNEY`). Fires
|
|
2076
|
+
* each time an agent maps such a refusal. Returns the unsubscribe function.
|
|
2077
|
+
*/
|
|
2078
|
+
onAccountRefused(listener: (agentId: AgentId) => void): () => void;
|
|
2079
|
+
/** Wires the optional hooks the SDK offers an agent. */
|
|
2080
|
+
private attachAgentHooks;
|
|
2081
|
+
/**
|
|
2082
|
+
* Funding-ledger read access handed to agents for earnings holds. Reads only
|
|
2083
|
+
* for the connected owner; null otherwise and on any failure.
|
|
2084
|
+
*/
|
|
2085
|
+
private agentLedgerAccess;
|
|
2086
|
+
/** Reports the swap leg. Never throws: reporting never affects a swap. */
|
|
2087
|
+
private ledgerSwap;
|
|
2088
|
+
/** Reports the swap leg of a swap that threw, with any identifier it carried. */
|
|
2089
|
+
private ledgerSwapFailed;
|
|
1194
2090
|
/**
|
|
1195
2091
|
* Establish connection state for all subsequent SDK calls.
|
|
1196
2092
|
* Must be called once before any agent operation that requires a wallet.
|
|
@@ -1202,7 +2098,36 @@ declare class OwneySDK {
|
|
|
1202
2098
|
* After calling this, `connect()` must be called again before using agent methods.
|
|
1203
2099
|
*/
|
|
1204
2100
|
disconnect(): Promise<void>;
|
|
2101
|
+
private clearConnectionState;
|
|
2102
|
+
private disconnectAgents;
|
|
1205
2103
|
private isAgentDisabled;
|
|
2104
|
+
/**
|
|
2105
|
+
* True when `id` takes no new deposits on this chain and asset this
|
|
2106
|
+
* session: its adapter reports no agent for the slot.
|
|
2107
|
+
*/
|
|
2108
|
+
private isAgentUnavailable;
|
|
2109
|
+
/**
|
|
2110
|
+
* The agents that take no new deposits on this chain and asset this
|
|
2111
|
+
* session, so the app can show them as unavailable: each agent whose
|
|
2112
|
+
* provider has no agent for this slot. They stay withdrawable.
|
|
2113
|
+
*/
|
|
2114
|
+
getUnavailableAgentIds(chainId: number, asset?: string): AgentId[];
|
|
2115
|
+
/**
|
|
2116
|
+
* The adapter reports no agent for this chain and asset this session (see
|
|
2117
|
+
* `IAgent.isSlotUnavailable`): there is nothing there to withdraw, so a
|
|
2118
|
+
* withdrawal without an explicit agent leaves it out instead of failing its
|
|
2119
|
+
* leg.
|
|
2120
|
+
*/
|
|
2121
|
+
private hasNoAgentForSlot;
|
|
2122
|
+
/**
|
|
2123
|
+
* The state an agent's reads use. An agent whose sign-in the user cancelled
|
|
2124
|
+
* on the connection chain this session is read from a saved sign-in only,
|
|
2125
|
+
* as `offChainPortfolioAgents` reads: a read that would need a wallet
|
|
2126
|
+
* prompt fails for that agent instead of reopening the prompt the user
|
|
2127
|
+
* cancelled. A later successful activation of the agent, or `disconnect()`,
|
|
2128
|
+
* lifts it.
|
|
2129
|
+
*/
|
|
2130
|
+
private readStateFor;
|
|
1206
2131
|
/**
|
|
1207
2132
|
* Check if the SDK has an active connection state.
|
|
1208
2133
|
* @returns `true` if `connect()` has been called and `disconnect()` has not
|
|
@@ -1213,32 +2138,52 @@ declare class OwneySDK {
|
|
|
1213
2138
|
* @returns The active chain ID, or `null` if `activateAgent` has not been called
|
|
1214
2139
|
*/
|
|
1215
2140
|
getActiveChainId(): number | null;
|
|
2141
|
+
/**
|
|
2142
|
+
* The funding-ledger operations this app has for the connected wallet and
|
|
2143
|
+
* `asset` (default chain: the active one). Never throws: resolves `null` when
|
|
2144
|
+
* not connected, with no chain, when ledger reporting is disabled, or on any
|
|
2145
|
+
* failure, which callers treat as "no ledger information".
|
|
2146
|
+
*
|
|
2147
|
+
* Full `clientOperationId`s come back only for ids passed in `ids`. The ids
|
|
2148
|
+
* are trimmed and lowercased, non-uuid strings are dropped, and the first 50
|
|
2149
|
+
* distinct ids (caller order) are sent; the rest are ignored.
|
|
2150
|
+
*/
|
|
2151
|
+
listFundingOperations(opts: {
|
|
2152
|
+
chainId?: number;
|
|
2153
|
+
asset: string;
|
|
2154
|
+
ids?: string[];
|
|
2155
|
+
since?: Date;
|
|
2156
|
+
}): Promise<FundingOperationRow[] | null>;
|
|
1216
2157
|
private requireState;
|
|
1217
2158
|
private requireChainId;
|
|
1218
2159
|
private requireConnectedProvider;
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
* used when the caller omits `depositCallback`. Wraps the connected EIP-1193
|
|
1222
|
-
* provider with viem `custom(provider)` to read token meta and sign the
|
|
1223
|
-
* `TransferWithAuthorization`, then POSTs to the sponsor API.
|
|
1224
|
-
*/
|
|
2160
|
+
private getPaidRpcClient;
|
|
2161
|
+
/** Builds the default USDC batch callback for the connected wallet. */
|
|
1225
2162
|
private getDefaultSponsoredCallback;
|
|
1226
|
-
/**
|
|
1227
|
-
* Lazily builds (and caches) the default Permit2 sponsored WETH deposit
|
|
1228
|
-
* callback used when the caller omits `depositCallback` for a WETH
|
|
1229
|
-
* deposit. Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
|
|
1230
|
-
* `PermitTransferFrom` instead of an EIP-3009 authorization.
|
|
1231
|
-
*/
|
|
2163
|
+
/** Builds the wallet-native sponsored calls callback for compatible paymasters. */
|
|
1232
2164
|
private getDefaultSponsoredCallsCallback;
|
|
1233
2165
|
/**
|
|
1234
2166
|
* Lazily builds (and caches) the default Permit2 sponsored WETH deposit
|
|
1235
2167
|
* callback used when the caller omits `depositCallback` for a WETH deposit.
|
|
1236
2168
|
* Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
|
|
1237
|
-
*
|
|
2169
|
+
* single-use batch authorization instead of an EIP-3009 authorization.
|
|
1238
2170
|
*/
|
|
1239
2171
|
private getDefaultWethSponsoredCallback;
|
|
1240
2172
|
private getAgent;
|
|
2173
|
+
getActiveAgentIds(): AgentId[];
|
|
1241
2174
|
private getActiveAgents;
|
|
2175
|
+
/**
|
|
2176
|
+
* Agents that do not run on the connection chain but can be read on their
|
|
2177
|
+
* own from a saved sign-in: Yieldseeker, Base-only, while the wallet sits on
|
|
2178
|
+
* Arbitrum or Ethereum. The whole-portfolio reads (ROUT-479) add them, under
|
|
2179
|
+
* a promptless state; with no saved sign-in they are left out, as before.
|
|
2180
|
+
*/
|
|
2181
|
+
private offChainPortfolioAgents;
|
|
2182
|
+
/** Every agent a whole-portfolio read covers: the active ones on the
|
|
2183
|
+
* connection chain, then the off-chain ones on their own chain. */
|
|
2184
|
+
private portfolioReads;
|
|
2185
|
+
/** The active agents, each with the state its reads use (`readStateFor`). */
|
|
2186
|
+
private activeReads;
|
|
1242
2187
|
/**
|
|
1243
2188
|
* Read the org's agent policy once and reuse it. fetchOrgAgentConfig never
|
|
1244
2189
|
* throws — it degrades to null — so this cannot break activation.
|
|
@@ -1269,9 +2214,19 @@ declare class OwneySDK {
|
|
|
1269
2214
|
* that support the given chainId (incompatible agents are silently skipped).
|
|
1270
2215
|
* If provided, ALL specified agents must support the chainId or the call
|
|
1271
2216
|
* throws before activating any agent.
|
|
1272
|
-
* @param options - Optional. `
|
|
2217
|
+
* @param options - Optional. `asset` limits setup to that asset;
|
|
2218
|
+
* `onAgentsSelected` fires once reads can start: after every agent's
|
|
2219
|
+
* account check (`checkAccount`) passed, before any agent activates.
|
|
2220
|
+
* @throws Activation stops at the first agent that fails, and the caller
|
|
2221
|
+
* should end the session. `AGENT_ACTIVATION_PARTIAL_FAILURE` when an
|
|
2222
|
+
* earlier agent activated; `walletRejected` in its details means the user
|
|
2223
|
+
* rejected a signature. `AGENT_ACTIVATION_BLOCKED` when the agent can
|
|
2224
|
+
* never be readied (`details.permanent`). Otherwise the agent's own error
|
|
2225
|
+
* is thrown as is. Until it signs in, an agent whose signature the user
|
|
2226
|
+
* rejected is read from a saved sign-in only and opens no prompt.
|
|
1273
2227
|
*/
|
|
1274
2228
|
activateAgent(chainId: number, agentId?: AgentId[], options?: ActivateAgentOptions): Promise<void>;
|
|
2229
|
+
private assertActivationSession;
|
|
1275
2230
|
/**
|
|
1276
2231
|
* Activate agents ONE AT A TIME, each followed by its org policy.
|
|
1277
2232
|
*
|
|
@@ -1285,10 +2240,19 @@ declare class OwneySDK {
|
|
|
1285
2240
|
* Serializing costs no real wall-clock: the user can only approve one prompt
|
|
1286
2241
|
* at a time anyway.
|
|
1287
2242
|
*
|
|
1288
|
-
*
|
|
1289
|
-
*
|
|
1290
|
-
*
|
|
1291
|
-
*
|
|
2243
|
+
* Stop at the first failure (2026-11-06): a connect needs every agent, so
|
|
2244
|
+
* no later agent's wallet prompt opens for a sign-in that already failed.
|
|
2245
|
+
* When an earlier agent activated, the partial failure reports it, and
|
|
2246
|
+
* `walletRejected` tells the app the user canceled; the app ends the
|
|
2247
|
+
* session either way. When none activated, the agent's own error is thrown.
|
|
2248
|
+
* A failure the provider marks `permanent` is thrown as
|
|
2249
|
+
* `AGENT_ACTIVATION_BLOCKED`.
|
|
2250
|
+
*
|
|
2251
|
+
* Account check first (2026-11-13): every agent's `checkAccount` runs, in
|
|
2252
|
+
* turn, before `onAgentsSelected` and before any agent activates, so a
|
|
2253
|
+
* wallet one agent can never serve signs in nowhere else, gets nothing
|
|
2254
|
+
* created and is not read. A failed check stops the connect like a failed
|
|
2255
|
+
* activation, with nothing activated.
|
|
1292
2256
|
*/
|
|
1293
2257
|
private activateAgentsInTurn;
|
|
1294
2258
|
/**
|
|
@@ -1299,9 +2263,14 @@ declare class OwneySDK {
|
|
|
1299
2263
|
* @param options.asset - Asset symbol to deposit (e.g. "USDC")
|
|
1300
2264
|
* @param options.depositCallback - Callback that performs the token transfer and returns a tx hash.
|
|
1301
2265
|
* When agentId is omitted, this callback is invoked once per eligible agent with that agent's
|
|
1302
|
-
* split amount and smart wallet address
|
|
2266
|
+
* split amount and smart wallet address. Default sponsored deposits batch
|
|
2267
|
+
* all shares into one signature; custom callbacks still run once per agent.
|
|
1303
2268
|
* @param options.agentId - Optional explicit target. Otherwise split equally,
|
|
1304
2269
|
* or fund remaining agents when a recovery deposit cannot meet every minimum.
|
|
2270
|
+
* @param options.excludeAgentIds - Agents that must receive nothing. The rest
|
|
2271
|
+
* split the whole amount under their own minimums. Throws
|
|
2272
|
+
* `ALL_AGENTS_EXCLUDED` when none is left or `agentId` is listed. Ignored
|
|
2273
|
+
* when resuming a signed batch.
|
|
1305
2274
|
* @returns {OwneyDepositResult} for a single agent, or {OwneyMultiDepositResult} with per-agent results
|
|
1306
2275
|
*/
|
|
1307
2276
|
deposit(options: DepositOptions): Promise<OwneyDepositResult | OwneyMultiDepositResult>;
|
|
@@ -1309,10 +2278,12 @@ declare class OwneySDK {
|
|
|
1309
2278
|
* Invokes `agent.deposit` with the resolved sponsored callback, composing
|
|
1310
2279
|
* two independent auto-recovery mechanisms:
|
|
1311
2280
|
*
|
|
1312
|
-
* 1. Missing Permit2 allowance
|
|
1313
|
-
* callback and the attempt fails with
|
|
1314
|
-
*
|
|
1315
|
-
*
|
|
2281
|
+
* 1. Missing Permit2 allowance outside the sponsored ERC-2612 path: when the
|
|
2282
|
+
* app did not supply its own callback and the attempt fails with
|
|
2283
|
+
* `PERMIT2_APPROVAL_REQUIRED`, this is the wallet's first Permit2 deposit
|
|
2284
|
+
* for that token. Native Base/Arbitrum USDC uses gasless ERC-2612 approval in
|
|
2285
|
+
* its sponsored deposit and never reaches this branch. Other tokens send
|
|
2286
|
+
* the one-time user-paid Permit2 approval via `approvePermit2()` and
|
|
1316
2287
|
* retry the SAME sponsored attempt once. Bounded to one approval attempt
|
|
1317
2288
|
* per call so a wallet/agent that keeps reporting the allowance as
|
|
1318
2289
|
* missing can't loop forever. If `approvePermit2()` itself throws (e.g.
|
|
@@ -1331,8 +2302,16 @@ declare class OwneySDK {
|
|
|
1331
2302
|
* doesn't force a retry of sibling agents in a multi-agent split.
|
|
1332
2303
|
*/
|
|
1333
2304
|
private depositWithFallback;
|
|
2305
|
+
/**
|
|
2306
|
+
* Refuses a new deposit that `excludeAgentIds` leaves with nobody to fund:
|
|
2307
|
+
* the explicit `agentId` is listed, or every agent that can take this asset
|
|
2308
|
+
* on this chain (and is not disabled) is. A no-op without a list, so a deposit
|
|
2309
|
+
* without exclusions is exactly as it was. Reads no provider.
|
|
2310
|
+
*/
|
|
2311
|
+
private assertDepositAgentsRemain;
|
|
1334
2312
|
private getMinDepositAmount;
|
|
1335
2313
|
private splitDepositAmount;
|
|
2314
|
+
private formatAgentName;
|
|
1336
2315
|
private validateMinDepositAmount;
|
|
1337
2316
|
/**
|
|
1338
2317
|
* Whether the user already holds a non-zero balance with `agent` for the
|
|
@@ -1359,7 +2338,137 @@ declare class OwneySDK {
|
|
|
1359
2338
|
*/
|
|
1360
2339
|
private validateChainHasAgents;
|
|
1361
2340
|
private validateAssetSupport;
|
|
2341
|
+
/**
|
|
2342
|
+
* The agents that support this asset on this chain. `excludeDisabled` is for
|
|
2343
|
+
* new deposits: it also leaves out the agents unavailable for this slot this
|
|
2344
|
+
* session (see `getUnavailableAgentIds`). Without it, withdrawals and deposit
|
|
2345
|
+
* recovery still see every agent that may hold funds.
|
|
2346
|
+
*/
|
|
1362
2347
|
private getEligibleAgents;
|
|
2348
|
+
/**
|
|
2349
|
+
* Run owner-approved withdrawals before relayer-only withdrawals. Wallet
|
|
2350
|
+
* approval is the only point at which the user can cancel the aggregate
|
|
2351
|
+
* operation, so no relayer leg should commit before it has completed.
|
|
2352
|
+
*/
|
|
2353
|
+
private orderAgentsForWithdrawal;
|
|
2354
|
+
/**
|
|
2355
|
+
* The user cancelled a wallet prompt, for any agent: see isWalletRejection.
|
|
2356
|
+
* That includes an agent error that kept the rejection only as text in
|
|
2357
|
+
* `details.cause`.
|
|
2358
|
+
*/
|
|
2359
|
+
private isUserRejectedWithdrawal;
|
|
2360
|
+
private captureReadScope;
|
|
2361
|
+
/** Revalidate a saved transfer against the authenticated account and actual receipt. */
|
|
2362
|
+
inspectFunding(evidence: FundingEvidence, direction: "deposit" | "withdraw", options?: {
|
|
2363
|
+
balanceRefreshUntil?: number;
|
|
2364
|
+
refreshBalance?: boolean;
|
|
2365
|
+
requireAmountMatch?: boolean;
|
|
2366
|
+
}): Promise<FundingEvidence>;
|
|
2367
|
+
/**
|
|
2368
|
+
* Tells the agent, once per confirmed deposit transfer, that its deposit
|
|
2369
|
+
* landed (`IAgent.depositConfirmed`), and records the outcome on the
|
|
2370
|
+
* deposit's ledger operation when there is one. In the background: never
|
|
2371
|
+
* throws and never delays the deposit. A missed notice only leaves the
|
|
2372
|
+
* provider on its own schedule.
|
|
2373
|
+
*
|
|
2374
|
+
* An agent that reports its provider calls (`onNotice`) gets one
|
|
2375
|
+
* `provider.deposit_notified` event per call and a final
|
|
2376
|
+
* `provider.deposit_allocation` with the outcome (allocated or why not).
|
|
2377
|
+
* Otherwise the outcome is the one `provider.deposit_notified`.
|
|
2378
|
+
*/
|
|
2379
|
+
private announceDepositConfirmed;
|
|
2380
|
+
private noteFundingRefresh;
|
|
2381
|
+
/**
|
|
2382
|
+
* Re-arms an agent's balance refresh after a confirmed deposit or withdrawal
|
|
2383
|
+
* the caller already verified (e.g. after a page reload, which loses the
|
|
2384
|
+
* refresh the SDK started in memory). Same refresh as receipt recovery
|
|
2385
|
+
* (`inspectFunding`), without a receipt read, and shared with it: once per
|
|
2386
|
+
* movement (`txHash`) in this SDK session, unless that recovery came after
|
|
2387
|
+
* its own deadline and so armed nothing. `until` bounds it (the agent caps
|
|
2388
|
+
* it further). Returns false when the agent has no such refresh or `until`
|
|
2389
|
+
* has passed; throws when not connected or on another chain. Never prompts.
|
|
2390
|
+
*/
|
|
2391
|
+
refreshAgentBalanceAfterMovement(input: {
|
|
2392
|
+
agentId: AgentId;
|
|
2393
|
+
chainId: number;
|
|
2394
|
+
token: OwneySupportedTokens;
|
|
2395
|
+
txHash?: string;
|
|
2396
|
+
until: number;
|
|
2397
|
+
}): boolean;
|
|
2398
|
+
/**
|
|
2399
|
+
* Lists on-chain payout candidates for a withdrawal the provider accepted
|
|
2400
|
+
* without a hash: ERC-20 `Transfer` logs on the evidence's token that reach
|
|
2401
|
+
* the owner, from `max(fromBlock, cursor − 20)` to `latest − 3`, chunked.
|
|
2402
|
+
* Discovery only: prove each candidate with
|
|
2403
|
+
* `inspectFunding({ ...evidence, txHash }, "withdraw", { requireAmountMatch: true })`.
|
|
2404
|
+
*
|
|
2405
|
+
* `fromBlock` defaults to `evidence.payoutSearch.fromBlock`; without either
|
|
2406
|
+
* (legacy records) the start is estimated from
|
|
2407
|
+
* `withdrawalRequest.acceptedAt ?? submittedAt` minus 5 minutes. Pass the
|
|
2408
|
+
* returned `scannedTo` back as `cursor` to scan only new blocks.
|
|
2409
|
+
* Never prompts and never throws: null on any failure or scope mismatch.
|
|
2410
|
+
*/
|
|
2411
|
+
findWithdrawalPayoutCandidates(evidence: FundingEvidence, opts?: {
|
|
2412
|
+
fromBlock?: string;
|
|
2413
|
+
cursor?: string;
|
|
2414
|
+
submittedAt?: number;
|
|
2415
|
+
}): Promise<WithdrawalPayoutScan | null>;
|
|
2416
|
+
/** Resolve a saved sponsored-withdrawal ID without opening a wallet prompt. */
|
|
2417
|
+
resolveSponsoredWithdrawalEvidence(evidence: FundingEvidence, options?: {
|
|
2418
|
+
submittedAt?: number;
|
|
2419
|
+
}): Promise<FundingEvidence>;
|
|
2420
|
+
/** Recover an EIP-5792 deposit or payout using this account's exact batch ID. */
|
|
2421
|
+
resolveWalletCallsFundingEvidence(evidence: FundingEvidence, direction: "deposit" | "withdraw"): Promise<FundingEvidence>;
|
|
2422
|
+
/** Whether a foreground deposit can resume the same signed batch, never a
|
|
2423
|
+
* fresh authorization. The batch rail independently rechecks the exact plan. */
|
|
2424
|
+
canResumePendingDeposit(evidences: FundingEvidence[], amount: string): Promise<boolean>;
|
|
2425
|
+
/** Whether a Permit2 deposit authorization can still execute and whether it
|
|
2426
|
+
* did: `expired` when the finalized block is more than 300 s past
|
|
2427
|
+
* `deadline` (chain time), `used` when the owner's Permit2 nonce bit is set
|
|
2428
|
+
* at that block. Null when anything cannot be read. Never throws. */
|
|
2429
|
+
checkDepositAuthorization(input: {
|
|
2430
|
+
chainId: number;
|
|
2431
|
+
owner: string;
|
|
2432
|
+
token?: string;
|
|
2433
|
+
permit2Nonce: string;
|
|
2434
|
+
deadline: number;
|
|
2435
|
+
}): Promise<{
|
|
2436
|
+
expired: boolean;
|
|
2437
|
+
used: boolean;
|
|
2438
|
+
} | null>;
|
|
2439
|
+
/** Drops the saved signed body of a hashless deposit the server may have
|
|
2440
|
+
* been sending (`serverBroadcast` 'unknown'/true, no hash) once the app has
|
|
2441
|
+
* settled it another way: by the ledger's hash or its expired deadline.
|
|
2442
|
+
* Only the body with this Permit2 deadline and these exact shares is
|
|
2443
|
+
* dropped, so it never resumes or blocks a different deposit. Never throws. */
|
|
2444
|
+
discardSavedDepositBatch(evidences: FundingEvidence[]): Promise<boolean>;
|
|
2445
|
+
/** Validate signed journal membership, never just a caller-supplied family ID. */
|
|
2446
|
+
validateDepositReplacement(previous: FundingEvidence[], next: FundingEvidence[]): Promise<DepositReplacementValidation | undefined>;
|
|
2447
|
+
/** Optional post-payout display proof; receipt verification and the provider
|
|
2448
|
+
* adapter must agree before attaching it to this exact balance object. */
|
|
2449
|
+
verifyWithdrawalBalance(evidence: FundingEvidence, balance: AgentBalance): Promise<AgentBalance>;
|
|
2450
|
+
/** A display acknowledgement controls polling only; it never confirms a financial outcome. */
|
|
2451
|
+
endFundingBalanceRefresh(evidence: FundingEvidence, read: AssetReadMetadata): boolean;
|
|
2452
|
+
/** History lookup for receipt recovery; adapters may not authenticate or sign here. */
|
|
2453
|
+
getFundingHistory(evidence: FundingEvidence, fromDate: string, options?: Pick<HistoryFilters, "cursor" | "toDate">): Promise<OwneyAgentHistory>;
|
|
2454
|
+
recoverDepositRegistration(evidence: FundingEvidence): Promise<FundingEvidence>;
|
|
2455
|
+
/** A Zyfai withdrawal's lifecycle by the id recorded on its evidence. Never signs,
|
|
2456
|
+
* prompts or authenticates; `null` when unavailable or not this wallet's Zyfai withdrawal. */
|
|
2457
|
+
getZyfaiWithdrawal(evidence: FundingEvidence): Promise<ZyfaiWithdrawalLifecycle | null>;
|
|
2458
|
+
/** A Zyfai deposit's placement status by the id recorded on its evidence. Never signs,
|
|
2459
|
+
* prompts or authenticates; `null` when unavailable or not this wallet's Zyfai deposit. */
|
|
2460
|
+
getZyfaiDeposit(evidence: FundingEvidence): Promise<ZyfaiDepositPlacement | null>;
|
|
2461
|
+
/** On-chain version and ownership status for this owner's Yieldseeker agent. */
|
|
2462
|
+
getYieldseekerWalletStatus(asset: OwneySupportedTokens): Promise<YieldseekerWalletStatus | null>;
|
|
2463
|
+
/** Deployment gate; an unavailable response keeps the current paid path. */
|
|
2464
|
+
isYieldseekerWithdrawalSponsorshipAvailable(): Promise<boolean>;
|
|
2465
|
+
isYieldseekerUpgradeSponsorshipAvailable(): Promise<boolean>;
|
|
2466
|
+
private isYieldseekerSponsorshipAvailable;
|
|
2467
|
+
/** Explicit V1-to-V2 upgrade, confirmed on chain before returning. */
|
|
2468
|
+
upgradeYieldseekerWallet(asset: OwneySupportedTokens, gasMode?: "paid" | "sponsored"): Promise<{
|
|
2469
|
+
txHash: viem.Hex;
|
|
2470
|
+
status: YieldseekerWalletStatus;
|
|
2471
|
+
}>;
|
|
1363
2472
|
/** Lazily built so an app that never swaps pays nothing for it. */
|
|
1364
2473
|
private swapApiClient?;
|
|
1365
2474
|
private swapApi;
|
|
@@ -1420,29 +2529,11 @@ declare class OwneySDK {
|
|
|
1420
2529
|
/** How much of `token` the wallet has already approved Permit2 to move. */
|
|
1421
2530
|
private readTokenPermit2Allowance;
|
|
1422
2531
|
/**
|
|
1423
|
-
*
|
|
1424
|
-
*
|
|
1425
|
-
*
|
|
1426
|
-
*
|
|
1427
|
-
*
|
|
1428
|
-
*
|
|
1429
|
-
* Something does. A first WETH deposit needs a one-time Permit2 approval,
|
|
1430
|
-
* and that approval is a transaction. A wallet holding no native gas token -
|
|
1431
|
-
* the normal state of someone who just swapped everything INTO WETH - pays
|
|
1432
|
-
* for it out of the WETH. The deposit then asked for ~2e12 wei more than was
|
|
1433
|
-
* left and refused with DEPOSIT_INSUFFICIENT_BALANCE, under a wrapper saying
|
|
1434
|
-
* the funds were safe but unadded (ROUT-242).
|
|
1435
|
-
*
|
|
1436
|
-
* So the approval happens here, before the amount is settled, and the amount
|
|
1437
|
-
* comes from a read taken after it. Two things this deliberately is not:
|
|
1438
|
-
*
|
|
1439
|
-
* - It is not a balance sweep. `received` is a DELTA over the pre-swap
|
|
1440
|
-
* balance, so a wallet already holding WETH reads far above it; depositing
|
|
1441
|
-
* the balance would move funds the user never offered. The arrival is the
|
|
1442
|
-
* ceiling and the balance is only ever allowed to lower it.
|
|
1443
|
-
* - It does not touch USDC, which moves on signed typed data and so spends
|
|
1444
|
-
* nothing of the user's in between, nor a paymaster-configured client,
|
|
1445
|
-
* where the sponsor covers the transfer and Permit2 never applies.
|
|
2532
|
+
* Finish any user-paid Permit2 approval before measuring the deposit.
|
|
2533
|
+
* Wallets can charge approval gas in the received token (ROUT-242/544).
|
|
2534
|
+
* Cap the result at the swap arrival to preserve pre-existing wallet funds.
|
|
2535
|
+
* Native Base/Arbitrum USDC uses sponsored ERC-2612; configured paymaster
|
|
2536
|
+
* wallet calls also cover approval without spending the received tokens.
|
|
1446
2537
|
*/
|
|
1447
2538
|
private settleSwapDepositAmount;
|
|
1448
2539
|
/**
|
|
@@ -1521,8 +2612,19 @@ declare class OwneySDK {
|
|
|
1521
2612
|
* second half of `swapAndDeposit` on its own. Cleared only once the deposit
|
|
1522
2613
|
* has actually gone through — a failure here leaves the record in place so it
|
|
1523
2614
|
* can be offered again rather than silently dropped.
|
|
2615
|
+
*
|
|
2616
|
+
* The record does not remember `excludeAgentIds`, on purpose: the caller must
|
|
2617
|
+
* pass the CURRENT list, because the user's choice may have changed since the
|
|
2618
|
+
* swap (a deposit reads it fresh each time). Without it, a record with no
|
|
2619
|
+
* `agentId` splits across every eligible agent. When the list leaves nobody to
|
|
2620
|
+
* fund (or names the record's own agent) it throws `ALL_AGENTS_EXCLUDED`
|
|
2621
|
+
* before the wallet is touched and keeps the record.
|
|
2622
|
+
*
|
|
2623
|
+
* @param options.excludeAgentIds - See `DepositOptions.excludeAgentIds`.
|
|
1524
2624
|
*/
|
|
1525
|
-
completePendingDeposit(id: string
|
|
2625
|
+
completePendingDeposit(id: string, options?: {
|
|
2626
|
+
excludeAgentIds?: AgentId[];
|
|
2627
|
+
}): Promise<OwneyDepositResult | OwneyMultiDepositResult>;
|
|
1526
2628
|
/**
|
|
1527
2629
|
* Pick up cross-chain swaps a previous session left in flight.
|
|
1528
2630
|
*
|
|
@@ -1539,11 +2641,12 @@ declare class OwneySDK {
|
|
|
1539
2641
|
* Every order is attempted even if an earlier one throws: they are unrelated
|
|
1540
2642
|
* escrows, and one ending badly must not abandon the next one's secrets.
|
|
1541
2643
|
* `unfinished` is not a verdict — the order may still settle, so unless the
|
|
1542
|
-
*
|
|
2644
|
+
* provider has confirmed full settlement or refund, its preimages are kept.
|
|
1543
2645
|
*/
|
|
1544
2646
|
resumePendingSwaps(options?: {
|
|
1545
2647
|
onStage?: (orderHash: string, stage: SwapStage) => void;
|
|
1546
2648
|
timeoutMs?: number;
|
|
2649
|
+
orderHash?: string;
|
|
1547
2650
|
}): Promise<{
|
|
1548
2651
|
orderHash: string;
|
|
1549
2652
|
status: "completed" | "unfinished";
|
|
@@ -1658,9 +2761,27 @@ declare class OwneySDK {
|
|
|
1658
2761
|
symbol: string;
|
|
1659
2762
|
};
|
|
1660
2763
|
agentId?: AgentId;
|
|
2764
|
+
/**
|
|
2765
|
+
* Agents the deposit must not fund (see `DepositOptions.excludeAgentIds`).
|
|
2766
|
+
* Checked before the quote, so a swap that could not end in a deposit never
|
|
2767
|
+
* starts. Not stored on a pending deposit: whoever finishes one later
|
|
2768
|
+
* passes the then-current list to `completePendingDeposit(id, options)`.
|
|
2769
|
+
*/
|
|
2770
|
+
excludeAgentIds?: AgentId[];
|
|
1661
2771
|
/** Percent, classic rail only. Fusion+ prices through its auction. */
|
|
1662
2772
|
slippage?: number;
|
|
1663
2773
|
onSwapProgress?: (stage: SwapStage) => void;
|
|
2774
|
+
/** Destination balance baseline, read after the swap and before deposit preparation. */
|
|
2775
|
+
onBeforeDeposit?: () => Promise<void>;
|
|
2776
|
+
onDepositProgress?: FundingProgress;
|
|
2777
|
+
onBeforeDepositSubmission?: DepositOptions["onBeforeSubmission"];
|
|
2778
|
+
/** Stop a stale foreground attempt before it prepares or sends another transaction. */
|
|
2779
|
+
assertCurrent?: () => void;
|
|
2780
|
+
/** Funding-ledger reference for this swap and its deposit. Generated when omitted. */
|
|
2781
|
+
operationId?: string;
|
|
2782
|
+
/** Groups this swap and deposit with the others started by one user action
|
|
2783
|
+
* (see `DepositOptions.batchId`). Saved on the pending deposit record. */
|
|
2784
|
+
batchId?: string;
|
|
1664
2785
|
}): Promise<{
|
|
1665
2786
|
swap: {
|
|
1666
2787
|
received: string;
|
|
@@ -1674,6 +2795,24 @@ declare class OwneySDK {
|
|
|
1674
2795
|
* want this one; `swap.received` stays what it says it is.
|
|
1675
2796
|
*/
|
|
1676
2797
|
deposited: string;
|
|
2798
|
+
/** Funding-ledger reference shared by the swap and its deposit. */
|
|
2799
|
+
operationId?: string;
|
|
2800
|
+
}>;
|
|
2801
|
+
/** Read-only confirmation of a saved pre-swap withdrawal. Never withdraws or swaps. */
|
|
2802
|
+
recheckWithdrawalSwap(id: string): Promise<WithdrawSwapRecord>;
|
|
2803
|
+
/** Explicit foreground continuation: spends verified payouts, never withdraws again. */
|
|
2804
|
+
continueWithdrawalSwap(id: string, callbacks?: Pick<Parameters<OwneySDK["withdrawAndSwap"]>[0], "onSwapProgress" | "onOrderSubmitted" | "onWithdrawalProgress" | "assertCurrent">): Promise<{
|
|
2805
|
+
withdraw: OwneyWithdrawResult | AgentWithdrawResult;
|
|
2806
|
+
/** What actually arrived in the wallet, smallest unit of the agent's asset. */
|
|
2807
|
+
withdrawn: string;
|
|
2808
|
+
swap: {
|
|
2809
|
+
received: string;
|
|
2810
|
+
spent?: string;
|
|
2811
|
+
orderHash?: string;
|
|
2812
|
+
txHash?: string;
|
|
2813
|
+
};
|
|
2814
|
+
/** Funding-ledger reference shared by the withdrawal and the swap. */
|
|
2815
|
+
operationId?: string;
|
|
1677
2816
|
}>;
|
|
1678
2817
|
/**
|
|
1679
2818
|
* Withdraw from an agent and swap the proceeds into whatever the user wants
|
|
@@ -1687,10 +2826,9 @@ declare class OwneySDK {
|
|
|
1687
2826
|
* Quoting before the tokens land would size the swap against a balance that
|
|
1688
2827
|
* is not there yet.
|
|
1689
2828
|
*
|
|
1690
|
-
*
|
|
1691
|
-
*
|
|
1692
|
-
*
|
|
1693
|
-
* the agent picks one.
|
|
2829
|
+
* Wait for each participating agent's owner payout and size one swap from
|
|
2830
|
+
* their confirmed net amounts. A first wallet increase cannot establish
|
|
2831
|
+
* that every payout arrived. Failed or incomplete withdrawals stop here.
|
|
1694
2832
|
*
|
|
1695
2833
|
* **Failure here is not symmetrical with the deposit path.** A failed
|
|
1696
2834
|
* deposit-swap leaves the user holding what they started with. A failed
|
|
@@ -1710,6 +2848,7 @@ declare class OwneySDK {
|
|
|
1710
2848
|
to: {
|
|
1711
2849
|
chainId: number;
|
|
1712
2850
|
symbol: string;
|
|
2851
|
+
decimals?: number;
|
|
1713
2852
|
};
|
|
1714
2853
|
/** Human units ("10.5"). Omit to withdraw the full agent balance. */
|
|
1715
2854
|
amount?: string;
|
|
@@ -1717,6 +2856,8 @@ declare class OwneySDK {
|
|
|
1717
2856
|
/** Percent, classic rail only. Fusion+ prices through its auction. */
|
|
1718
2857
|
slippage?: number;
|
|
1719
2858
|
onSwapProgress?: (stage: SwapStage) => void;
|
|
2859
|
+
/** Receipt evidence for the existing funding/recovery tracker. */
|
|
2860
|
+
onWithdrawalProgress?: FundingProgress;
|
|
1720
2861
|
/**
|
|
1721
2862
|
* Fires once the order is with the relayer, before the watch.
|
|
1722
2863
|
*
|
|
@@ -1742,18 +2883,38 @@ declare class OwneySDK {
|
|
|
1742
2883
|
withdrawn: string;
|
|
1743
2884
|
/** Smallest unit of the destination — the auction's start, not its floor. */
|
|
1744
2885
|
expected: string;
|
|
2886
|
+
spent?: string;
|
|
2887
|
+
durable?: boolean;
|
|
1745
2888
|
}) => void;
|
|
1746
2889
|
/** How long to wait for the withdrawal to land before giving up on the swap. */
|
|
1747
2890
|
arrivalTimeoutMs?: number;
|
|
2891
|
+
/** UI ownership fence, checked before each financial continuation. */
|
|
2892
|
+
assertCurrent?: () => void;
|
|
2893
|
+
/** Used only by explicit continueWithdrawalSwap; it never sends another withdrawal. */
|
|
2894
|
+
recoveryId?: string;
|
|
2895
|
+
/**
|
|
2896
|
+
* Funding-ledger reference for this withdrawal and swap. Generated when
|
|
2897
|
+
* omitted; a continuation reuses the one saved on its record.
|
|
2898
|
+
*/
|
|
2899
|
+
operationId?: string;
|
|
2900
|
+
/**
|
|
2901
|
+
* Groups this withdrawal with the others started by one user action (see
|
|
2902
|
+
* `WithdrawOptions.batchId`). Saved on the record, so a continuation
|
|
2903
|
+
* reports into the same batch.
|
|
2904
|
+
*/
|
|
2905
|
+
batchId?: string;
|
|
1748
2906
|
}): Promise<{
|
|
1749
2907
|
withdraw: OwneyWithdrawResult | AgentWithdrawResult;
|
|
1750
2908
|
/** What actually arrived in the wallet, smallest unit of the agent's asset. */
|
|
1751
2909
|
withdrawn: string;
|
|
1752
2910
|
swap: {
|
|
1753
2911
|
received: string;
|
|
2912
|
+
spent?: string;
|
|
1754
2913
|
orderHash?: string;
|
|
1755
2914
|
txHash?: string;
|
|
1756
2915
|
};
|
|
2916
|
+
/** Funding-ledger reference shared by the withdrawal and the swap. */
|
|
2917
|
+
operationId?: string;
|
|
1757
2918
|
}>;
|
|
1758
2919
|
/**
|
|
1759
2920
|
* Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
|
|
@@ -1765,6 +2926,67 @@ declare class OwneySDK {
|
|
|
1765
2926
|
* @returns {AgentWithdrawResult} for a single agent, or {OwneyWithdrawResult} with per-agent results
|
|
1766
2927
|
*/
|
|
1767
2928
|
withdraw(options: WithdrawOptions): Promise<OwneyWithdrawResult | AgentWithdrawResult>;
|
|
2929
|
+
/**
|
|
2930
|
+
* Claims the cross-device hold for every agent in the plan. Returns the hold,
|
|
2931
|
+
* or undefined when the reservation is off or the API is unavailable and the
|
|
2932
|
+
* mode is fail-open. Throws only before anything is submitted:
|
|
2933
|
+
* - `WITHDRAW_IN_PROGRESS` / `RESERVED_ELSEWHERE` on a 409;
|
|
2934
|
+
* - `WITHDRAW_RESERVATION_UNAVAILABLE` when unavailable and fail-closed.
|
|
2935
|
+
*/
|
|
2936
|
+
private reserveWithdrawal;
|
|
2937
|
+
/**
|
|
2938
|
+
* The cached Yieldseeker SIWE proof, when Yieldseeker is active for this
|
|
2939
|
+
* SDK. Cache only: never prompts. Yieldseeker signs on Base, so a claim on
|
|
2940
|
+
* another chain falls back to the Base proof (the server checks the
|
|
2941
|
+
* signature, the address and its age, not the chain).
|
|
2942
|
+
*/
|
|
2943
|
+
private peekReservationProof;
|
|
2944
|
+
/**
|
|
2945
|
+
* Releases or keeps each agent's hold when `withdraw()` ends. Never throws.
|
|
2946
|
+
* - unattempted agents: `not_submitted`;
|
|
2947
|
+
* - `confirmed` / definitively `failed` legs: released;
|
|
2948
|
+
* - pending/unknown legs (Zyfai's hashless acknowledgement): kept;
|
|
2949
|
+
* - a throw without submission evidence: `not_submitted`;
|
|
2950
|
+
* - Zyfai "withdrawal already in progress": kept, dispatch `provider_in_progress`.
|
|
2951
|
+
*/
|
|
2952
|
+
private settleWithdrawalReservation;
|
|
2953
|
+
/**
|
|
2954
|
+
* Releases a withdrawal reservation this browser still holds (the holder
|
|
2955
|
+
* token is kept per operationId). Use it when the app learns the outcome of a
|
|
2956
|
+
* kept hold, for example a Zyfai payout that arrived later. Never throws; a
|
|
2957
|
+
* hold this SDK does not know about is left to the server's expiry.
|
|
2958
|
+
*/
|
|
2959
|
+
releaseWithdrawalReservation(operationId: string, reason: ReservationReleaseReason, agents?: ReservationAgent[]): Promise<void>;
|
|
2960
|
+
/**
|
|
2961
|
+
* Reports a withdrawal step the app closed as never sent (a reload before its
|
|
2962
|
+
* request was saved) as a failed ledger leg with `NOT_SUBMITTED`, so other
|
|
2963
|
+
* devices and later recovery stop treating it as in flight. Refuses any step
|
|
2964
|
+
* with a hash or a saved request. Never touches the hold; never throws.
|
|
2965
|
+
*/
|
|
2966
|
+
reportWithdrawalNotSubmitted(operationId: string, evidence: FundingEvidence): Promise<void>;
|
|
2967
|
+
/**
|
|
2968
|
+
* Reports a withdrawal leg that was proven after its call ended (a hashless
|
|
2969
|
+
* Zyfai payout found on chain or in history) to the funding ledger, then
|
|
2970
|
+
* releases the withdrawal reservation this browser holds, as a fallback to
|
|
2971
|
+
* the server's own release. Only evidence with a hash whose transfer and
|
|
2972
|
+
* delivery are both confirmed is reported; anything else is ignored.
|
|
2973
|
+
* The ledger PATCHes the existing operation (creating it only on a 404) and
|
|
2974
|
+
* the server re-verifies the hash. Never throws.
|
|
2975
|
+
*/
|
|
2976
|
+
reportWithdrawalRecovery(operationId: string, evidence: FundingEvidence): Promise<void>;
|
|
2977
|
+
/**
|
|
2978
|
+
* Reports a deposit leg that the app's recovery verified on chain after its
|
|
2979
|
+
* call ended to the funding ledger. Only evidence whose transfer is confirmed
|
|
2980
|
+
* with a transaction hash is reported; anything else is ignored. The ledger
|
|
2981
|
+
* PATCHes the existing operation (creating it only on a 404) and the server
|
|
2982
|
+
* re-verifies the hash. Deposits hold no reservation, so nothing is released.
|
|
2983
|
+
* Never throws.
|
|
2984
|
+
*/
|
|
2985
|
+
reportDepositRecovery(operationId: string, evidence: FundingEvidence): Promise<void>;
|
|
2986
|
+
private withdrawFromAgents;
|
|
2987
|
+
/** Read-only invalidation after new pool-deposit activity. Does not restart
|
|
2988
|
+
* funding reconciliation, bypass cooldowns, or authorize a transaction. */
|
|
2989
|
+
invalidateAllocationRead(scope: Pick<FundingEvidence, "agentId" | "walletAddress" | "chainId" | "token">): boolean;
|
|
1768
2990
|
/**
|
|
1769
2991
|
* Get the user's balances for a specific agent, or aggregated across all agents.
|
|
1770
2992
|
* @param agentId - Optional. Agent to query. Omit for aggregated balances.
|
|
@@ -1783,7 +3005,13 @@ declare class OwneySDK {
|
|
|
1783
3005
|
* @returns {OwneyWithdrawAllResult} one leg per position attempted.
|
|
1784
3006
|
*/
|
|
1785
3007
|
withdrawAll(): Promise<OwneyWithdrawAllResult>;
|
|
1786
|
-
getBalances(agentId?: AgentId
|
|
3008
|
+
getBalances(agentId?: AgentId, options?: {
|
|
3009
|
+
chainId?: number;
|
|
3010
|
+
asset?: OwneySupportedTokens;
|
|
3011
|
+
}): Promise<OwneyBalances | AgentBalance>;
|
|
3012
|
+
private readBalances;
|
|
3013
|
+
/** Preserve failure objects for withdrawal recovery without changing public balance results. */
|
|
3014
|
+
private readAggregatedBalances;
|
|
1787
3015
|
/**
|
|
1788
3016
|
* Get the user's on-chain earnings for a specific agent, or aggregated across all agents.
|
|
1789
3017
|
* @param agentId - Optional. Agent to query. Omit for aggregated earnings.
|
|
@@ -1795,6 +3023,7 @@ declare class OwneySDK {
|
|
|
1795
3023
|
* Agents without a refresh capability fall back to their current snapshot.
|
|
1796
3024
|
*/
|
|
1797
3025
|
refreshEarnings(agentId?: AgentId): Promise<OwneyEarnings | AgentEarnings>;
|
|
3026
|
+
private aggregateEarnings;
|
|
1798
3027
|
/**
|
|
1799
3028
|
* Get the weighted APY for the user's account over a time period.
|
|
1800
3029
|
* When querying all agents, the total APY is a balance-weighted average.
|
|
@@ -1804,10 +3033,8 @@ declare class OwneySDK {
|
|
|
1804
3033
|
* @returns {AccountAgentApy} for a single agent, or {OwneyAccountApy} with totalApy and per-agent breakdown
|
|
1805
3034
|
*/
|
|
1806
3035
|
/**
|
|
1807
|
-
* Daily cumulative
|
|
1808
|
-
* "recent earnings" subline.
|
|
1809
|
-
* `lifetime + unrealized + current x 0.9`, so the figure reconciles with the
|
|
1810
|
-
* balance headline rather than reading ~11% high. (ROUT-452)
|
|
3036
|
+
* Daily cumulative earnings in the selected asset's units, backing the
|
|
3037
|
+
* "recent earnings" subline. Each adapter uses its provider's earnings basis.
|
|
1811
3038
|
*
|
|
1812
3039
|
* Unlike getAccountApy this does NOT blend across agents: earnings are
|
|
1813
3040
|
* summed, not weighted, and an agent that fails to report must not silently
|
|
@@ -1847,7 +3074,14 @@ declare class OwneySDK {
|
|
|
1847
3074
|
assets: Array<"USDC" | "WETH">;
|
|
1848
3075
|
agentId?: AgentId;
|
|
1849
3076
|
}): Promise<SavedPoolSelection>;
|
|
3077
|
+
/**
|
|
3078
|
+
* The agents a person can customize pools for: registered, enabled, and
|
|
3079
|
+
* able to list a pool catalogue. Waits for agent initialization, so an agent
|
|
3080
|
+
* the organization disabled is known and left out.
|
|
3081
|
+
*/
|
|
3082
|
+
getPoolCustomizationAgents(): Promise<AgentId[]>;
|
|
1850
3083
|
getAccountApy({ agentId, days, tokenSymbol, chainId: scope, }: AccountApyOptions): Promise<OwneyAccountApy | AccountAgentApy>;
|
|
3084
|
+
private enrichApyHistory;
|
|
1851
3085
|
/**
|
|
1852
3086
|
* Get transaction history for a specific agent, or all agents.
|
|
1853
3087
|
*
|
|
@@ -1881,14 +3115,17 @@ declare class OwneySDK {
|
|
|
1881
3115
|
*/
|
|
1882
3116
|
ensureAutoSelectProtocols(asset: "USDC" | "WETH", agentId?: AgentId): Promise<boolean>;
|
|
1883
3117
|
/**
|
|
1884
|
-
*
|
|
1885
|
-
* the
|
|
1886
|
-
*
|
|
1887
|
-
*
|
|
1888
|
-
*
|
|
3118
|
+
* User-paid approval of Permit2 on the selected token for the active chain.
|
|
3119
|
+
* Grants the maximum ERC20 allowance so later deposits do not require another
|
|
3120
|
+
* approval. Resolves after one confirmation so the subsequent deposit attempt
|
|
3121
|
+
* sees the new allowance. Deposit retries pass their captured chain id so a
|
|
3122
|
+
* concurrent activation cannot redirect the approval to another network.
|
|
3123
|
+
*
|
|
3124
|
+
* @param requiredAmount Raw base-unit amount the pending deposit must cover.
|
|
3125
|
+
* @param expectedChainId Chain captured by the deposit that requested approval.
|
|
1889
3126
|
* @returns the approval transaction hash.
|
|
1890
3127
|
*/
|
|
1891
|
-
approvePermit2(asset?:
|
|
3128
|
+
approvePermit2(asset?: OwneySupportedTokens, requiredAmount?: bigint, expectedChainId?: OwneySupportedChainId, assertCurrent?: () => void): Promise<`0x${string}`>;
|
|
1892
3129
|
/**
|
|
1893
3130
|
* Get the agent's average APY performance over a time period. Does not require a wallet connection.
|
|
1894
3131
|
* @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")
|
|
@@ -1912,6 +3149,663 @@ declare class OwneySDK {
|
|
|
1912
3149
|
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
1913
3150
|
}
|
|
1914
3151
|
|
|
3152
|
+
type YieldseekerAuthToken = {
|
|
3153
|
+
message: string;
|
|
3154
|
+
signature: Hex;
|
|
3155
|
+
};
|
|
3156
|
+
type YieldseekerAuthDependencies = {
|
|
3157
|
+
origin?: string;
|
|
3158
|
+
now?: () => Date;
|
|
3159
|
+
nonce?: () => string;
|
|
3160
|
+
};
|
|
3161
|
+
|
|
3162
|
+
type YieldseekerFetch = typeof fetch;
|
|
3163
|
+
|
|
3164
|
+
type YieldseekerTransaction = {
|
|
3165
|
+
from: `0x${string}`;
|
|
3166
|
+
to: `0x${string}`;
|
|
3167
|
+
data: `0x${string}`;
|
|
3168
|
+
value: string;
|
|
3169
|
+
chainId: number;
|
|
3170
|
+
};
|
|
3171
|
+
|
|
3172
|
+
type YieldseekerWalletStatus = {
|
|
3173
|
+
agentWallet: Address;
|
|
3174
|
+
owner: Address;
|
|
3175
|
+
ownerPath: "eoa" | "smart";
|
|
3176
|
+
asset: Address;
|
|
3177
|
+
implementation: Address;
|
|
3178
|
+
version: "v1" | "v2" | "unknown";
|
|
3179
|
+
upgradeAvailable: boolean;
|
|
3180
|
+
/** The factory, owner, base asset, and provider wallet mapping all agree. */
|
|
3181
|
+
verified: boolean;
|
|
3182
|
+
};
|
|
3183
|
+
|
|
3184
|
+
type YieldseekerAgentOptions = {
|
|
3185
|
+
baseUrl?: string;
|
|
3186
|
+
routingApiBaseUrl?: string;
|
|
3187
|
+
fetchFn?: YieldseekerFetch;
|
|
3188
|
+
auth?: YieldseekerAuthDependencies;
|
|
3189
|
+
/** Dedicated read transport; Base is used for receipt polling. */
|
|
3190
|
+
rpcUrls?: RpcUrlsConfig;
|
|
3191
|
+
/** Test seam for the wallet-submission/receipt boundary. */
|
|
3192
|
+
transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction, onReceipt?: (receipt: viem.TransactionReceipt) => void) => Promise<Hex>;
|
|
3193
|
+
/** Test seam for transactions submitted outside transactionExecutor. */
|
|
3194
|
+
unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
|
|
3195
|
+
};
|
|
3196
|
+
declare class YieldseekerAgent implements IAgent {
|
|
3197
|
+
readonly id = "yieldseeker";
|
|
3198
|
+
readonly balanceComposition: "tokens-plus-positions";
|
|
3199
|
+
readonly withdrawalRequiresWalletApproval = true;
|
|
3200
|
+
readonly supportedChainIds: readonly [8453];
|
|
3201
|
+
readonly supportedAssets: readonly [{
|
|
3202
|
+
readonly chainId: 8453;
|
|
3203
|
+
readonly chain: "BASE";
|
|
3204
|
+
readonly assets: readonly [{
|
|
3205
|
+
readonly symbol: "USDC";
|
|
3206
|
+
readonly minDepositAmount: "10000000";
|
|
3207
|
+
}, {
|
|
3208
|
+
readonly symbol: "WETH";
|
|
3209
|
+
readonly minDepositAmount: "1";
|
|
3210
|
+
}];
|
|
3211
|
+
}];
|
|
3212
|
+
private readonly api;
|
|
3213
|
+
private readonly auth;
|
|
3214
|
+
private readonly rpcUrls?;
|
|
3215
|
+
private readonly owneyApiKey;
|
|
3216
|
+
private readonly routingApiBaseUrl?;
|
|
3217
|
+
private receiptClient?;
|
|
3218
|
+
private readonly withdrawalVersionCache;
|
|
3219
|
+
private readonly pendingWalletStatus;
|
|
3220
|
+
/** Lowercase Agent Wallet -> when this instance's deploy request succeeded. */
|
|
3221
|
+
private readonly recentDeployments;
|
|
3222
|
+
private readonly pendingUpgrades;
|
|
3223
|
+
private readonly transactionExecutor?;
|
|
3224
|
+
private readonly unwindReceiptWaiter?;
|
|
3225
|
+
private readonly agentContexts;
|
|
3226
|
+
private readonly walletContexts;
|
|
3227
|
+
private readonly agentAccountReads;
|
|
3228
|
+
private readonly sessionAgents;
|
|
3229
|
+
private readonly reportedAccounts;
|
|
3230
|
+
private readonly missingSlots;
|
|
3231
|
+
private readonly rethrownSlotFailures;
|
|
3232
|
+
private readonly closedSlots;
|
|
3233
|
+
private readonly pendingReopens;
|
|
3234
|
+
private readonly unavailableSlots;
|
|
3235
|
+
private readonly pendingReactivates;
|
|
3236
|
+
private readonly freshListReads;
|
|
3237
|
+
private readonly knownContextKeys;
|
|
3238
|
+
private readonly pendingSlotInvalidations;
|
|
3239
|
+
private readonly balanceContexts;
|
|
3240
|
+
private readonly balanceVaults;
|
|
3241
|
+
private readonly users;
|
|
3242
|
+
private readonly pendingAgents;
|
|
3243
|
+
private readonly pendingWalletContexts;
|
|
3244
|
+
private readonly readCache;
|
|
3245
|
+
private readonly pendingReads;
|
|
3246
|
+
private readGeneration;
|
|
3247
|
+
private readonly portfolioVersions;
|
|
3248
|
+
private readonly liquidityVersions;
|
|
3249
|
+
private readonly snapshotFailures;
|
|
3250
|
+
private readonly standardReadFailures;
|
|
3251
|
+
private readonly endpointReadFailures;
|
|
3252
|
+
private readonly reconcileUntil;
|
|
3253
|
+
private readonly allocationRefresh;
|
|
3254
|
+
/** Contexts whose next permitted snapshot read is forced once: a funding
|
|
3255
|
+
* invalidation with a tx hash (receipt recovery, a re-armed refresh). */
|
|
3256
|
+
private readonly forceNextSnapshot;
|
|
3257
|
+
private readonly activityRefreshUntil;
|
|
3258
|
+
private readonly snapshotMovements;
|
|
3259
|
+
private readonly movementEpochs;
|
|
3260
|
+
private readonly settlementChecks;
|
|
3261
|
+
private ledgerAccess?;
|
|
3262
|
+
private accountRefusedListener?;
|
|
3263
|
+
private readonly ledgerReads;
|
|
3264
|
+
/** contextKey -> movements this instance started settling (by tx hash) and how they refresh:
|
|
3265
|
+
* awaiting the ledger, refreshed when ready (ledger), or on the timed backoff (legacy). */
|
|
3266
|
+
private readonly localMovements;
|
|
3267
|
+
/** contextKey -> tx hash -> refresh-when-ready state of a ledger movement. */
|
|
3268
|
+
private readonly refreshPlans;
|
|
3269
|
+
/** contextKey -> the agent's ledger movements from the latest ledger read. */
|
|
3270
|
+
private readonly ledgerMovementCache;
|
|
3271
|
+
/** Contexts whose next snapshot request is a refresh-when-ready force. */
|
|
3272
|
+
private readonly readyForces;
|
|
3273
|
+
private readonly serverBaselines;
|
|
3274
|
+
private readonly snapshotHistory;
|
|
3275
|
+
/** contextKey -> the history key its refresh plans persist forced times under. */
|
|
3276
|
+
private readonly planHistoryKeys;
|
|
3277
|
+
/** A ledger read slower than this counts as "no ledger information" for that read. */
|
|
3278
|
+
private ledgerBudgetMs;
|
|
3279
|
+
/** slotKey -> the last successful ledger rows and when they arrived. */
|
|
3280
|
+
private readonly lastLedgerRows;
|
|
3281
|
+
/** Keyed by `vaultOptionsKey`: each asset's usable list and its full list are cached apart. */
|
|
3282
|
+
private readonly vaultOptions;
|
|
3283
|
+
private readonly pendingVaultOptions;
|
|
3284
|
+
private readonly assetApyStats;
|
|
3285
|
+
private readonly pendingAssetApyStats;
|
|
3286
|
+
constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
|
|
3287
|
+
private getReceiptClient;
|
|
3288
|
+
/** Reads the actual proxy implementation; Yieldseeker's API walletType is not a version check. */
|
|
3289
|
+
getWalletStatus(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, useCachedV2?: boolean): Promise<YieldseekerWalletStatus | null>;
|
|
3290
|
+
/** Reads (or reuses the 15-minute verified V2 hint for) this exact context's wallet. */
|
|
3291
|
+
private readWalletStatus;
|
|
3292
|
+
/**
|
|
3293
|
+
* Deposits go only to an agent Yieldseeker still has open. The session caches
|
|
3294
|
+
* the selected agent, so a tab left open can hold one Yieldseeker has since
|
|
3295
|
+
* closed (deactivated). This reads the agent wallet fresh from Yieldseeker,
|
|
3296
|
+
* bypassing the cached wallet contexts, and:
|
|
3297
|
+
* - open, same wallet address: returns the context to deposit with;
|
|
3298
|
+
* - closed (`deactivatedDate` set): reactivates it, re-reads the wallet, and
|
|
3299
|
+
* continues only when it is now open with the same address. Only the
|
|
3300
|
+
* verified record's agent is reopened: any other closed agent (a
|
|
3301
|
+
* superseded-wallet match, or the agent this session created or adopted
|
|
3302
|
+
* before its record exists, also when the accounts could not be read)
|
|
3303
|
+
* refuses without a request;
|
|
3304
|
+
* - anything else refuses with nothing sent, before any progress event,
|
|
3305
|
+
* signature or callback. Every refusal carries `notSubmitted` and
|
|
3306
|
+
* `safeToFallback: false`, so no paid fallback runs.
|
|
3307
|
+
* A slot recorded unavailable (the active-agent limit) refuses at once with
|
|
3308
|
+
* no request. The reactivate goes through reactivateSlot, which shares one
|
|
3309
|
+
* request per slot and remembers a failure for the list-cache window, so
|
|
3310
|
+
* repeated deposits do not repeat it. A failed wallet read fails closed
|
|
3311
|
+
* (YIELDSEEKER_WALLET_UNVERIFIED, reason UNAVAILABLE), like the on-chain
|
|
3312
|
+
* gate. A reactivate that fails keeps its error code
|
|
3313
|
+
* (YIELDSEEKER_AGENT_CLOSED, or the mapped API error for a transient
|
|
3314
|
+
* failure). At the limit the slot is also recorded unavailable for the
|
|
3315
|
+
* session (see isSlotUnavailable). Session changes keep their own
|
|
3316
|
+
* NOT_CONNECTED error.
|
|
3317
|
+
*/
|
|
3318
|
+
private assertAgentOpen;
|
|
3319
|
+
/**
|
|
3320
|
+
* Deposits go only to a wallet whose identity is verified on chain (factory
|
|
3321
|
+
* mapping, owner, base asset, FACTORY). The API key is public, so the wallet
|
|
3322
|
+
* the provider API returned is not trusted on its own. V1 wallets still
|
|
3323
|
+
* accept deposits: only identity is required, not the V2 implementation.
|
|
3324
|
+
* A failed read fails closed (reason UNAVAILABLE): an unverified wallet never
|
|
3325
|
+
* receives funds. Session changes keep their own NOT_CONNECTED error.
|
|
3326
|
+
*/
|
|
3327
|
+
private assertDepositWalletVerified;
|
|
3328
|
+
private rememberWalletStatus;
|
|
3329
|
+
/** Explicit owner action. This never runs as a side effect of withdrawal. */
|
|
3330
|
+
upgradeWallet(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, gasMode?: "paid" | "sponsored"): Promise<{
|
|
3331
|
+
txHash: Hex;
|
|
3332
|
+
status: YieldseekerWalletStatus;
|
|
3333
|
+
}>;
|
|
3334
|
+
disconnect(): Promise<void>;
|
|
3335
|
+
/**
|
|
3336
|
+
* The connect's account check (2026-11-13), run before any agent activates:
|
|
3337
|
+
* sign in (a saved sign-in, else login-with-wallet, else POST /users for a
|
|
3338
|
+
* wallet with no account, which is Owney's by definition), then ask Owney's
|
|
3339
|
+
* routing whether the account was created through Owney. Refused:
|
|
3340
|
+
* AGENT_ACCOUNT_NOT_OWNEY, permanent, and the listener is told. Cannot tell
|
|
3341
|
+
* yet: the Retry-After is waited once when it is 30 s or less, otherwise a
|
|
3342
|
+
* temporary failure. Lists, creates and reads no agent.
|
|
3343
|
+
*/
|
|
3344
|
+
checkAccount(state: ConnectionState, chainId: number): Promise<void>;
|
|
3345
|
+
/**
|
|
3346
|
+
* Ready every asset's agent, `asset` first: a missing one is created and a
|
|
3347
|
+
* closed one reopened (2026-11-06). A slot Yieldseeker will never let the
|
|
3348
|
+
* user have (the agent limit, closed for good, missing with no way to
|
|
3349
|
+
* reopen) is rethrown with `details.permanent`, which refuses the connect.
|
|
3350
|
+
* A temporary failure (an API error or timeout) on another asset does not:
|
|
3351
|
+
* that slot answers again where it is needed. On the selected asset every
|
|
3352
|
+
* failure is thrown as before, without readying the rest, so a failed
|
|
3353
|
+
* sign-in never opens a second prompt.
|
|
3354
|
+
*/
|
|
3355
|
+
activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
|
|
3356
|
+
/** The same failure, marked as one that will not go away this session. */
|
|
3357
|
+
private permanentFailure;
|
|
3358
|
+
isSlotUnavailable(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): boolean;
|
|
3359
|
+
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback, onProgress?: FundingProgress, onBeforeSubmission?: (evidence: FundingEvidence) => void | Promise<void>): Promise<OwneyDepositResult>;
|
|
3360
|
+
withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string, onProgress?: FundingProgress, gasMode?: "auto" | "sponsored" | "paid", onBeforeSubmission?: FundingProgress, assertOperation?: () => void, submission?: {
|
|
3361
|
+
operationId?: string;
|
|
3362
|
+
}): Promise<AgentWithdrawResult>;
|
|
3363
|
+
private withdrawInternal;
|
|
3364
|
+
/** Fresh position amounts for withdrawal planning, net of reserved fees. */
|
|
3365
|
+
getWithdrawableBalance(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, minimumAmount?: bigint): Promise<bigint>;
|
|
3366
|
+
/**
|
|
3367
|
+
* The cached SIWE proof, decoded, for the withdrawal reservation claim's
|
|
3368
|
+
* owner proof. Only a proof already in the cache: this never prompts the
|
|
3369
|
+
* wallet and never throws. Never log the result.
|
|
3370
|
+
*/
|
|
3371
|
+
peekReservationProof(state: ConnectionState, chainId: number): YieldseekerAuthToken | undefined;
|
|
3372
|
+
/** Recheck MAX without re-unwinding, paying out, or requesting a signature. */
|
|
3373
|
+
verifyWithdrawalCompletion(state: ConnectionState, evidence: FundingEvidence): Promise<WithdrawalCompletion>;
|
|
3374
|
+
private readVaultShares;
|
|
3375
|
+
private validateWithdrawalPositions;
|
|
3376
|
+
private withdrawalVaultHints;
|
|
3377
|
+
private readWithdrawalPositions;
|
|
3378
|
+
private resolveWithdrawalLiquidity;
|
|
3379
|
+
hasReadSession(state: ConnectionState, chainId: number): boolean;
|
|
3380
|
+
getBalances(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<AgentBalance>;
|
|
3381
|
+
verifyWithdrawalBalance(state: ConnectionState, evidence: FundingEvidence, balance: AgentBalance): Promise<AssetReadMetadata | undefined>;
|
|
3382
|
+
invalidateAllocationRead(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): void;
|
|
3383
|
+
invalidateFundingRead(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, refreshUntil?: number, txHash?: string): void;
|
|
3384
|
+
endFundingBalanceRefresh(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, read: AssetReadMetadata): boolean;
|
|
3385
|
+
/**
|
|
3386
|
+
* Tells Yieldseeker a deposit landed (`deposit-made`), so the agent allocates
|
|
3387
|
+
* it now instead of on its next 30-minute check, and confirms it did.
|
|
3388
|
+
* Yieldseeker decides whether anything moves (the funding minimum, a
|
|
3389
|
+
* deployed agent, no manual withdrawal in the last hour), and its answer
|
|
3390
|
+
* (`{}`) does not say, so a minute after each notice the agent reads its
|
|
3391
|
+
* wallet: the deposit has gone into a vault when less than its amount is
|
|
3392
|
+
* left idle. While it has not, Yieldseeker is told again, up to
|
|
3393
|
+
* DEPOSIT_NOTICE_ATTEMPTS calls in all; a failed call (network, server, rate
|
|
3394
|
+
* limit) is sent again after a wait. Within an hour of a withdrawal it is
|
|
3395
|
+
* told once, since nothing can move yet. Uses the agent this session already
|
|
3396
|
+
* knows for the asset and the saved sign-in only: never prompts, never
|
|
3397
|
+
* throws. Each call is reported through `onNotice`.
|
|
3398
|
+
*/
|
|
3399
|
+
depositConfirmed(state: ConnectionState, chainId: number, evidence: FundingEvidence, onNotice?: (notice: DepositNotice & {
|
|
3400
|
+
attempt: number;
|
|
3401
|
+
}) => void): Promise<DepositNotice>;
|
|
3402
|
+
/** One `deposit-made` call. A failure that may pass on its own carries the wait before the next try. */
|
|
3403
|
+
private sendDepositNotice;
|
|
3404
|
+
/**
|
|
3405
|
+
* Tells Yieldseeker (`deposit-made`) after a pool save, so the agent runs
|
|
3406
|
+
* now and rebalances money already in a vault the list no longer allows.
|
|
3407
|
+
* Up to DEPOSIT_NOTICE_ATTEMPTS calls in all, waiting between them only
|
|
3408
|
+
* after a failure that may pass; stops when the session ends. Never throws.
|
|
3409
|
+
*/
|
|
3410
|
+
private rebalanceAfterPoolSave;
|
|
3411
|
+
/**
|
|
3412
|
+
* When Yieldseeker may move funds again after this agent wallet's last
|
|
3413
|
+
* confirmed withdrawal, if that is still ahead; null when there was none in
|
|
3414
|
+
* the last hour or the ledger cannot say.
|
|
3415
|
+
*/
|
|
3416
|
+
private withdrawalCooldownEnd;
|
|
3417
|
+
/**
|
|
3418
|
+
* The agent wallet's base-asset balance and the platform fee Yieldseeker has
|
|
3419
|
+
* not collected from it, read at one block for a balance read. Cached
|
|
3420
|
+
* briefly per agent wallet and dropped by funding and allocation
|
|
3421
|
+
* invalidations. Null when any read fails or is slow: the snapshot's
|
|
3422
|
+
* amounts are used instead.
|
|
3423
|
+
*/
|
|
3424
|
+
private readLiveWallet;
|
|
3425
|
+
private readWalletFunds;
|
|
3426
|
+
/** The agent wallet's idle base asset; null when the read fails. */
|
|
3427
|
+
private readIdleBalance;
|
|
3428
|
+
getFundingWallet(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<string>;
|
|
3429
|
+
hasExistingDepositFunds(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<true | undefined>;
|
|
3430
|
+
getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
|
|
3431
|
+
getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string,
|
|
3432
|
+
/** The chart's chain filter (ROUT-479); null is every chain. */
|
|
3433
|
+
scopeChainId?: number | null): Promise<AccountAgentApy>;
|
|
3434
|
+
getDailyEarnings(state: ConnectionState, chainId: number, days: LookbackDays, tokenSymbol?: string): Promise<AccountDailyEarnings>;
|
|
3435
|
+
getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
|
|
3436
|
+
getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
|
|
3437
|
+
getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
|
|
3438
|
+
supportsAgentApyPeriod(days: DailyApyDays): boolean;
|
|
3439
|
+
private loadAssetApyStats;
|
|
3440
|
+
/**
|
|
3441
|
+
* The deposit-time Pools step's catalogue: every vault Yieldseeker lists
|
|
3442
|
+
* for a new agent on `asset` on Base, grouped by provider (the provider is
|
|
3443
|
+
* both `protocolId` and `name`). Nothing is filtered on our side, on
|
|
3444
|
+
* liquidity, size or provider. `strategy` is accepted for the IAgent
|
|
3445
|
+
* contract and ignored.
|
|
3446
|
+
*/
|
|
3447
|
+
getPoolCatalog(params: {
|
|
3448
|
+
asset: string;
|
|
3449
|
+
strategy?: "conservative" | "aggressive" | "yieldmaxxing";
|
|
3450
|
+
}): Promise<PoolCatalogProtocol[]>;
|
|
3451
|
+
/**
|
|
3452
|
+
* The asset's vaults on Base. By default only those a new agent can use:
|
|
3453
|
+
* Yieldseeker leaves out the ones it has disabled (40acres and Moonwell
|
|
3454
|
+
* among them), gated or can't use, so the picker follows its list
|
|
3455
|
+
* (2026-11-04). `includeUnavailable` adds those back, for anything about
|
|
3456
|
+
* money an agent may still hold in one: withdrawals and activity.
|
|
3457
|
+
*/
|
|
3458
|
+
private loadVaultOptions;
|
|
3459
|
+
/**
|
|
3460
|
+
* Save the user's Yieldseeker picks as the agent's managed vault list, then
|
|
3461
|
+
* read the rules back before any money moves. Each asset has its own agent,
|
|
3462
|
+
* so each is saved on its own. `pools` and `availablePools` hold vault
|
|
3463
|
+
* addresses.
|
|
3464
|
+
*
|
|
3465
|
+
* - Only Base entries are ours. An asset with no picks whose entries showed
|
|
3466
|
+
* no vault is skipped and nothing is sent.
|
|
3467
|
+
* - None picked (vaults shown) for any asset: every agent keeps at least one
|
|
3468
|
+
* pool (2026-11-11), so the whole save throws POOL_SELECTION_REQUIRED
|
|
3469
|
+
* before anything is written, for any asset.
|
|
3470
|
+
* - Some vaults picked: the managed list names them. Saving it again
|
|
3471
|
+
* replaces it, so there is only ever one.
|
|
3472
|
+
* - Every vault picked: the managed list is deleted, and no allow-list may
|
|
3473
|
+
* remain, so vaults Yieldseeker adds later are allowed too.
|
|
3474
|
+
* - A free-text allow-list we saved before the managed list existed is
|
|
3475
|
+
* deleted once the new state is written. A failed delete does not fail the
|
|
3476
|
+
* save; it is debug-logged, and the read-back decides.
|
|
3477
|
+
* - A read-back that differs puts the previous managed list back (or deletes
|
|
3478
|
+
* the one just created) and throws POOL_SELECTION_NOT_APPLIED. If putting
|
|
3479
|
+
* it back fails too, that is still the error thrown. An old free-text list
|
|
3480
|
+
* already deleted is not put back.
|
|
3481
|
+
* - An agent already holding the most active memories, none of them ours,
|
|
3482
|
+
* throws POOL_SELECTION_RULE_LIMIT before anything is written.
|
|
3483
|
+
*
|
|
3484
|
+
* Always Base, whichever chain the wallet is connected on.
|
|
3485
|
+
*/
|
|
3486
|
+
setPoolSelection(selection: UserPoolSelectionRequest, state?: ConnectionState): Promise<void>;
|
|
3487
|
+
private savePoolPicks;
|
|
3488
|
+
/**
|
|
3489
|
+
* Delete the free-text allow-lists we saved before the managed list existed.
|
|
3490
|
+
* Never throws: a list left behind is caught by the read-back. Logs no
|
|
3491
|
+
* sign-in token.
|
|
3492
|
+
*/
|
|
3493
|
+
private deleteLegacyPoolMemories;
|
|
3494
|
+
/**
|
|
3495
|
+
* `<address> (<name>)` for each pick, under the prefix. An unnamed address
|
|
3496
|
+
* has no brackets. There is always at least one pick (setPoolSelection
|
|
3497
|
+
* refuses a save with none).
|
|
3498
|
+
*/
|
|
3499
|
+
private poolMemoryContent;
|
|
3500
|
+
/** Undo a failed save of the managed list. Never throws: the caller reports the save's own failure. */
|
|
3501
|
+
private restorePoolMemory;
|
|
3502
|
+
/**
|
|
3503
|
+
* What the user's Yieldseeker agents currently allow, as `SavedPoolSelection`
|
|
3504
|
+
* pairs: the allowed vault addresses under the provider each belongs to, for
|
|
3505
|
+
* the vaults a new agent can use. An agent with no allow-list adds nothing,
|
|
3506
|
+
* and no pairs at all means every shown vault is on. Reads never create an
|
|
3507
|
+
* agent, and always read Base. A read that fails throws, because "no
|
|
3508
|
+
* allow-list" would wrongly mean "everything".
|
|
3509
|
+
*
|
|
3510
|
+
* An allow-list naming none of the listed vaults (the saved "none", or vaults
|
|
3511
|
+
* Yieldseeker has since stopped listing) leaves the agent nowhere to go, so
|
|
3512
|
+
* it reports none chosen for its asset: a pair with empty `pools` for every
|
|
3513
|
+
* provider listing vaults for it. With no vault listed at all there is
|
|
3514
|
+
* nothing to name that by, and it throws: the rules still restrict the agent.
|
|
3515
|
+
*
|
|
3516
|
+
* `pairs` is accepted for the contract but does not trim the answer: cutting
|
|
3517
|
+
* a real allow-list down to the pairs asked about could leave none, and none
|
|
3518
|
+
* reads as every vault on.
|
|
3519
|
+
*/
|
|
3520
|
+
getPoolSelection(state: ConnectionState, _chainId: number, params: {
|
|
3521
|
+
pairs: Array<{
|
|
3522
|
+
protocolId: string;
|
|
3523
|
+
chainId: number;
|
|
3524
|
+
}>;
|
|
3525
|
+
assets: Array<"USDC" | "WETH">;
|
|
3526
|
+
}): Promise<SavedPoolSelection>;
|
|
3527
|
+
/**
|
|
3528
|
+
* The allow-list in the agent's rules: every `allowedVaultAddresses` on an
|
|
3529
|
+
* `ignored_vault` user rule. Undefined when no rule has one, which allows
|
|
3530
|
+
* every vault; an empty list allows none. A response that does not have the
|
|
3531
|
+
* expected shape throws rather than reading as no allow-list.
|
|
3532
|
+
*/
|
|
3533
|
+
private readAllowList;
|
|
3534
|
+
private listMemories;
|
|
3535
|
+
/** A memory call for an agent, on Base whichever chain the wallet is on. */
|
|
3536
|
+
private memoryRequest;
|
|
3537
|
+
private userKey;
|
|
3538
|
+
/** One deposit/withdraw slot: owner, chain and asset. */
|
|
3539
|
+
private slotKey;
|
|
3540
|
+
/**
|
|
3541
|
+
* One agent's portfolio state. Includes the agentId so duplicate or renamed
|
|
3542
|
+
* agents for the same asset never share caches, versions or settlement.
|
|
3543
|
+
*/
|
|
3544
|
+
private contextKey;
|
|
3545
|
+
/**
|
|
3546
|
+
* Context keys an asset-only call applies to: the selected agent when known,
|
|
3547
|
+
* else every agent of the slot seen this session.
|
|
3548
|
+
*/
|
|
3549
|
+
private slotContextKeys;
|
|
3550
|
+
/**
|
|
3551
|
+
* Apply an asset-only invalidation. Before any agent of the slot resolves,
|
|
3552
|
+
* queue it so the first resolved agents still see it (as the slot-keyed
|
|
3553
|
+
* state did before contexts were keyed by agentId).
|
|
3554
|
+
*/
|
|
3555
|
+
private invalidateSlot;
|
|
3556
|
+
/** Record the selected agent for a slot; queued invalidations are now settled. */
|
|
3557
|
+
private selectContext;
|
|
3558
|
+
private assertSession;
|
|
3559
|
+
private cachedRead;
|
|
3560
|
+
private agentListKey;
|
|
3561
|
+
private listAgents;
|
|
3562
|
+
/**
|
|
3563
|
+
* The routing API's stored accounts for owner+chain, read once per session.
|
|
3564
|
+
* Resolves null when unavailable and never rejects; callers then refuse
|
|
3565
|
+
* (AGENT_ACCOUNTS_UNAVAILABLE) and create nothing. A failure is not kept:
|
|
3566
|
+
* concurrent callers share the in-flight read, and the next call reads again.
|
|
3567
|
+
*/
|
|
3568
|
+
private agentAccounts;
|
|
3569
|
+
/** Yieldseeker accounts for one slot (returned addresses are compared lowercase). */
|
|
3570
|
+
private slotAccounts;
|
|
3571
|
+
private agentFits;
|
|
3572
|
+
/**
|
|
3573
|
+
* The listed agent of the slot whose resolved wallet is in the
|
|
3574
|
+
* highest-priority set of `priorities` (index 0 first). Hinted agentIds are
|
|
3575
|
+
* resolved first and a hinted top-priority match ends the search; then other
|
|
3576
|
+
* listed agents, at most YIELDSEEKER_WALLET_MATCH_LIMIT wallets in total.
|
|
3577
|
+
* A candidate whose wallet shows it closed (deactivated) never ranks, and its
|
|
3578
|
+
* agentId is added to `closed`.
|
|
3579
|
+
*/
|
|
3580
|
+
private agentWithWallet;
|
|
3581
|
+
/**
|
|
3582
|
+
* chooseAgent, re-reading a cached list once (bypassing its cache) when the
|
|
3583
|
+
* verified agent is missing. Still missing, Yieldseeker may have closed
|
|
3584
|
+
* (deactivated) it: the verified record's agent is reactivated and selected
|
|
3585
|
+
* from a fresh list, by the verified wallet only (never created). A slot
|
|
3586
|
+
* that still fails is remembered with its error for the list cache window,
|
|
3587
|
+
* so later reads fail without another re-read or reactivate. A slot
|
|
3588
|
+
* Yieldseeker will not reopen because of its active-agent limit throws
|
|
3589
|
+
* YIELDSEEKER_SLOT_UNAVAILABLE, here and for the rest of the session, with
|
|
3590
|
+
* no request.
|
|
3591
|
+
*/
|
|
3592
|
+
private chooseAgentRefreshing;
|
|
3593
|
+
private throwIfSlotUnavailable;
|
|
3594
|
+
/**
|
|
3595
|
+
* Rethrow the error a slot's lookup failed with while the slot is still
|
|
3596
|
+
* marked, or for the session when Yieldseeker will never reopen its agent.
|
|
3597
|
+
* A remembered rate limit is rethrown with the time left on its marker as
|
|
3598
|
+
* its retry delay (`retryAfterSeconds`): no new attempt is made before then,
|
|
3599
|
+
* so a caller that waits it out retries once instead of every few seconds.
|
|
3600
|
+
*/
|
|
3601
|
+
private throwIfSlotMissing;
|
|
3602
|
+
/**
|
|
3603
|
+
* Remember a slot's failed lookup or reactivate for the list-cache window.
|
|
3604
|
+
* A sign-in failure is not remembered (the wallet's rejection,
|
|
3605
|
+
* AGENT_AUTH_FAILED, NOT_CONNECTED): it says nothing about the slot, and
|
|
3606
|
+
* remembered it would refuse the next sign-in, even one the user starts,
|
|
3607
|
+
* with no request for the whole window.
|
|
3608
|
+
*/
|
|
3609
|
+
private rememberMissingSlot;
|
|
3610
|
+
/**
|
|
3611
|
+
* Reactivate the slot's verified agent, then read the list bypassing its
|
|
3612
|
+
* cache, with a read sent after the reactivate answered. Concurrent lookups
|
|
3613
|
+
* of one slot share one reopen. Resolves to the fresh list. At the
|
|
3614
|
+
* active-agent limit the slot is recorded unavailable and this throws
|
|
3615
|
+
* YIELDSEEKER_SLOT_UNAVAILABLE.
|
|
3616
|
+
*/
|
|
3617
|
+
private reopenAgent;
|
|
3618
|
+
/**
|
|
3619
|
+
* The one way to reactivate a slot's agent, for the slot lookup (reopenAgent)
|
|
3620
|
+
* and the pre-deposit check (assertAgentOpen), so a slot costs at most one
|
|
3621
|
+
* reactivate per list-cache window:
|
|
3622
|
+
* - a slot recorded unavailable (the limit) answers "limit" with no request;
|
|
3623
|
+
* - concurrent callers share one request;
|
|
3624
|
+
* - a failed reactivate (closed code, rate limit, timeout, 5xx...) is
|
|
3625
|
+
* remembered as the slot's failure for the list-cache window (missingSlots)
|
|
3626
|
+
* and rethrown to later callers with no request; a closed code
|
|
3627
|
+
* (closedSlots) for the session; a sign-in failure is not remembered;
|
|
3628
|
+
* - the limit is recorded in unavailableSlots only while the session is
|
|
3629
|
+
* unchanged, so a disconnect during the request is not undone by its late
|
|
3630
|
+
* answer.
|
|
3631
|
+
*/
|
|
3632
|
+
private reactivateSlot;
|
|
3633
|
+
/**
|
|
3634
|
+
* Ask Yieldseeker to reopen a closed (deactivated) agent, with the user's
|
|
3635
|
+
* Yieldseeker sign-in. AGENT_NOT_DEACTIVATED (already open, e.g. reopened
|
|
3636
|
+
* by another tab) counts as reopened; the active-agent limit is an outcome,
|
|
3637
|
+
* not an error. An agent that cannot come back throws
|
|
3638
|
+
* YIELDSEEKER_AGENT_CLOSED; any other failure (rate limit, timeout, network,
|
|
3639
|
+
* 5xx, an unknown code) throws the mapped API error.
|
|
3640
|
+
*/
|
|
3641
|
+
private reactivateAgent;
|
|
3642
|
+
/** Drop the cached and in-flight wallet contexts of one agent, in every slot. */
|
|
3643
|
+
private forgetAgentWallet;
|
|
3644
|
+
/**
|
|
3645
|
+
* The agent that serves deposits and withdrawals for a slot (Ruling 23):
|
|
3646
|
+
* 1. the listed fitting agent whose wallet is the verified account's wallet,
|
|
3647
|
+
* whatever its name; the stored agentId is only a hint;
|
|
3648
|
+
* 2. else a listed fitting agent whose wallet is a superseded account's wallet;
|
|
3649
|
+
* 3. else, with a verified account, throw YIELDSEEKER_AGENT_MISSING (never
|
|
3650
|
+
* create);
|
|
3651
|
+
* 4. else, with no record at all, the listed agent this session created or
|
|
3652
|
+
* adopted for the slot (sessionAgents); without one, undefined (the
|
|
3653
|
+
* caller creates an agent named "owney"). An agent is never picked by
|
|
3654
|
+
* its name: only our records, and this session's own create, say which
|
|
3655
|
+
* agents are Owney's.
|
|
3656
|
+
* Without the account records (`null`: the read failed) nothing can be
|
|
3657
|
+
* known, so the call is refused and nothing is created.
|
|
3658
|
+
* Steps 1 and 2 share one search of at most YIELDSEEKER_WALLET_MATCH_LIMIT
|
|
3659
|
+
* wallet reads. The account report then records the selected wallet; the
|
|
3660
|
+
* server marks it superseded when it differs from the verified wallet.
|
|
3661
|
+
*/
|
|
3662
|
+
private chooseAgent;
|
|
3663
|
+
private isAgentMissing;
|
|
3664
|
+
private agentMissing;
|
|
3665
|
+
private slotUnavailable;
|
|
3666
|
+
/** The slot has no usable agent: missing, at Yieldseeker's agent limit, or closed for good. */
|
|
3667
|
+
private isSlotEmpty;
|
|
3668
|
+
/**
|
|
3669
|
+
* The slot's lookup failed through the missing-agent / reopen path and was
|
|
3670
|
+
* remembered with this very error, even a transient one (429, 5xx, timeout),
|
|
3671
|
+
* or with the copy of it a remembered rate limit is rethrown as. Compares
|
|
3672
|
+
* the remembered error, not its expiry, so it holds however long the rest
|
|
3673
|
+
* of the read takes.
|
|
3674
|
+
*/
|
|
3675
|
+
private isMarkedSlotFailure;
|
|
3676
|
+
/** providerCode is absent when Yieldseeker named none (the agent stayed closed after a reopen). */
|
|
3677
|
+
private agentClosed;
|
|
3678
|
+
/**
|
|
3679
|
+
* Fire-and-forget: record which agent serves this slot. Never awaited on the
|
|
3680
|
+
* funds path and never throws; once per agent wallet and deployment state
|
|
3681
|
+
* per session.
|
|
3682
|
+
*/
|
|
3683
|
+
private reportAccount;
|
|
3684
|
+
private contextForAgent;
|
|
3685
|
+
private resolveUser;
|
|
3686
|
+
private forgetUser;
|
|
3687
|
+
private ensureAgent;
|
|
3688
|
+
private findAgent;
|
|
3689
|
+
private resolveAgent;
|
|
3690
|
+
/**
|
|
3691
|
+
* Create the slot's agent, named "owney". Only reached when the slot has no
|
|
3692
|
+
* account record and no agent this session made; the created agent is
|
|
3693
|
+
* remembered for the session (sessionAgents) so reads select it before its
|
|
3694
|
+
* record exists.
|
|
3695
|
+
*/
|
|
3696
|
+
private createAgent;
|
|
3697
|
+
/**
|
|
3698
|
+
* The routing create lock refused the create: another tab or app owns or is
|
|
3699
|
+
* creating this slot's agent. Re-read the accounts and the list (bypassing
|
|
3700
|
+
* their caches) and select that agent, once more after 2 s if needed. A
|
|
3701
|
+
* verified account is matched by wallet; otherwise the returned agentId is
|
|
3702
|
+
* used. Never creates again.
|
|
3703
|
+
*/
|
|
3704
|
+
private adoptConflictingAgent;
|
|
3705
|
+
private loadPortfolio;
|
|
3706
|
+
private loadActivityPortfolio;
|
|
3707
|
+
private resolvePortfolioContexts;
|
|
3708
|
+
private portfolioVersion;
|
|
3709
|
+
/** Snapshot cache lifetime: the settlement backoff while a movement is being
|
|
3710
|
+
* checked, otherwise the routine non-forced cadence. */
|
|
3711
|
+
private portfolioCacheMs;
|
|
3712
|
+
/** A pending movement inside its ten-minute window. */
|
|
3713
|
+
private settlementWindow;
|
|
3714
|
+
/** A pending movement inside its ten-minute window forces snapshots, unless
|
|
3715
|
+
* every movement being settled is refreshed when ready through the ledger. */
|
|
3716
|
+
private settling;
|
|
3717
|
+
/** Start a new forced-check schedule, or keep the active one. */
|
|
3718
|
+
private beginSettlement;
|
|
3719
|
+
private snapshotMovement;
|
|
3720
|
+
private advancePortfolioVersion;
|
|
3721
|
+
private requestPortfolioSnapshot;
|
|
3722
|
+
private snapshotPath;
|
|
3723
|
+
/** True while `walletRequest` would refuse a read of `path`: this user's
|
|
3724
|
+
* rate-limit cooldown or that endpoint's outage cooldown. */
|
|
3725
|
+
private readCoolingDown;
|
|
3726
|
+
private portfolioSnapshot;
|
|
3727
|
+
private loadPortfolioContext;
|
|
3728
|
+
private loadActivityContext;
|
|
3729
|
+
private loadPortfolioParts;
|
|
3730
|
+
private deployAgent;
|
|
3731
|
+
setAccountRefusedListener(listener: (() => void) | undefined): void;
|
|
3732
|
+
setFundingLedgerAccess(access: AgentFundingLedgerAccess | undefined): void;
|
|
3733
|
+
private historyKey;
|
|
3734
|
+
/** Funding-ledger rows for this slot, cached 15 s. Never throws: null on any failure. */
|
|
3735
|
+
private readLedger;
|
|
3736
|
+
/**
|
|
3737
|
+
* A ledger read within the read budget. On a timeout or failure, the last
|
|
3738
|
+
* successful rows are reused if at most 60 s old (no hold flicker); older
|
|
3739
|
+
* means null, i.e. today's behaviour.
|
|
3740
|
+
*/
|
|
3741
|
+
private readLedgerBudgeted;
|
|
3742
|
+
private ledgerMovementsFor;
|
|
3743
|
+
/** Track a movement this instance is settling. With ledger access and a tx
|
|
3744
|
+
* hash it awaits the ledger; otherwise it keeps the timed backoff. */
|
|
3745
|
+
private trackLocalMovement;
|
|
3746
|
+
/** Timed (legacy) entries end with their ten-minute window; ledger ones after the one-hour index window. */
|
|
3747
|
+
private pruneLocalMovements;
|
|
3748
|
+
private hasAwaitingMovement;
|
|
3749
|
+
/** Every movement being settled here is (or may yet be) refreshed when ready through the ledger. */
|
|
3750
|
+
private deferredToLedger;
|
|
3751
|
+
/** A null ledger sends every local movement back to the timed backoff; a
|
|
3752
|
+
* listed tx hash is refreshed when ready; an unlisted one after the grace too. */
|
|
3753
|
+
private resolveLocalMovements;
|
|
3754
|
+
/**
|
|
3755
|
+
* Refresh when ready, before a portfolio read: read the ledger (cached) when
|
|
3756
|
+
* an earnings read asks for it or a movement is being tracked, update each
|
|
3757
|
+
* recent movement's plan, poll the provider's history (non-forced, 15 s
|
|
3758
|
+
* cache) for un-indexed tx hashes, and mark the next snapshot as forced when
|
|
3759
|
+
* a plan is due. Never throws.
|
|
3760
|
+
*/
|
|
3761
|
+
private prepareLedgerRefresh;
|
|
3762
|
+
/** Apply one ledger read to local movements and refresh plans. False when the ledger is unavailable. */
|
|
3763
|
+
private applyLedgerRows;
|
|
3764
|
+
private updateRefreshPlans;
|
|
3765
|
+
/** Non-forced provider history read (15 s cache) to learn when a tx hash is indexed. */
|
|
3766
|
+
private pollIndexing;
|
|
3767
|
+
/** The forced snapshot about to be requested counts for every plan that is
|
|
3768
|
+
* due. False (do not force) when none is. */
|
|
3769
|
+
private noteReadyForce;
|
|
3770
|
+
private recordSnapshotHistory;
|
|
3771
|
+
private localHistory;
|
|
3772
|
+
/** After a snapshot: if this SDK's own history shows every recent ledger
|
|
3773
|
+
* movement in net deposits, no plan needs (more) forcing. */
|
|
3774
|
+
private checkLocalBooking;
|
|
3775
|
+
/** The newest server sample observed at or before `cutoff`, cached. Null when none or on failure. */
|
|
3776
|
+
private serverBaseline;
|
|
3777
|
+
/**
|
|
3778
|
+
* Earnings hold (spec B2): while a recent ledger movement is not booked by
|
|
3779
|
+
* the provider, report the last good `cumulativeYieldBase`. The balance is
|
|
3780
|
+
* untouched. Any missing input (no ledger, no baseline) or failure returns
|
|
3781
|
+
* the provider's value. Never throws.
|
|
3782
|
+
*/
|
|
3783
|
+
private applyEarningsHold;
|
|
3784
|
+
private refreshSnapshotAfterMovement;
|
|
3785
|
+
private agentPath;
|
|
3786
|
+
private walletRequest;
|
|
3787
|
+
private providerRequest;
|
|
3788
|
+
/**
|
|
3789
|
+
* mapApiError for a request that may have opened the Yieldseeker sign-in
|
|
3790
|
+
* prompt (providerRequest signs when no sign-in is saved, and again when
|
|
3791
|
+
* Yieldseeker refuses one). The wallet's rejection, the user cancelling that
|
|
3792
|
+
* prompt, is returned unchanged: the client and the app must see the user's
|
|
3793
|
+
* cancel (no further prompt, no retry), never a provider failure.
|
|
3794
|
+
*/
|
|
3795
|
+
private mapRequestFailure;
|
|
3796
|
+
private mapApiError;
|
|
3797
|
+
private submitTransaction;
|
|
3798
|
+
private waitForReceipt;
|
|
3799
|
+
private assertTransaction;
|
|
3800
|
+
private assertAgent;
|
|
3801
|
+
private assetForAgent;
|
|
3802
|
+
private isTransactionHash;
|
|
3803
|
+
private assertChain;
|
|
3804
|
+
private assertOptionalChain;
|
|
3805
|
+
private assertAsset;
|
|
3806
|
+
private invalidResponse;
|
|
3807
|
+
}
|
|
3808
|
+
|
|
1915
3809
|
declare class InvalidHistoryCursorError extends Error {
|
|
1916
3810
|
readonly code: "invalid_cursor";
|
|
1917
3811
|
constructor(message: string);
|
|
@@ -1988,6 +3882,7 @@ declare function switchWalletConnectChain(provider: unknown, chainId: number, ti
|
|
|
1988
3882
|
*/
|
|
1989
3883
|
type StoredOrder = {
|
|
1990
3884
|
orderHash: string;
|
|
3885
|
+
walletAddress?: string;
|
|
1991
3886
|
/** Preimages, one per fill. Index matters — fill N needs secret N. */
|
|
1992
3887
|
secrets: string[];
|
|
1993
3888
|
/** Chain the funds left from, so a resumed session can report it. */
|
|
@@ -1997,13 +3892,107 @@ type StoredOrder = {
|
|
|
1997
3892
|
dstSymbol: string;
|
|
1998
3893
|
dstChainId: number;
|
|
1999
3894
|
amount: string;
|
|
2000
|
-
/** Epoch ms
|
|
3895
|
+
/** Epoch ms, for ordering recovery records. */
|
|
2001
3896
|
createdAt: number;
|
|
3897
|
+
/**
|
|
3898
|
+
* A swap-deposit's deposit half, so a resume that finishes the swap can
|
|
3899
|
+
* record it (ROUT-625). `received` is the quote's guaranteed minimum. Absent
|
|
3900
|
+
* on plain swaps and on records written by an older SDK.
|
|
3901
|
+
*/
|
|
3902
|
+
pendingDeposit?: {
|
|
3903
|
+
received: string;
|
|
3904
|
+
symbol: string;
|
|
3905
|
+
chainId: number;
|
|
3906
|
+
agentId?: string;
|
|
3907
|
+
operationId?: string;
|
|
3908
|
+
/** The user action's batch (see `DepositOptions.batchId`), carried to the recorded pending deposit. */
|
|
3909
|
+
batchId?: string;
|
|
3910
|
+
};
|
|
3911
|
+
/**
|
|
3912
|
+
* Our routing API accepted these secrets (part 5's opt-in handoff) and
|
|
3913
|
+
* publishes them itself once 1inch is ready. Informational: this browser
|
|
3914
|
+
* still publishes and resumes as before. Absent when no handoff was accepted.
|
|
3915
|
+
*/
|
|
3916
|
+
serverSecrets?: true;
|
|
2002
3917
|
};
|
|
2003
3918
|
/**
|
|
2004
|
-
* Every stored order, newest first
|
|
3919
|
+
* Every unresolved stored order, newest first.
|
|
2005
3920
|
* Used on mount to resume orders the user left in flight.
|
|
2006
3921
|
*/
|
|
2007
|
-
declare function listOrders(
|
|
3922
|
+
declare function listOrders(_now?: number): StoredOrder[];
|
|
3923
|
+
|
|
3924
|
+
/**
|
|
3925
|
+
* Capability flag (part 5): this SDK can hand a signed Fusion+ order's secrets
|
|
3926
|
+
* to the routing API (`handoffSecrets`), which then publishes each one when
|
|
3927
|
+
* 1inch is ready, even if this tab is gone. Older builds do not export this.
|
|
3928
|
+
*/
|
|
3929
|
+
declare const FUSION_SECRET_SERVER_PUBLISH: 1;
|
|
3930
|
+
|
|
3931
|
+
/**
|
|
3932
|
+
* Non-blocking funding ledger reporter.
|
|
3933
|
+
*
|
|
3934
|
+
* Reports each funding operation (deposit / withdraw / swap) to the routing
|
|
3935
|
+
* API's `/api/v1/funding/operations` endpoints so support can reconstruct what
|
|
3936
|
+
* happened. Hard rule: reporting NEVER blocks or fails a funding action.
|
|
3937
|
+
*
|
|
3938
|
+
* - `start()` / `leg()` / `finish()` are synchronous and never throw.
|
|
3939
|
+
* - Requests run on a per-operation promise chain, create first.
|
|
3940
|
+
* - Every error is swallowed (visible only with debug logging on).
|
|
3941
|
+
*/
|
|
3942
|
+
/** Set by tsup's `define`; "dev" when running from source. */
|
|
3943
|
+
declare const SDK_VERSION: string;
|
|
3944
|
+
type LedgerLegReport = {
|
|
3945
|
+
legKey: string;
|
|
3946
|
+
legKind: "agent" | "swap" | "approval";
|
|
3947
|
+
agentType?: string;
|
|
3948
|
+
agentWallet?: string;
|
|
3949
|
+
rail?: string;
|
|
3950
|
+
amountRaw?: string;
|
|
3951
|
+
status?: "created" | "submitted" | "unknown" | "failed" | "confirmed";
|
|
3952
|
+
txHash?: string;
|
|
3953
|
+
userOpHash?: string;
|
|
3954
|
+
callsId?: string;
|
|
3955
|
+
orderHash?: string;
|
|
3956
|
+
/** The provider's own id for this leg's request (Zyfai's v2 withdrawal id). */
|
|
3957
|
+
providerRef?: string;
|
|
3958
|
+
confirmedAmountRaw?: string;
|
|
3959
|
+
blockNumber?: string;
|
|
3960
|
+
errorCode?: string;
|
|
3961
|
+
swap?: {
|
|
3962
|
+
rail: "swap_classic" | "swap_fusion" | "swap_fusion_plus";
|
|
3963
|
+
srcChainId: number;
|
|
3964
|
+
dstChainId: number;
|
|
3965
|
+
srcToken: string;
|
|
3966
|
+
dstToken: string;
|
|
3967
|
+
srcAmountRaw: string;
|
|
3968
|
+
quotedDstAmountRaw?: string;
|
|
3969
|
+
receivedDstAmountRaw?: string;
|
|
3970
|
+
feeBps?: number;
|
|
3971
|
+
feeBpsSource?: "measured" | "stated";
|
|
3972
|
+
feeToken?: string;
|
|
3973
|
+
};
|
|
3974
|
+
};
|
|
3975
|
+
|
|
3976
|
+
/** This SDK hands every Zyfai withdrawal request to the caller's
|
|
3977
|
+
* `onBeforeSubmission` before sending it, and a failed checkpoint stops it.
|
|
3978
|
+
* A caller that persisted nothing for a dead run can therefore conclude the
|
|
3979
|
+
* request was never sent. Older builds do not export this. */
|
|
3980
|
+
declare const ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT: 1;
|
|
3981
|
+
|
|
3982
|
+
/** Capability flag: this SDK opts in to the server sending an accepted
|
|
3983
|
+
* sponsored deposit itself (prepare `serverBroadcast: true`) and reports such a
|
|
3984
|
+
* deposit as pending, never "not sent". Older builds do not export this. */
|
|
3985
|
+
declare const SPONSORED_DEPOSIT_SERVER_BROADCAST: 1;
|
|
3986
|
+
|
|
3987
|
+
/** Capability flag: this SDK opts in to the server sending its signed sponsored
|
|
3988
|
+
* Yieldseeker withdrawal userOp itself (`serverSubmit=1` on its own
|
|
3989
|
+
* `eth_sendUserOperation`) and reports such a leg as pending, never "not sent".
|
|
3990
|
+
* Older builds do not export this. */
|
|
3991
|
+
declare const YIELDSEEKER_WITHDRAW_SERVER_SUBMIT: 1;
|
|
3992
|
+
|
|
3993
|
+
/** Capability flag: this SDK has `reportDepositRecovery`, which reports a
|
|
3994
|
+
* deposit leg the app's recovery verified on chain to the funding ledger.
|
|
3995
|
+
* Older builds do not export this. */
|
|
3996
|
+
declare const FUNDING_DEPOSIT_RECOVERY_REPORT: 1;
|
|
2008
3997
|
|
|
2009
|
-
export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, 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 ApyCoverage, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, 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 OrgPoolPolicy, type OrgPoolSelection, 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 OwneyWithdrawAllLeg, type OwneyWithdrawAllResult, type OwneyWithdrawResult, type PendingDeposit, type PoolCatalogProtocol, type PoolSelectionStrategy, type RebalanceLog, type SavedPoolSelection, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, switchWalletConnectChain, updateWithdrawSwap };
|
|
3998
|
+
export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyCoverage, type ApyHistoryPoint, type ApyIncentive, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, FUNDING_DEPOSIT_RECOVERY_REPORT, FUSION_SECRET_SERVER_PUBLISH, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, type LookbackDays, NotConnectedError, type OrgPoolPolicy, type OrgPoolSelection, 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 OwneyWithdrawAllLeg, type OwneyWithdrawAllResult, type OwneyWithdrawResult, type PendingDeposit, type PoolCatalogProtocol, type PoolSelectionStrategy, type ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, SPONSORED_DEPOSIT_SERVER_BROADCAST, type SavedPoolSelection, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YIELDSEEKER_WITHDRAW_SERVER_SUBMIT, YieldseekerAgent, type YieldseekerWalletStatus, ZYFAI_REGISTRATION_NOT_SENT_CODES, ZYFAI_SERVER_TASKS, ZYFAI_WITHDRAWAL_NOT_SENT_CODES, ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT, type ZyfaiDepositPlacement, type ZyfaiRpcUrlsConfig, type ZyfaiWithdrawalLifecycle, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, switchWalletConnectChain, updateWithdrawSwap };
|