@owney/sdk 0.7.17-beta.3 → 0.7.17
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 +0 -2
- package/dist/index.cjs +563 -2289
- package/dist/index.d.cts +11 -133
- package/dist/index.d.ts +11 -133
- package/dist/index.js +560 -2298
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Hex } from 'viem';
|
|
2
1
|
import { SIWXConfig } from '@reown/appkit-controllers';
|
|
3
2
|
|
|
4
3
|
type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
|
|
@@ -9,10 +8,6 @@ interface OwneySDKConfig {
|
|
|
9
8
|
* Example: { 8453: "https://...", 42161: "https://..." }
|
|
10
9
|
*/
|
|
11
10
|
zyfaiRpcUrls?: ZyfaiRpcUrlsConfig;
|
|
12
|
-
/** Optional Owney Yieldseeker proxy base URL override for integration tests. */
|
|
13
|
-
yieldseekerApiBaseUrl?: string;
|
|
14
|
-
/** Optional SIWE origin override. Defaults to the requesting browser origin. */
|
|
15
|
-
yieldseekerSiweOrigin?: string;
|
|
16
11
|
/**
|
|
17
12
|
* Optional override for the Owney routing API base URL used by all routing
|
|
18
13
|
* calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
|
|
@@ -59,7 +54,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
|
59
54
|
type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
|
|
60
55
|
type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
|
|
61
56
|
|
|
62
|
-
type AgentId = "zyfai"
|
|
57
|
+
type AgentId = "zyfai";
|
|
63
58
|
type Asset = string;
|
|
64
59
|
type AgentSupportedAsset = {
|
|
65
60
|
readonly symbol: string;
|
|
@@ -216,8 +211,6 @@ interface OwneyPosition {
|
|
|
216
211
|
pool?: string;
|
|
217
212
|
asset: string;
|
|
218
213
|
amount: string;
|
|
219
|
-
/** Smallest-unit amount when the provider exposes it alongside `amount`. */
|
|
220
|
-
amountRaw?: string;
|
|
221
214
|
apy?: number;
|
|
222
215
|
tvl?: number;
|
|
223
216
|
/** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
|
|
@@ -248,19 +241,10 @@ interface OwneyPendingAllocation {
|
|
|
248
241
|
since?: string;
|
|
249
242
|
}
|
|
250
243
|
interface AgentBalance {
|
|
251
|
-
/** Authoritative native balances per asset/network, including idle and invested funds. */
|
|
252
|
-
assetBalances?: OwneyToken[];
|
|
253
244
|
smartWallet?: `0x${string}`;
|
|
254
245
|
totalBalance: string;
|
|
255
246
|
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
256
247
|
totalBalanceAsset: string;
|
|
257
|
-
/**
|
|
258
|
-
* Describes whether `tokens` already includes deployed `positions`.
|
|
259
|
-
* Consumers must add matching positions only for `tokens-plus-positions`;
|
|
260
|
-
* doing so for Zyfai would double-count, while omitting it for Yieldseeker
|
|
261
|
-
* makes its balance disappear as soon as idle funds enter a vault.
|
|
262
|
-
*/
|
|
263
|
-
balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
|
|
264
248
|
tokens: OwneyToken[];
|
|
265
249
|
/**
|
|
266
250
|
* Per-protocol/pool positions when the agent's portfolio payload includes
|
|
@@ -275,14 +259,10 @@ interface OwneyBalances {
|
|
|
275
259
|
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
276
260
|
totalBalanceAsset: string;
|
|
277
261
|
agentBalances: Record<AgentId, AgentBalance>;
|
|
278
|
-
/**
|
|
279
|
-
|
|
280
|
-
* partial result. Callers may display the successful balances, but funding
|
|
281
|
-
* operations must not interpret a missing agent as having a zero balance.
|
|
282
|
-
*/
|
|
283
|
-
agentErrors?: Partial<Record<AgentId, string>>;
|
|
262
|
+
/** Omitted agents failed to load; they must not be interpreted as zero. */
|
|
263
|
+
agentErrors?: Record<AgentId, string>;
|
|
284
264
|
/** Absolute provider cooldown deadlines (Unix milliseconds). */
|
|
285
|
-
agentRetryAt?:
|
|
265
|
+
agentRetryAt?: Record<AgentId, number>;
|
|
286
266
|
}
|
|
287
267
|
interface AgentEarnings {
|
|
288
268
|
smartWallet: `0x${string}`;
|
|
@@ -316,12 +296,6 @@ interface OwneyAccountApy {
|
|
|
316
296
|
totalApy: string;
|
|
317
297
|
agentApy: Record<AgentId, AccountAgentApy>;
|
|
318
298
|
apyByChainAndAsset: ApyByChainAndAsset;
|
|
319
|
-
/**
|
|
320
|
-
* Balance-weighted daily APY across the agents that returned a point for each
|
|
321
|
-
* date. The weights use the selected chain/asset balance when getAccountApy
|
|
322
|
-
* is asset-scoped, otherwise each agent's total balance.
|
|
323
|
-
*/
|
|
324
|
-
history?: ApyHistoryPoint[];
|
|
325
299
|
}
|
|
326
300
|
interface AllocationAgentApy {
|
|
327
301
|
/** Account-wide weighted APY for this agent, as a decimal string. */
|
|
@@ -420,15 +394,8 @@ interface IAgent {
|
|
|
420
394
|
readonly id: string;
|
|
421
395
|
readonly supportedChainIds: readonly OwneySupportedChainId[];
|
|
422
396
|
readonly supportedAssets: readonly AgentSupportedAssets[];
|
|
423
|
-
/**
|
|
424
|
-
* Describes how `AgentBalance.tokens` relates to `positions`.
|
|
425
|
-
* Most adapters expose token totals that already include deployed positions.
|
|
426
|
-
* Providers such as Yieldseeker expose idle wallet tokens separately, so
|
|
427
|
-
* withdrawal planning must add matching position amounts.
|
|
428
|
-
*/
|
|
429
|
-
readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
|
|
430
397
|
disconnect(): Promise<void>;
|
|
431
|
-
activateAgent(state: ConnectionState, chainId: number
|
|
398
|
+
activateAgent(state: ConnectionState, chainId: number): Promise<void>;
|
|
432
399
|
/**
|
|
433
400
|
* Apply the organization's agent policy to this user's account.
|
|
434
401
|
*
|
|
@@ -493,8 +460,6 @@ declare class OwneySDK {
|
|
|
493
460
|
private orgAgentConfig;
|
|
494
461
|
private orgAgentConfigPromise;
|
|
495
462
|
private zyfaiRpcUrls?;
|
|
496
|
-
private yieldseekerApiBaseUrl?;
|
|
497
|
-
private yieldseekerSiweOrigin?;
|
|
498
463
|
private routingApiBaseUrl?;
|
|
499
464
|
private referralSource?;
|
|
500
465
|
private cachedSponsoredCallback;
|
|
@@ -585,7 +550,7 @@ declare class OwneySDK {
|
|
|
585
550
|
* If provided, ALL specified agents must support the chainId or the call
|
|
586
551
|
* throws before activating any agent.
|
|
587
552
|
*/
|
|
588
|
-
activateAgent(chainId: number, agentId?: AgentId[]
|
|
553
|
+
activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
|
|
589
554
|
/**
|
|
590
555
|
* Activate agents ONE AT A TIME, each followed by its org policy.
|
|
591
556
|
*
|
|
@@ -600,9 +565,9 @@ declare class OwneySDK {
|
|
|
600
565
|
* at a time anyway.
|
|
601
566
|
*
|
|
602
567
|
* Every agent is attempted even if an earlier one fails, so one declined
|
|
603
|
-
* signature can't deny the remaining agents their turn.
|
|
604
|
-
*
|
|
605
|
-
*
|
|
568
|
+
* signature can't deny the remaining agents their turn. The first failure is
|
|
569
|
+
* rethrown (matching the previous `Promise.all` rejection) once all agents
|
|
570
|
+
* have had a chance to activate.
|
|
606
571
|
*/
|
|
607
572
|
private activateAgentsInTurn;
|
|
608
573
|
/**
|
|
@@ -647,7 +612,6 @@ declare class OwneySDK {
|
|
|
647
612
|
private depositWithFallback;
|
|
648
613
|
private getMinDepositAmount;
|
|
649
614
|
private splitDepositAmount;
|
|
650
|
-
private formatAgentName;
|
|
651
615
|
private validateMinDepositAmount;
|
|
652
616
|
/**
|
|
653
617
|
* Whether the user already holds a non-zero balance with `agent` for the
|
|
@@ -758,93 +722,7 @@ declare class OwneySDK {
|
|
|
758
722
|
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
759
723
|
}
|
|
760
724
|
|
|
761
|
-
type
|
|
762
|
-
origin?: string;
|
|
763
|
-
now?: () => Date;
|
|
764
|
-
nonce?: () => string;
|
|
765
|
-
};
|
|
766
|
-
|
|
767
|
-
type YieldseekerFetch = typeof fetch;
|
|
768
|
-
|
|
769
|
-
type YieldseekerTransaction = {
|
|
770
|
-
from: `0x${string}`;
|
|
771
|
-
to: `0x${string}`;
|
|
772
|
-
data: `0x${string}`;
|
|
773
|
-
value: string;
|
|
774
|
-
chainId: number;
|
|
775
|
-
};
|
|
776
|
-
|
|
777
|
-
type YieldseekerAgentOptions = {
|
|
778
|
-
baseUrl?: string;
|
|
779
|
-
fetchFn?: YieldseekerFetch;
|
|
780
|
-
auth?: YieldseekerAuthDependencies;
|
|
781
|
-
/** Test seam for the wallet-submission/receipt boundary. */
|
|
782
|
-
transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
|
|
783
|
-
/** Test seam for transactions submitted outside transactionExecutor. */
|
|
784
|
-
unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
|
|
785
|
-
};
|
|
786
|
-
declare class YieldseekerAgent implements IAgent {
|
|
787
|
-
readonly id = "yieldseeker";
|
|
788
|
-
readonly balanceComposition: "tokens-plus-positions";
|
|
789
|
-
readonly supportedChainIds: readonly [8453];
|
|
790
|
-
readonly supportedAssets: readonly [{
|
|
791
|
-
readonly chainId: 8453;
|
|
792
|
-
readonly chain: "BASE";
|
|
793
|
-
readonly assets: readonly [{
|
|
794
|
-
readonly symbol: "USDC";
|
|
795
|
-
readonly minDepositAmount: "10000000";
|
|
796
|
-
}, {
|
|
797
|
-
readonly symbol: "WETH";
|
|
798
|
-
readonly minDepositAmount: "1";
|
|
799
|
-
}];
|
|
800
|
-
}];
|
|
801
|
-
private readonly api;
|
|
802
|
-
private readonly auth;
|
|
803
|
-
private readonly transactionExecutor?;
|
|
804
|
-
private readonly unwindReceiptWaiter?;
|
|
805
|
-
private readonly agentContexts;
|
|
806
|
-
private readonly users;
|
|
807
|
-
private readonly pendingAgents;
|
|
808
|
-
constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
|
|
809
|
-
disconnect(): Promise<void>;
|
|
810
|
-
activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
|
|
811
|
-
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
812
|
-
withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
|
|
813
|
-
getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
|
|
814
|
-
getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
|
|
815
|
-
getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
|
|
816
|
-
getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
|
|
817
|
-
getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
|
|
818
|
-
getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
|
|
819
|
-
private userKey;
|
|
820
|
-
private contextKey;
|
|
821
|
-
private resolveUser;
|
|
822
|
-
private forgetUser;
|
|
823
|
-
private ensureAgent;
|
|
824
|
-
private findAgent;
|
|
825
|
-
private resolveAgent;
|
|
826
|
-
private loadPortfolio;
|
|
827
|
-
private loadPortfolioContext;
|
|
828
|
-
private deployAfterFunding;
|
|
829
|
-
private refreshSnapshotAfterMovement;
|
|
830
|
-
private agentPath;
|
|
831
|
-
private walletRequest;
|
|
832
|
-
private providerRequest;
|
|
833
|
-
private mapApiError;
|
|
834
|
-
private submitTransaction;
|
|
835
|
-
private waitForReceipt;
|
|
836
|
-
private assertTransaction;
|
|
837
|
-
private assertAgent;
|
|
838
|
-
private isOwneyAgent;
|
|
839
|
-
private assetForAgent;
|
|
840
|
-
private isTransactionHash;
|
|
841
|
-
private assertChain;
|
|
842
|
-
private assertOptionalChain;
|
|
843
|
-
private assertAsset;
|
|
844
|
-
private invalidResponse;
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "AGENT_ACTIVATION_PARTIAL_FAILURE" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_BALANCE_UNAVAILABLE" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "AGENT_RATE_LIMITED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "AGENT_API_ERROR" | "AGENT_AUTH_FAILED" | "AGENT_INVALID_RESPONSE" | "AGENT_TIMEOUT" | "AGENT_TRANSACTION_REVERTED" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
725
|
+
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "AGENT_RATE_LIMITED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
848
726
|
declare class OwneyError extends Error {
|
|
849
727
|
readonly code: OwneyErrorCode;
|
|
850
728
|
readonly details?: Record<string, unknown>;
|
|
@@ -910,4 +788,4 @@ type OwneySIWXConfig = {
|
|
|
910
788
|
*/
|
|
911
789
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
912
790
|
|
|
913
|
-
export { type AccountAgentApy, type AccountApyOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions,
|
|
791
|
+
export { type AccountAgentApy, type AccountApyOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions, createOwneySIWX, setOwneyDebug };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Hex } from 'viem';
|
|
2
1
|
import { SIWXConfig } from '@reown/appkit-controllers';
|
|
3
2
|
|
|
4
3
|
type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
|
|
@@ -9,10 +8,6 @@ interface OwneySDKConfig {
|
|
|
9
8
|
* Example: { 8453: "https://...", 42161: "https://..." }
|
|
10
9
|
*/
|
|
11
10
|
zyfaiRpcUrls?: ZyfaiRpcUrlsConfig;
|
|
12
|
-
/** Optional Owney Yieldseeker proxy base URL override for integration tests. */
|
|
13
|
-
yieldseekerApiBaseUrl?: string;
|
|
14
|
-
/** Optional SIWE origin override. Defaults to the requesting browser origin. */
|
|
15
|
-
yieldseekerSiweOrigin?: string;
|
|
16
11
|
/**
|
|
17
12
|
* Optional override for the Owney routing API base URL used by all routing
|
|
18
13
|
* calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
|
|
@@ -59,7 +54,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
|
59
54
|
type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
|
|
60
55
|
type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
|
|
61
56
|
|
|
62
|
-
type AgentId = "zyfai"
|
|
57
|
+
type AgentId = "zyfai";
|
|
63
58
|
type Asset = string;
|
|
64
59
|
type AgentSupportedAsset = {
|
|
65
60
|
readonly symbol: string;
|
|
@@ -216,8 +211,6 @@ interface OwneyPosition {
|
|
|
216
211
|
pool?: string;
|
|
217
212
|
asset: string;
|
|
218
213
|
amount: string;
|
|
219
|
-
/** Smallest-unit amount when the provider exposes it alongside `amount`. */
|
|
220
|
-
amountRaw?: string;
|
|
221
214
|
apy?: number;
|
|
222
215
|
tvl?: number;
|
|
223
216
|
/** Pool liquidity. Prepared slot — Zyfai will add this to its portfolio
|
|
@@ -248,19 +241,10 @@ interface OwneyPendingAllocation {
|
|
|
248
241
|
since?: string;
|
|
249
242
|
}
|
|
250
243
|
interface AgentBalance {
|
|
251
|
-
/** Authoritative native balances per asset/network, including idle and invested funds. */
|
|
252
|
-
assetBalances?: OwneyToken[];
|
|
253
244
|
smartWallet?: `0x${string}`;
|
|
254
245
|
totalBalance: string;
|
|
255
246
|
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
256
247
|
totalBalanceAsset: string;
|
|
257
|
-
/**
|
|
258
|
-
* Describes whether `tokens` already includes deployed `positions`.
|
|
259
|
-
* Consumers must add matching positions only for `tokens-plus-positions`;
|
|
260
|
-
* doing so for Zyfai would double-count, while omitting it for Yieldseeker
|
|
261
|
-
* makes its balance disappear as soon as idle funds enter a vault.
|
|
262
|
-
*/
|
|
263
|
-
balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
|
|
264
248
|
tokens: OwneyToken[];
|
|
265
249
|
/**
|
|
266
250
|
* Per-protocol/pool positions when the agent's portfolio payload includes
|
|
@@ -275,14 +259,10 @@ interface OwneyBalances {
|
|
|
275
259
|
/** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
|
|
276
260
|
totalBalanceAsset: string;
|
|
277
261
|
agentBalances: Record<AgentId, AgentBalance>;
|
|
278
|
-
/**
|
|
279
|
-
|
|
280
|
-
* partial result. Callers may display the successful balances, but funding
|
|
281
|
-
* operations must not interpret a missing agent as having a zero balance.
|
|
282
|
-
*/
|
|
283
|
-
agentErrors?: Partial<Record<AgentId, string>>;
|
|
262
|
+
/** Omitted agents failed to load; they must not be interpreted as zero. */
|
|
263
|
+
agentErrors?: Record<AgentId, string>;
|
|
284
264
|
/** Absolute provider cooldown deadlines (Unix milliseconds). */
|
|
285
|
-
agentRetryAt?:
|
|
265
|
+
agentRetryAt?: Record<AgentId, number>;
|
|
286
266
|
}
|
|
287
267
|
interface AgentEarnings {
|
|
288
268
|
smartWallet: `0x${string}`;
|
|
@@ -316,12 +296,6 @@ interface OwneyAccountApy {
|
|
|
316
296
|
totalApy: string;
|
|
317
297
|
agentApy: Record<AgentId, AccountAgentApy>;
|
|
318
298
|
apyByChainAndAsset: ApyByChainAndAsset;
|
|
319
|
-
/**
|
|
320
|
-
* Balance-weighted daily APY across the agents that returned a point for each
|
|
321
|
-
* date. The weights use the selected chain/asset balance when getAccountApy
|
|
322
|
-
* is asset-scoped, otherwise each agent's total balance.
|
|
323
|
-
*/
|
|
324
|
-
history?: ApyHistoryPoint[];
|
|
325
299
|
}
|
|
326
300
|
interface AllocationAgentApy {
|
|
327
301
|
/** Account-wide weighted APY for this agent, as a decimal string. */
|
|
@@ -420,15 +394,8 @@ interface IAgent {
|
|
|
420
394
|
readonly id: string;
|
|
421
395
|
readonly supportedChainIds: readonly OwneySupportedChainId[];
|
|
422
396
|
readonly supportedAssets: readonly AgentSupportedAssets[];
|
|
423
|
-
/**
|
|
424
|
-
* Describes how `AgentBalance.tokens` relates to `positions`.
|
|
425
|
-
* Most adapters expose token totals that already include deployed positions.
|
|
426
|
-
* Providers such as Yieldseeker expose idle wallet tokens separately, so
|
|
427
|
-
* withdrawal planning must add matching position amounts.
|
|
428
|
-
*/
|
|
429
|
-
readonly balanceComposition?: "tokens-include-positions" | "tokens-plus-positions";
|
|
430
397
|
disconnect(): Promise<void>;
|
|
431
|
-
activateAgent(state: ConnectionState, chainId: number
|
|
398
|
+
activateAgent(state: ConnectionState, chainId: number): Promise<void>;
|
|
432
399
|
/**
|
|
433
400
|
* Apply the organization's agent policy to this user's account.
|
|
434
401
|
*
|
|
@@ -493,8 +460,6 @@ declare class OwneySDK {
|
|
|
493
460
|
private orgAgentConfig;
|
|
494
461
|
private orgAgentConfigPromise;
|
|
495
462
|
private zyfaiRpcUrls?;
|
|
496
|
-
private yieldseekerApiBaseUrl?;
|
|
497
|
-
private yieldseekerSiweOrigin?;
|
|
498
463
|
private routingApiBaseUrl?;
|
|
499
464
|
private referralSource?;
|
|
500
465
|
private cachedSponsoredCallback;
|
|
@@ -585,7 +550,7 @@ declare class OwneySDK {
|
|
|
585
550
|
* If provided, ALL specified agents must support the chainId or the call
|
|
586
551
|
* throws before activating any agent.
|
|
587
552
|
*/
|
|
588
|
-
activateAgent(chainId: number, agentId?: AgentId[]
|
|
553
|
+
activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
|
|
589
554
|
/**
|
|
590
555
|
* Activate agents ONE AT A TIME, each followed by its org policy.
|
|
591
556
|
*
|
|
@@ -600,9 +565,9 @@ declare class OwneySDK {
|
|
|
600
565
|
* at a time anyway.
|
|
601
566
|
*
|
|
602
567
|
* Every agent is attempted even if an earlier one fails, so one declined
|
|
603
|
-
* signature can't deny the remaining agents their turn.
|
|
604
|
-
*
|
|
605
|
-
*
|
|
568
|
+
* signature can't deny the remaining agents their turn. The first failure is
|
|
569
|
+
* rethrown (matching the previous `Promise.all` rejection) once all agents
|
|
570
|
+
* have had a chance to activate.
|
|
606
571
|
*/
|
|
607
572
|
private activateAgentsInTurn;
|
|
608
573
|
/**
|
|
@@ -647,7 +612,6 @@ declare class OwneySDK {
|
|
|
647
612
|
private depositWithFallback;
|
|
648
613
|
private getMinDepositAmount;
|
|
649
614
|
private splitDepositAmount;
|
|
650
|
-
private formatAgentName;
|
|
651
615
|
private validateMinDepositAmount;
|
|
652
616
|
/**
|
|
653
617
|
* Whether the user already holds a non-zero balance with `agent` for the
|
|
@@ -758,93 +722,7 @@ declare class OwneySDK {
|
|
|
758
722
|
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
759
723
|
}
|
|
760
724
|
|
|
761
|
-
type
|
|
762
|
-
origin?: string;
|
|
763
|
-
now?: () => Date;
|
|
764
|
-
nonce?: () => string;
|
|
765
|
-
};
|
|
766
|
-
|
|
767
|
-
type YieldseekerFetch = typeof fetch;
|
|
768
|
-
|
|
769
|
-
type YieldseekerTransaction = {
|
|
770
|
-
from: `0x${string}`;
|
|
771
|
-
to: `0x${string}`;
|
|
772
|
-
data: `0x${string}`;
|
|
773
|
-
value: string;
|
|
774
|
-
chainId: number;
|
|
775
|
-
};
|
|
776
|
-
|
|
777
|
-
type YieldseekerAgentOptions = {
|
|
778
|
-
baseUrl?: string;
|
|
779
|
-
fetchFn?: YieldseekerFetch;
|
|
780
|
-
auth?: YieldseekerAuthDependencies;
|
|
781
|
-
/** Test seam for the wallet-submission/receipt boundary. */
|
|
782
|
-
transactionExecutor?: (state: ConnectionState, chainId: number, transaction: YieldseekerTransaction) => Promise<Hex>;
|
|
783
|
-
/** Test seam for transactions submitted outside transactionExecutor. */
|
|
784
|
-
unwindReceiptWaiter?: (state: ConnectionState, chainId: number, transactionHash: Hex) => Promise<void>;
|
|
785
|
-
};
|
|
786
|
-
declare class YieldseekerAgent implements IAgent {
|
|
787
|
-
readonly id = "yieldseeker";
|
|
788
|
-
readonly balanceComposition: "tokens-plus-positions";
|
|
789
|
-
readonly supportedChainIds: readonly [8453];
|
|
790
|
-
readonly supportedAssets: readonly [{
|
|
791
|
-
readonly chainId: 8453;
|
|
792
|
-
readonly chain: "BASE";
|
|
793
|
-
readonly assets: readonly [{
|
|
794
|
-
readonly symbol: "USDC";
|
|
795
|
-
readonly minDepositAmount: "10000000";
|
|
796
|
-
}, {
|
|
797
|
-
readonly symbol: "WETH";
|
|
798
|
-
readonly minDepositAmount: "1";
|
|
799
|
-
}];
|
|
800
|
-
}];
|
|
801
|
-
private readonly api;
|
|
802
|
-
private readonly auth;
|
|
803
|
-
private readonly transactionExecutor?;
|
|
804
|
-
private readonly unwindReceiptWaiter?;
|
|
805
|
-
private readonly agentContexts;
|
|
806
|
-
private readonly users;
|
|
807
|
-
private readonly pendingAgents;
|
|
808
|
-
constructor(owneyApiKey: string, options?: YieldseekerAgentOptions);
|
|
809
|
-
disconnect(): Promise<void>;
|
|
810
|
-
activateAgent(state: ConnectionState, chainId: number, asset?: OwneySupportedTokens): Promise<void>;
|
|
811
|
-
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
812
|
-
withdraw(state: ConnectionState, chainId: number, asset: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
|
|
813
|
-
getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
|
|
814
|
-
getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
|
|
815
|
-
getAccountApy(state: ConnectionState, chainId: number, days: DailyApyDays, tokenSymbol?: string): Promise<AccountAgentApy>;
|
|
816
|
-
getHistory(state: ConnectionState, chainId: number, options?: HistoryFilters): Promise<OwneyAgentHistory>;
|
|
817
|
-
getUserProfile(state: ConnectionState, chainId: number): Promise<AgentUserProfile>;
|
|
818
|
-
getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
|
|
819
|
-
private userKey;
|
|
820
|
-
private contextKey;
|
|
821
|
-
private resolveUser;
|
|
822
|
-
private forgetUser;
|
|
823
|
-
private ensureAgent;
|
|
824
|
-
private findAgent;
|
|
825
|
-
private resolveAgent;
|
|
826
|
-
private loadPortfolio;
|
|
827
|
-
private loadPortfolioContext;
|
|
828
|
-
private deployAfterFunding;
|
|
829
|
-
private refreshSnapshotAfterMovement;
|
|
830
|
-
private agentPath;
|
|
831
|
-
private walletRequest;
|
|
832
|
-
private providerRequest;
|
|
833
|
-
private mapApiError;
|
|
834
|
-
private submitTransaction;
|
|
835
|
-
private waitForReceipt;
|
|
836
|
-
private assertTransaction;
|
|
837
|
-
private assertAgent;
|
|
838
|
-
private isOwneyAgent;
|
|
839
|
-
private assetForAgent;
|
|
840
|
-
private isTransactionHash;
|
|
841
|
-
private assertChain;
|
|
842
|
-
private assertOptionalChain;
|
|
843
|
-
private assertAsset;
|
|
844
|
-
private invalidResponse;
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "AGENT_ACTIVATION_PARTIAL_FAILURE" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_BALANCE_UNAVAILABLE" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "AGENT_RATE_LIMITED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "AGENT_API_ERROR" | "AGENT_AUTH_FAILED" | "AGENT_INVALID_RESPONSE" | "AGENT_TIMEOUT" | "AGENT_TRANSACTION_REVERTED" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
725
|
+
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "AGENT_RATE_LIMITED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
848
726
|
declare class OwneyError extends Error {
|
|
849
727
|
readonly code: OwneyErrorCode;
|
|
850
728
|
readonly details?: Record<string, unknown>;
|
|
@@ -910,4 +788,4 @@ type OwneySIWXConfig = {
|
|
|
910
788
|
*/
|
|
911
789
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
912
790
|
|
|
913
|
-
export { type AccountAgentApy, type AccountApyOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions,
|
|
791
|
+
export { type AccountAgentApy, type AccountApyOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions, createOwneySIWX, setOwneyDebug };
|