@owney/sdk 0.7.32-beta.13 → 0.7.32-beta.14

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.cjs CHANGED
@@ -1723,7 +1723,7 @@ var SnapshotHistory = class {
1723
1723
  };
1724
1724
 
1725
1725
  // src/lib/funding-ledger.ts
1726
- var SDK_VERSION = "0.7.32-beta.13";
1726
+ var SDK_VERSION = "0.7.32-beta.14";
1727
1727
  var SCOPE2 = "funding-ledger";
1728
1728
  var REQUEST_TIMEOUT_MS2 = 5e3;
1729
1729
  var RETRY_DELAYS_MS = [1e3, 4e3, 16e3];
@@ -3996,14 +3996,16 @@ function splitOpportunity(opportunity) {
3996
3996
  }
3997
3997
  function mapEntries(rawEntries, chainId) {
3998
3998
  const actionMap = {
3999
- "Top up wallet": "Top up",
3999
+ // EOA -> smart wallet. Named "Top up" before ROUT-758; "Deposit" is what
4000
+ // users call it.
4001
+ "Top up wallet": "Deposit",
4000
4002
  "Partial withdraw from protocol": "Withdraw",
4001
4003
  "Withdraw from protocol": "Withdraw",
4002
- // The agent's own leg of a top up: the funds the user sent moving into the
4004
+ // The agent's own leg of a deposit: the funds the user sent moving into the
4003
4005
  // pool that earns the APY. Zyfai emits it as a separate entry seconds after
4004
- // "Top up wallet" and for slightly less (gas). `Deposit` already exists in
4005
- // the public HistoryAction union, so no consumer type change is needed.
4006
- "Deposit to protocol": "Deposit",
4006
+ // "Top up wallet" and for slightly less (gas). Smart wallet -> pool, so
4007
+ // "Allocate" (ROUT-758; it was "Deposit").
4008
+ "Deposit to protocol": "Allocate",
4007
4009
  // Withdrawing from an async vault (Superform) is logged under its own
4008
4010
  // label and paid out later in a separate batch (ROUT-624).
4009
4011
  "Request async withdrawal": "Withdraw",
@@ -4054,7 +4056,7 @@ function mapEntries(rawEntries, chainId) {
4054
4056
  const asyncRequest = entry.action === "Request async withdrawal";
4055
4057
  const rawAmount2 = entry?.positions?.[0]?.amount;
4056
4058
  const hasAmount = (mappedAction !== "Withdraw" || asyncRequest) && typeof rawAmount2 === "string" && rawAmount2 !== "" && rawAmount2 !== "0x" && rawAmount2 !== "0x0" && rawAmount2 !== "0";
4057
- const rawDelta = mappedAction === "Deposit" ? decodeDeltaAmount(
4059
+ const rawDelta = mappedAction === "Allocate" ? decodeDeltaAmount(
4058
4060
  entry?.positions?.[0]?.deltaAmount,
4059
4061
  tokenDecimals(entry?.positions?.[0]?.token_symbol)
4060
4062
  ) : void 0;
@@ -4332,7 +4334,7 @@ var isJwtExpired = (token) => {
4332
4334
  }
4333
4335
  };
4334
4336
  var memorySessions = /* @__PURE__ */ new Map();
4335
- var isFreshSession = (session) => !!session && typeof session.isPredeployed === "boolean" && !!session.token && !isJwtExpired(session.token);
4337
+ var isFreshSession = (session) => typeof session === "object" && session !== null && typeof session.isPredeployed === "boolean" && !!session.token && !isJwtExpired(session.token);
4336
4338
  var readLegacySession = (store, address) => {
4337
4339
  if (!store) return null;
4338
4340
  const prefix = legacyKeyPrefix(address);
@@ -4414,13 +4416,24 @@ var clearSession = (address, _chainId) => {
4414
4416
  }
4415
4417
  readLegacySession(store, address);
4416
4418
  };
4419
+ var BrowserSessionStore = class {
4420
+ read(_agentId, address) {
4421
+ return readSession(address, 0);
4422
+ }
4423
+ write(_agentId, address, session) {
4424
+ writeSession(address, 0, session);
4425
+ }
4426
+ clear(_agentId, address) {
4427
+ clearSession(address, 0);
4428
+ }
4429
+ };
4417
4430
 
4418
4431
  // src/agents/zyfai/autoSelect.ts
4419
4432
  function buildAutoSelectUpdate(current, asset, chainId) {
4420
4433
  const chains = current.chains ?? [];
4421
4434
  const chainMissing = chainId !== void 0 && !chains.includes(chainId);
4422
4435
  const nextChains = chainMissing ? [...chains, chainId] : chains;
4423
- if (current.savedPoolChoices) {
4436
+ if (current.savedPoolChoices || current.autoSelectProtocols === false) {
4424
4437
  return chainMissing ? { asset, chains: nextChains } : null;
4425
4438
  }
4426
4439
  if (current.autoSelectProtocols === true && !chainMissing) return null;
@@ -4432,15 +4445,34 @@ function buildAutoSelectUpdate(current, asset, chainId) {
4432
4445
  }
4433
4446
 
4434
4447
  // src/agents/zyfai/protocol-merge.ts
4435
- function buildProtocolMergeUpdate(available, current, asset) {
4448
+ function isExcludedProtocol(protocol, excluded) {
4449
+ if (excluded.length === 0) return false;
4450
+ const wanted = new Set(excluded.map((entry) => entry.toLowerCase()));
4451
+ return wanted.has(protocol.id.toLowerCase()) || protocol.name !== void 0 && wanted.has(protocol.name.toLowerCase());
4452
+ }
4453
+ function buildProtocolMergeUpdate(available, current, asset, excluded = []) {
4454
+ const excludedIds = /* @__PURE__ */ new Set([
4455
+ ...excluded.map((entry) => entry.toLowerCase()),
4456
+ ...available.filter((p) => isExcludedProtocol(p, excluded)).map((p) => p.id.toLowerCase())
4457
+ ]);
4458
+ const isExcludedId = (id) => excluded.length > 0 && excludedIds.has(id.toLowerCase());
4436
4459
  const enabled = current.protocols ?? [];
4437
- const enabledSet = new Set(enabled);
4438
- const missing = available.filter((p) => !enabledSet.has(p.id));
4439
- if (missing.length === 0) return null;
4460
+ const kept = enabled.filter((id) => !isExcludedId(id));
4461
+ const keptSet = new Set(kept);
4462
+ const missing = current.autoSelectProtocols === false ? [] : available.filter((p) => !keptSet.has(p.id) && !isExcluded(p));
4463
+ const fixAutoSelect = excluded.length > 0 && current.autoSelectProtocols !== false;
4464
+ const removedAny = kept.length !== enabled.length;
4465
+ if (missing.length === 0 && !removedAny && !fixAutoSelect) return null;
4466
+ const protocols = [.../* @__PURE__ */ new Set([...kept, ...missing.map((p) => p.id)])];
4467
+ if (protocols.length === 0) return null;
4440
4468
  return {
4441
4469
  asset,
4442
- protocols: [.../* @__PURE__ */ new Set([...enabled, ...missing.map((p) => p.id)])]
4470
+ protocols,
4471
+ ...excluded.length > 0 ? { autoSelectProtocols: false } : {}
4443
4472
  };
4473
+ function isExcluded(p) {
4474
+ return isExcludedProtocol(p, excluded);
4475
+ }
4444
4476
  }
4445
4477
 
4446
4478
  // src/agents/zyfai/splitting.ts
@@ -5003,6 +5035,7 @@ var ERC7579_IS_MODULE_INSTALLED_ABI = (0, import_viem10.parseAbi)([
5003
5035
  "function isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) view returns (bool)"
5004
5036
  ]);
5005
5037
  var ZYFAI_SIGN_IN_REQUIRED_MESSAGE = "No Zyfai sign-in is available without a prompt.";
5038
+ var isPromiseLike = (value) => typeof value?.then === "function";
5006
5039
  var isSignInFailure = (error) => error instanceof OwneyError && error.code === "AGENT_AUTH_FAILED";
5007
5040
  var WETH_ADDRESS_BY_CHAIN = {
5008
5041
  8453: "0x4200000000000000000000000000000000000006",
@@ -5072,16 +5105,20 @@ function belowMinimumCeiling(rejection, token, decimals) {
5072
5105
  return idle === void 0 || minimum === void 0 ? void 0 : idle < minimum ? idle : minimum;
5073
5106
  }
5074
5107
  var ZyfaiAgent = class _ZyfaiAgent {
5075
- constructor(apiKey, rpcUrls, referralSource, accountReporting = {}) {
5108
+ constructor(apiKey, rpcUrls, referralSource, accountReporting = {}, sessionStore = new BrowserSessionStore(), excludedProtocols = []) {
5076
5109
  this.apiKey = apiKey;
5077
5110
  this.referralSource = referralSource;
5078
5111
  this.accountReporting = accountReporting;
5112
+ this.sessionStore = sessionStore;
5113
+ this.excludedProtocols = excludedProtocols;
5079
5114
  this.rpcUrls = resolveRpcUrls(rpcUrls);
5080
5115
  this.sdk = this.createSdk();
5081
5116
  }
5082
5117
  apiKey;
5083
5118
  referralSource;
5084
5119
  accountReporting;
5120
+ sessionStore;
5121
+ excludedProtocols;
5085
5122
  id = "zyfai";
5086
5123
  /** This adapter can hand its withdrawals to our server (part 4). */
5087
5124
  supportsServerTasks = true;
@@ -5233,7 +5270,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
5233
5270
  */
5234
5271
  async resolveFundingTransfers(entries, chainId, recipient, smartWallet, tokenSymbol) {
5235
5272
  const movements = entries.filter(
5236
- (e) => (e.action === "Withdraw" && !e.asyncRequest || e.action === "Top up") && e.transactions[0]?.txHashes[0]
5273
+ (e) => (e.action === "Withdraw" && !e.asyncRequest || e.action === "Deposit") && e.transactions[0]?.txHashes[0]
5237
5274
  );
5238
5275
  if (movements.length === 0) return;
5239
5276
  const client = this.getPublicClient(chainId);
@@ -5290,6 +5327,48 @@ var ZyfaiAgent = class _ZyfaiAgent {
5290
5327
  })
5291
5328
  );
5292
5329
  }
5330
+ /**
5331
+ * The session store is a cache: an unavailable store must never block
5332
+ * authentication or teardown. Failures read as a cache miss. The store is
5333
+ * called synchronously, so a synchronous store (the browser default) has
5334
+ * already acted when this returns.
5335
+ */
5336
+ async storeOp(op) {
5337
+ try {
5338
+ return await op();
5339
+ } catch (error) {
5340
+ console.warn(
5341
+ "owney-sdk: agent session store failed, continuing without it",
5342
+ error
5343
+ );
5344
+ return null;
5345
+ }
5346
+ }
5347
+ /**
5348
+ * The fresh saved session for `address`, or null. Answered synchronously
5349
+ * when the store answers synchronously (the browser default), so a check
5350
+ * that must not yield keeps its order; a promise for an asynchronous store.
5351
+ * A store failure reads as no session.
5352
+ */
5353
+ savedSession(address) {
5354
+ let value;
5355
+ try {
5356
+ value = this.sessionStore.read(this.id, address);
5357
+ } catch (error) {
5358
+ console.warn("owney-sdk: agent session store failed, continuing without it", error);
5359
+ return null;
5360
+ }
5361
+ if (isPromiseLike(value)) {
5362
+ return Promise.resolve(value).then(
5363
+ (session) => isFreshSession(session) ? session : null,
5364
+ (error) => {
5365
+ console.warn("owney-sdk: agent session store failed, continuing without it", error);
5366
+ return null;
5367
+ }
5368
+ );
5369
+ }
5370
+ return isFreshSession(value) ? value : null;
5371
+ }
5293
5372
  /**
5294
5373
  * Patches `sdk.authenticateUser` so a fresh page can reuse the JWT from a
5295
5374
  * prior session instead of triggering a new SIWE prompt. Runs inside
@@ -5297,21 +5376,21 @@ var ZyfaiAgent = class _ZyfaiAgent {
5297
5376
  * (Zyfai dist line 1374). At that point `walletClient` + `currentChainId`
5298
5377
  * are populated, so the cache lookup has both keys it needs.
5299
5378
  *
5300
- * No-op on the server (no `window`) — the SDK is constructed during SSR
5301
- * for some apps and the patch only matters in the browser anyway.
5379
+ * The session lives in `sessionStore`: localStorage in the browser (a no-op
5380
+ * on the server), or whatever the host passed in `OwneySDKConfig`.
5302
5381
  */
5303
5382
  installAuthCache(sdk = this.sdk) {
5304
- if (typeof window === "undefined") return;
5305
5383
  const internals = sdk;
5306
5384
  const original = internals.authenticateUser.bind(internals);
5307
5385
  let inFlight2 = null;
5308
5386
  const authenticate = async () => {
5309
5387
  if (internals.authenticatedUserId !== null) return;
5310
5388
  const address = internals.walletClient?.account?.address;
5311
- const chainId = internals.currentChainId ?? 0;
5312
5389
  if (address) {
5313
- const cached = readSession(address, chainId);
5314
- if (cached) {
5390
+ const cached = await this.storeOp(
5391
+ () => this.sessionStore.read(this.id, address)
5392
+ );
5393
+ if (isFreshSession(cached)) {
5315
5394
  internals.httpClient.setAuthToken(cached.token);
5316
5395
  internals.authenticatedUserId = cached.userId;
5317
5396
  internals.hasActiveSessionKey = cached.hasActiveSessionKey;
@@ -5322,15 +5401,16 @@ var ZyfaiAgent = class _ZyfaiAgent {
5322
5401
  if (this.promptlessSdks.has(sdk)) throw this.signInRequired();
5323
5402
  await original();
5324
5403
  const newAddress = internals.walletClient?.account?.address;
5325
- const newChainId = internals.currentChainId ?? 0;
5326
5404
  const newToken = internals.httpClient.authToken;
5327
5405
  if (newAddress && newToken) {
5328
- writeSession(newAddress, newChainId, {
5329
- token: newToken,
5330
- userId: internals.authenticatedUserId,
5331
- hasActiveSessionKey: internals.hasActiveSessionKey,
5332
- isPredeployed: internals.isPredeployed
5333
- });
5406
+ await this.storeOp(
5407
+ () => this.sessionStore.write(this.id, newAddress, {
5408
+ token: newToken,
5409
+ userId: internals.authenticatedUserId,
5410
+ hasActiveSessionKey: internals.hasActiveSessionKey,
5411
+ isPredeployed: internals.isPredeployed
5412
+ })
5413
+ );
5334
5414
  }
5335
5415
  };
5336
5416
  internals.authenticateUser = () => {
@@ -5359,11 +5439,19 @@ var ZyfaiAgent = class _ZyfaiAgent {
5359
5439
  * Whether connecting now would ask the wallet to sign in: not connected for
5360
5440
  * this wallet and chain (the check `connectAuth` returns early on) and no
5361
5441
  * fresh saved session. Never prompts; reads only what is saved.
5442
+ *
5443
+ * A session store that answers only asynchronously (a host's own
5444
+ * `sessionStore`) cannot be read here, so this throws: the caller counts an
5445
+ * unknown answer its own way (`OwneySDK.signInsNeeded` as a sign-in).
5362
5446
  */
5363
5447
  needsSignIn(state, chainId) {
5364
5448
  const owner = state.walletAddress.toLowerCase();
5365
5449
  if (this.connectedAddress?.toLowerCase() === owner && this.connectedChainId === chainId) return false;
5366
- return readSession(state.walletAddress, chainId) === null;
5450
+ const saved = this.savedSession(state.walletAddress);
5451
+ if (isPromiseLike(saved)) {
5452
+ throw new Error("The Zyfai session store answers asynchronously; whether a sign-in is needed is unknown.");
5453
+ }
5454
+ return saved === null;
5367
5455
  }
5368
5456
  /** A read (promptless state) needs a sign-in it may not ask for. */
5369
5457
  signInRequired() {
@@ -5393,7 +5481,15 @@ var ZyfaiAgent = class _ZyfaiAgent {
5393
5481
  else await this.connectAuthPromise;
5394
5482
  return this.connectAuth(state, chainId);
5395
5483
  }
5396
- if (promptless && readSession(state.walletAddress, validChainId) === null) throw this.signInRequired();
5484
+ if (promptless) {
5485
+ let saved = this.savedSession(state.walletAddress);
5486
+ if (isPromiseLike(saved)) {
5487
+ saved = await saved;
5488
+ if (saved === null) throw this.signInRequired();
5489
+ if (this.connectedAddress?.toLowerCase() === owner && this.connectedChainId === validChainId || this.connectAuthPromise && this.connectAuthScope === scope) return this.connectAuth(state, chainId);
5490
+ }
5491
+ if (saved === null) throw this.signInRequired();
5492
+ }
5397
5493
  if (this.sdkHasConnected || this.connectedAddress) this.sdk = this.createSdk();
5398
5494
  this.sdkHasConnected = true;
5399
5495
  const executionSdk = this.sdk;
@@ -5453,8 +5549,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
5453
5549
  if (!message.toLowerCase().includes("unauthorized")) throw error;
5454
5550
  const internals = executionSdk;
5455
5551
  const address = internals.walletClient?.account?.address;
5456
- if (promptless) throw this.dropRefusedReadSession(address, executionSdk, internals.httpClient.authToken, message);
5457
- if (address) clearSession(address, chainId);
5552
+ if (promptless) throw await this.dropRefusedReadSession(address, executionSdk, internals.httpClient.authToken, message);
5553
+ if (address) {
5554
+ await this.storeOp(() => this.sessionStore.clear(this.id, address));
5555
+ }
5458
5556
  return await executionSdk.connectAccount(provider, chainId);
5459
5557
  }
5460
5558
  }
@@ -5477,14 +5575,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
5477
5575
  * the user's (connect, deposit, withdraw), on a new client. Returns the
5478
5576
  * read's error.
5479
5577
  */
5480
- dropRefusedReadSession(owner, executionSdk, authToken, refusal) {
5578
+ async dropRefusedReadSession(owner, executionSdk, authToken, refusal) {
5481
5579
  debugLog("zyfai:auth", "a read's session was refused; dropped without signing in again", { refusal });
5482
5580
  if (owner && typeof authToken === "string") {
5483
5581
  let dropped = false;
5484
- if (readSession(owner, 0)?.token === authToken) {
5485
- clearSession(owner, 0);
5486
- dropped = true;
5487
- }
5488
5582
  const internals = executionSdk;
5489
5583
  if (internals.httpClient.authToken === authToken) {
5490
5584
  dropped = true;
@@ -5494,6 +5588,11 @@ var ZyfaiAgent = class _ZyfaiAgent {
5494
5588
  if (executionSdk === this.sdk && this.connectedAddress?.toLowerCase() === owner.toLowerCase())
5495
5589
  this.connectedChainId = null;
5496
5590
  }
5591
+ const saved = await this.savedSession(owner);
5592
+ if (saved?.token === authToken) {
5593
+ await this.storeOp(() => this.sessionStore.clear(this.id, owner));
5594
+ dropped = true;
5595
+ }
5497
5596
  if (dropped) this.tellSignInRefused();
5498
5597
  }
5499
5598
  return this.signInRequired();
@@ -5513,7 +5612,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
5513
5612
  if (state.promptless !== true || error instanceof OwneyError) throw error;
5514
5613
  if (message.includes(ZYFAI_SIGN_IN_REQUIRED_MESSAGE)) throw this.signInRequired();
5515
5614
  if (!isZyfaiSessionRejected(message)) throw error;
5516
- throw this.dropRefusedReadSession(state.walletAddress, executionSdk, authToken, message);
5615
+ throw await this.dropRefusedReadSession(state.walletAddress, executionSdk, authToken, message);
5517
5616
  }
5518
5617
  }
5519
5618
  /**
@@ -5549,7 +5648,8 @@ var ZyfaiAgent = class _ZyfaiAgent {
5549
5648
  dropWithdrawalSession(state, chainId, authToken) {
5550
5649
  const internals = this.sdk;
5551
5650
  if (typeof authToken !== "string" || internals.httpClient.authToken !== authToken || this.connectedAddress?.toLowerCase() !== state.walletAddress.toLowerCase() || this.connectedChainId !== chainId) return;
5552
- clearSession(state.walletAddress, chainId);
5651
+ const owner = state.walletAddress;
5652
+ void this.storeOp(() => this.sessionStore.clear(this.id, owner));
5553
5653
  internals.httpClient.clearAuthToken();
5554
5654
  internals.authenticatedUserId = null;
5555
5655
  this.connectedChainId = null;
@@ -5590,10 +5690,15 @@ var ZyfaiAgent = class _ZyfaiAgent {
5590
5690
  available,
5591
5691
  current.chains ?? []
5592
5692
  );
5693
+ const excluded = this.excludedProtocols.length === 0 ? [] : [
5694
+ ...this.excludedProtocols,
5695
+ ...available.filter((protocol) => isExcludedProtocol(protocol, this.excludedProtocols)).map((protocol) => protocol.id)
5696
+ ];
5593
5697
  const update = buildProtocolMergeUpdate(
5594
5698
  available.filter((protocol) => !decided.has(protocol.id)),
5595
5699
  current,
5596
- asset
5700
+ asset,
5701
+ excluded
5597
5702
  );
5598
5703
  if (!update) return;
5599
5704
  await this.sdk.updateUserProfile(update);
@@ -5668,9 +5773,8 @@ var ZyfaiAgent = class _ZyfaiAgent {
5668
5773
  this.holdActiveScopes.clear();
5669
5774
  this.pendingRegistrations.clear();
5670
5775
  this.lastGoodEarnings.clear();
5671
- if (!options?.keepSignIns && this.connectedAddress && this.connectedChainId !== null) {
5672
- clearSession(this.connectedAddress, this.connectedChainId);
5673
- }
5776
+ const address = this.connectedAddress;
5777
+ const sessionCleared = !options?.keepSignIns && address ? this.storeOp(() => this.sessionStore.clear(this.id, address)) : void 0;
5674
5778
  this.connectedAddress = null;
5675
5779
  this.connectedChainId = null;
5676
5780
  this.connectAuthPromise = null;
@@ -5680,6 +5784,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
5680
5784
  this.reportedAccounts.clear();
5681
5785
  this.sdk = this.createSdk();
5682
5786
  this.sdkHasConnected = false;
5787
+ await sessionCleared;
5683
5788
  await executionSdk.disconnectAccount();
5684
5789
  }
5685
5790
  // --- IAgent: Account lifecycle ---
@@ -5891,9 +5996,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
5891
5996
  * lookup fails is skipped rather than failing the whole catalogue.
5892
5997
  */
5893
5998
  async getPoolCatalog(params) {
5894
- const { protocols: universe } = await this.sdk.getAvailableProtocols(
5999
+ const { protocols: allProtocols } = await this.sdk.getAvailableProtocols(
5895
6000
  this.supportedChainIds[0]
5896
6001
  );
6002
+ const universe = allProtocols.filter(
6003
+ (protocol) => !isExcludedProtocol(protocol, this.excludedProtocols)
6004
+ );
5897
6005
  const poolResults = await Promise.all(
5898
6006
  universe.map(async (protocol) => {
5899
6007
  try {
@@ -6045,6 +6153,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
6045
6153
  }
6046
6154
  for (const protocol of universe) {
6047
6155
  if (excluded.has(protocol.id)) continue;
6156
+ if (isExcludedProtocol(protocol, this.excludedProtocols)) continue;
6048
6157
  try {
6049
6158
  const names = mapAvailablePools(await this.sdk.getAvailablePools(protocol.id, "yieldmaxxing")).filter((pool) => pool.chainId === chainId && pool.token.toUpperCase() === asset).map((pool) => pool.name);
6050
6159
  if (names.length === 0) continue;
@@ -6431,6 +6540,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
6431
6540
  assertCurrent();
6432
6541
  const setupResult = await executionSdk.ensureFirstDepositSetup("aggressive");
6433
6542
  debugLog("zyfai:first-deposit", "setup call completed", { asset, chainId: validChainId, requestedStrategy: "aggressive", setupResult });
6543
+ if (this.excludedProtocols.length > 0) {
6544
+ assertCurrent();
6545
+ await this.ensureProtocolsSynced(validChainId, asset);
6546
+ }
6434
6547
  if (isOwneyDebug()) {
6435
6548
  try {
6436
6549
  const profile = await executionSdk.getUserDetails(asset === "WETH" ? "WETH" : "USDC");
@@ -8640,6 +8753,10 @@ function dailyApy(point) {
8640
8753
  if (principal <= 0n || earned === 0n) return 0;
8641
8754
  return Number(earned) / Number(principal) * 365 * 100;
8642
8755
  }
8756
+ var DUST_USD = 5e-3;
8757
+ function heldPosition(tokens, priceUsd) {
8758
+ return Number.isFinite(priceUsd) && priceUsd > 0 ? tokens * priceUsd >= DUST_USD : tokens > 0;
8759
+ }
8643
8760
  function aggregateHistory(contexts, dayCount, now, scopedAsset) {
8644
8761
  const today = new Date(now).toISOString().slice(0, 10);
8645
8762
  const cutoff = new Date(Date.parse(today) - (dayCount - 1) * 864e5).toISOString().slice(0, 10);
@@ -8656,6 +8773,7 @@ function aggregateHistory(contexts, dayCount, now, scopedAsset) {
8656
8773
  if (!Number.isFinite(amount) || amount < 0) {
8657
8774
  invalid("historic position", "expected a finite non-negative balance");
8658
8775
  }
8776
+ if (!heldPosition(tokens, point.baseAssetPriceUsd)) continue;
8659
8777
  const current = byDate.get(point.date) ?? { weighted: 0, amount: 0 };
8660
8778
  current.weighted += dailyApy(point) * amount;
8661
8779
  current.amount += amount;
@@ -8676,7 +8794,8 @@ function historyCoverage2(contexts, dayCount, now) {
8676
8794
  for (const context of contexts) {
8677
8795
  for (const point of context.historic?.dailyYieldSnapshots ?? []) {
8678
8796
  if (!/^\d{4}-\d{2}-\d{2}$/.test(point.date) || point.date < cutoff || point.date > today) continue;
8679
- if (!(Number(decimal(point.totalValueBase, point.baseAssetDecimals, "historic position")) > 0)) continue;
8797
+ const tokens = Number(decimal(point.totalValueBase, point.baseAssetDecimals, "historic position"));
8798
+ if (!heldPosition(tokens, point.baseAssetPriceUsd)) continue;
8680
8799
  const asset = context.asset.toUpperCase();
8681
8800
  const dates = datesByAsset.get(asset) ?? /* @__PURE__ */ new Set();
8682
8801
  dates.add(point.date);
@@ -8718,7 +8837,7 @@ function mapYieldseekerApy(walletAddress, contexts, days, now = Date.now(), scop
8718
8837
  }
8719
8838
  function actionType(value) {
8720
8839
  const normalized = value.toLowerCase();
8721
- if (normalized.includes("deposit")) return "Deposit";
8840
+ if (normalized.includes("deposit")) return "Allocate";
8722
8841
  if (normalized.includes("withdraw")) return "Withdraw";
8723
8842
  if (normalized.includes("yield") || normalized.includes("earn"))
8724
8843
  return "Earned";
@@ -8779,14 +8898,87 @@ function allocationLegs(value, context, requireAmount) {
8779
8898
  }
8780
8899
  return legs;
8781
8900
  }
8782
- function allocationEntry(action, context) {
8901
+ function vaultBook(context, vaultAddresses, catalog = []) {
8902
+ const base7 = context.agent.assetAddress.toLowerCase();
8903
+ const labels = /* @__PURE__ */ new Map();
8904
+ const name = (address, label) => {
8905
+ if (typeof address !== "string" || !(0, import_viem12.isAddress)(address)) return;
8906
+ const key2 = address.toLowerCase();
8907
+ if (!labels.has(key2)) labels.set(key2, label);
8908
+ };
8909
+ for (const action of context.actions ?? []) {
8910
+ for (const list of [action.details?.deposits, action.details?.withdrawals]) {
8911
+ if (!Array.isArray(list)) continue;
8912
+ for (const leg of list) {
8913
+ if (leg && typeof leg.vaultProvider === "string" && leg.vaultProvider)
8914
+ name(leg.vaultAddress, {
8915
+ protocol: leg.vaultProvider,
8916
+ ...typeof leg.vaultName === "string" && leg.vaultName ? { pool: leg.vaultName } : {}
8917
+ });
8918
+ }
8919
+ }
8920
+ }
8921
+ for (const option of [...context.positions.map((entry) => entry.vaultOption), ...catalog])
8922
+ if (option?.chainId === context.agent.chainId)
8923
+ name(option.address, { protocol: option.provider || "Vault", ...option.name ? { pool: option.name } : {} });
8924
+ for (const asset of context.historic?.assets ?? [])
8925
+ if (asset.chainId === context.agent.chainId && !asset.isSpam && asset.address.toLowerCase() !== base7)
8926
+ name(asset.address, { protocol: "Vault", ...asset.name || asset.symbol ? { pool: asset.name || asset.symbol } : {} });
8927
+ const addresses = /* @__PURE__ */ new Set([...vaultAddresses, ...labels.keys()]);
8928
+ return { addresses, label: (address) => labels.get(address.toLowerCase()) ?? { protocol: "Vault" } };
8929
+ }
8930
+ function recycledDeposits(context, movements, vaults) {
8931
+ const base7 = context.agent.assetAddress.toLowerCase();
8932
+ const agentWallet = context.wallet.walletAddress.toLowerCase();
8933
+ const relevant = movements.filter((movement) => movement.chainId === context.agent.chainId && movement.assetAddress.toLowerCase() === base7 && /^\d+$/.test(movement.assetAmount) && BigInt(movement.assetAmount) > 0n && (movement.fromAddress.toLowerCase() === agentWallet || movement.toAddress.toLowerCase() === agentWallet)).sort((a, b) => a.blockDate.localeCompare(b.blockDate) || a.blockNumber - b.blockNumber || a.logIndex - b.logIndex);
8934
+ const transactions = /* @__PURE__ */ new Map();
8935
+ for (const movement of relevant) {
8936
+ const hash2 = movement.transactionHash.toLowerCase();
8937
+ transactions.set(hash2, [...transactions.get(hash2) ?? [], movement]);
8938
+ }
8939
+ const held = [];
8940
+ const spend = (amount) => {
8941
+ const used = [];
8942
+ while (amount > 0n && held.length) {
8943
+ const first = held[0];
8944
+ const taken = first.amount < amount ? first.amount : amount;
8945
+ if (!used.some((entry) => entry.vault === first.vault && entry.hash === first.hash))
8946
+ used.push({ vault: first.vault, hash: first.hash });
8947
+ first.amount -= taken;
8948
+ amount -= taken;
8949
+ if (first.amount === 0n) held.shift();
8950
+ }
8951
+ return used;
8952
+ };
8953
+ const covered = /* @__PURE__ */ new Map();
8954
+ for (const [hash2, legs] of transactions) {
8955
+ let deposited = 0n;
8956
+ for (const movement of legs) {
8957
+ const from = movement.fromAddress.toLowerCase();
8958
+ const to = movement.toAddress.toLowerCase();
8959
+ const amount = BigInt(movement.assetAmount);
8960
+ if (to === agentWallet && from !== agentWallet) {
8961
+ if (vaults.has(from)) held.push({ vault: from, hash: hash2, amount });
8962
+ } else if (from === agentWallet && to !== agentWallet) {
8963
+ if (vaults.has(to)) deposited += amount;
8964
+ else spend(amount);
8965
+ }
8966
+ }
8967
+ if (deposited === 0n) continue;
8968
+ const available = held.reduce((total, entry) => total + entry.amount, 0n);
8969
+ const used = spend(deposited);
8970
+ if (available >= deposited) covered.set(hash2, used);
8971
+ }
8972
+ return covered;
8973
+ }
8974
+ function allocationEntry(action, context, evidence) {
8783
8975
  if (action.actionType.toLowerCase() !== "autoseek") return void 0;
8784
8976
  const hash2 = action.details?.depositTransactionHash;
8785
8977
  const withdrawHash = action.details?.withdrawTransactionHash;
8786
8978
  if (typeof hash2 !== "string" || !TX_HASH3.test(hash2)) return null;
8787
8979
  const deposits = allocationLegs(action.details?.deposits, context, true);
8788
- const withdrawals = action.details?.withdrawals == null ? [] : allocationLegs(action.details.withdrawals, context, false);
8789
- if (!deposits?.length || !withdrawals) return null;
8980
+ const listed = action.details?.withdrawals == null ? [] : allocationLegs(action.details.withdrawals, context, false);
8981
+ if (!deposits?.length || !listed) return null;
8790
8982
  const decimals = YIELDSEEKER_ASSET_METADATA[context.asset].decimals;
8791
8983
  const positions = deposits.map((leg) => ({
8792
8984
  protocol: leg.protocol,
@@ -8795,15 +8987,26 @@ function allocationEntry(action, context) {
8795
8987
  amount: (0, import_viem12.formatUnits)(leg.rawAmount, decimals)
8796
8988
  }));
8797
8989
  const amountRaw = deposits.reduce((total, leg) => total + leg.rawAmount, 0n);
8990
+ const withdrawTx = typeof withdrawHash === "string" && TX_HASH3.test(withdrawHash) && withdrawHash.toLowerCase() !== hash2.toLowerCase() ? withdrawHash : void 0;
8991
+ let withdrawals = listed;
8992
+ let hashes = listed.length && withdrawTx ? [hash2, withdrawTx] : [hash2];
8993
+ if (!listed.length) {
8994
+ const agentWallet = context.wallet.walletAddress.toLowerCase();
8995
+ const inWithdrawTx = withdrawTx ? evidence.movements.filter((movement) => movement.transactionHash.toLowerCase() === withdrawTx.toLowerCase() && movement.assetAddress.toLowerCase() === context.agent.assetAddress.toLowerCase() && movement.toAddress.toLowerCase() === agentWallet && evidence.book.addresses.has(movement.fromAddress.toLowerCase())).map((movement) => ({ vault: movement.fromAddress.toLowerCase(), hash: withdrawTx })) : [];
8996
+ const recycled = evidence.recycled.get(hash2.toLowerCase()) ?? [];
8997
+ const sources = inWithdrawTx.length ? inWithdrawTx : recycled;
8998
+ withdrawals = [...new Set(sources.map((source2) => source2.vault))].map((vault) => evidence.book.label(vault));
8999
+ hashes = [hash2, ...new Set(withdrawTx ? [withdrawTx] : sources.map((source2) => source2.hash).filter((value) => value !== hash2.toLowerCase()))];
9000
+ }
8798
9001
  const rebalance = withdrawals.length > 0;
8799
- const hashes = rebalance && typeof withdrawHash === "string" && TX_HASH3.test(withdrawHash) && withdrawHash.toLowerCase() !== hash2.toLowerCase() ? [hash2, withdrawHash] : [hash2];
9002
+ if (!rebalance) hashes = [hash2];
8800
9003
  const source = withdrawals.length === 1 ? withdrawals[0] : {
8801
9004
  protocol: [...new Set(withdrawals.map((leg) => leg.protocol))].join(" + "),
8802
9005
  pool: withdrawals.map((leg) => leg.pool).filter(Boolean).join(" + ") || void 0
8803
9006
  };
8804
9007
  return {
8805
9008
  agent: "yieldseeker",
8806
- action: rebalance ? "Rebalance" : "Deposit",
9009
+ action: rebalance ? "Rebalance" : "Allocate",
8807
9010
  date: action.createdDate,
8808
9011
  oldApy: null,
8809
9012
  newApy: null,
@@ -8850,17 +9053,17 @@ function movementEntry(movement, wallet, agent, asset, ownerAddress, vaultAddres
8850
9053
  }
8851
9054
  let action;
8852
9055
  if (to === agentWallet && !vaultAddresses.has(from)) {
8853
- action = "Top up";
9056
+ action = "Deposit";
8854
9057
  } else if (from === agentWallet && to === owner) {
8855
9058
  action = "Withdraw";
8856
9059
  } else if (from === agentWallet && destination) {
8857
- action = "Deposit";
9060
+ action = "Allocate";
8858
9061
  }
8859
9062
  if (!action) return void 0;
8860
9063
  return {
8861
9064
  agent: "yieldseeker",
8862
9065
  action,
8863
- ...action === "Deposit" && destination ? { positions: [{
9066
+ ...action === "Allocate" && destination ? { positions: [{
8864
9067
  ...destination,
8865
9068
  amount: decimal(movement.assetAmount, YIELDSEEKER_ASSET_METADATA[asset].decimals, "historic position")
8866
9069
  }] } : {},
@@ -8897,11 +9100,13 @@ function mapYieldseekerHistory(contexts, options) {
8897
9100
  seenMovements.add(key2);
8898
9101
  return true;
8899
9102
  });
9103
+ const book = vaultBook(context, options.vaultAddresses, options.vaultOptions);
9104
+ const evidence = { book, movements, recycled: recycledDeposits(context, movements, book.addresses) };
8900
9105
  const allocations = /* @__PURE__ */ new Map();
8901
9106
  const rebalanceHashes = /* @__PURE__ */ new Set();
8902
9107
  const actions = [];
8903
9108
  for (const action of context.actions ?? []) {
8904
- const allocation = allocationEntry(action, context);
9109
+ const allocation = allocationEntry(action, context, evidence);
8905
9110
  if (allocation === null) continue;
8906
9111
  if (!allocation) {
8907
9112
  const entry = actionEntry(action);
@@ -8921,11 +9126,11 @@ function mapYieldseekerHistory(contexts, options) {
8921
9126
  context.agent,
8922
9127
  context.asset,
8923
9128
  options.ownerAddress,
8924
- options.vaultAddresses,
9129
+ book.addresses,
8925
9130
  depositDestination(context, movement)
8926
9131
  )
8927
- ).filter((entry) => entry !== void 0 && !((entry.action === "Deposit" || entry.action === "Top up") && rebalanceHashes.has(entry.transactions[0]?.txHashes[0]?.toLowerCase() ?? "")));
8928
- const deposits = new Set(movementEntries.filter((entry) => entry.action === "Deposit").map((entry) => entry.transactions[0]?.txHashes[0]?.toLowerCase()));
9132
+ ).filter((entry) => entry !== void 0 && !((entry.action === "Allocate" || entry.action === "Deposit") && rebalanceHashes.has(entry.transactions[0]?.txHashes[0]?.toLowerCase() ?? "")));
9133
+ const deposits = new Set(movementEntries.filter((entry) => entry.action === "Allocate").map((entry) => entry.transactions[0]?.txHashes[0]?.toLowerCase()));
8929
9134
  for (const [hash2, allocation] of allocations)
8930
9135
  if (allocation.action === "Rebalance" || !deposits.has(hash2)) actions.push(allocation);
8931
9136
  return [...movementEntries, ...actions];
@@ -8946,14 +9151,14 @@ function mapYieldseekerHistory(contexts, options) {
8946
9151
  grouped.set(key2, entry);
8947
9152
  continue;
8948
9153
  }
8949
- if (entry.action === "Deposit" && entry.positions?.length) {
9154
+ if (entry.action === "Allocate" && entry.positions?.length) {
8950
9155
  if (!previous.positions?.length) {
8951
9156
  grouped.set(key2, entry);
8952
9157
  continue;
8953
9158
  }
8954
9159
  previous.positions.push(...entry.positions);
8955
9160
  previous.transactions.push(...entry.transactions);
8956
- } else if ((entry.action === "Top up" || entry.action === "Withdraw") && tx.amountRaw) {
9161
+ } else if ((entry.action === "Deposit" || entry.action === "Withdraw") && tx.amountRaw) {
8957
9162
  const target = previous.transactions[0];
8958
9163
  const known = new Set(target.logIndexes ?? []);
8959
9164
  if (tx.logIndexes?.some((index) => !known.has(index))) {
@@ -12252,16 +12457,18 @@ var YieldseekerAgent = class {
12252
12457
  (contextAsset) => this.loadVaultOptions(contextAsset, { includeUnavailable: true })
12253
12458
  )
12254
12459
  );
12460
+ const vaultOptions = catalog.flat().filter(
12461
+ (vaultOption) => vaultOption.chainId === chainId && (0, import_viem17.isAddress)(vaultOption.address)
12462
+ );
12255
12463
  const vaultAddresses = new Set(
12256
- catalog.flat().filter(
12257
- (vaultOption) => vaultOption.chainId === chainId && (0, import_viem17.isAddress)(vaultOption.address)
12258
- ).map((vaultOption) => vaultOption.address.toLowerCase())
12464
+ vaultOptions.map((vaultOption) => vaultOption.address.toLowerCase())
12259
12465
  );
12260
12466
  return mapYieldseekerHistory(contexts, {
12261
12467
  limit: options?.limit ?? 10,
12262
12468
  cursor: options?.cursor,
12263
12469
  ownerAddress: state.walletAddress,
12264
12470
  vaultAddresses,
12471
+ vaultOptions,
12265
12472
  ...options?.fromDate ? { fromDate: options.fromDate } : {},
12266
12473
  ...options?.toDate ? { toDate: options.toDate } : {}
12267
12474
  });
@@ -17389,7 +17596,6 @@ async function runAgentDepositBatch(chainId, legs, transfer) {
17389
17596
  // src/lib/walletconnect-switch.ts
17390
17597
  var WALLET_SWITCH_TIMEOUT_MS = 12e4;
17391
17598
  var HOLD_CHAIN_MS = 15e3;
17392
- var MAX_RESENDS = 2;
17393
17599
  var holds = /* @__PURE__ */ new Map();
17394
17600
  function parseChainId(raw2) {
17395
17601
  if (typeof raw2 === "number") return raw2;
@@ -17398,28 +17604,76 @@ function parseChainId(raw2) {
17398
17604
  const id = ref.startsWith("0x") ? Number.parseInt(ref, 16) : Number(ref);
17399
17605
  return Number.isFinite(id) ? id : void 0;
17400
17606
  }
17401
- function walletConnectCore(provider) {
17607
+ function walletConnectSession(provider) {
17402
17608
  const p = provider;
17403
17609
  const core = p?.signer ?? p;
17404
- if (typeof core?.client?.request !== "function" || typeof core.setDefaultChain !== "function" || typeof core.session?.topic !== "string") {
17610
+ if (typeof core?.request !== "function" || typeof core?.client?.request !== "function" || typeof core.setDefaultChain !== "function" || typeof core.session?.topic !== "string") {
17405
17611
  return null;
17406
17612
  }
17407
17613
  const peer = core.session.peer?.metadata?.name ?? "";
17408
- if (!/metamask/i.test(peer)) return null;
17409
- return core;
17614
+ if (/metamask/i.test(peer)) {
17615
+ return { core, strategy: "remote-wallet" };
17616
+ }
17617
+ if (/fireblocks/i.test(peer)) {
17618
+ return { core, strategy: "session-default" };
17619
+ }
17620
+ return null;
17621
+ }
17622
+ function approvedChains(core) {
17623
+ const approved = /* @__PURE__ */ new Set();
17624
+ for (const namespace of Object.values(core.session.namespaces ?? {})) {
17625
+ for (const chain2 of namespace.chains ?? []) approved.add(chain2);
17626
+ for (const account of namespace.accounts ?? []) {
17627
+ const [namespaceName, reference] = account.split(":");
17628
+ if (namespaceName && reference) {
17629
+ approved.add(`${namespaceName}:${reference}`);
17630
+ }
17631
+ }
17632
+ }
17633
+ return approved;
17634
+ }
17635
+ async function selectSessionDefaultChain(core, chainId) {
17636
+ const target = `eip155:${chainId}`;
17637
+ if (!approvedChains(core).has(target)) {
17638
+ throw new Error(
17639
+ `The WalletConnect session has not approved ${target}. Reconnect the wallet and try again.`
17640
+ );
17641
+ }
17642
+ core.setDefaultChain(target);
17643
+ const selected = parseChainId(
17644
+ await core.request({ method: "eth_chainId" })
17645
+ );
17646
+ debugLog("wc-switch", "selected WalletConnect session default", {
17647
+ peer: core.session.peer?.metadata?.name,
17648
+ target: chainId,
17649
+ selected
17650
+ });
17651
+ if (selected !== chainId) {
17652
+ throw new Error(
17653
+ `WalletConnect stayed on chain ${selected ?? "unknown"}; expected ${chainId}.`
17654
+ );
17655
+ }
17410
17656
  }
17411
17657
  async function switchWalletConnectChain(provider, chainId, timeoutMs = WALLET_SWITCH_TIMEOUT_MS) {
17412
- const core = walletConnectCore(provider);
17413
- if (!core) return false;
17658
+ const session = walletConnectSession(provider);
17659
+ if (!session) return false;
17660
+ const { core, strategy } = session;
17414
17661
  holds.get(core.session.topic)?.();
17662
+ if (strategy === "session-default") {
17663
+ await selectSessionDefaultChain(core, chainId);
17664
+ return true;
17665
+ }
17415
17666
  await requestSwitch(core, provider, chainId, timeoutMs);
17416
- holdChain(core, provider, chainId);
17667
+ holdChain(core, chainId);
17417
17668
  return true;
17418
17669
  }
17419
17670
  async function requestSwitch(core, provider, chainId, timeoutMs) {
17420
- const current = Number(
17671
+ const current = parseChainId(
17421
17672
  await provider.request({ method: "eth_chainId" })
17422
17673
  );
17674
+ if (current === void 0) {
17675
+ throw new Error("WalletConnect could not report its current chain.");
17676
+ }
17423
17677
  const hexChainId = `0x${chainId.toString(16)}`;
17424
17678
  let timer;
17425
17679
  try {
@@ -17449,26 +17703,27 @@ async function requestSwitch(core, provider, chainId, timeoutMs) {
17449
17703
  } catch {
17450
17704
  }
17451
17705
  }
17452
- function holdChain(core, provider, chainId) {
17706
+ function holdChain(core, chainId) {
17453
17707
  if (typeof core.on !== "function" || typeof core.removeListener !== "function") {
17454
17708
  return;
17455
17709
  }
17456
- let resends = 0;
17710
+ let repins = 0;
17457
17711
  const listener = (raw2) => {
17458
17712
  const reported = parseChainId(raw2);
17459
17713
  debugLog("wc-switch", "wallet reported chain", {
17460
17714
  reported,
17461
17715
  holding: chainId,
17462
- resends
17716
+ repins
17463
17717
  });
17464
17718
  if (reported === void 0 || reported === chainId) return;
17465
- if (resends >= MAX_RESENDS) return;
17466
- resends += 1;
17467
- void requestSwitch(core, provider, chainId, WALLET_SWITCH_TIMEOUT_MS).catch(
17468
- (error) => debugLog("wc-switch", "re-switch failed", {
17719
+ repins += 1;
17720
+ try {
17721
+ core.setDefaultChain(`eip155:${chainId}`);
17722
+ } catch (error) {
17723
+ debugLog("wc-switch", "session re-pin failed", {
17469
17724
  error: error instanceof Error ? error.message : String(error)
17470
- })
17471
- );
17725
+ });
17726
+ }
17472
17727
  };
17473
17728
  const release = () => {
17474
17729
  clearTimeout(timer);
@@ -17482,7 +17737,7 @@ function holdChain(core, provider, chainId) {
17482
17737
  holds.set(core.session.topic, release);
17483
17738
  }
17484
17739
  function withWalletConnectSwitch(provider) {
17485
- if (!walletConnectCore(provider)) return provider;
17740
+ if (!walletConnectSession(provider)) return provider;
17486
17741
  const target = provider;
17487
17742
  const request2 = async (args) => {
17488
17743
  if (args?.method !== "wallet_switchEthereumChain") {
@@ -17833,6 +18088,7 @@ var OwneySDK = class {
17833
18088
  yieldseekerApiBaseUrl;
17834
18089
  yieldseekerSiweOrigin;
17835
18090
  userPoolCustomization = false;
18091
+ excludedProtocols = [];
17836
18092
  routingApiBaseUrl;
17837
18093
  referralSource;
17838
18094
  ledger;
@@ -17843,6 +18099,7 @@ var OwneySDK = class {
17843
18099
  zyfaiServerTasks;
17844
18100
  /** The caller opted in to the Fusion+ secret handoff (`fusionSecretHandoff: true`). */
17845
18101
  fusionSecretHandoff;
18102
+ sessionStore;
17846
18103
  cachedSponsoredCallback = null;
17847
18104
  cachedWethSponsoredCallback = null;
17848
18105
  paymasterServiceUrl;
@@ -17885,7 +18142,9 @@ var OwneySDK = class {
17885
18142
  this.routingApiBaseUrl = config.routingApiBaseUrl;
17886
18143
  this.paymasterServiceUrl = config.paymasterServiceUrl;
17887
18144
  this.referralSource = config.referralSource;
18145
+ this.sessionStore = config.sessionStore;
17888
18146
  this.userPoolCustomization = config.userPoolCustomization ?? false;
18147
+ this.excludedProtocols = config.excludedProtocols ?? [];
17889
18148
  this.ledger = createFundingLedger({
17890
18149
  apiKey: config.apiKey,
17891
18150
  baseUrl: config.routingApiBaseUrl,
@@ -18640,7 +18899,9 @@ var OwneySDK = class {
18640
18899
  // Only an explicit opt-in lets the agent hand the Zyfai session to
18641
18900
  // Owney; a function is passed as it is and read per handoff.
18642
18901
  ...this.zyfaiServerTasks !== void 0 ? { zyfaiServerTasks: this.zyfaiServerTasks } : {}
18643
- }
18902
+ },
18903
+ this.sessionStore,
18904
+ this.excludedProtocols
18644
18905
  );
18645
18906
  }
18646
18907
  if (agentId === "yieldseeker") {