keyring-agent-core 0.2.54 → 0.2.55

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.ts CHANGED
@@ -1384,10 +1384,14 @@ interface AgentConfig {
1384
1384
  llm: LLMProviderConfig;
1385
1385
  /**
1386
1386
  * Core-wide RPC overrides, keyed by hex chain id (e.g. `{ '0x1': 'https://…' }`).
1387
- * The single place to configure RPC endpoints — shared by every on-chain read
1388
- * in the core: gas-reserve estimation for wallet actions, the swap allowance
1389
- * check, and the pool tools. A chain that is not listed falls back to the
1390
- * built-in public default for that chain.
1387
+ * Shared by every on-chain read in the core: gas-reserve estimation for wallet
1388
+ * actions, the swap allowance check, and the pool tools.
1389
+ *
1390
+ * An entry PREFERS an endpoint rather than replacing the list — a chain's
1391
+ * built-in defaults, plus the endpoints loaded from the Pantograph chains
1392
+ * catalogue on startup, stay behind it as backups, so a configured node going
1393
+ * down degrades to the public ones instead of losing the chain. A chain that
1394
+ * is not listed simply uses those built-in and catalogue endpoints.
1391
1395
  */
1392
1396
  rpcUrls?: Record<string, string>;
1393
1397
  /**
@@ -1462,7 +1466,7 @@ interface AgentConfig {
1462
1466
  pantographUrl?: string;
1463
1467
  } | false;
1464
1468
  /**
1465
- * USDC lending / supply tool config (`get-lending-markets` and
1469
+ * Lending / supply tool config (`get-lending-markets` and
1466
1470
  * `get-wallet-lending-positions`). Set to `false` to skip registering them —
1467
1471
  * to keep the tools but stop routing to them, use `subagents.lending: false`.
1468
1472
  * Independent of `moralis`: the curated market list comes from the CoinPool
@@ -1487,7 +1491,7 @@ interface AgentConfig {
1487
1491
  wallet?: boolean;
1488
1492
  'wallet-action'?: boolean;
1489
1493
  /**
1490
- * USDC lending expert: which markets to supply to and what the wallet
1494
+ * Lending expert: which markets to supply to and what the wallet
1491
1495
  * already supplies. Needs `lending` (its tools) to be enabled.
1492
1496
  */
1493
1497
  lending?: boolean;
@@ -5401,87 +5405,111 @@ interface MulticallRequest {
5401
5405
  * simply does the fetch.
5402
5406
  */
5403
5407
  /** Market kinds `/supply/v2` returns; see {@link PROTOCOLS}. */
5404
- type LendingProtocolType = 'aave-v3' | 'compound-v3' | 'spark' | 'spark-ethereum' | 'morpho-v2';
5405
-
5408
+ type LendingProtocolType = 'aave-v3' | 'compound-v3' | 'spark' | 'spark-ethereum' | 'spark-l2-susds' | 'morpho-v2';
5406
5409
  /**
5407
- * Client for the CoinPool USDC **lending / supply** markets — the data behind
5408
- * the app's "Supply" product (Aave v3, Compound v3, Spark, Morpho v2 vaults).
5410
+ * The per-chain facts a protocol needs — the numeric chain id, and nothing else.
5409
5411
  *
5410
- * A wallet's supplied balance is NOT read from an indexer: the receipt token
5411
- * (aToken / Comet / ERC-4626 vault share) is read straight from chain through
5412
- * Multicall3, so the number always matches what the app shows. Everything else
5413
- * comes from the same sources the CoinPool web app itself uses — its
5414
- * `useUsdcLendingData` hook, in the SEPARATE `coinpool-v2` repository
5415
- * (`src/hooks/useUsdcLendingData.ts`), is the reference this service was checked
5416
- * against protocol by protocol:
5417
- *
5418
- * - market list ................. CoinPool `GET /supply/v2?chainId=…`
5419
- * - supply-APY history ......... Aave v3 GraphQL (`aave-v3`),
5420
- * Morpho GraphQL (`morpho-v2`),
5421
- * CoinPool `GET /supply/rates/history` (rest)
5422
- * - supplied amount / market size on-chain via Multicall3
5423
- *
5424
- * Reported APY is the AVERAGE of the daily supply-APY samples of the last
5425
- * {@link APY_HISTORY_DAYS} days plus the live rate — a spot rate swings with
5426
- * borrow demand, so an average is what a supplier actually earns.
5427
- *
5428
- * ## Protocols differ; the pipeline does not
5429
- *
5430
- * The market kinds disagree on every input: where the market size lives, whether
5431
- * the receipt token is 1:1 with USDC or an ERC-4626 share, which API knows the
5432
- * rate history, and whether a live rate has to come off-chain. Each kind is a
5433
- * class in {@link file://./lending/protocols.ts}; this file is the pipeline that
5434
- * drives them and knows about no protocol by name.
5435
- *
5436
- * | | market size | balance | APY history | live APY |
5437
- * |--------------|----------------|-------------|-------------|------------|
5438
- * | aave-v3 | aToken supply | underlying | Aave API | on-chain |
5439
- * | compound-v3 | Comet supply | underlying | CoinPool | newest row |
5440
- * | spark* | totalAssets() | ERC-4626 | CoinPool | newest row |
5441
- * | morpho-v2 | totalAssets() | ERC-4626 | Morpho API | from API |
5442
- *
5443
- * Two entries in that last column are worth stating outright, because the app
5444
- * looks like it disagrees. The app derives EVERY protocol's live rate on-chain,
5445
- * each with its own formula; here only Aave does. That is not a shortcut taken
5446
- * blindly — CoinPool's history endpoint refreshes intraday and its newest row
5447
- * was checked against chain to six decimals for all three protocols that use it
5448
- * (see `fetchCoinPoolApy`). Aave is the one case where the API and the on-chain
5449
- * figure genuinely differ, so it is the one case that pays for the extra call.
5412
+ * This used to also carry the chain's USDC address and decimals, as the DEFAULT
5413
+ * underlying for a market whose own underlying could not be read. That default
5414
+ * is gone: every market's asset now comes from the market itself ({@link
5415
+ * MarketAsset}), and a market that cannot name its asset is reported unresolved
5416
+ * rather than assumed to be USDC. Keeping the fields around would invite exactly
5417
+ * the assumption they were removed for.
5418
+ */
5419
+ interface LendingChainInfo {
5420
+ chainId: number;
5421
+ }
5422
+ /** Endpoints {@link LendingProtocol.fetchApy} may call, injected so they stay configurable. */
5423
+ interface ApyEndpoints {
5424
+ coinPoolBaseUrl: string;
5425
+ aaveApiUrl: string;
5426
+ morphoApiUrl: string;
5427
+ }
5428
+ /**
5429
+ * Display name of a market's protocol family, derived from its `type`.
5450
5430
  *
5451
- * Protocols DECLARE their on-chain calls rather than making them, so every
5452
- * market on a chain still resolves in ONE Multicall3 round-trip regardless of
5453
- * how many protocols are involved — see the protocols module for why.
5431
+ * `type` is the one identifier that is always exact — it is what selects the
5432
+ * on-chain calls — whereas the market's `name` and `protocol` are display
5433
+ * strings whose form depends on where the market came from: discovery writes
5434
+ * "Aave v3" with a lowercase v, the catalogue passes through whatever
5435
+ * `/supply/v2` supplies, and a Morpho market's `name` is the VAULT's name
5436
+ * ("Gauntlet USDC Core"), not the protocol's.
5454
5437
  *
5455
- * Independent of {@link file://./MoralisService.ts}: these markets are curated by the
5456
- * CoinPool platform and an indexer neither knows the curated set nor the vault
5457
- * share → USDC conversion.
5438
+ * Returns null for a market kind with no label — an unknown `type` from the
5439
+ * catalogue, or a family added upstream after this table. Callers fall back to
5440
+ * the market's own strings rather than showing a guess.
5458
5441
  */
5459
- interface LendingServiceConfig {
5460
- /** Base URL of the CoinPool API. Defaults to `https://api.coinpool.app`. */
5461
- coinPoolBaseUrl?: string;
5462
- /** Aave v3 GraphQL endpoint (supply-APY history). */
5463
- aaveApiUrl?: string;
5464
- /** Morpho GraphQL endpoint (vault APY history + live net APY). */
5465
- morphoApiUrl?: string;
5466
- }
5467
- /** One curated USDC lending market. */
5442
+ declare function protocolLabelFor(type: string): string | null;
5443
+
5444
+ /**
5445
+ * The shapes every lending module agrees on, kept apart from the services that
5446
+ * produce them so `catalog`, `discovery` and `describe` can share them without
5447
+ * importing each other or the facade.
5448
+ */
5449
+
5450
+ /** One lending market — curated by CoinPool or discovered from its receipt token. */
5468
5451
  interface LendingMarket {
5469
5452
  /** Hex chain id the market lives on. */
5470
5453
  chain: string;
5471
- /** Display name, e.g. "Aave v3 USDC" / "Spark USDC Savings Vault". */
5454
+ /**
5455
+ * Display name of THIS MARKET, e.g. "Aave v3 USDC" / "Spark USDC Savings
5456
+ * Vault". For a Morpho market it is the vault's own name from Morpho's API
5457
+ * ("Gauntlet USDC Core") — the vault, not the protocol, which is why the app
5458
+ * link's slug is built from it.
5459
+ *
5460
+ * Not the protocol's name: use {@link protocolLabel} to title a market by the
5461
+ * protocol it belongs to.
5462
+ */
5472
5463
  name: string;
5473
- /** Protocol family, e.g. "AAVE" / "MORPHO". */
5464
+ /**
5465
+ * Protocol family as its SOURCE spells it — "AAVE" / "MORPHO" from discovery,
5466
+ * or whatever `/supply/v2` supplies for a curated market. Neither casing nor
5467
+ * wording is guaranteed, so prefer {@link protocolLabel} for display.
5468
+ */
5474
5469
  protocol: string;
5470
+ /**
5471
+ * Protocol family in the form a reader should see: "Aave V3", "Compound V3",
5472
+ * "Spark", "Morpho V2". Derived from {@link type}, the one identifier that is
5473
+ * always exact, so it is stable no matter whether the market was discovered
5474
+ * on chain or came from the catalogue.
5475
+ *
5476
+ * Null for a market kind with no known label — an unrecognised `type` from the
5477
+ * catalogue, or a family added upstream. Fall back to {@link name} /
5478
+ * {@link protocol} then, rather than showing nothing.
5479
+ */
5480
+ protocolLabel: string | null;
5475
5481
  /** Protocol app URL, when known. */
5476
5482
  protocolUrl: string | null;
5477
5483
  type: LendingProtocolType | string;
5478
- /** Pool / vault contract — where a supply goes. */
5484
+ /**
5485
+ * Pool / vault contract — where a supply goes.
5486
+ *
5487
+ * One exception: `spark-l2-susds` markets are read-only and have no vault on
5488
+ * their chain, so this holds the SSR oracle they are read through.
5489
+ */
5479
5490
  contract: string;
5480
5491
  /** Receipt token holding the user's balance (aToken, Comet, vault share). */
5481
5492
  token: string;
5493
+ /**
5494
+ * Underlying asset ADDRESS, supplied when the market cannot name it on chain.
5495
+ *
5496
+ * Normally absent: a market's asset is read from its own contract at describe
5497
+ * time ({@link LendingProtocol.underlyingCall}), which is the only source that
5498
+ * cannot go stale. This exists for the one family with no such accessor —
5499
+ * cross-chain sUSDS, whose asset comes from PSM3 during discovery — so the
5500
+ * answer is carried forward rather than re-derived or guessed.
5501
+ *
5502
+ * Deliberately NOT named `asset`: {@link LendingMarketOverview.asset} is the
5503
+ * resolved object (address + decimals + symbol + logo), and this is only the
5504
+ * raw input to it. Decimals and symbol are still read on chain from this
5505
+ * address, so nothing here bypasses the checks that suppress a mis-scaled
5506
+ * amount.
5507
+ */
5508
+ assetAddress?: string;
5482
5509
  /**
5483
5510
  * CoinPool's balanced score for the market, 0–10 (higher is better) — weighs
5484
- * protocol safety, market size and yield. Null when the market is unscored.
5511
+ * protocol safety, market size and yield. Null when the market is unscored,
5512
+ * which every DISCOVERED market is: the score exists only in the catalogue.
5485
5513
  */
5486
5514
  platformScore: number | null;
5487
5515
  }
@@ -5493,7 +5521,36 @@ interface ApyPoint {
5493
5521
  }
5494
5522
  /** A lending market plus its live rate and size — what you'd compare before supplying. */
5495
5523
  interface LendingMarketOverview extends LendingMarket {
5496
- /** Total USDC supplied to this market by everyone (market size). */
5524
+ /**
5525
+ * The asset this market lends, read on chain. Most curated markets are USDC;
5526
+ * those on WETH / wstETH / other assets report their own here.
5527
+ *
5528
+ * Always consult this before rendering an amount: {@link totalSuppliedUsdc} and
5529
+ * {@link LendingSupplyPosition.suppliedUsdc} are denominated in THIS asset, not
5530
+ * necessarily in USDC, and labelling a WETH figure "USDC" is worse than showing
5531
+ * no label at all.
5532
+ */
5533
+ asset: {
5534
+ address: string;
5535
+ decimals: number;
5536
+ /** ERC-20 symbol, when it could be read. Null otherwise — never guessed. */
5537
+ symbol: string | null;
5538
+ /**
5539
+ * Icon URL for the underlying, from Pantograph's token metadata. Null when
5540
+ * the asset is unresolved, unknown to Pantograph, or the lookup failed — it
5541
+ * is cosmetic, so it never blocks or delays the rest of the description.
5542
+ *
5543
+ * The UNDERLYING's icon, not the receipt token's: a withdraw form shows what
5544
+ * the user receives (USDC, WETH), which is a different image from the
5545
+ * aToken / vault share they hold.
5546
+ */
5547
+ logo: string | null;
5548
+ };
5549
+ /**
5550
+ * Total supplied to this market by everyone (market size), denominated in
5551
+ * {@link asset} — despite the name, which predates non-USDC support and is
5552
+ * kept so existing callers keep compiling.
5553
+ */
5497
5554
  totalSuppliedUsdc: number | null;
5498
5555
  /** Mean of {@link apyHistory} — the headline APY. Null when history is unavailable. */
5499
5556
  avgApyPercent: number | null;
@@ -5506,32 +5563,365 @@ interface LendingMarketOverview extends LendingMarket {
5506
5563
  }
5507
5564
  /** A wallet's live supply position in one lending market. */
5508
5565
  interface LendingSupplyPosition extends LendingMarketOverview {
5509
- /** Supplied USDC, receipt-token balance converted to underlying. */
5566
+ /** Supplied amount, receipt-token balance converted to the underlying {@link asset}. */
5510
5567
  suppliedUsdc: number;
5511
5568
  /** `suppliedUsdc × avgApyPercent` — projected yearly earnings at the average rate. */
5512
5569
  estimatedAnnualYieldUsdc: number | null;
5513
5570
  }
5514
- declare class LendingService {
5515
- private readonly coinPoolBaseUrl;
5516
- /** Passed to each protocol's `fetchApy`, so endpoints stay configurable. */
5517
- private readonly apiEndpoints;
5518
- /** Shared across chains, so a whole-catalogue scan stays within the cap. */
5571
+ /** Endpoint overrides shared by every lending service. */
5572
+ interface LendingServiceConfig {
5573
+ /** Base URL of the CoinPool API. Defaults to `https://api.coinpool.app`. */
5574
+ coinPoolBaseUrl?: string;
5575
+ /** Aave v3 GraphQL endpoint (supply-APY history). */
5576
+ aaveApiUrl?: string;
5577
+ /** Morpho GraphQL endpoint (vault APY history + live net APY). */
5578
+ morphoApiUrl?: string;
5579
+ }
5580
+
5581
+ /**
5582
+ * The description pipeline: markets in, markets WITH their asset, size and APY
5583
+ * out. Protocol-agnostic by design — it knows about no protocol by name, only
5584
+ * about the calls each one declares (see `protocols.ts`).
5585
+ *
5586
+ * This is the half both services share. Reading a wallet's positions and listing
5587
+ * the supply catalogue ask the same question of a market once it is identified,
5588
+ * so asking it lives here rather than in either service.
5589
+ *
5590
+ * Everything is batched per chain: twenty markets across four protocols still
5591
+ * cost one multicall for their sizes and live rates, plus at most one follow-up
5592
+ * round for the rates that are a function of it.
5593
+ */
5594
+
5595
+ /** A receipt-token balance awaiting conversion to its underlying. */
5596
+ interface HeldBalance {
5597
+ market: LendingMarket;
5598
+ /** Receipt-token balance (shares for a vault, underlying for aToken/Comet). */
5599
+ rawBalance: bigint;
5600
+ /** Receipt-token `decimals()`, null when the call failed. */
5601
+ tokenDecimals: number | null;
5602
+ }
5603
+ /**
5604
+ * Describes markets on one chain, sharing an APY concurrency budget across every
5605
+ * call it makes. One instance per service, so a whole-catalogue scan and a
5606
+ * wallet read never together exceed the cap.
5607
+ */
5608
+ declare class MarketDescriber {
5609
+ private readonly endpoints;
5519
5610
  private readonly apyLimiter;
5520
- constructor(config?: LendingServiceConfig);
5521
- /** Hex chain ids with USDC lending markets (intersected with the active set). */
5522
- listSupportedChains(): string[];
5523
- /** True when the given chain (any alias / hex / decimal form) has lending markets. */
5524
- isSupported(chain?: string | null): boolean;
5525
5611
  /**
5526
- * Every curated USDC lending market on a chain. Empty when the chain has none
5527
- * or the API is unreachable — never throws.
5612
+ * Token metadata source for the underlying's ICON — the one thing about the
5613
+ * asset that is not on chain. Cosmetic only: every failure path here leaves
5614
+ * `logo: null` and changes nothing else about the description.
5528
5615
  */
5529
- getMarkets(chain: string): Promise<LendingMarket[]>;
5530
- /** The USDC a supply on this chain moves. Null when the chain has no markets. */
5531
- getUsdc(chain: string): {
5616
+ private readonly pantograph;
5617
+ constructor(endpoints: ApyEndpoints);
5618
+ /**
5619
+ * Attach market size and the APY series to each market — one batched on-chain
5620
+ * read plus one API call per market. Order is preserved, so callers can zip
5621
+ * the result with their own per-market data. Never throws.
5622
+ *
5623
+ * Asset resolution comes FIRST and is awaited on its own: both the state read
5624
+ * (which reserve to quote, which decimals to scale by) and the APY fetch
5625
+ * (which reserve's history to ask for) are parameterised by it, so they cannot
5626
+ * be started until it lands. That is one extra round-trip per chain, batched
5627
+ * across every market — the price of describing a market in its own asset
5628
+ * rather than assuming the chain's USDC.
5629
+ */
5630
+ describe(chain: string, info: LendingChainInfo, markets: LendingMarket[]): Promise<LendingMarketOverview[]>;
5631
+ /**
5632
+ * Every market's receipt-token balance + decimals in one batch, narrowed to the
5633
+ * markets the wallet actually holds something in — the step that decides how
5634
+ * much further work the rest of the flow has to do.
5635
+ */
5636
+ readBalances(chain: string, address: string, markets: LendingMarket[]): Promise<HeldBalance[]>;
5637
+ /**
5638
+ * Each held balance in its market's own underlying, aligned with `held`. A
5639
+ * protocol whose receipt token is an ERC-4626 share declares a
5640
+ * `convertToAssets` call; one whose balance is already underlying declares
5641
+ * none. As with {@link readMarketState}, every conversion across every protocol
5642
+ * shares ONE multicall.
5643
+ *
5644
+ * A vault whose conversion reverts falls back to the raw balance in the share
5645
+ * token's own decimals — an approximation that beats dropping the position
5646
+ * outright.
5647
+ *
5648
+ * `assets[i]` carries the decimals to scale by; a market whose asset could not
5649
+ * be resolved has NaN decimals and yields 0, so an unscalable balance is
5650
+ * dropped as dust rather than reported at the wrong magnitude.
5651
+ */
5652
+ convertToUnderlying(chain: string, held: HeldBalance[], assets: Array<LendingMarketOverview['asset']>): Promise<number[]>;
5653
+ /**
5654
+ * The asset each market lends, aligned with `markets`, in three batched rounds:
5655
+ * ask every market for its underlying, then ask every distinct underlying for
5656
+ * its `decimals()` and `symbol()`, then ask Pantograph for those same
5657
+ * underlyings' ICONS — the only part of the asset that is not on chain, and the
5658
+ * only round that is allowed to fail without consequence.
5659
+ *
5660
+ * The market is the ONLY source consulted. There used to be a per-chain USDC
5661
+ * fallback for a market whose accessor was missing or reverted, and it was
5662
+ * wrong in exactly the cases it fired: a market that fails to name its asset is
5663
+ * not thereby a USDC market, and calling it one attributes a WETH or DAI size
5664
+ * to the wrong token with the wrong decimals. An unresolvable asset is now
5665
+ * reported unresolved (NaN decimals), which suppresses the size instead of
5666
+ * misstating it — the same treatment a chain with no curated USDC always got.
5667
+ *
5668
+ * This is also what lets a market lend anything at all: nothing here knows or
5669
+ * cares which asset a chain's "real" stablecoin is.
5670
+ */
5671
+ private resolveAssets;
5672
+ /** `decimals()` + `symbol()` for each distinct asset address, in one multicall. */
5673
+ private readAssetMetadata;
5674
+ /**
5675
+ * Icon URL for each distinct asset address, from Pantograph's token metadata —
5676
+ * one request for the whole set.
5677
+ *
5678
+ * Purely cosmetic, and treated as such throughout: an unknown token, a chain
5679
+ * Pantograph does not index, or an outright failure all yield an EMPTY map, so
5680
+ * the assets come back with `logo: null` and every number in the description is
5681
+ * exactly what it would have been without this call. `getTokensMetadata`
5682
+ * already swallows its own errors; the catch is for the unexpected.
5683
+ */
5684
+ private fetchAssetLogos;
5685
+ /**
5686
+ * On-chain state of each market, aligned with `markets`: its size and its live
5687
+ * supply rate.
5688
+ *
5689
+ * This is where the batching lives. Each market's protocol only DECLARES the
5690
+ * calls it wants (`sizeCall`, `liveRateCall`); they are pooled here into a
5691
+ * single multicall, and each protocol then decodes its own slice of the result.
5692
+ *
5693
+ * Compound and Spark need a SECOND call that depends on the first's answer
5694
+ * (`getSupplyRate` of the utilization just read; `getAPR` on the rate provider
5695
+ * just named), so a second round follows when any market asks for one. Those
5696
+ * follow-ups are batched together too — two round-trips per chain at worst,
5697
+ * never two per market.
5698
+ *
5699
+ * Either field is null when its call failed or decoded implausibly.
5700
+ */
5701
+ private readMarketState;
5702
+ /**
5703
+ * Historical supply-APY samples for one market, from whichever upstream its
5704
+ * protocol queries, plus that source's own live rate where it reports one.
5705
+ *
5706
+ * Unlike the on-chain reads there is nothing to batch here — each protocol
5707
+ * talks to a different API, one request per market — so the protocol performs
5708
+ * the fetch itself. Never throws: an unreachable source yields no samples, so
5709
+ * the market is still listed, just without APY.
5710
+ */
5711
+ private fetchApy;
5712
+ }
5713
+
5714
+ /**
5715
+ * Reading lending markets — **every asset, every chain**, and every protocol the
5716
+ * probes can recognise (see the caveat under "What this does NOT cover").
5717
+ *
5718
+ * This is the half the Keyring app consumes. The app already knows what a wallet
5719
+ * holds: its token API returns each row with `yieldProtocol` / `yieldAsset`
5720
+ * tags, and {@link file://./yieldTokenValue.ts} converts vault shares to
5721
+ * underlying for the USD figure. What the app cannot get from a token list is
5722
+ * everything ABOUT the market behind a receipt token — its name, its protocol,
5723
+ * the rate it pays, how large it is. That is what this service supplies.
5724
+ *
5725
+ * ## Why this is separate from supplying
5726
+ *
5727
+ * Supplying is narrow on purpose: only the markets CoinPool curates, and only the
5728
+ * protocol families the FE can encode a deposit for. Those limits come from the
5729
+ * write path and have nothing to do with reading.
5730
+ *
5731
+ * A wallet, meanwhile, can hold any receipt token at all — aWETH on Base, an
5732
+ * uncurated Morpho vault, a receipt from a chain `/supply/v2` does not cover.
5733
+ * Each of those describes its own market on chain, so each is readable. Gating a
5734
+ * read on the supply catalogue would make a position the user genuinely holds
5735
+ * vanish from the app for a reason that belongs to a different feature, so this
5736
+ * service applies NO catalogue restriction and NO chain restriction.
5737
+ *
5738
+ * ## What this does NOT cover
5739
+ *
5740
+ * The one real limit is the SHAPE of the receipt token, and it is worth stating
5741
+ * plainly because "reads everything" is the easy thing to assume here.
5742
+ *
5743
+ * {@link file://./discovery.ts} identifies a token by the accessor only its
5744
+ * family implements, and it probes three: Aave v3's `POOL()` +
5745
+ * `UNDERLYING_ASSET_ADDRESS()`, Compound v3's `baseToken()`, and ERC-4626's
5746
+ * `asset()`. A token answering none of them returns null — so Aave **v2**
5747
+ * (`LENDING_POOL()`), Compound **v2** (cToken `underlying()`), and any other
5748
+ * non-4626 design are NOT seen. Verified: `aUSDC` (v2) and `cDAI` (v2) both
5749
+ * resolve to null, while `sDAI` (a genuine 4626) resolves.
5750
+ *
5751
+ * That null is indistinguishable from "this is a plain ERC-20", so an unseen
5752
+ * protocol fails INVISIBLY rather than loudly — no error, the position simply
5753
+ * does not appear. Widening coverage means adding a probe in `discovery.ts`, not
5754
+ * adding a class in `protocols.ts`.
5755
+ *
5756
+ * Note the asymmetry with the catalogue path: a market that arrives from
5757
+ * `/supply/v2` with an unrecognised `type` still gets described, because
5758
+ * `protocolFor` falls back to generic ERC-4626 handling. Only the probe path
5759
+ * drops what it cannot identify.
5760
+ *
5761
+ * ## Chain first, catalogue second
5762
+ *
5763
+ * Identification happens ON CHAIN: a receipt token answers the accessor only its
5764
+ * family implements, so the market behind it is derivable without asking anyone.
5765
+ * That puts curated and uncurated markets on the SAME path. Under catalogue-first,
5766
+ * Base USDC was resolved by an endpoint while Base WETH was resolved by a probe,
5767
+ * so the two could disagree and only one was exercised in testing.
5768
+ *
5769
+ * `/supply/v2` is therefore NOT consulted on this path at all: it defines which
5770
+ * markets can be supplied to, and reading has no business paying for it. The
5771
+ * catalogue would only have contributed cosmetics anyway — a curated display
5772
+ * name, a platform score, a market deep link — so a market read here carries the
5773
+ * name and protocol chain reports. Every number is identical either way.
5774
+ *
5775
+ * (The supply-POSITIONS path below is different, and still catalogue-driven: it
5776
+ * answers "what did the user supply to a curated market", which is a question
5777
+ * about the catalogue by definition.)
5778
+ *
5779
+ * APY history is unaffected — Compound and generic 4626 markets read theirs from
5780
+ * `/supply/rates/history`, a different endpoint, queried per market.
5781
+ *
5782
+ * See {@link file://./LendingSupplyService.ts} for the write path, and
5783
+ * {@link file://./describe.ts} for the pipeline both share.
5784
+ */
5785
+
5786
+ declare class LendingReadService {
5787
+ private readonly coinPoolBaseUrl;
5788
+ private readonly endpoints;
5789
+ private readonly describer;
5790
+ constructor(coinPoolBaseUrl: string, endpoints: ApyEndpoints, describer: MarketDescriber);
5791
+ /**
5792
+ * Describe the markets behind a wallet's RECEIPT TOKENS — the app's entry
5793
+ * point. Given the yield-bearing token addresses the app already has, returns
5794
+ * each one's market with its asset, size, live APY and weekly average.
5795
+ *
5796
+ * Keyed by the LOWERCASED token address, with an entry only for tokens that
5797
+ * resolved: a token that identifies itself as no lending receipt is simply
5798
+ * absent, which is the honest answer rather than a null the caller must filter.
5799
+ *
5800
+ * Batched end to end, which is the point of taking a list rather than one
5801
+ * token: identifying five vault shares costs the same two multicalls as
5802
+ * identifying one, and describing them shares a third. Calling
5803
+ * {@link findMarketByReceiptToken} five times instead would cost roughly five
5804
+ * times as much.
5805
+ *
5806
+ * Works on any chain the RPC layer serves, curated or not. Never throws.
5807
+ *
5808
+ * @param rpcUrl Optional endpoint for `chain`, installed as this core's
5809
+ * override before the read — see {@link registerRpcUrl}. Pass it for any chain
5810
+ * this core carries no definition for; omit it to use the resolved defaults.
5811
+ */
5812
+ describeReceiptTokens(chain: string, tokens: readonly string[], rpcUrl?: string): Promise<Map<string, LendingMarketOverview>>;
5813
+ /**
5814
+ * The market ONE receipt token belongs to — "the user holds this aToken /
5815
+ * Comet / vault share; which market is it?" — described with its size and APY.
5816
+ *
5817
+ * A thin wrapper over {@link describeReceiptTokens}; prefer that one whenever
5818
+ * you have more than a single token, since it batches. Null when the token
5819
+ * identifies itself as no lending receipt, or its market could not be
5820
+ * described. Never throws.
5821
+ *
5822
+ * @param rpcUrl Optional endpoint for `chain` — see {@link describeReceiptTokens}.
5823
+ */
5824
+ findMarketByReceiptToken(chain: string, receiptToken: string, rpcUrl?: string): Promise<LendingMarketOverview | null>;
5825
+ /**
5826
+ * Every market on `chains` the wallet currently supplies to, highest supplied
5827
+ * amount first.
5828
+ *
5829
+ * Scoped to the CURATED catalogue — this walks `/supply/v2`'s markets and
5830
+ * checks the wallet's balance in each, so it reports what the CoinPool product
5831
+ * covers, on whichever chains it covers them (asked, never assumed). A wallet
5832
+ * holding a receipt token from outside that set is not found here;
5833
+ * {@link describeReceiptTokens} is the entry point for those, since it starts
5834
+ * from tokens the caller already knows about rather than from a catalogue to
5835
+ * scan.
5836
+ *
5837
+ * Any asset, not just USDC: each market's own underlying decides what its
5838
+ * balance is denominated in, and {@link LendingSupplyPosition.asset} reports it.
5839
+ *
5840
+ * Chains are queried in parallel and contribute independently: a chain whose
5841
+ * API or RPC fails yields nothing rather than failing the whole call.
5842
+ * Positions worth less than {@link DUST_USDC} are dropped as withdrawal residue.
5843
+ */
5844
+ getSupplyPositions(params: {
5532
5845
  address: string;
5533
- decimals: number;
5534
- } | null;
5846
+ chains: readonly string[];
5847
+ }): Promise<LendingSupplyPosition[]>;
5848
+ /** Size + APY for markets already resolved elsewhere, in the order given. */
5849
+ describeResolvedMarkets(chain: string, markets: LendingMarket[]): Promise<LendingMarketOverview[]>;
5850
+ /** Supply positions on ONE chain: market list → balances → supplied amount + overview. */
5851
+ private positionsForChain;
5852
+ }
5853
+
5854
+ /**
5855
+ * Supplying — the WRITE path, and the narrower of the two.
5856
+ *
5857
+ * TWO limits define it, and both are stated here rather than scattered across
5858
+ * the tools that enforce them:
5859
+ *
5860
+ * 1. **Curated markets only.** `/supply/v2` is what says a market exists to
5861
+ * deposit into. A market discovered on chain is readable but not suppliable:
5862
+ * nobody curated it, nobody scored it, and it was never checked.
5863
+ * 2. **Encodable protocols only** — {@link SUPPLIABLE_TYPES}. The deposit call
5864
+ * differs per family, so a market outside this set has no correct calldata
5865
+ * and would fail at signing, AFTER the user had already approved the asset
5866
+ * to it. That is the worst possible failure point, which is why the check
5867
+ * lives in the service rather than at the edge.
5868
+ *
5869
+ * There is no third limit any more. Supplying used to be pinned to five hardcoded
5870
+ * chains and to USDC; both are now consequences of limit 1 rather than rules of
5871
+ * their own — the chains are whichever ones the catalogue answers for
5872
+ * ({@link listChains}), and the asset is whatever each market's own underlying
5873
+ * turns out to be. Neither is declared in this repository, so CoinPool adding a
5874
+ * chain or a non-USDC market needs no code change here.
5875
+ *
5876
+ * Those limits belong to supplying alone. Reading is wider still — no catalogue
5877
+ * and no chain set at all — see {@link file://./LendingReadService.ts}.
5878
+ *
5879
+ * As with everything in this core, no transaction is built or signed here: this
5880
+ * resolves and validates a market, and the FE owns the allowance check, the
5881
+ * per-protocol encoding and the signing.
5882
+ */
5883
+
5884
+ /**
5885
+ * The protocol families the FE can encode a deposit for. A market whose `type`
5886
+ * falls outside this set is refused rather than sent to the form.
5887
+ *
5888
+ * NOTE this is narrower than the set of types the READ path handles: reading
5889
+ * falls back to generic ERC-4626 for an unrecognised type, which is right for
5890
+ * describing a market and wrong for depositing into one, where a guess costs the
5891
+ * user their approval.
5892
+ */
5893
+ declare const SUPPLIABLE_TYPES: readonly SupplyProtocolType[];
5894
+ /** A market that passed every supply check — {@link LendingSupplyService.canSupply}. */
5895
+ interface SuppliableMarket extends LendingMarket {
5896
+ type: SupplyProtocolType;
5897
+ }
5898
+ declare class LendingSupplyService {
5899
+ private readonly coinPoolBaseUrl;
5900
+ constructor(coinPoolBaseUrl: string);
5901
+ /**
5902
+ * Hex chain ids a supply can target — the chains the catalogue actually
5903
+ * answers for, asked at call time rather than read from a table.
5904
+ */
5905
+ listChains(): Promise<string[]>;
5906
+ /** True when a chain (any alias / hex / decimal form) can be supplied on. */
5907
+ isSupported(chain?: string | null): Promise<boolean>;
5908
+ /** Every curated market on a chain. Empty when the chain has none. */
5909
+ getMarkets(chain: string): Promise<LendingMarket[]>;
5910
+ /**
5911
+ * Resolve ONE market on a chain from a free-text reference — the market name,
5912
+ * the protocol, or the contract address.
5913
+ *
5914
+ * Returns every close match rather than guessing when the reference is
5915
+ * ambiguous ("Morpho" on a chain with several Morpho vaults): depositing into
5916
+ * the wrong vault is not reversible, so the caller asks instead of picking.
5917
+ */
5918
+ findMarket(chain: string, reference: string): Promise<LendingMarket[]>;
5919
+ /**
5920
+ * Whether a deposit into this market can actually be encoded — the last gate
5921
+ * before a form opens. Narrows the type as it answers, so a caller that passes
5922
+ * this has a {@link SuppliableMarket} rather than a market with a string type.
5923
+ */
5924
+ canSupply(market: LendingMarket): market is SuppliableMarket;
5535
5925
  /**
5536
5926
  * The receipt token a supply into `market` credits — its own ERC-20 symbol and
5537
5927
  * decimals, read on chain in one multicall.
@@ -5554,26 +5944,232 @@ declare class LendingService {
5554
5944
  decimals: number | null;
5555
5945
  isUnderlying: boolean;
5556
5946
  }>;
5947
+ }
5948
+
5949
+ /**
5950
+ * Chain-id arithmetic for the lending module — a LEAF, importing nothing from
5951
+ * the rest of it.
5952
+ *
5953
+ * `chains.ts` is where "which chains can be supplied on?" is answered, and that
5954
+ * answer now comes from the catalogue, so `chains.ts` imports `catalog.ts`. The
5955
+ * catalogue in turn needs to parse a chain id before it can request one. These
5956
+ * two functions are what it needs and they depend on nothing, so they live here
5957
+ * rather than completing an import cycle.
5958
+ *
5959
+ * `chains.ts` re-exports both, so callers keep importing them from there.
5960
+ */
5961
+
5962
+ /**
5963
+ * Stands in for "this market's asset could not be established" — a sentinel,
5964
+ * never an address to read or approve.
5965
+ *
5966
+ * A market that cannot name its own underlying used to be attributed to the
5967
+ * chain's USDC. That was a guess, and a costly one on the supply path: the user
5968
+ * would approve and spend USDC against a market lending something else. There is
5969
+ * no chain-level asset to fall back to any more, so the resolver reports this
5970
+ * address with NaN decimals instead, which suppresses the market's size on the
5971
+ * read path and blocks the form on the write path.
5972
+ */
5973
+ declare const UNRESOLVED_ASSET = "0x0000000000000000000000000000000000000000";
5974
+
5975
+ /**
5976
+ * Which chains lending works on — and the distinction that runs through this
5977
+ * whole module: **reading is wider than supplying**.
5978
+ *
5979
+ * The two are not the same set and must never be conflated:
5980
+ *
5981
+ * - **Supply chains** — wherever CoinPool actually returns curated markets, asked
5982
+ * at runtime rather than declared here. `/supply/v2` is what says a market
5983
+ * exists; this module's job is to ASK it, not to predict its answer.
5984
+ * - **Read chains** — anywhere at all. A receipt token identifies its own market
5985
+ * on chain (see `discovery.ts`), so describing an aWETH position on a chain
5986
+ * CoinPool never heard of is perfectly possible. Reading is gated by what the
5987
+ * RPC layer supports, not by the supply catalogue.
5988
+ *
5989
+ * Gating a READ on the supply set is the bug this split exists to prevent: it
5990
+ * makes a position the user genuinely holds disappear from the app, for the
5991
+ * unrelated reason that nobody can deposit there through us.
5992
+ *
5993
+ * ## Why there is no chain table here any more
5994
+ *
5995
+ * There used to be a five-entry `SUPPLY_CHAINS` map, each with a hardcoded USDC
5996
+ * address. It was wrong in both directions: CoinPool adding a chain did nothing
5997
+ * until someone edited this file, and a market that lends something other than
5998
+ * USDC had no way to say so. Both facts already exist upstream — the chain list
5999
+ * is whatever `/supply/v2` answers for, and the asset is whatever the market's
6000
+ * own `underlyingCall` returns on chain — so both are read from there now.
6001
+ *
6002
+ * The candidate chains to ASK are the RPC layer's own active set
6003
+ * ({@link listCandidateChains}); a chain the core cannot reach has nothing to
6004
+ * offer a supply flow even if CoinPool lists it.
6005
+ *
6006
+ * Every function that consults the catalogue takes the CoinPool base URL, since
6007
+ * a host may point the core at its own deployment — there is no global default
6008
+ * hiding in here for the same reason there is no chain table.
6009
+ */
6010
+
6011
+ /**
6012
+ * The chains worth ASKING `/supply/v2` about — the RPC layer's active set.
6013
+ *
6014
+ * Not a claim that any of them has markets; that is what {@link listSupplyChains}
6015
+ * resolves. A chain the core has no RPC for is excluded because every downstream
6016
+ * step (market size, balances, receipt-token metadata) needs one.
6017
+ */
6018
+ declare function listCandidateChains(): string[];
6019
+ /**
6020
+ * Hex chain ids that currently have curated supply markets, discovered by asking
6021
+ * `/supply/v2` for every candidate chain in parallel.
6022
+ *
6023
+ * Live, not declared: a chain CoinPool adds shows up here with no code change,
6024
+ * and one it drops disappears. `catalog.ts` caches each chain's answer briefly,
6025
+ * so the repeated calls one turn makes cost a single round of requests.
6026
+ */
6027
+ declare function listSupplyChains(baseUrl: string): Promise<string[]>;
6028
+ /**
6029
+ * True when a chain (any alias / hex / decimal form) has curated supply markets
6030
+ * right now — asked, not assumed.
6031
+ */
6032
+ declare function isSupplyChain(baseUrl: string, chain?: string | null): Promise<boolean>;
6033
+
6034
+ /**
6035
+ * The lending domain, in one object — a facade over two services split by what
6036
+ * they are FOR.
6037
+ *
6038
+ * ## The split, and why it exists
6039
+ *
6040
+ * Reading and supplying want different things, and an earlier single class made
6041
+ * them share limits that belong to only one of them:
6042
+ *
6043
+ * - **{@link read} — {@link LendingReadService}. Every asset, every chain.**
6044
+ * What the Keyring app consumes. A wallet can hold any receipt token at all:
6045
+ * aWETH on Base, an uncurated Morpho vault, a receipt from a chain
6046
+ * `/supply/v2` never covered. Each of those describes its own market on chain,
6047
+ * so each is describable — provided its receipt token is one of the three
6048
+ * shapes the probes recognise (Aave v3 aToken, Comet, ERC-4626); Aave v2 and
6049
+ * Compound v2 are NOT among them. See that service's "What this does NOT
6050
+ * cover". The app already knows WHICH tokens a wallet
6051
+ * holds (its token API tags them `yieldProtocol` / `yieldAsset`, and
6052
+ * {@link file://./lending/yieldTokenValue.ts} values them); what it cannot get
6053
+ * from a token list is the market behind the token, which is what
6054
+ * {@link LendingReadService.describeReceiptTokens} answers — in one batch.
6055
+ *
6056
+ * - **{@link supply} — {@link LendingSupplyService}. Curated and encodable.**
6057
+ * Narrower on purpose, but along two axes only: `/supply/v2` decides a market
6058
+ * exists, and only the protocol families the FE can encode a deposit for may be
6059
+ * targeted. That second limit comes from the write path — a market with no
6060
+ * correct calldata fails at signing, after the user already approved the asset
6061
+ * to it. Neither the CHAIN nor the ASSET is limited here: the chains are
6062
+ * whichever ones the catalogue answers for, and each market's asset is read
6063
+ * from the market itself, so a non-USDC market supplies its own asset.
6064
+ *
6065
+ * Gating a READ on the supply set is the specific bug this split prevents — it
6066
+ * makes a position the user genuinely holds disappear from the app, for the
6067
+ * unrelated reason that nobody can deposit there through us.
6068
+ *
6069
+ * Both halves share one pipeline ({@link file://./lending/describe.ts}) and one
6070
+ * APY concurrency budget, so a wide scan stays polite to every upstream.
6071
+ *
6072
+ * ## Where the numbers come from
6073
+ *
6074
+ * A wallet's supplied balance is NOT read from an indexer: the receipt token
6075
+ * (aToken / Comet / ERC-4626 vault share) is read straight from chain through
6076
+ * Multicall3, so the number always matches what the app shows. Everything else
6077
+ * comes from the same sources the CoinPool web app itself uses — its
6078
+ * `useUsdcLendingData` hook, in the SEPARATE `coinpool-v2` repository
6079
+ * (`src/hooks/useUsdcLendingData.ts`), is the reference this service was checked
6080
+ * against protocol by protocol:
6081
+ *
6082
+ * - market list ................. CoinPool `GET /supply/v2?chainId=…`
6083
+ * - supply-APY history ......... Aave v3 GraphQL (`aave-v3`),
6084
+ * Morpho GraphQL (`morpho-v2`),
6085
+ * CoinPool `GET /supply/rates/history` (rest)
6086
+ * - supplied amount / market size on-chain via Multicall3
6087
+ *
6088
+ * Reported APY is the AVERAGE of the daily supply-APY samples of the last
6089
+ * `APY_HISTORY_DAYS` days plus the live rate — a spot rate swings with borrow
6090
+ * demand, so an average is what a supplier actually earns.
6091
+ *
6092
+ * ## Protocols differ; the pipeline does not
6093
+ *
6094
+ * The market kinds disagree on every input: where the market size lives, whether
6095
+ * the receipt token is 1:1 with USDC or an ERC-4626 share, which API knows the
6096
+ * rate history, and whether a live rate has to come off-chain. Each kind is a
6097
+ * class in {@link file://./lending/protocols.ts}; the pipeline drives them and
6098
+ * knows about no protocol by name.
6099
+ *
6100
+ * | | market size | balance | APY history | live APY |
6101
+ * |--------------|----------------|-------------|-------------|------------|
6102
+ * | aave-v3 | aToken supply | underlying | Aave API | on-chain |
6103
+ * | compound-v3 | Comet supply | underlying | CoinPool | newest row |
6104
+ * | spark* | totalAssets() | ERC-4626 | CoinPool | newest row |
6105
+ * | morpho-v2 | totalAssets() | ERC-4626 | Morpho API | from API |
6106
+ *
6107
+ * Two entries in that last column are worth stating outright, because the app
6108
+ * looks like it disagrees. The app derives EVERY protocol's live rate on-chain,
6109
+ * each with its own formula; here only Aave does. That is not a shortcut taken
6110
+ * blindly — CoinPool's history endpoint refreshes intraday and its newest row
6111
+ * was checked against chain to six decimals for all three protocols that use it.
6112
+ * Aave is the one case where the API and the on-chain figure genuinely differ,
6113
+ * so it is the one case that pays for the extra call.
6114
+ *
6115
+ * Protocols DECLARE their on-chain calls rather than making them, so every
6116
+ * market on a chain still resolves in ONE Multicall3 round-trip regardless of
6117
+ * how many protocols are involved — see the protocols module for why.
6118
+ *
6119
+ * Independent of {@link file://./MoralisService.ts}: these markets are curated
6120
+ * by the CoinPool platform and an indexer neither knows the curated set nor the
6121
+ * vault share → USDC conversion.
6122
+ */
6123
+ declare class LendingService {
6124
+ /** Reading: every asset, every chain; Aave v3 / Comet / ERC-4626 receipt shapes. */
6125
+ readonly read: LendingReadService;
6126
+ /** Supplying: curated markets and encodable protocols only — any chain, any asset. */
6127
+ readonly supply: LendingSupplyService;
6128
+ constructor(config?: LendingServiceConfig);
6129
+ /** Hex chain ids with curated supply markets, as the catalogue reports them now. */
6130
+ listSupportedChains(): Promise<string[]>;
6131
+ /** True when the given chain (any alias / hex / decimal form) can be supplied on. */
6132
+ isSupported(chain?: string | null): Promise<boolean>;
6133
+ /** Every curated market on a chain. Empty when it has none; never throws. */
6134
+ getMarkets(chain: string): Promise<LendingMarket[]>;
6135
+ /** Resolve markets on a chain from a name, protocol or contract address. */
6136
+ findMarket(chain: string, reference: string): Promise<LendingMarket[]>;
6137
+ /** Whether a deposit into this market can be encoded by the FE. */
6138
+ canSupply(market: LendingMarket): boolean;
6139
+ /** ERC-20 symbol + decimals of the receipt token a supply credits. */
6140
+ readReceiptToken(chain: string, market: Pick<LendingMarket, 'token' | 'type'>): Promise<{
6141
+ symbol: string | null;
6142
+ decimals: number | null;
6143
+ isUnderlying: boolean;
6144
+ }>;
5557
6145
  /**
5558
- * Resolve ONE market on a chain from a free-text reference — the market name,
5559
- * the protocol, or the contract address — for the supply flow, which needs a
5560
- * single unambiguous target rather than a ranked list.
6146
+ * Describe the markets behind a wallet's receipt tokens, batched. The app's
6147
+ * entry point for showing assets other than USDC — see
6148
+ * {@link LendingReadService.describeReceiptTokens}.
5561
6149
  *
5562
- * Returns every close match rather than guessing when the reference is
5563
- * ambiguous ("Morpho" on a chain with several Morpho vaults): depositing into
5564
- * the wrong vault is not something the user can undo, so the caller asks
5565
- * instead of picking. An exact name or contract match always wins outright.
6150
+ * @param rpcUrl Optional endpoint for `chain`, installed as this core's RPC
6151
+ * override before the read. Pass the host's own endpoint for any chain this
6152
+ * core carries no definition for — without one the read comes back empty as
6153
+ * though the token were a plain ERC-20.
5566
6154
  */
5567
- findMarket(chain: string, reference: string): Promise<LendingMarket[]>;
6155
+ describeReceiptTokens(chain: string, tokens: readonly string[], rpcUrl?: string): Promise<Map<string, LendingMarketOverview>>;
5568
6156
  /**
5569
- * Size + APY for markets already resolved by {@link findMarket}, so the supply
5570
- * flow can quote a rate without re-listing (and re-pricing) the whole chain.
5571
- * Returns them in the order given; empty when the chain is unsupported.
6157
+ * The market ONE receipt token belongs to. Prefer {@link describeReceiptTokens} for several.
6158
+ *
6159
+ * @param rpcUrl Optional endpoint for `chain` — see {@link describeReceiptTokens}.
5572
6160
  */
6161
+ findMarketByReceiptToken(chain: string, receiptToken: string, rpcUrl?: string): Promise<LendingMarketOverview | null>;
6162
+ /** Size + APY for markets already resolved by {@link findMarket}, in the order given. */
5573
6163
  describeResolvedMarkets(chain: string, markets: LendingMarket[]): Promise<LendingMarketOverview[]>;
5574
6164
  /**
5575
6165
  * Every curated market on `chains`, each with its size and APY — the "where
5576
- * can I supply USDC?" view. Highest average APY first, unrated markets last.
6166
+ * can I supply?" view. Highest average APY first, unrated markets last.
6167
+ *
6168
+ * No chain is filtered out in advance: a chain with no markets contributes an
6169
+ * empty catalogue and therefore nothing, which is the same outcome an
6170
+ * allowlist would produce and costs one request instead of a stale assumption.
6171
+ * Each market reports its own {@link LendingMarketOverview.asset}, so a
6172
+ * non-USDC market is listed as itself rather than dropped.
5577
6173
  *
5578
6174
  * Chains are queried in parallel and contribute independently: a chain whose
5579
6175
  * API or RPC fails yields nothing rather than failing the whole call.
@@ -5582,69 +6178,14 @@ declare class LendingService {
5582
6178
  chains: readonly string[];
5583
6179
  }): Promise<LendingMarketOverview[]>;
5584
6180
  /**
5585
- * Every lending market the wallet currently supplies to, across `chains`,
5586
- * highest supplied amount first. Same parallelism and failure isolation as
5587
- * {@link getMarketOverviews}; positions worth less than {@link DUST_USDC} are
5588
- * dropped as withdrawal residue.
6181
+ * Every curated lending market the wallet currently supplies to, across
6182
+ * `chains`, highest supplied amount first — see
6183
+ * {@link LendingReadService.getSupplyPositions}.
5589
6184
  */
5590
6185
  getSupplyPositions(params: {
5591
6186
  address: string;
5592
6187
  chains: readonly string[];
5593
6188
  }): Promise<LendingSupplyPosition[]>;
5594
- /** Supply positions on ONE chain: market list → balances → supplied amount + overview. */
5595
- private positionsForChain;
5596
- /**
5597
- * Attach market size and the APY series to each market — one batched on-chain
5598
- * read plus one API call per market, both at once. Order is preserved, so
5599
- * callers can zip the result with their own per-market data. Never throws.
5600
- */
5601
- private describeMarkets;
5602
- /**
5603
- * Every market's receipt-token balance + decimals in one batch, narrowed to the
5604
- * markets the wallet actually holds something in — the step that decides how
5605
- * much further work the rest of the flow has to do.
5606
- */
5607
- private readBalances;
5608
- /**
5609
- * On-chain state of each market, aligned with `markets`: its size and its live
5610
- * supply rate.
5611
- *
5612
- * This is where the batching lives. Each market's protocol only DECLARES the
5613
- * calls it wants ({@link LendingProtocol.sizeCall}, {@link LendingProtocol.liveRateCall});
5614
- * they are pooled here into a single multicall, and each protocol then decodes
5615
- * its own slice of the result. Twenty markets across four protocols still cost
5616
- * one RPC round-trip.
5617
- *
5618
- * Compound and Spark need a SECOND call that depends on the first's answer
5619
- * (`getSupplyRate` of the utilization just read; `getAPR` on the rate provider
5620
- * just named), so a second round follows when any market asks for one. Those
5621
- * follow-ups are batched together too — two round-trips per chain at worst,
5622
- * never two per market.
5623
- *
5624
- * Either field is null when its call failed or decoded implausibly.
5625
- */
5626
- private readMarketState;
5627
- /**
5628
- * Each held balance as USDC, aligned with `held`. A protocol whose receipt
5629
- * token is an ERC-4626 share declares a `convertToAssets` call; one whose
5630
- * balance is already underlying declares none. As with {@link readMarketState},
5631
- * every conversion across every protocol shares ONE multicall.
5632
- *
5633
- * A vault whose conversion reverts falls back to the raw balance in the share
5634
- * token's own decimals — an approximation that beats dropping the position
5635
- * outright.
5636
- */
5637
- private convertToUnderlying;
5638
- /**
5639
- * Historical supply-APY samples for one market, from whichever upstream its
5640
- * protocol queries, plus that source's own live rate where it reports one.
5641
- *
5642
- * Unlike the on-chain reads there is nothing to batch here — each protocol
5643
- * talks to a different API, one request per market — so the protocol performs
5644
- * the fetch itself. Never throws: an unreachable source yields no samples, so
5645
- * the market is still listed, just without APY.
5646
- */
5647
- private fetchApySamples;
5648
6189
  }
5649
6190
 
5650
6191
  type LendingMarketsToolConfig = LendingServiceConfig;
@@ -5653,7 +6194,7 @@ type SortKey = 'apy' | 'score' | 'size';
5653
6194
  /**
5654
6195
  * Tool: get-lending-markets
5655
6196
  *
5656
- * The USDC lending markets a user CAN supply to — the catalogue side of the
6197
+ * The lending markets a user CAN supply to — the catalogue side of the
5657
6198
  * lending domain, as opposed to `get-wallet-lending-positions` which reports
5658
6199
  * what a wallet already supplies. Each market carries its size, the protocol's
5659
6200
  * live supply APY — the rate the list is ranked on, and the one a depositor is
@@ -5707,6 +6248,12 @@ declare class LendingMarketsTool extends BaseTool {
5707
6248
  currentApyPercent: number | null;
5708
6249
  apyChangePercent: number | null;
5709
6250
  totalSuppliedUsdc: number | null;
6251
+ /**
6252
+ * What `totalSuppliedUsdc` is denominated in. Almost always USDC, but a
6253
+ * market on another asset reports its own — so the formatting rule below
6254
+ * can say "dollars" only when this actually is a dollar stablecoin.
6255
+ */
6256
+ suppliedAssetSymbol: string | null;
5710
6257
  platformScore: number | null;
5711
6258
  }[];
5712
6259
  protocolFilter?: string | undefined;
@@ -5780,6 +6327,16 @@ declare class WalletLendingPositionsTool extends BaseTool {
5780
6327
  chainsQueried: string[];
5781
6328
  positionCount: number;
5782
6329
  totals: {
6330
+ mixedAssets: boolean;
6331
+ suppliedUsdc: null;
6332
+ estimatedAnnualYieldUsdc: null;
6333
+ weightedAvgApyPercent: null;
6334
+ /** Denominated in the single asset every position shares. */
6335
+ assetSymbol?: undefined;
6336
+ } | {
6337
+ mixedAssets: boolean;
6338
+ /** Denominated in the single asset every position shares. */
6339
+ assetSymbol: string | null;
5783
6340
  suppliedUsdc: number;
5784
6341
  estimatedAnnualYieldUsdc: number;
5785
6342
  weightedAvgApyPercent: number | null;
@@ -5790,6 +6347,8 @@ declare class WalletLendingPositionsTool extends BaseTool {
5790
6347
  protocolUrl: string | null;
5791
6348
  chain: string;
5792
6349
  suppliedUsdc: number;
6350
+ /** What `suppliedUsdc` and `estimatedAnnualYieldUsdc` are denominated in. */
6351
+ suppliedAssetSymbol: string | null;
5793
6352
  avgApyPercent: number | null;
5794
6353
  currentApyPercent: number | null;
5795
6354
  apyChangePercent: number | null;
@@ -5806,16 +6365,22 @@ declare class WalletLendingPositionsTool extends BaseTool {
5806
6365
  }
5807
6366
 
5808
6367
  interface OpenSupplyFormToolConfig extends LendingServiceConfig {
5809
- /** Moralis config for the USDC balance shown on the form. */
6368
+ /** Moralis config for the asset balance shown on the form. */
5810
6369
  moralis?: MoralisServiceConfig;
5811
6370
  }
5812
6371
  /**
5813
6372
  * Tool: open-supply-usdc-form
5814
6373
  *
5815
- * Opens the form that deposits USDC into ONE lending market. The counterpart to
6374
+ * Opens the form that deposits into ONE lending market. The counterpart to
5816
6375
  * `get-lending-markets`, which only lists what is available: this resolves the
5817
- * market the user picked, checks their USDC balance, and hands the FE everything
5818
- * it needs to run the approve → supply sequence itself.
6376
+ * market the user picked, reads the asset THAT market lends, checks the wallet's
6377
+ * balance of it, and hands the FE everything it needs to run the approve →
6378
+ * supply sequence itself.
6379
+ *
6380
+ * The asset is never assumed to be USDC. `/supply/v2` decides which markets
6381
+ * exist and `LendingService` resolves each one's underlying on chain, so a
6382
+ * market on WETH is supplied in WETH; USDC is only the fallback for a market
6383
+ * whose asset could not be read. See {@link supplyAsset}.
5819
6384
  *
5820
6385
  * Like every wallet action in this core, the tool does NOT build or sign a
5821
6386
  * transaction — it resolves and validates, then emits a `SupplyUsdcForm` payload.
@@ -5839,7 +6404,8 @@ declare class OpenSupplyFormTool extends BaseTool {
5839
6404
  candidates?: undefined;
5840
6405
  marketName?: undefined;
5841
6406
  protocol?: undefined;
5842
- usdcBalance?: undefined;
6407
+ assetSymbol?: undefined;
6408
+ assetBalance?: undefined;
5843
6409
  requestedAmount?: undefined;
5844
6410
  ui?: undefined;
5845
6411
  apyPercent?: undefined;
@@ -5852,7 +6418,8 @@ declare class OpenSupplyFormTool extends BaseTool {
5852
6418
  candidates?: undefined;
5853
6419
  marketName?: undefined;
5854
6420
  protocol?: undefined;
5855
- usdcBalance?: undefined;
6421
+ assetSymbol?: undefined;
6422
+ assetBalance?: undefined;
5856
6423
  requestedAmount?: undefined;
5857
6424
  ui?: undefined;
5858
6425
  apyPercent?: undefined;
@@ -5865,7 +6432,8 @@ declare class OpenSupplyFormTool extends BaseTool {
5865
6432
  candidates?: undefined;
5866
6433
  marketName?: undefined;
5867
6434
  protocol?: undefined;
5868
- usdcBalance?: undefined;
6435
+ assetSymbol?: undefined;
6436
+ assetBalance?: undefined;
5869
6437
  requestedAmount?: undefined;
5870
6438
  ui?: undefined;
5871
6439
  apyPercent?: undefined;
@@ -5881,7 +6449,8 @@ declare class OpenSupplyFormTool extends BaseTool {
5881
6449
  chainsWithLendingMarkets?: undefined;
5882
6450
  marketName?: undefined;
5883
6451
  protocol?: undefined;
5884
- usdcBalance?: undefined;
6452
+ assetSymbol?: undefined;
6453
+ assetBalance?: undefined;
5885
6454
  requestedAmount?: undefined;
5886
6455
  ui?: undefined;
5887
6456
  apyPercent?: undefined;
@@ -5894,20 +6463,22 @@ declare class OpenSupplyFormTool extends BaseTool {
5894
6463
  chainsWithLendingMarkets?: undefined;
5895
6464
  market?: undefined;
5896
6465
  candidates?: undefined;
5897
- usdcBalance?: undefined;
6466
+ assetSymbol?: undefined;
6467
+ assetBalance?: undefined;
5898
6468
  requestedAmount?: undefined;
5899
6469
  ui?: undefined;
5900
6470
  apyPercent?: undefined;
5901
6471
  } | {
5902
6472
  error: string;
6473
+ marketName: string;
5903
6474
  chain: string;
5904
6475
  _instructions: string;
5905
6476
  chainsWithLendingMarkets?: undefined;
5906
6477
  market?: undefined;
5907
6478
  candidates?: undefined;
5908
- marketName?: undefined;
5909
6479
  protocol?: undefined;
5910
- usdcBalance?: undefined;
6480
+ assetSymbol?: undefined;
6481
+ assetBalance?: undefined;
5911
6482
  requestedAmount?: undefined;
5912
6483
  ui?: undefined;
5913
6484
  apyPercent?: undefined;
@@ -5915,7 +6486,8 @@ declare class OpenSupplyFormTool extends BaseTool {
5915
6486
  error: string;
5916
6487
  marketName: string;
5917
6488
  chain: string;
5918
- usdcBalance: string;
6489
+ assetSymbol: string;
6490
+ assetBalance: string;
5919
6491
  _instructions: string;
5920
6492
  chainsWithLendingMarkets?: undefined;
5921
6493
  market?: undefined;
@@ -5928,8 +6500,9 @@ declare class OpenSupplyFormTool extends BaseTool {
5928
6500
  error: string;
5929
6501
  marketName: string;
5930
6502
  chain: string;
6503
+ assetSymbol: string;
5931
6504
  requestedAmount: string | null;
5932
- usdcBalance: string;
6505
+ assetBalance: string;
5933
6506
  _instructions: string;
5934
6507
  chainsWithLendingMarkets?: undefined;
5935
6508
  market?: undefined;
@@ -5943,7 +6516,8 @@ declare class OpenSupplyFormTool extends BaseTool {
5943
6516
  protocol: string;
5944
6517
  chain: string;
5945
6518
  apyPercent: number | null;
5946
- usdcBalance: string | null;
6519
+ assetSymbol: string;
6520
+ assetBalance: string | null;
5947
6521
  _instructions: string;
5948
6522
  error?: undefined;
5949
6523
  chainsWithLendingMarkets?: undefined;
@@ -5954,24 +6528,24 @@ declare class OpenSupplyFormTool extends BaseTool {
5954
6528
  /** Size + live APY for the one resolved market. Null when it can't be priced. */
5955
6529
  private describeOne;
5956
6530
  /**
5957
- * The wallet's USDC on this chain, for the form's spendable line and the
5958
- * balance checks above.
6531
+ * The wallet's balance of the market's asset on this chain, for the form's
6532
+ * spendable line and the balance checks above.
5959
6533
  *
5960
6534
  * The distinction that matters here is "the call FAILED" vs "the call
5961
6535
  * succeeded and reported nothing", which a bare null cannot express:
5962
6536
  *
5963
6537
  * - `null` — the balance is genuinely UNREADABLE (request failed or threw).
5964
6538
  * The form still opens: blocking a supply over a flaky call would be worse.
5965
- * - `{ amount: '0' }` — the request SUCCEEDED and returned no USDC row.
6539
+ * - `{ amount: '0' }` — the request SUCCEEDED and returned no row for it.
5966
6540
  *
5967
6541
  * The second case is the one that was being missed. `getWalletTokenBalances`
5968
6542
  * serves portfolio LISTS, so it drops zero rows and anything worth under a
5969
6543
  * cent; we asked it for this one token, so a successful call with no row means
5970
6544
  * the wallet holds nothing spendable here — not that the read failed. Reporting
5971
- * it as '0' is what lets the `no_usdc_balance` branch fire instead of opening a
5972
- * form the user cannot submit.
6545
+ * it as '0' is what lets the `no_asset_balance` branch fire instead of opening
6546
+ * a form the user cannot submit.
5973
6547
  */
5974
- private usdcBalance;
6548
+ private assetBalance;
5975
6549
  /**
5976
6550
  * Presentation contract for the synthesizer. Only reached once the supply is
5977
6551
  * actually possible — an empty or short balance returns earlier with its own
@@ -8483,6 +9057,18 @@ interface ClientBatchConfig {
8483
9057
  batchSize?: number;
8484
9058
  /** Extra ms to keep collecting before sending (default 0 — same tick). */
8485
9059
  wait?: number;
9060
+ /**
9061
+ * On a chain with NO Multicall3, batches degrade to individual
9062
+ * `eth_call`s — this bounds how many are in flight (default 8). Raise it
9063
+ * for a private node, lower it for an endpoint that rate-limits hard.
9064
+ */
9065
+ fallbackConcurrency?: number;
9066
+ /**
9067
+ * Skip the one-off `eth_getCode` that verifies Multicall3 exists, and
9068
+ * assume it does. For hosts that only ever touch chains they know carry
9069
+ * the deployment and want to save the probe. Default `false`.
9070
+ */
9071
+ assumeMulticall3?: boolean;
8486
9072
  };
8487
9073
  }
8488
9074
  interface Client {
@@ -8533,9 +9119,11 @@ type MulticallResult<TResult = unknown> = {
8533
9119
  * Chain lookup + RPC-endpoint resolution — the single source of truth for
8534
9120
  * "which node do we talk to for chain X".
8535
9121
  *
8536
- * Resolution order, unchanged from before the client rewrite:
9122
+ * Resolution order:
8537
9123
  * 1. a caller-supplied override (`AgentConfig.rpcUrls` → {@link setRpcOverrides}),
8538
- * 2. the chain definition's default public RPC.
9124
+ * 2. the remote Pantograph catalogue ({@link file://./remote.ts}), once loaded —
9125
+ * which also supplies endpoints for chains carrying no definition here,
9126
+ * 3. the chain definition's default public RPC, as the floor beneath both.
8539
9127
  *
8540
9128
  * An override changes only which endpoint is PREFERRED — the chain's built-in
8541
9129
  * endpoints stay behind it as backups, so a host that configures its own node
@@ -8565,12 +9153,30 @@ declare function setRpcOverrides(overrides?: Record<string, string>): void;
8565
9153
  /** The currently installed overrides (read-only copy). */
8566
9154
  declare function getRpcOverrides(): Readonly<Record<string, string>>;
8567
9155
  /**
8568
- * Every endpoint for a chain, most-preferred first: the caller-supplied override
8569
- * (when set) ahead of the chain's own list, which is itself ordered. Duplicates
8570
- * are dropped, so an override naming an endpoint already in the definition
9156
+ * Every endpoint for a chain, most-preferred first, from three layers:
9157
+ *
9158
+ * 1. the caller-supplied override (`AgentConfig.rpcUrls`),
9159
+ * 2. the remote Pantograph catalogue, when {@link loadRemoteChains} has run,
9160
+ * 3. the chain definition's built-in list.
9161
+ *
9162
+ * Duplicates are dropped, so an override naming an endpoint already present
8571
9163
  * simply promotes it rather than making it appear twice.
8572
9164
  *
8573
- * Empty only when the chain is neither overridden nor known.
9165
+ * The catalogue sits AHEAD of the built-ins: it is the same table the wallet
9166
+ * itself dials, maintained live, so an endpoint that has degraded since this
9167
+ * package was published is corrected there without a release. The built-ins
9168
+ * become the floor beneath it — still present, still ordered, and still the
9169
+ * whole answer whenever the catalogue has not loaded (startup, offline host,
9170
+ * API down) or does not carry the chain.
9171
+ *
9172
+ * The trade-off this accepts: the endpoint normally dialled for a known chain is
9173
+ * now chosen upstream rather than pinned in this repo, so a bad head entry in
9174
+ * the catalogue is felt on the first call rather than only as a backup. The
9175
+ * `fallback` transport covers that — it walks to the next endpoint on a
9176
+ * timeout/5xx/rate-limit — but latency is paid before it does.
9177
+ *
9178
+ * Empty only when the chain is overridden by nothing, absent from the
9179
+ * catalogue, and known to no definition.
8574
9180
  */
8575
9181
  declare function resolveRpcUrls(chainId: string | number): string[];
8576
9182
  /**
@@ -9154,6 +9760,15 @@ type StateOverride = Record<Address, StateOverrideAccount>;
9154
9760
  interface CallParameters extends TransactionRequest, BlockParameters {
9155
9761
  /** Temporary state (balances, code, storage) the call is simulated against. */
9156
9762
  stateOverride?: StateOverride;
9763
+ /**
9764
+ * Send this call on its own, never folded into the client's shared
9765
+ * `aggregate3`.
9766
+ *
9767
+ * Set by the no-Multicall3 fallback: those calls exist PRECISELY because the
9768
+ * chain has no Multicall3, so re-batching them would route them straight back
9769
+ * into the contract that isn't there.
9770
+ */
9771
+ skipBatch?: boolean;
9157
9772
  }
9158
9773
  interface CallReturnType {
9159
9774
  /** Return data, or `undefined` when the call returned nothing (`0x`). */
@@ -9234,11 +9849,16 @@ interface MulticallParameters extends BlockParameters {
9234
9849
  allowFailure?: boolean;
9235
9850
  /** Max calldata bytes per aggregated call; `0` disables splitting. */
9236
9851
  batchSize?: number;
9237
- /** Multicall3 address override — required on a chain the registry doesn't know. */
9852
+ /** Multicall3 address override — trusted as-is, skipping the deployment probe. */
9238
9853
  multicallAddress?: Address;
9239
9854
  /** Sender each read is simulated as. */
9240
9855
  account?: Address;
9241
9856
  stateOverride?: StateOverride;
9857
+ /**
9858
+ * Max `eth_call`s in flight on the no-Multicall3 fallback (default 8, or the
9859
+ * client's `batch.multicall.fallbackConcurrency`).
9860
+ */
9861
+ fallbackConcurrency?: number;
9242
9862
  }
9243
9863
  declare function multicall(client: Client, parameters: MulticallParameters & {
9244
9864
  allowFailure?: true;
@@ -9265,6 +9885,10 @@ declare function multicall(client: Client, parameters: MulticallParameters): Pro
9265
9885
  * batch. viem's `batchSize` bounds the REQUEST (calldata bytes); `maxCalls`
9266
9886
  * bounds the RESPONSE, which is what matters for reads whose returns are large
9267
9887
  * and unpredictable — on-chain `data:` token URIs being the case this core hits.
9888
+ *
9889
+ * On a chain with NO Multicall3 deployment it falls back to individual
9890
+ * `eth_call`s at bounded concurrency — see {@link file://./multicallFallback.ts}.
9891
+ * The result contract is identical either way, so callers never branch on it.
9268
9892
  */
9269
9893
 
9270
9894
  /** One pre-encoded call. */
@@ -9286,9 +9910,17 @@ interface MulticallRawParameters extends BlockParameters {
9286
9910
  multicallAddress?: Address;
9287
9911
  account?: Address;
9288
9912
  stateOverride?: StateOverride;
9913
+ /**
9914
+ * Max `eth_call`s in flight on the no-Multicall3 fallback (default 8, or the
9915
+ * client's `batch.multicall.fallbackConcurrency`). Ignored when the chain has
9916
+ * the deployment, where the whole batch is one request anyway.
9917
+ */
9918
+ fallbackConcurrency?: number;
9289
9919
  }
9290
9920
  /**
9291
- * Run pre-encoded calls through `aggregate3`, chunked and in parallel.
9921
+ * Run pre-encoded calls through `aggregate3`, chunked and in parallel — or, on a
9922
+ * chain with no Multicall3 deployment, as individual `eth_call`s at bounded
9923
+ * concurrency. Both routes return the same thing, so callers never branch.
9292
9924
  *
9293
9925
  * NEVER throws for a partial failure: a chunk whose RPC round-trip fails marks
9294
9926
  * only ITS OWN entries `success: false`, so one bad batch can't sink the rest.
@@ -9501,6 +10133,17 @@ interface GetPublicClientOptions {
9501
10133
  pinRpcUrl?: boolean;
9502
10134
  /** Fold parallel reads into one aggregate3 (default `true` — see below). */
9503
10135
  batch?: boolean;
10136
+ /**
10137
+ * How many `eth_call`s run at once when the chain turns out to have no
10138
+ * Multicall3 and a batch degrades to individual calls (default 8).
10139
+ */
10140
+ fallbackConcurrency?: number;
10141
+ /**
10142
+ * Trust the canonical Multicall3 address without the one-off `eth_getCode`
10143
+ * that verifies it. Saves a request per chain; only safe when every chain this
10144
+ * client touches is known to carry the deployment.
10145
+ */
10146
+ assumeMulticall3?: boolean;
9504
10147
  }
9505
10148
  /**
9506
10149
  * The shared client for a chain, created on first use.
@@ -10105,6 +10748,13 @@ declare function createX402SignatureProvider(opts: {
10105
10748
  * underlying (their decimals match it) and yield arrives as a growing
10106
10749
  * `balanceOf`. Converting these would be a bug, so they are left untouched.
10107
10750
  *
10751
+ * - **Oracle-priced shares** (`spark-l2-susds`) — share-based like the first
10752
+ * group, but with no `convertToAssets` to ask: bridged sUSDS is a plain ERC-20
10753
+ * on its chain (the vault stays on Ethereum), so the conversion reads the SSR
10754
+ * oracle's ray-scaled rate and multiplies. Still ONE call per token, decoded
10755
+ * differently — see {@link YieldConversionPlan.rateKeys}. Needs
10756
+ * {@link YieldTokenInput.chain}, since the oracle is per chain.
10757
+ *
10108
10758
  * Which side a token falls on is decided by an explicit allow-list of
10109
10759
  * share-based protocols, mirroring the wallet app's own `LENDING_PLATFORMS`.
10110
10760
  * The protocol classes encode the same split as `balanceIsUnderlying`, but that
@@ -10162,6 +10812,16 @@ interface YieldTokenInput {
10162
10812
  address?: string;
10163
10813
  decimals?: number;
10164
10814
  } | null;
10815
+ /**
10816
+ * Chain id — hex (`'0x2105'`) or decimal (`8453`), both accepted. Needed ONLY
10817
+ * by `spark-l2-susds`, whose conversion goes to that chain's SSR oracle rather
10818
+ * than to the token, and whose oracle address is per chain.
10819
+ *
10820
+ * Optional so existing callers are unaffected: every ERC-4626 type converts
10821
+ * against the token itself and never reads this. A sUSDS row without it is
10822
+ * passed through unconverted rather than converted against a guessed oracle.
10823
+ */
10824
+ chain?: string | number | null;
10165
10825
  }
10166
10826
  /** One declared `convertToAssets` read, tagged with the token it belongs to. */
10167
10827
  interface YieldConversionCall extends MulticallRequest {
@@ -10172,6 +10832,17 @@ interface YieldConversionCall extends MulticallRequest {
10172
10832
  interface YieldConversionPlan {
10173
10833
  /** Reads to perform, in order. Empty when nothing needs converting. */
10174
10834
  calls: YieldConversionCall[];
10835
+ /**
10836
+ * Keys in {@link calls} whose read returns a ray-scaled RATE rather than an
10837
+ * amount — cross-chain sUSDS, which has no `convertToAssets` and is valued
10838
+ * against its chain's SSR oracle instead.
10839
+ *
10840
+ * Exposed so {@link applyYieldConversions} can tell the two apart: decoding a
10841
+ * ray as though it were assets would report a ~10^27 balance. Callers execute
10842
+ * the plan exactly as before and need not consult this — it stays a single
10843
+ * round-trip, and there is no second phase to forget.
10844
+ */
10845
+ rateKeys: string[];
10175
10846
  }
10176
10847
  /** A token's corrected valuation. */
10177
10848
  interface YieldTokenValue {
@@ -10237,6 +10908,210 @@ declare function planYieldTokenConversions(tokens: YieldTokenInput[]): YieldConv
10237
10908
  */
10238
10909
  declare function applyYieldConversions(tokens: YieldTokenInput[], plan: YieldConversionPlan, returns: Array<string | null>): Map<string, YieldTokenValue>;
10239
10910
 
10911
+ /**
10912
+ * Executing half of the yield-token valuation — the transport `yieldTokenValue`
10913
+ * deliberately leaves to its caller, supplied once here so every consumer stops
10914
+ * writing its own.
10915
+ *
10916
+ * {@link file://./yieldTokenValue.ts} stays what it is: two pure, synchronous
10917
+ * functions that declare reads and fold answers back. That split earns its keep —
10918
+ * it is what makes the arithmetic testable without a node. What it did NOT earn
10919
+ * is a copy of the batching, chunking and error-swallowing in every app that
10920
+ * calls it, which is what actually happened: the wallet grew its own `aggregate3`
10921
+ * encoder and its own sequential fallback, duplicating `multicallRead` almost
10922
+ * line for line.
10923
+ *
10924
+ * So this module supplies the missing half against the core's own chain stack:
10925
+ *
10926
+ * - {@link valueYieldTokens} tokens the caller ALREADY described → values
10927
+ * - {@link getTokenPriceUSD} an address → the price of one unit, metadata
10928
+ * fetched here
10929
+ *
10930
+ * ## Why two entry points rather than one
10931
+ *
10932
+ * They differ in who owns the token's yield IDENTITY, and that is not a detail.
10933
+ *
10934
+ * A wallet's token list resolves `yieldProtocol` / `yieldAsset` from several
10935
+ * sources it alone can see — the live API response, the field persisted on the
10936
+ * token, a by-address re-ask, and its own stored snapshot — because no single one
10937
+ * is complete: the chain-wide discovery list omits the tag for real vaults, and a
10938
+ * vault recovered from a snapshot has no live entry at all. A token arriving with
10939
+ * an identity already resolved that way must be valued AS DESCRIBED;
10940
+ * re-fetching it here would see only the first of those sources and would
10941
+ * silently drop the tag, which understates the position by exactly the yield
10942
+ * accrued — the failure this whole area exists to prevent.
10943
+ *
10944
+ * {@link valueYieldTokens} is therefore the honest shape for a list: the caller
10945
+ * describes, this executes. It is also the only shape that is one batch rather
10946
+ * than N requests.
10947
+ *
10948
+ * {@link getTokenPriceUSD} is for the opposite case — a screen holding nothing
10949
+ * but an address (a token detail, a swap target, a search row). There is no
10950
+ * richer identity to respect, so fetching it here is not a loss, and it removes
10951
+ * the fetch-then-convert dance every such caller was repeating.
10952
+ */
10953
+
10954
+ /** Shared options for the calls in this module. */
10955
+ interface YieldPricingOptions {
10956
+ /**
10957
+ * Preferred RPC endpoint. PREFERS rather than replaces: the chain's other
10958
+ * known endpoints stay behind it as backups, so a caller passing its paid
10959
+ * provider keeps a fallback rather than losing one.
10960
+ */
10961
+ rpcUrl?: string;
10962
+ /**
10963
+ * Token API base URL. Defaults to the same Pantograph host the rest of the
10964
+ * core dials.
10965
+ */
10966
+ apiBaseUrl?: string;
10967
+ }
10968
+ /**
10969
+ * Value a set of ALREADY-DESCRIBED tokens, running their conversions in one
10970
+ * batch.
10971
+ *
10972
+ * Exactly {@link planYieldTokenConversions} → execute → {@link
10973
+ * applyYieldConversions}, which is the sequence every caller was writing by
10974
+ * hand. The contract of the two pure halves is preserved unchanged:
10975
+ *
10976
+ * - the returned map has an entry for EVERY input token, converted or not, so
10977
+ * the caller applies it uniformly;
10978
+ * - a failed read is never destructive — that token falls back to
10979
+ * `balance × price` with `converted: false`, so a flaky RPC understates a
10980
+ * position at worst instead of zeroing it;
10981
+ * - nothing convertible plans no calls and costs no RPC.
10982
+ *
10983
+ * `chainId` is also what reaches each input's `chain` field when the caller left
10984
+ * it unset — needed by cross-chain sUSDS, whose conversion goes to that chain's
10985
+ * SSR oracle rather than to the token. An input that names its own `chain` keeps
10986
+ * it, so a caller mixing chains in one array is not silently re-pointed.
10987
+ */
10988
+ declare function valueYieldTokens(chainId: string | number, tokens: YieldTokenInput[], options?: YieldPricingOptions): Promise<Map<string, YieldTokenValue>>;
10989
+ /**
10990
+ * The USD price of ONE unit of a token, in the unit its balance is actually
10991
+ * denominated in.
10992
+ *
10993
+ * The problem this solves is that the token API quotes a share-based vault at
10994
+ * its UNDERLYING asset's price, while the holder's balance is in SHARES — worth
10995
+ * more, and drifting further up as yield accrues. A screen showing the raw API
10996
+ * price therefore disagrees with the same wallet's token list, which converts.
10997
+ *
10998
+ * Conversion runs against a synthetic ONE-share balance, so the answer needs no
10999
+ * wallet balance and is equally right for a vault the user does not hold — the
11000
+ * token they are swapping INTO, say.
11001
+ *
11002
+ * Returns:
11003
+ * - the API price unchanged, and NO RPC, for every plain token and every
11004
+ * rebasing receipt (`aave-v3`, `compound-v3`), whose balance is already the
11005
+ * underlying;
11006
+ * - the per-SHARE price for a share-based vault that converted;
11007
+ * - `null` when there is no usable price, INCLUDING when a share-based vault's
11008
+ * read fails. That last case is deliberate: the API price is known to be in
11009
+ * the wrong unit there, so no price is better than a wrong one, and the
11010
+ * caller falls back to whatever it already had.
11011
+ */
11012
+ declare function getTokenPriceUSD(chainId: string | number, address: string, options?: YieldPricingOptions): Promise<number | null>;
11013
+ /**
11014
+ * The per-unit price of a token the caller has ALREADY fetched.
11015
+ *
11016
+ * Same answer as {@link getTokenPriceUSD} without the request, for callers that
11017
+ * hold an API row already — a search screen listing many tokens, or a wallet
11018
+ * pricing a vault whose zero balance left it nothing to convert.
11019
+ */
11020
+ declare function resolveTokenPriceUSD(chainId: string | number, token: YieldPricingToken, options?: YieldPricingOptions): Promise<number | null>;
11021
+ /** The fields {@link resolveTokenPriceUSD} reads off a token API row. */
11022
+ interface YieldPricingToken {
11023
+ address?: string | null;
11024
+ decimals?: number | string | null;
11025
+ /** The API's quote — for a share-based vault, the UNDERLYING's price. */
11026
+ price?: number | string | null;
11027
+ yieldProtocol?: string | null;
11028
+ yieldAsset?: {
11029
+ address?: string;
11030
+ decimals?: number;
11031
+ } | null;
11032
+ }
11033
+
11034
+ /**
11035
+ * Spark's PSM3 — the one hard-coded address per chain that makes cross-chain
11036
+ * sUSDS describable, and the reason nothing ELSE about it has to be hard-coded.
11037
+ *
11038
+ * ## Why a constant exists here at all
11039
+ *
11040
+ * Every other family in {@link file://./discovery.ts} is identified by probing
11041
+ * the receipt token: an aToken answers `POOL()`, a Comet answers `baseToken()`,
11042
+ * a 4626 vault answers `asset()`. Cross-chain sUSDS answers NONE of them, and
11043
+ * that is by design rather than by omission — Spark's docs are explicit:
11044
+ *
11045
+ * > The crosschain sUSDS token does not contain any ERC4626 functionality -
11046
+ * > this is only available on Ethereum mainnet.
11047
+ *
11048
+ * The reason is where the assets live. Mainnet sUSDS is a real vault holding
11049
+ * USDS; bridging via SkyLink moves only the SHARE token, leaving the USDS on
11050
+ * Ethereum. The token on Base therefore has no assets to report and nothing to
11051
+ * convert against, so `asset()`, `totalAssets()`, `convertToAssets()` and
11052
+ * `rateProvider()` all revert (verified on Base). It is, on chain, a plain
11053
+ * ERC-20 that happens to appreciate.
11054
+ *
11055
+ * With nothing on the token to probe, identification has to come from somewhere
11056
+ * that KNOWS the token, and PSM3 is that somewhere: it is the contract L2 swaps
11057
+ * route through, and it names all three assets plus the rate oracle.
11058
+ *
11059
+ * ## Why the address cannot be derived
11060
+ *
11061
+ * Checked, in order, before settling for a constant:
11062
+ *
11063
+ * - **CREATE2 / deterministic deploy** — no. `spark-psm/deploy/PSM3Deploy.sol`
11064
+ * is a plain `new PSM3(owner, usdc, usds, susds, rateProvider)`, so the
11065
+ * address falls out of the deployer's nonce. The four live deployments below
11066
+ * share no prefix, which is the same fact observed from outside.
11067
+ * - **An on-chain registry** — no. `sparkdotfi/spark-address-registry` is the
11068
+ * canonical source, but it is a Solidity `library` of `constant`s consumed at
11069
+ * COMPILE time; it is not deployed and cannot be called. No npm package
11070
+ * mirrors it either.
11071
+ * - **Sky's Chainlog** (`0xdA0Ab1e0…740F`) — genuinely on-chain and genuinely a
11072
+ * registry, but the wrong one: it lists Sky's MAINNET contracts (`MCD_PSM_*`,
11073
+ * `MCD_LITE_PSM_*`), holds no `PSM3` key, and is deployed only on Ethereum,
11074
+ * so a Base read cannot reach it.
11075
+ * - **A backlink from the token** — no. sUSDS exposes no `psm()`, `oracle()`,
11076
+ * `usds()` or any other pointer (probed; all revert). The relationship runs
11077
+ * one way, PSM3 → token.
11078
+ *
11079
+ * So one anchor per chain is the floor, not a shortcut.
11080
+ *
11081
+ * ## Why THIS constant rather than the obvious three
11082
+ *
11083
+ * The alternative is hard-coding USDS, sUSDS and the SSR oracle per chain.
11084
+ * PSM3 replaces all three because it names them at runtime, which is better on
11085
+ * two counts beyond arithmetic:
11086
+ *
11087
+ * - It is **self-checking**. A wrong PSM3 address makes `susds()` revert or
11088
+ * return a token that matches no holding, and the position simply stays
11089
+ * undiscovered — exactly today's behaviour, no worse. A wrong hard-coded
11090
+ * USDS, by contrast, yields a market that looks correct while describing the
11091
+ * wrong asset, which is the failure `protocols.ts` refuses to make anywhere
11092
+ * else.
11093
+ * - It **tracks upstream**. Spark governance can repoint the rate oracle;
11094
+ * `rateProvider()` follows it with no code change.
11095
+ *
11096
+ * Addresses come from Spark's own registry, quoted with the version comment it
11097
+ * carries so a future reader can diff against it:
11098
+ * https://github.com/sparkdotfi/spark-address-registry/blob/master/src/Base.sol
11099
+ */
11100
+
11101
+ /**
11102
+ * PSM3 on `chain`, or null where Spark has deployed none.
11103
+ *
11104
+ * Accepts hex (`'0x2105'`) or decimal (`8453`) — the lending paths use hex, the
11105
+ * wallet's token list carries numbers, and keying on the raw value would
11106
+ * silently miss one of them.
11107
+ *
11108
+ * Exported from the package because the app needs it too: exiting a cross-chain
11109
+ * sUSDS position is a PSM3 swap, and the app would otherwise keep its own copy
11110
+ * of this table, which is exactly the pair that drifts. This module is the one
11111
+ * place the addresses are recorded and justified.
11112
+ */
11113
+ declare function psm3For(chain: string | number | null | undefined): string | null;
11114
+
10240
11115
  /**
10241
11116
  * PantographService — Pantograph API client.
10242
11117
  *
@@ -10258,6 +11133,28 @@ declare const HEX_TO_PANTOGRAPH: Record<string, string>;
10258
11133
  */
10259
11134
  declare const TRENDING_DEFAULT_BY_HEX_CHAIN: Record<string, string[]>;
10260
11135
  declare function toPantographChain(hexChain: string): string;
11136
+ /** Raw token shape returned by Pantograph list endpoints (pre-normalization). */
11137
+ interface PantographRawToken {
11138
+ address?: string;
11139
+ token_address?: string;
11140
+ price?: number | string;
11141
+ icon_image?: string;
11142
+ decimals?: number | string;
11143
+ /**
11144
+ * Yield identity, carried through verbatim rather than normalised.
11145
+ *
11146
+ * These decide whether a balance is vault SHARES (which must be converted
11147
+ * on-chain before it can be valued) or already the underlying, so the
11148
+ * distinction between an ABSENT tag and a tag of `null` matters to callers:
11149
+ * absent means the question was never answered and should be re-asked, null
11150
+ * means answered "not a vault". Defaulting either one here would erase that.
11151
+ */
11152
+ yieldProtocol?: string | null;
11153
+ yieldAsset?: {
11154
+ address?: string;
11155
+ decimals?: number;
11156
+ } | null;
11157
+ }
10261
11158
  declare class PantographService {
10262
11159
  private baseUrl;
10263
11160
  constructor(config?: PantographServiceConfig);
@@ -10273,6 +11170,25 @@ declare class PantographService {
10273
11170
  * Mutates the array in-place. Non-fatal: silently skips on failure.
10274
11171
  */
10275
11172
  enrichTokenPrices(tokens: TokenBalance[], moralisChain: string): Promise<void>;
11173
+ /**
11174
+ * Raw pricing rows for specific contracts, with their yield identity intact.
11175
+ *
11176
+ * Separate from {@link enrichTokenPrices} because that one answers a different
11177
+ * question: it folds a price and a logo onto balances it was handed, dropping
11178
+ * everything else. Yield valuation needs the fields it drops — `decimals`, and
11179
+ * the `yieldProtocol` / `yieldAsset` pair that decides whether the quoted price
11180
+ * even belongs to the unit the balance is in.
11181
+ *
11182
+ * Rows are returned VERBATIM rather than normalised: `decimals` arrives as a
11183
+ * string on some tokens and an absent `yieldProtocol` must stay absent (see
11184
+ * {@link PantographRawToken}), so coercing here would destroy the very
11185
+ * distinctions the caller reads.
11186
+ *
11187
+ * Accepts a decimal or hex chain id — this route is keyed by the decimal id and
11188
+ * serves every EVM chain, so no per-chain slug is involved. Never throws: a
11189
+ * failed request yields an empty array, and the caller degrades per token.
11190
+ */
11191
+ getYieldPricingTokens(chainId: string | number, addresses: string[]): Promise<Array<PantographRawToken>>;
10276
11192
  /**
10277
11193
  * Fetch metadata + price for a single token from Pantograph.
10278
11194
  * Returns null if the token is not found or the request fails.
@@ -10636,4 +11552,4 @@ declare class AbortError extends Error {
10636
11552
  */
10637
11553
  declare function isAbortError(err: unknown): boolean;
10638
11554
 
10639
- export { AI_AGENT_TOOL_NAMES, type Abi, type AbiItem, type AbiParameter, AbortError, type AddLiquidityFormProps, type AddLiquiditySummary, type Address, type AffiliateFee, type AgentConfig, AgentCore, type AgentResponse, ApproveTokenTool, type ApyPoint, BaseNftAiTool, BaseSwapService, BaseTool, BaseWalletActionTool, type BlockParameters, type BlockTag, type BuyTokenConfirmTxProps, type BuyTokenSide, BuyTokenTool, type CallParameters, type Chain, type ChainMeta, type ChainRef, type ChainSelector, ChatHistory, type ChatMessage, type ChatOptions, type ChatRole, type CheckApprovalParams, type CheckApprovalResult, type Client, type ClientBatchConfig, type ConfirmAddLiquidityTxProps, type ContractFunctionParameters, type CortexResponse, DEFAULT_CHAIN, DEFAULT_PROVIDER, DEFAULT_RPC_BY_CHAIN, DebridgeAdapter, type DecodedCall, type DecodedEvent, type DecodedParam, type DefaultSubagentName, type DefiPosition, type DefiPositionDetails, type DefiPositionToken, type DefiProtocolSummary, type EIP1193RequestFn, EstimatePoolYieldTool, type EstimatePoolYieldToolConfig, type ExchangeProviderConfig, type ExecuteSwapParams, type ExecuteSwapResult, GeminiProvider, GeminiSearchAiTool, type GeminiSearchAiToolConfig, HEX_TO_PANTOGRAPH, type Hex, type HolderChangePeriod, type HolderSupplyTier, type HttpMethod, type IngestKnowledgeBaseInput, type IngestKnowledgeBaseResult, type InputTokenInfo, type KBSearchResult, KnowledgeBase, type KnowledgeBaseEntry, type KnowledgeBaseProvider, type LLMProvider, type LLMProviderConfig, type LLMResponse, type LLMToolCall, type LendingMarket, type LendingMarketOverview, LendingMarketsTool, type LendingMarketsToolConfig, type LendingProtocolType, LendingService, type LendingServiceConfig, type LendingSupplyPosition, MULTICALL3_ADDRESS, ManageLiquidityRedirectTool, type MarketplaceLink, type MoralisApiResponse, MoralisService, type MoralisServiceConfig, type MulticallParameters, type MulticallRawParameters, type MulticallResult, NFC_AGENT_TOOL_NAMES, NFC_AMAZON_DEFAULT_DOMAIN, NFC_AMAZON_DOMAINS, type NFTCollectionItem, NFTContractInfoTool, type NFTContractMetadata, type NFTItem, type NFTLastSale, type NFTMetadata, NFTMetadataTool, NFT_AGENT_TOOL_NAMES, type NativeTokenInfo, NfcBuyTool, NfcInfoTool, type NftTransferLastSale, NoFormTool, type NoFormToolMessages, OpenAddLiquidityFormTool, type OpenAddLiquidityFormToolConfig, OpenSupplyFormTool, type OpenSupplyFormToolConfig, POOL_AGENT_TOOL_NAMES, PantographService, type PantographServiceConfig, type PaymentToken, PoolByAddressTool, type PoolByAddressToolConfig, PoolDetailTool, type PoolDetailToolConfig, type PoolDisplayInfo, PoolFallbackAiTool, type PoolFallbackAiToolConfig, type PoolOnchainInfo, PoolPriceRangesTool, type PoolPriceRangesToolConfig, PoolSearchTool, type PoolSearchToolConfig, PoolService, type PoolServiceConfig, type PresetInputs, PreviewAddLiquidityTool, type PreviewAddLiquidityToolConfig, type PriceBounds, type PriceRangePrefill, type ProviderName, PublicClient, type PublicClientConfig, type QuickRate, type RangePreset, type ReActPhase, type ReActStep, type ReActTrace, type ReadContractParameters, RelayAdapter, type ResolvedRange, Router, type RouterAssignment, type RouterDecision, SUPPORTED_CHAINS, SUPPORTED_CHAINS_LABEL, SWAP_PROVIDER_CONFIG, SendNativeTool, SendNftTool, SendTokenTool, type StateOverride, type StorageProvider, Subagent, type SubagentCard, type SubagentOptions, type SubagentParams, type SubagentResult, type SubagentTask, type SubagentToggles, SubgraphAddPoolTool, type SubgraphAddPoolToolConfig, SubgraphCoinPoolPairsTool, type SubgraphCoinPoolPairsToolConfig, SubgraphPoolByAddressTool, type SubgraphPoolByAddressToolConfig, SubgraphPoolByPositionIdTool, type SubgraphPoolByPositionIdToolConfig, SubgraphPoolSearchTool, type SubgraphPoolSearchToolConfig, SubgraphPositionDetailTool, type SubgraphPositionDetailToolConfig, SubgraphTrendingPoolsTool, type SubgraphTrendingPoolsToolConfig, type SuggestedAction, Summarizer, type SupplyProtocolType, type SupplyUsdcProps, type SupportedChainId, type SupportedChainName, type SwapQuoteParams, type SwapQuoteResult, type SwapServiceConfig, SwapServiceFactory, type SwapTokenConfirmTxProps, SwapTokenTool, type SwapTxData, Synthesizer, TOKEN_AGENT_TOOL_NAMES, TRANSFER_TOPIC, TRENDING_DEFAULT_BY_HEX_CHAIN, type TokenAnalyticsResponse, type TokenAnalyticsTimeframeBuckets, TokenAnalyticsTool, type TokenAnalyticsToolConfig, type TokenApproval, type TokenApprovalSpender, type TokenApprovalToken, type TokenBalance, type TokenDisplay, type TokenHoldersResponse, TokenHoldersTool, type TokenHoldersToolConfig, TokenInfoTool, type TokenInfoToolConfig, type TokenMetadata, type TokenScoreMetrics, type TokenScoreResponse, type TokenScoreSupply, type TokenScoreTimeframeBuckets, TokenScoreTool, type TokenScoreToolConfig, type Tool, type ToolDefinition, type ToolKind, type ToolParameter, ToolRegistry, type ToolResult, type TopGainerTimeFrames, type TopGainerToken, type TopGainersTimeFrame, TopGainersTool, type TopGainersToolConfig, TopPoolsTool, type TopPoolsToolConfig, type TrackStatus, type TrackTransactionParams, type TrackTransactionResult, type TransactionByHashResponse, TransactionByHashTool, type TransactionByHashToolConfig, type TransactionLog, type TransactionReceipt, type TransactionReceiptLog, type Transport, type TransportConfig, type TrendingToken, type TrendingTokenTimeframeBuckets, TrendingTokensTool, type TrendingTokensToolConfig, type UIPayload, UNISWAP_CHAIN_SLUG, type UnsignedTx, type UpstashEmbedStrategy, type UpstashFusionAlgorithm, type UpstashKBUpsertEntry, UpstashKnowledgeBase, type UpstashKnowledgeBaseConfig, type UserContext, type VectorKBConfig, WALLET_ACTION_AGENT_TOOL_NAMES, WALLET_AGENT_TOOL_NAMES, type WalletActionProps, type WalletActionType, type WalletApprovalsResponse, WalletApprovalsTool, type WalletApprovalsToolConfig, type WalletDefiPositionSummary, WalletDefiPositionsTool, type WalletDefiPositionsToolConfig, type WalletDefiPositionsV1Response, type WalletDefiProtocolPositionsResponse, WalletDefiProtocolPositionsTool, type WalletDefiProtocolPositionsToolConfig, type WalletDefiProtocolPositionsV1Response, type WalletDefiSummaryResponse, type WalletDefiSummaryV1Response, type WalletHistoryCategory, type WalletHistoryContractInteraction, type WalletHistoryErc20Transfer, type WalletHistoryItem, type WalletHistoryNativeTransfer, type WalletHistoryNftTransfer, type WalletHistoryResponse, WalletHistoryTool, type WalletHistoryToolConfig, WalletLendingPositionsTool, type WalletLendingPositionsToolConfig, WalletNFTsTool, type WalletNFTsToolConfig, type WalletNftCardProps, type WalletNftListProps, type WalletNftTransferItem, type WalletNftTransfersResponse, WalletNftTransfersTool, type WalletNftTransfersToolConfig, type WalletPnlDaysWindow, type WalletPnlResponse, type WalletPnlSummaryResponse, WalletPnlSummaryTool, type WalletPnlSummaryToolConfig, type WalletPnlTokenItem, WalletPnlTool, type WalletPnlToolConfig, WalletTokenBalancesTool, type WalletTokenBalancesToolConfig, type WalletTokenTransferItem, type WalletTokenTransfersResponse, WalletTokenTransfersTool, type WalletTokenTransfersToolConfig, type WebsiteTrustExtraData, type WebsiteTrustInput, WebsiteTrustKeyringAgent, type WebsiteTrustKeyringAgentConfig, type WebsiteTrustResult, type X402Authorization, type X402Challenge, type X402Display, type X402Outcome, type X402PaymentRequiredProps, type X402Receipt, type X402RequestSpec, type X402Requirements, type X402SignRequest, type X402Signer, type X402TypedData, type X402Version, type YieldConversionCall, type YieldConversionPlan, type YieldTokenInput, type YieldTokenValue, ZERO_ADDRESS, amazonDomainForLanguage, apiClient, applyYieldConversions, buildChallenge, buildRangePresets, buildUniswapPoolUrl, call, chains, checksumAddress, clampTick, clearPublicClientCache, completeX402, configureSupportedChains, createAiAgent, createDefaultSubagents, createNfcAgent, createNftAgent, createPoolAgent, createPublicClient, createTokenAgent, createTransport, createWalletActionAgent, createWalletAgent, createX402SignatureProvider, decodeAbiParameters, decodeErrorResult, decodeFunctionData, decodeFunctionResult, displayFromChallenge, encodeAbiParameters, encodeErrorResult, encodeFunctionData, encodeSignedHeader, erc1155Abi, erc20Abi, erc20Abi_bytes32, erc721Abi, estimateGas, ethCallAt, ethCallByChain, fallback, fetchTopMarketplaces, getAbiItem, getAddress, getAffiliateFee, getBalance, getBlock, getBlockNumber, getChain, getChainContractAddress, getChainId, getChainMeta, getCode, getDefaultRpcUrl, getGasPrice, getGatewayAddress, getGatewayChains, getNativeTokenInfo, getPositionManagerAddress, getProviderByChain, getPublicClient, getRevertReason, getRpcOverrides, getStorageAt, getTransactionCount, http, ingestKnowledgeBase, isAbortError, isAddress, isAddressEqual, isPaymentRequired, isShareBasedProtocol, isShareBasedYieldToken, multicall, multicall3Abi, multicallRaw, nfcAmazonSearchUrl, normaliseCountry, normalizePriceRangeToPool, parseAbi, parseAbiItem, parseAbiParameters, planYieldTokenConversions, priceToTick, readContract, readPaymentError, readPaymentRequired, readReceipt, registerMaybeNoForm, requestWithX402, resolveNfcShopLinks, resolveRpcUrl, resolveRpcUrls, roundTickToSpacing, rpcCall, setRpcOverrides, swapServiceFactory, tickToPrice, toEventSelector, toFunctionSelector, toPantographChain };
11555
+ export { AI_AGENT_TOOL_NAMES, type Abi, type AbiItem, type AbiParameter, AbortError, type AddLiquidityFormProps, type AddLiquiditySummary, type Address, type AffiliateFee, type AgentConfig, AgentCore, type AgentResponse, ApproveTokenTool, type ApyPoint, BaseNftAiTool, BaseSwapService, BaseTool, BaseWalletActionTool, type BlockParameters, type BlockTag, type BuyTokenConfirmTxProps, type BuyTokenSide, BuyTokenTool, type CallParameters, type Chain, type ChainMeta, type ChainRef, type ChainSelector, ChatHistory, type ChatMessage, type ChatOptions, type ChatRole, type CheckApprovalParams, type CheckApprovalResult, type Client, type ClientBatchConfig, type ConfirmAddLiquidityTxProps, type ContractFunctionParameters, type CortexResponse, DEFAULT_CHAIN, DEFAULT_PROVIDER, DEFAULT_RPC_BY_CHAIN, DebridgeAdapter, type DecodedCall, type DecodedEvent, type DecodedParam, type DefaultSubagentName, type DefiPosition, type DefiPositionDetails, type DefiPositionToken, type DefiProtocolSummary, type EIP1193RequestFn, EstimatePoolYieldTool, type EstimatePoolYieldToolConfig, type ExchangeProviderConfig, type ExecuteSwapParams, type ExecuteSwapResult, GeminiProvider, GeminiSearchAiTool, type GeminiSearchAiToolConfig, HEX_TO_PANTOGRAPH, type Hex, type HolderChangePeriod, type HolderSupplyTier, type HttpMethod, type IngestKnowledgeBaseInput, type IngestKnowledgeBaseResult, type InputTokenInfo, type KBSearchResult, KnowledgeBase, type KnowledgeBaseEntry, type KnowledgeBaseProvider, type LLMProvider, type LLMProviderConfig, type LLMResponse, type LLMToolCall, type LendingMarket, type LendingMarketOverview, LendingMarketsTool, type LendingMarketsToolConfig, type LendingProtocolType, LendingReadService, LendingService, type LendingServiceConfig, type LendingSupplyPosition, LendingSupplyService, MULTICALL3_ADDRESS, ManageLiquidityRedirectTool, type MarketplaceLink, type MoralisApiResponse, MoralisService, type MoralisServiceConfig, type MulticallParameters, type MulticallRawParameters, type MulticallResult, NFC_AGENT_TOOL_NAMES, NFC_AMAZON_DEFAULT_DOMAIN, NFC_AMAZON_DOMAINS, type NFTCollectionItem, NFTContractInfoTool, type NFTContractMetadata, type NFTItem, type NFTLastSale, type NFTMetadata, NFTMetadataTool, NFT_AGENT_TOOL_NAMES, type NativeTokenInfo, NfcBuyTool, NfcInfoTool, type NftTransferLastSale, NoFormTool, type NoFormToolMessages, OpenAddLiquidityFormTool, type OpenAddLiquidityFormToolConfig, OpenSupplyFormTool, type OpenSupplyFormToolConfig, POOL_AGENT_TOOL_NAMES, PantographService, type PantographServiceConfig, type PaymentToken, PoolByAddressTool, type PoolByAddressToolConfig, PoolDetailTool, type PoolDetailToolConfig, type PoolDisplayInfo, PoolFallbackAiTool, type PoolFallbackAiToolConfig, type PoolOnchainInfo, PoolPriceRangesTool, type PoolPriceRangesToolConfig, PoolSearchTool, type PoolSearchToolConfig, PoolService, type PoolServiceConfig, type PresetInputs, PreviewAddLiquidityTool, type PreviewAddLiquidityToolConfig, type PriceBounds, type PriceRangePrefill, type ProviderName, PublicClient, type PublicClientConfig, type QuickRate, type RangePreset, type ReActPhase, type ReActStep, type ReActTrace, type ReadContractParameters, RelayAdapter, type ResolvedRange, Router, type RouterAssignment, type RouterDecision, SUPPLIABLE_TYPES, SUPPORTED_CHAINS, SUPPORTED_CHAINS_LABEL, SWAP_PROVIDER_CONFIG, SendNativeTool, SendNftTool, SendTokenTool, type StateOverride, type StorageProvider, Subagent, type SubagentCard, type SubagentOptions, type SubagentParams, type SubagentResult, type SubagentTask, type SubagentToggles, SubgraphAddPoolTool, type SubgraphAddPoolToolConfig, SubgraphCoinPoolPairsTool, type SubgraphCoinPoolPairsToolConfig, SubgraphPoolByAddressTool, type SubgraphPoolByAddressToolConfig, SubgraphPoolByPositionIdTool, type SubgraphPoolByPositionIdToolConfig, SubgraphPoolSearchTool, type SubgraphPoolSearchToolConfig, SubgraphPositionDetailTool, type SubgraphPositionDetailToolConfig, SubgraphTrendingPoolsTool, type SubgraphTrendingPoolsToolConfig, type SuggestedAction, Summarizer, type SuppliableMarket, type SupplyProtocolType, type SupplyUsdcProps, type SupportedChainId, type SupportedChainName, type SwapQuoteParams, type SwapQuoteResult, type SwapServiceConfig, SwapServiceFactory, type SwapTokenConfirmTxProps, SwapTokenTool, type SwapTxData, Synthesizer, TOKEN_AGENT_TOOL_NAMES, TRANSFER_TOPIC, TRENDING_DEFAULT_BY_HEX_CHAIN, type TokenAnalyticsResponse, type TokenAnalyticsTimeframeBuckets, TokenAnalyticsTool, type TokenAnalyticsToolConfig, type TokenApproval, type TokenApprovalSpender, type TokenApprovalToken, type TokenBalance, type TokenDisplay, type TokenHoldersResponse, TokenHoldersTool, type TokenHoldersToolConfig, TokenInfoTool, type TokenInfoToolConfig, type TokenMetadata, type TokenScoreMetrics, type TokenScoreResponse, type TokenScoreSupply, type TokenScoreTimeframeBuckets, TokenScoreTool, type TokenScoreToolConfig, type Tool, type ToolDefinition, type ToolKind, type ToolParameter, ToolRegistry, type ToolResult, type TopGainerTimeFrames, type TopGainerToken, type TopGainersTimeFrame, TopGainersTool, type TopGainersToolConfig, TopPoolsTool, type TopPoolsToolConfig, type TrackStatus, type TrackTransactionParams, type TrackTransactionResult, type TransactionByHashResponse, TransactionByHashTool, type TransactionByHashToolConfig, type TransactionLog, type TransactionReceipt, type TransactionReceiptLog, type Transport, type TransportConfig, type TrendingToken, type TrendingTokenTimeframeBuckets, TrendingTokensTool, type TrendingTokensToolConfig, type UIPayload, UNISWAP_CHAIN_SLUG, UNRESOLVED_ASSET, type UnsignedTx, type UpstashEmbedStrategy, type UpstashFusionAlgorithm, type UpstashKBUpsertEntry, UpstashKnowledgeBase, type UpstashKnowledgeBaseConfig, type UserContext, type VectorKBConfig, WALLET_ACTION_AGENT_TOOL_NAMES, WALLET_AGENT_TOOL_NAMES, type WalletActionProps, type WalletActionType, type WalletApprovalsResponse, WalletApprovalsTool, type WalletApprovalsToolConfig, type WalletDefiPositionSummary, WalletDefiPositionsTool, type WalletDefiPositionsToolConfig, type WalletDefiPositionsV1Response, type WalletDefiProtocolPositionsResponse, WalletDefiProtocolPositionsTool, type WalletDefiProtocolPositionsToolConfig, type WalletDefiProtocolPositionsV1Response, type WalletDefiSummaryResponse, type WalletDefiSummaryV1Response, type WalletHistoryCategory, type WalletHistoryContractInteraction, type WalletHistoryErc20Transfer, type WalletHistoryItem, type WalletHistoryNativeTransfer, type WalletHistoryNftTransfer, type WalletHistoryResponse, WalletHistoryTool, type WalletHistoryToolConfig, WalletLendingPositionsTool, type WalletLendingPositionsToolConfig, WalletNFTsTool, type WalletNFTsToolConfig, type WalletNftCardProps, type WalletNftListProps, type WalletNftTransferItem, type WalletNftTransfersResponse, WalletNftTransfersTool, type WalletNftTransfersToolConfig, type WalletPnlDaysWindow, type WalletPnlResponse, type WalletPnlSummaryResponse, WalletPnlSummaryTool, type WalletPnlSummaryToolConfig, type WalletPnlTokenItem, WalletPnlTool, type WalletPnlToolConfig, WalletTokenBalancesTool, type WalletTokenBalancesToolConfig, type WalletTokenTransferItem, type WalletTokenTransfersResponse, WalletTokenTransfersTool, type WalletTokenTransfersToolConfig, type WebsiteTrustExtraData, type WebsiteTrustInput, WebsiteTrustKeyringAgent, type WebsiteTrustKeyringAgentConfig, type WebsiteTrustResult, type X402Authorization, type X402Challenge, type X402Display, type X402Outcome, type X402PaymentRequiredProps, type X402Receipt, type X402RequestSpec, type X402Requirements, type X402SignRequest, type X402Signer, type X402TypedData, type X402Version, type YieldConversionCall, type YieldConversionPlan, type YieldPricingOptions, type YieldPricingToken, type YieldTokenInput, type YieldTokenValue, ZERO_ADDRESS, amazonDomainForLanguage, apiClient, applyYieldConversions, buildChallenge, buildRangePresets, buildUniswapPoolUrl, call, chains, checksumAddress, clampTick, clearPublicClientCache, completeX402, configureSupportedChains, createAiAgent, createDefaultSubagents, createNfcAgent, createNftAgent, createPoolAgent, createPublicClient, createTokenAgent, createTransport, createWalletActionAgent, createWalletAgent, createX402SignatureProvider, decodeAbiParameters, decodeErrorResult, decodeFunctionData, decodeFunctionResult, displayFromChallenge, encodeAbiParameters, encodeErrorResult, encodeFunctionData, encodeSignedHeader, erc1155Abi, erc20Abi, erc20Abi_bytes32, erc721Abi, estimateGas, ethCallAt, ethCallByChain, fallback, fetchTopMarketplaces, getAbiItem, getAddress, getAffiliateFee, getBalance, getBlock, getBlockNumber, getChain, getChainContractAddress, getChainId, getChainMeta, getCode, getDefaultRpcUrl, getGasPrice, getGatewayAddress, getGatewayChains, getNativeTokenInfo, getPositionManagerAddress, getProviderByChain, getPublicClient, getRevertReason, getRpcOverrides, getStorageAt, getTokenPriceUSD, getTransactionCount, http, ingestKnowledgeBase, isAbortError, isAddress, isAddressEqual, isPaymentRequired, isShareBasedProtocol, isShareBasedYieldToken, isSupplyChain, listCandidateChains, listSupplyChains, multicall, multicall3Abi, multicallRaw, nfcAmazonSearchUrl, normaliseCountry, normalizePriceRangeToPool, parseAbi, parseAbiItem, parseAbiParameters, planYieldTokenConversions, priceToTick, protocolLabelFor, psm3For, readContract, readPaymentError, readPaymentRequired, readReceipt, registerMaybeNoForm, requestWithX402, resolveNfcShopLinks, resolveRpcUrl, resolveRpcUrls, resolveTokenPriceUSD, roundTickToSpacing, rpcCall, setRpcOverrides, swapServiceFactory, tickToPrice, toEventSelector, toFunctionSelector, toPantographChain, valueYieldTokens };