@owney/sdk 0.8.0-beta.1 → 0.8.1

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/dist/index.d.cts CHANGED
@@ -247,8 +247,32 @@ type SwapQuoteParams = {
247
247
  };
248
248
 
249
249
  type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
250
+ /**
251
+ * Where an agent keeps its login session (for Zyfai: the JWT plus the flags
252
+ * it caches). The value is opaque JSON owned by the agent; the agent validates
253
+ * it on read. Default is the browser's localStorage; a server passes its own
254
+ * store (database, cache) so one login survives across requests and replicas.
255
+ */
256
+ interface AgentSessionStore {
257
+ read(agentId: string, address: string): Promise<unknown | null> | unknown | null;
258
+ write(agentId: string, address: string, session: unknown): Promise<void> | void;
259
+ clear(agentId: string, address: string): Promise<void> | void;
260
+ }
250
261
  interface OwneySDKConfig {
251
262
  apiKey: string;
263
+ /**
264
+ * Optional persistence for agent authentication sessions.
265
+ *
266
+ * When omitted, browser integrations use the default localStorage store.
267
+ * On the server the default store is a no-op, so every `connect` signs in
268
+ * again unless a store is provided.
269
+ *
270
+ * Stored values may contain bearer tokens and must be treated as secrets.
271
+ * Server implementations should bind each store instance to a trusted
272
+ * application user/session, encrypt values, apply a TTL, and never use a
273
+ * caller-provided wallet address as the sole authorization boundary.
274
+ */
275
+ sessionStore?: AgentSessionStore;
252
276
  /**
253
277
  * Optional per-chain RPC overrides for Zyfai SDK network calls.
254
278
  * Example: { 8453: "https://...", 42161: "https://..." }
@@ -302,7 +326,7 @@ interface ConnectionState {
302
326
  walletAddress: `0x${string}`;
303
327
  chainId: number | null;
304
328
  }
305
- declare const SUPPORTED_TOKENS: readonly ["USDC", "WETH", "EURC", "USDT"];
329
+ declare const SUPPORTED_TOKENS: readonly ["USDC", "WETH"];
306
330
  declare const SUPPORTED_CHAIN_IDS: readonly [8453, 42161, 1];
307
331
  declare const SUPPORTED_CHAINS: readonly ["BASE", "ARBITRUM", "ETHEREUM"];
308
332
  type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
@@ -556,7 +580,7 @@ type AvailablePool = {
556
580
  type PoolSelectionStrategy = "aggressive" | "yieldmaxxing";
557
581
  /** One asset's explicit choice for a protocol on one chain. */
558
582
  type UserPoolSelection = {
559
- asset: OwneySupportedTokens;
583
+ asset: "USDC" | "WETH";
560
584
  protocolId: string;
561
585
  chainId: number;
562
586
  /** Names enabled by the user for this asset/protocol/chain. */
@@ -567,7 +591,7 @@ type UserPoolSelection = {
567
591
  /** The complete saved draft for the asset/chain legs selected in the deposit. */
568
592
  type UserPoolSelectionRequest = {
569
593
  strategies: Array<{
570
- asset: OwneySupportedTokens;
594
+ asset: "USDC" | "WETH";
571
595
  strategy: PoolSelectionStrategy;
572
596
  }>;
573
597
  selections: UserPoolSelection[];
@@ -579,7 +603,7 @@ type UserPoolSelectionRequest = {
579
603
  */
580
604
  type SavedPoolSelection = {
581
605
  strategies: Array<{
582
- asset: OwneySupportedTokens;
606
+ asset: "USDC" | "WETH";
583
607
  strategy: string;
584
608
  }>;
585
609
  pairs: Array<{
@@ -802,7 +826,11 @@ interface OwneyAllocationApy {
802
826
  apyByChainAndAsset: ApyByChainAndAsset;
803
827
  agentApy: Record<AgentId, AllocationAgentApy>;
804
828
  }
805
- type HistoryAction = "Rebalance" | "Deposit" | "Top up" | "Withdraw" | "Earned";
829
+ type HistoryAction = "Rebalance"
830
+ /** Funds moving from the smart wallet into a pool (ROUT-758: was "Deposit"). */
831
+ | "Allocate"
832
+ /** Funds arriving from the user's wallet (ROUT-758: was "Top up"). */
833
+ | "Deposit" | "Withdraw" | "Earned";
806
834
  interface HistoryTransaction {
807
835
  txHashes: string[];
808
836
  chainId?: number;
@@ -977,7 +1005,7 @@ interface IAgent {
977
1005
  protocolId: string;
978
1006
  chainId: number;
979
1007
  }>;
980
- assets: Array<OwneySupportedTokens>;
1008
+ assets: Array<"USDC" | "WETH">;
981
1009
  }): Promise<SavedPoolSelection>;
982
1010
  deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
983
1011
  withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
@@ -1015,7 +1043,7 @@ interface IAgent {
1015
1043
  * backend models per-asset protocol selection implement it. Returns whether
1016
1044
  * a write occurred (`false` = already enabled / not supported).
1017
1045
  */
1018
- ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<boolean>;
1046
+ ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
1019
1047
  getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
1020
1048
  }
1021
1049
  /**
@@ -1196,8 +1224,9 @@ declare class OwneySDK {
1196
1224
  private userPoolCustomization;
1197
1225
  private routingApiBaseUrl?;
1198
1226
  private referralSource?;
1199
- private cachedSponsoredCallbacks;
1200
- private cachedPermit2SponsoredCallbacks;
1227
+ private sessionStore?;
1228
+ private cachedSponsoredCallback;
1229
+ private cachedWethSponsoredCallback;
1201
1230
  private paymasterServiceUrl?;
1202
1231
  private cachedSponsoredCallsCallbacks;
1203
1232
  private readonly agentReads;
@@ -1238,18 +1267,19 @@ declare class OwneySDK {
1238
1267
  */
1239
1268
  private getDefaultSponsoredCallback;
1240
1269
  /**
1241
- * Lazily builds (and caches, per asset) the default paymaster-sponsored
1242
- * deposit callback used when the caller omits `depositCallback` and a
1243
- * `paymasterServiceUrl` is configured. One rail serves every asset.
1270
+ * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
1271
+ * callback used when the caller omits `depositCallback` for a WETH
1272
+ * deposit. Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
1273
+ * `PermitTransferFrom` instead of an EIP-3009 authorization.
1244
1274
  */
1245
1275
  private getDefaultSponsoredCallsCallback;
1246
1276
  /**
1247
- * Lazily builds (and caches, per asset) the default Permit2 sponsored
1248
- * deposit callback used when the caller omits `depositCallback` for a
1249
- * Permit2 asset (WETH, USDT). Mirrors `getDefaultSponsoredCallback()` but
1250
- * signs a Permit2 `PermitTransferFrom` instead of an EIP-3009 authorization.
1277
+ * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
1278
+ * callback used when the caller omits `depositCallback` for a WETH deposit.
1279
+ * Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
1280
+ * `PermitTransferFrom` instead of an EIP-3009 authorization.
1251
1281
  */
1252
- private getDefaultPermit2SponsoredCallback;
1282
+ private getDefaultWethSponsoredCallback;
1253
1283
  private getAgent;
1254
1284
  private getActiveAgents;
1255
1285
  /**
@@ -1324,16 +1354,15 @@ declare class OwneySDK {
1324
1354
  *
1325
1355
  * 1. Missing Permit2 allowance: when the app did not supply its own
1326
1356
  * callback and the attempt fails with `PERMIT2_APPROVAL_REQUIRED` on a
1327
- * Permit2 asset (WETH, USDT), this is the wallet's first gasless deposit
1328
- * of that asset on this chain. We send the one-time (user-paid) Permit2
1329
- * approval via `approvePermit2(asset)` and retry the SAME sponsored
1330
- * attempt once. Bounded to one approval attempt per call so a
1331
- * wallet/agent that keeps reporting the allowance as missing can't loop
1332
- * forever. If `approvePermit2()` itself throws (e.g.
1357
+ * WETH deposit, this is the wallet's first gasless WETH deposit. We send
1358
+ * the one-time (user-paid) Permit2 approval via `approvePermit2()` and
1359
+ * retry the SAME sponsored attempt once. Bounded to one approval attempt
1360
+ * per call so a wallet/agent that keeps reporting the allowance as
1361
+ * missing can't loop forever. If `approvePermit2()` itself throws (e.g.
1333
1362
  * the user rejects the wallet prompt), that error propagates as-is —
1334
1363
  * the user said no to a transaction, so we must not turn around and ask
1335
1364
  * them to pay for a different one via the fallback below.
1336
- * 2. `shouldFallbackToUserPaid`: the SDK's own sponsor path failed at
1365
+ * 2. `shouldFallbackToUserPaid`: the SDK's own WETH sponsor path failed at
1337
1366
  * the infrastructure layer in a provably safe-to-retry way, so we warn
1338
1367
  * and retry once with `undefined`, falling through to a user-paid
1339
1368
  * native deposit. This still applies after a successful Permit2
@@ -1440,26 +1469,23 @@ declare class OwneySDK {
1440
1469
  * figure directly. It is the entire arrival, so there is no slack: anything
1441
1470
  * that spends the target asset between the two fails the deposit outright.
1442
1471
  *
1443
- * Something does. A first deposit of a Permit2 asset (WETH, USDT) needs a
1444
- * one-time Permit2 approval, and that approval is a transaction. For WETH,
1445
- * a wallet holding no native gas token - the normal state of someone who
1446
- * just swapped everything INTO WETH - pays for it out of the WETH. The
1447
- * deposit then asked for ~2e12 wei more than was left and refused with
1448
- * DEPOSIT_INSUFFICIENT_BALANCE, under a wrapper saying the funds were safe
1449
- * but unadded (ROUT-242). For USDT the gas cannot come out of the token, so
1450
- * this step only adds the one-time approval and the read changes nothing.
1472
+ * Something does. A first WETH deposit needs a one-time Permit2 approval,
1473
+ * and that approval is a transaction. A wallet holding no native gas token -
1474
+ * the normal state of someone who just swapped everything INTO WETH - pays
1475
+ * for it out of the WETH. The deposit then asked for ~2e12 wei more than was
1476
+ * left and refused with DEPOSIT_INSUFFICIENT_BALANCE, under a wrapper saying
1477
+ * the funds were safe but unadded (ROUT-242).
1451
1478
  *
1452
1479
  * So the approval happens here, before the amount is settled, and the amount
1453
1480
  * comes from a read taken after it. Two things this deliberately is not:
1454
1481
  *
1455
1482
  * - It is not a balance sweep. `received` is a DELTA over the pre-swap
1456
- * balance, so a wallet already holding the asset reads far above it;
1457
- * depositing the balance would move funds the user never offered. The
1458
- * arrival is the ceiling and the balance is only ever allowed to lower it.
1459
- * - It does not touch USDC or EURC, which move on signed typed data
1460
- * (EIP-3009) and so spend nothing of the user's in between, nor a
1461
- * paymaster-configured client, where the sponsor covers the transfer and
1462
- * Permit2 never applies.
1483
+ * balance, so a wallet already holding WETH reads far above it; depositing
1484
+ * the balance would move funds the user never offered. The arrival is the
1485
+ * ceiling and the balance is only ever allowed to lower it.
1486
+ * - It does not touch USDC, which moves on signed typed data and so spends
1487
+ * nothing of the user's in between, nor a paymaster-configured client,
1488
+ * where the sponsor covers the transfer and Permit2 never applies.
1463
1489
  */
1464
1490
  private settleSwapDepositAmount;
1465
1491
  /**
@@ -1861,7 +1887,7 @@ declare class OwneySDK {
1861
1887
  protocolId: string;
1862
1888
  chainId: number;
1863
1889
  }>;
1864
- assets: Array<OwneySupportedTokens>;
1890
+ assets: Array<"USDC" | "WETH">;
1865
1891
  agentId?: AgentId;
1866
1892
  }): Promise<SavedPoolSelection>;
1867
1893
  getAccountApy({ agentId, days, tokenSymbol, chainId: scope, }: AccountApyOptions): Promise<OwneyAccountApy | AccountAgentApy>;
@@ -1893,26 +1919,20 @@ declare class OwneySDK {
1893
1919
  /**
1894
1920
  * Ensure the given asset uses backend protocol auto-selection for the active
1895
1921
  * chain's account. No-op (returns false) for agents that don't support it.
1896
- * @param asset - Asset symbol (e.g. "USDC").
1922
+ * @param asset - "USDC" or "WETH".
1897
1923
  * @param agentId - Agent to target. Defaults to "zyfai".
1898
1924
  * @returns whether a profile write occurred.
1899
1925
  */
1900
- ensureAutoSelectProtocols(asset: OwneySupportedTokens, agentId?: AgentId): Promise<boolean>;
1926
+ ensureAutoSelectProtocols(asset: "USDC" | "WETH", agentId?: AgentId): Promise<boolean>;
1901
1927
  /**
1902
- * One-time, user-paid approval of Permit2 on the sponsored WETH (default) or
1903
- * USDT token for the active chain. Required once per wallet per chain before
1904
- * gasless deposits of that asset; afterwards deposit() is signature-only.
1905
- * Resolves only after the approval transaction is mined (1 confirmation), so
1906
- * a subsequent deposit() will see the new allowance; throws if the
1907
- * transaction reverted.
1908
- *
1909
- * On mainnet USDT only (`needsAllowanceReset`), a non-zero existing allowance
1910
- * is first zeroed in its own transaction. If the user rejects the second
1911
- * prompt, the previous Permit2 allowance stays zeroed; calling this again
1912
- * approves from zero in a single transaction.
1928
+ * One-time, user-paid approval of Permit2 on the sponsored WETH token for
1929
+ * the active chain. Required once per wallet per chain before gasless WETH
1930
+ * deposits; afterwards deposit() is signature-only. Resolves only after the
1931
+ * approval transaction is mined (1 confirmation), so a subsequent deposit()
1932
+ * will see the new allowance; throws if the transaction reverted.
1913
1933
  * @returns the approval transaction hash.
1914
1934
  */
1915
- approvePermit2(asset?: "WETH" | "USDT"): Promise<`0x${string}`>;
1935
+ approvePermit2(asset?: "WETH"): Promise<`0x${string}`>;
1916
1936
  /**
1917
1937
  * Get the agent's average APY performance over a time period. Does not require a wallet connection.
1918
1938
  * @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")
@@ -1978,16 +1998,17 @@ type OwneySIWXConfig = {
1978
1998
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
1979
1999
 
1980
2000
  /**
1981
- * Ask the wallet ITSELF to switch networks, over WalletConnect.
2001
+ * Align a supported WalletConnect session with `chainId`.
1982
2002
  *
1983
2003
  * WalletConnect's provider answers `wallet_switchEthereumChain` locally when
1984
2004
  * the chain was approved at connect time: it moves its own default chain and
1985
2005
  * reports success without telling the wallet. MetaMask mobile then stays on
1986
2006
  * its network, keeps reporting it, and every guard downstream fails with
1987
2007
  * CHAIN_MISMATCH — after a swap, with the user's funds already moved (ROUT-727).
1988
- * Sending the request through the session client reaches the wallet, which
1989
- * shows a real "switch network" prompt; the client also deep-links the wallet
1990
- * app open on mobile.
2008
+ * Sending the request through the session client reaches MetaMask, which shows
2009
+ * a real "switch network" prompt. Fireblocks instead uses the approved
2010
+ * multi-chain session's local default; its subsequent signature request is
2011
+ * explicitly scoped to that chain and needs no separate network prompt.
1991
2012
  *
1992
2013
  * Returns false when `provider` is not a WalletConnect session, so the caller
1993
2014
  * can fall back to an ordinary switch.
@@ -2030,4 +2051,4 @@ type StoredOrder = {
2030
2051
  */
2031
2052
  declare function listOrders(now?: number): StoredOrder[];
2032
2053
 
2033
- 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 ApyIncentive, 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 };
2054
+ 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 AgentSessionStore, 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 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 };
package/dist/index.d.ts CHANGED
@@ -247,8 +247,32 @@ type SwapQuoteParams = {
247
247
  };
248
248
 
249
249
  type ZyfaiRpcUrlsConfig = Partial<Record<(typeof SUPPORTED_CHAIN_IDS)[number], string>>;
250
+ /**
251
+ * Where an agent keeps its login session (for Zyfai: the JWT plus the flags
252
+ * it caches). The value is opaque JSON owned by the agent; the agent validates
253
+ * it on read. Default is the browser's localStorage; a server passes its own
254
+ * store (database, cache) so one login survives across requests and replicas.
255
+ */
256
+ interface AgentSessionStore {
257
+ read(agentId: string, address: string): Promise<unknown | null> | unknown | null;
258
+ write(agentId: string, address: string, session: unknown): Promise<void> | void;
259
+ clear(agentId: string, address: string): Promise<void> | void;
260
+ }
250
261
  interface OwneySDKConfig {
251
262
  apiKey: string;
263
+ /**
264
+ * Optional persistence for agent authentication sessions.
265
+ *
266
+ * When omitted, browser integrations use the default localStorage store.
267
+ * On the server the default store is a no-op, so every `connect` signs in
268
+ * again unless a store is provided.
269
+ *
270
+ * Stored values may contain bearer tokens and must be treated as secrets.
271
+ * Server implementations should bind each store instance to a trusted
272
+ * application user/session, encrypt values, apply a TTL, and never use a
273
+ * caller-provided wallet address as the sole authorization boundary.
274
+ */
275
+ sessionStore?: AgentSessionStore;
252
276
  /**
253
277
  * Optional per-chain RPC overrides for Zyfai SDK network calls.
254
278
  * Example: { 8453: "https://...", 42161: "https://..." }
@@ -302,7 +326,7 @@ interface ConnectionState {
302
326
  walletAddress: `0x${string}`;
303
327
  chainId: number | null;
304
328
  }
305
- declare const SUPPORTED_TOKENS: readonly ["USDC", "WETH", "EURC", "USDT"];
329
+ declare const SUPPORTED_TOKENS: readonly ["USDC", "WETH"];
306
330
  declare const SUPPORTED_CHAIN_IDS: readonly [8453, 42161, 1];
307
331
  declare const SUPPORTED_CHAINS: readonly ["BASE", "ARBITRUM", "ETHEREUM"];
308
332
  type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
@@ -556,7 +580,7 @@ type AvailablePool = {
556
580
  type PoolSelectionStrategy = "aggressive" | "yieldmaxxing";
557
581
  /** One asset's explicit choice for a protocol on one chain. */
558
582
  type UserPoolSelection = {
559
- asset: OwneySupportedTokens;
583
+ asset: "USDC" | "WETH";
560
584
  protocolId: string;
561
585
  chainId: number;
562
586
  /** Names enabled by the user for this asset/protocol/chain. */
@@ -567,7 +591,7 @@ type UserPoolSelection = {
567
591
  /** The complete saved draft for the asset/chain legs selected in the deposit. */
568
592
  type UserPoolSelectionRequest = {
569
593
  strategies: Array<{
570
- asset: OwneySupportedTokens;
594
+ asset: "USDC" | "WETH";
571
595
  strategy: PoolSelectionStrategy;
572
596
  }>;
573
597
  selections: UserPoolSelection[];
@@ -579,7 +603,7 @@ type UserPoolSelectionRequest = {
579
603
  */
580
604
  type SavedPoolSelection = {
581
605
  strategies: Array<{
582
- asset: OwneySupportedTokens;
606
+ asset: "USDC" | "WETH";
583
607
  strategy: string;
584
608
  }>;
585
609
  pairs: Array<{
@@ -802,7 +826,11 @@ interface OwneyAllocationApy {
802
826
  apyByChainAndAsset: ApyByChainAndAsset;
803
827
  agentApy: Record<AgentId, AllocationAgentApy>;
804
828
  }
805
- type HistoryAction = "Rebalance" | "Deposit" | "Top up" | "Withdraw" | "Earned";
829
+ type HistoryAction = "Rebalance"
830
+ /** Funds moving from the smart wallet into a pool (ROUT-758: was "Deposit"). */
831
+ | "Allocate"
832
+ /** Funds arriving from the user's wallet (ROUT-758: was "Top up"). */
833
+ | "Deposit" | "Withdraw" | "Earned";
806
834
  interface HistoryTransaction {
807
835
  txHashes: string[];
808
836
  chainId?: number;
@@ -977,7 +1005,7 @@ interface IAgent {
977
1005
  protocolId: string;
978
1006
  chainId: number;
979
1007
  }>;
980
- assets: Array<OwneySupportedTokens>;
1008
+ assets: Array<"USDC" | "WETH">;
981
1009
  }): Promise<SavedPoolSelection>;
982
1010
  deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
983
1011
  withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
@@ -1015,7 +1043,7 @@ interface IAgent {
1015
1043
  * backend models per-asset protocol selection implement it. Returns whether
1016
1044
  * a write occurred (`false` = already enabled / not supported).
1017
1045
  */
1018
- ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: OwneySupportedTokens): Promise<boolean>;
1046
+ ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
1019
1047
  getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
1020
1048
  }
1021
1049
  /**
@@ -1196,8 +1224,9 @@ declare class OwneySDK {
1196
1224
  private userPoolCustomization;
1197
1225
  private routingApiBaseUrl?;
1198
1226
  private referralSource?;
1199
- private cachedSponsoredCallbacks;
1200
- private cachedPermit2SponsoredCallbacks;
1227
+ private sessionStore?;
1228
+ private cachedSponsoredCallback;
1229
+ private cachedWethSponsoredCallback;
1201
1230
  private paymasterServiceUrl?;
1202
1231
  private cachedSponsoredCallsCallbacks;
1203
1232
  private readonly agentReads;
@@ -1238,18 +1267,19 @@ declare class OwneySDK {
1238
1267
  */
1239
1268
  private getDefaultSponsoredCallback;
1240
1269
  /**
1241
- * Lazily builds (and caches, per asset) the default paymaster-sponsored
1242
- * deposit callback used when the caller omits `depositCallback` and a
1243
- * `paymasterServiceUrl` is configured. One rail serves every asset.
1270
+ * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
1271
+ * callback used when the caller omits `depositCallback` for a WETH
1272
+ * deposit. Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
1273
+ * `PermitTransferFrom` instead of an EIP-3009 authorization.
1244
1274
  */
1245
1275
  private getDefaultSponsoredCallsCallback;
1246
1276
  /**
1247
- * Lazily builds (and caches, per asset) the default Permit2 sponsored
1248
- * deposit callback used when the caller omits `depositCallback` for a
1249
- * Permit2 asset (WETH, USDT). Mirrors `getDefaultSponsoredCallback()` but
1250
- * signs a Permit2 `PermitTransferFrom` instead of an EIP-3009 authorization.
1277
+ * Lazily builds (and caches) the default Permit2 sponsored WETH deposit
1278
+ * callback used when the caller omits `depositCallback` for a WETH deposit.
1279
+ * Mirrors `getDefaultSponsoredCallback()` but signs a Permit2
1280
+ * `PermitTransferFrom` instead of an EIP-3009 authorization.
1251
1281
  */
1252
- private getDefaultPermit2SponsoredCallback;
1282
+ private getDefaultWethSponsoredCallback;
1253
1283
  private getAgent;
1254
1284
  private getActiveAgents;
1255
1285
  /**
@@ -1324,16 +1354,15 @@ declare class OwneySDK {
1324
1354
  *
1325
1355
  * 1. Missing Permit2 allowance: when the app did not supply its own
1326
1356
  * callback and the attempt fails with `PERMIT2_APPROVAL_REQUIRED` on a
1327
- * Permit2 asset (WETH, USDT), this is the wallet's first gasless deposit
1328
- * of that asset on this chain. We send the one-time (user-paid) Permit2
1329
- * approval via `approvePermit2(asset)` and retry the SAME sponsored
1330
- * attempt once. Bounded to one approval attempt per call so a
1331
- * wallet/agent that keeps reporting the allowance as missing can't loop
1332
- * forever. If `approvePermit2()` itself throws (e.g.
1357
+ * WETH deposit, this is the wallet's first gasless WETH deposit. We send
1358
+ * the one-time (user-paid) Permit2 approval via `approvePermit2()` and
1359
+ * retry the SAME sponsored attempt once. Bounded to one approval attempt
1360
+ * per call so a wallet/agent that keeps reporting the allowance as
1361
+ * missing can't loop forever. If `approvePermit2()` itself throws (e.g.
1333
1362
  * the user rejects the wallet prompt), that error propagates as-is —
1334
1363
  * the user said no to a transaction, so we must not turn around and ask
1335
1364
  * them to pay for a different one via the fallback below.
1336
- * 2. `shouldFallbackToUserPaid`: the SDK's own sponsor path failed at
1365
+ * 2. `shouldFallbackToUserPaid`: the SDK's own WETH sponsor path failed at
1337
1366
  * the infrastructure layer in a provably safe-to-retry way, so we warn
1338
1367
  * and retry once with `undefined`, falling through to a user-paid
1339
1368
  * native deposit. This still applies after a successful Permit2
@@ -1440,26 +1469,23 @@ declare class OwneySDK {
1440
1469
  * figure directly. It is the entire arrival, so there is no slack: anything
1441
1470
  * that spends the target asset between the two fails the deposit outright.
1442
1471
  *
1443
- * Something does. A first deposit of a Permit2 asset (WETH, USDT) needs a
1444
- * one-time Permit2 approval, and that approval is a transaction. For WETH,
1445
- * a wallet holding no native gas token - the normal state of someone who
1446
- * just swapped everything INTO WETH - pays for it out of the WETH. The
1447
- * deposit then asked for ~2e12 wei more than was left and refused with
1448
- * DEPOSIT_INSUFFICIENT_BALANCE, under a wrapper saying the funds were safe
1449
- * but unadded (ROUT-242). For USDT the gas cannot come out of the token, so
1450
- * this step only adds the one-time approval and the read changes nothing.
1472
+ * Something does. A first WETH deposit needs a one-time Permit2 approval,
1473
+ * and that approval is a transaction. A wallet holding no native gas token -
1474
+ * the normal state of someone who just swapped everything INTO WETH - pays
1475
+ * for it out of the WETH. The deposit then asked for ~2e12 wei more than was
1476
+ * left and refused with DEPOSIT_INSUFFICIENT_BALANCE, under a wrapper saying
1477
+ * the funds were safe but unadded (ROUT-242).
1451
1478
  *
1452
1479
  * So the approval happens here, before the amount is settled, and the amount
1453
1480
  * comes from a read taken after it. Two things this deliberately is not:
1454
1481
  *
1455
1482
  * - It is not a balance sweep. `received` is a DELTA over the pre-swap
1456
- * balance, so a wallet already holding the asset reads far above it;
1457
- * depositing the balance would move funds the user never offered. The
1458
- * arrival is the ceiling and the balance is only ever allowed to lower it.
1459
- * - It does not touch USDC or EURC, which move on signed typed data
1460
- * (EIP-3009) and so spend nothing of the user's in between, nor a
1461
- * paymaster-configured client, where the sponsor covers the transfer and
1462
- * Permit2 never applies.
1483
+ * balance, so a wallet already holding WETH reads far above it; depositing
1484
+ * the balance would move funds the user never offered. The arrival is the
1485
+ * ceiling and the balance is only ever allowed to lower it.
1486
+ * - It does not touch USDC, which moves on signed typed data and so spends
1487
+ * nothing of the user's in between, nor a paymaster-configured client,
1488
+ * where the sponsor covers the transfer and Permit2 never applies.
1463
1489
  */
1464
1490
  private settleSwapDepositAmount;
1465
1491
  /**
@@ -1861,7 +1887,7 @@ declare class OwneySDK {
1861
1887
  protocolId: string;
1862
1888
  chainId: number;
1863
1889
  }>;
1864
- assets: Array<OwneySupportedTokens>;
1890
+ assets: Array<"USDC" | "WETH">;
1865
1891
  agentId?: AgentId;
1866
1892
  }): Promise<SavedPoolSelection>;
1867
1893
  getAccountApy({ agentId, days, tokenSymbol, chainId: scope, }: AccountApyOptions): Promise<OwneyAccountApy | AccountAgentApy>;
@@ -1893,26 +1919,20 @@ declare class OwneySDK {
1893
1919
  /**
1894
1920
  * Ensure the given asset uses backend protocol auto-selection for the active
1895
1921
  * chain's account. No-op (returns false) for agents that don't support it.
1896
- * @param asset - Asset symbol (e.g. "USDC").
1922
+ * @param asset - "USDC" or "WETH".
1897
1923
  * @param agentId - Agent to target. Defaults to "zyfai".
1898
1924
  * @returns whether a profile write occurred.
1899
1925
  */
1900
- ensureAutoSelectProtocols(asset: OwneySupportedTokens, agentId?: AgentId): Promise<boolean>;
1926
+ ensureAutoSelectProtocols(asset: "USDC" | "WETH", agentId?: AgentId): Promise<boolean>;
1901
1927
  /**
1902
- * One-time, user-paid approval of Permit2 on the sponsored WETH (default) or
1903
- * USDT token for the active chain. Required once per wallet per chain before
1904
- * gasless deposits of that asset; afterwards deposit() is signature-only.
1905
- * Resolves only after the approval transaction is mined (1 confirmation), so
1906
- * a subsequent deposit() will see the new allowance; throws if the
1907
- * transaction reverted.
1908
- *
1909
- * On mainnet USDT only (`needsAllowanceReset`), a non-zero existing allowance
1910
- * is first zeroed in its own transaction. If the user rejects the second
1911
- * prompt, the previous Permit2 allowance stays zeroed; calling this again
1912
- * approves from zero in a single transaction.
1928
+ * One-time, user-paid approval of Permit2 on the sponsored WETH token for
1929
+ * the active chain. Required once per wallet per chain before gasless WETH
1930
+ * deposits; afterwards deposit() is signature-only. Resolves only after the
1931
+ * approval transaction is mined (1 confirmation), so a subsequent deposit()
1932
+ * will see the new allowance; throws if the transaction reverted.
1913
1933
  * @returns the approval transaction hash.
1914
1934
  */
1915
- approvePermit2(asset?: "WETH" | "USDT"): Promise<`0x${string}`>;
1935
+ approvePermit2(asset?: "WETH"): Promise<`0x${string}`>;
1916
1936
  /**
1917
1937
  * Get the agent's average APY performance over a time period. Does not require a wallet connection.
1918
1938
  * @param options - Contains agentId (optional) and days ("7D", "14D", or "30D")
@@ -1978,16 +1998,17 @@ type OwneySIWXConfig = {
1978
1998
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
1979
1999
 
1980
2000
  /**
1981
- * Ask the wallet ITSELF to switch networks, over WalletConnect.
2001
+ * Align a supported WalletConnect session with `chainId`.
1982
2002
  *
1983
2003
  * WalletConnect's provider answers `wallet_switchEthereumChain` locally when
1984
2004
  * the chain was approved at connect time: it moves its own default chain and
1985
2005
  * reports success without telling the wallet. MetaMask mobile then stays on
1986
2006
  * its network, keeps reporting it, and every guard downstream fails with
1987
2007
  * CHAIN_MISMATCH — after a swap, with the user's funds already moved (ROUT-727).
1988
- * Sending the request through the session client reaches the wallet, which
1989
- * shows a real "switch network" prompt; the client also deep-links the wallet
1990
- * app open on mobile.
2008
+ * Sending the request through the session client reaches MetaMask, which shows
2009
+ * a real "switch network" prompt. Fireblocks instead uses the approved
2010
+ * multi-chain session's local default; its subsequent signature request is
2011
+ * explicitly scoped to that chain and needs no separate network prompt.
1991
2012
  *
1992
2013
  * Returns false when `provider` is not a WalletConnect session, so the caller
1993
2014
  * can fall back to an ordinary switch.
@@ -2030,4 +2051,4 @@ type StoredOrder = {
2030
2051
  */
2031
2052
  declare function listOrders(now?: number): StoredOrder[];
2032
2053
 
2033
- 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 ApyIncentive, 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 };
2054
+ 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 AgentSessionStore, 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 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 };