keyring-agent-core 0.2.54 → 0.2.56

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,126 @@ 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
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
+ * `shares × conversionRate`, in RAW units of the underlying — the arithmetic
5430
+ * that stands in for `convertToAssets()` on a token that has none.
5429
5431
  *
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.
5432
+ * Shared by the read path and the wallet-valuation path so the two cannot
5433
+ * disagree. Null when the rate is missing or not positive.
5435
5434
  *
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.
5435
+ * The subtlety is DECIMALS. `convertToAssets` returns raw underlying units, and
5436
+ * callers scale its result by the UNDERLYING's decimals; this must therefore do
5437
+ * the same. sUSDS and USDS are both 18, so the share/asset scales cancel and the
5438
+ * ray is the only conversion — but that cancellation is a property of this pair,
5439
+ * not a general truth, so it is asserted rather than assumed: a caller passing
5440
+ * mismatched decimals gets the correction applied instead of a silent 10^n error.
5441
+ */
5442
+ declare function convertSusdsShares(rawShares: bigint, conversionRateRay: bigint, shareDecimals: number, assetDecimals: number): bigint | null;
5443
+ /**
5444
+ * Display name of a market's protocol family, derived from its `type`.
5450
5445
  *
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.
5446
+ * `type` is the one identifier that is always exact — it is what selects the
5447
+ * on-chain calls — whereas the market's `name` and `protocol` are display
5448
+ * strings whose form depends on where the market came from: discovery writes
5449
+ * "Aave v3" with a lowercase v, the catalogue passes through whatever
5450
+ * `/supply/v2` supplies, and a Morpho market's `name` is the VAULT's name
5451
+ * ("Gauntlet USDC Core"), not the protocol's.
5454
5452
  *
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.
5453
+ * Returns null for a market kind with no label — an unknown `type` from the
5454
+ * catalogue, or a family added upstream after this table. Callers fall back to
5455
+ * the market's own strings rather than showing a guess.
5458
5456
  */
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. */
5457
+ declare function protocolLabelFor(type: string): string | null;
5458
+
5459
+ /**
5460
+ * The shapes every lending module agrees on, kept apart from the services that
5461
+ * produce them so `catalog`, `discovery` and `describe` can share them without
5462
+ * importing each other or the facade.
5463
+ */
5464
+
5465
+ /** One lending market — curated by CoinPool or discovered from its receipt token. */
5468
5466
  interface LendingMarket {
5469
5467
  /** Hex chain id the market lives on. */
5470
5468
  chain: string;
5471
- /** Display name, e.g. "Aave v3 USDC" / "Spark USDC Savings Vault". */
5469
+ /**
5470
+ * Display name of THIS MARKET, e.g. "Aave v3 USDC" / "Spark USDC Savings
5471
+ * Vault". For a Morpho market it is the vault's own name from Morpho's API
5472
+ * ("Gauntlet USDC Core") — the vault, not the protocol, which is why the app
5473
+ * link's slug is built from it.
5474
+ *
5475
+ * Not the protocol's name: use {@link protocolLabel} to title a market by the
5476
+ * protocol it belongs to.
5477
+ */
5472
5478
  name: string;
5473
- /** Protocol family, e.g. "AAVE" / "MORPHO". */
5479
+ /**
5480
+ * Protocol family as its SOURCE spells it — "AAVE" / "MORPHO" from discovery,
5481
+ * or whatever `/supply/v2` supplies for a curated market. Neither casing nor
5482
+ * wording is guaranteed, so prefer {@link protocolLabel} for display.
5483
+ */
5474
5484
  protocol: string;
5485
+ /**
5486
+ * Protocol family in the form a reader should see: "Aave V3", "Compound V3",
5487
+ * "Spark", "Morpho V2". Derived from {@link type}, the one identifier that is
5488
+ * always exact, so it is stable no matter whether the market was discovered
5489
+ * on chain or came from the catalogue.
5490
+ *
5491
+ * Null for a market kind with no known label — an unrecognised `type` from the
5492
+ * catalogue, or a family added upstream. Fall back to {@link name} /
5493
+ * {@link protocol} then, rather than showing nothing.
5494
+ */
5495
+ protocolLabel: string | null;
5475
5496
  /** Protocol app URL, when known. */
5476
5497
  protocolUrl: string | null;
5477
5498
  type: LendingProtocolType | string;
5478
- /** Pool / vault contract — where a supply goes. */
5499
+ /**
5500
+ * Pool / vault contract — where a supply goes.
5501
+ *
5502
+ * One exception: `spark-l2-susds` markets are read-only and have no vault on
5503
+ * their chain, so this holds the SSR oracle they are read through.
5504
+ */
5479
5505
  contract: string;
5480
5506
  /** Receipt token holding the user's balance (aToken, Comet, vault share). */
5481
5507
  token: string;
5508
+ /**
5509
+ * Underlying asset ADDRESS, supplied when the market cannot name it on chain.
5510
+ *
5511
+ * Normally absent: a market's asset is read from its own contract at describe
5512
+ * time ({@link LendingProtocol.underlyingCall}), which is the only source that
5513
+ * cannot go stale. This exists for the one family with no such accessor —
5514
+ * cross-chain sUSDS, whose asset comes from PSM3 during discovery — so the
5515
+ * answer is carried forward rather than re-derived or guessed.
5516
+ *
5517
+ * Deliberately NOT named `asset`: {@link LendingMarketOverview.asset} is the
5518
+ * resolved object (address + decimals + symbol + logo), and this is only the
5519
+ * raw input to it. Decimals and symbol are still read on chain from this
5520
+ * address, so nothing here bypasses the checks that suppress a mis-scaled
5521
+ * amount.
5522
+ */
5523
+ assetAddress?: string;
5482
5524
  /**
5483
5525
  * 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.
5526
+ * protocol safety, market size and yield. Null when the market is unscored,
5527
+ * which every DISCOVERED market is: the score exists only in the catalogue.
5485
5528
  */
5486
5529
  platformScore: number | null;
5487
5530
  }
@@ -5493,7 +5536,36 @@ interface ApyPoint {
5493
5536
  }
5494
5537
  /** A lending market plus its live rate and size — what you'd compare before supplying. */
5495
5538
  interface LendingMarketOverview extends LendingMarket {
5496
- /** Total USDC supplied to this market by everyone (market size). */
5539
+ /**
5540
+ * The asset this market lends, read on chain. Most curated markets are USDC;
5541
+ * those on WETH / wstETH / other assets report their own here.
5542
+ *
5543
+ * Always consult this before rendering an amount: {@link totalSuppliedUsdc} and
5544
+ * {@link LendingSupplyPosition.suppliedUsdc} are denominated in THIS asset, not
5545
+ * necessarily in USDC, and labelling a WETH figure "USDC" is worse than showing
5546
+ * no label at all.
5547
+ */
5548
+ asset: {
5549
+ address: string;
5550
+ decimals: number;
5551
+ /** ERC-20 symbol, when it could be read. Null otherwise — never guessed. */
5552
+ symbol: string | null;
5553
+ /**
5554
+ * Icon URL for the underlying, from Pantograph's token metadata. Null when
5555
+ * the asset is unresolved, unknown to Pantograph, or the lookup failed — it
5556
+ * is cosmetic, so it never blocks or delays the rest of the description.
5557
+ *
5558
+ * The UNDERLYING's icon, not the receipt token's: a withdraw form shows what
5559
+ * the user receives (USDC, WETH), which is a different image from the
5560
+ * aToken / vault share they hold.
5561
+ */
5562
+ logo: string | null;
5563
+ };
5564
+ /**
5565
+ * Total supplied to this market by everyone (market size), denominated in
5566
+ * {@link asset} — despite the name, which predates non-USDC support and is
5567
+ * kept so existing callers keep compiling.
5568
+ */
5497
5569
  totalSuppliedUsdc: number | null;
5498
5570
  /** Mean of {@link apyHistory} — the headline APY. Null when history is unavailable. */
5499
5571
  avgApyPercent: number | null;
@@ -5506,32 +5578,365 @@ interface LendingMarketOverview extends LendingMarket {
5506
5578
  }
5507
5579
  /** A wallet's live supply position in one lending market. */
5508
5580
  interface LendingSupplyPosition extends LendingMarketOverview {
5509
- /** Supplied USDC, receipt-token balance converted to underlying. */
5581
+ /** Supplied amount, receipt-token balance converted to the underlying {@link asset}. */
5510
5582
  suppliedUsdc: number;
5511
5583
  /** `suppliedUsdc × avgApyPercent` — projected yearly earnings at the average rate. */
5512
5584
  estimatedAnnualYieldUsdc: number | null;
5513
5585
  }
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. */
5586
+ /** Endpoint overrides shared by every lending service. */
5587
+ interface LendingServiceConfig {
5588
+ /** Base URL of the CoinPool API. Defaults to `https://api.coinpool.app`. */
5589
+ coinPoolBaseUrl?: string;
5590
+ /** Aave v3 GraphQL endpoint (supply-APY history). */
5591
+ aaveApiUrl?: string;
5592
+ /** Morpho GraphQL endpoint (vault APY history + live net APY). */
5593
+ morphoApiUrl?: string;
5594
+ }
5595
+
5596
+ /**
5597
+ * The description pipeline: markets in, markets WITH their asset, size and APY
5598
+ * out. Protocol-agnostic by design — it knows about no protocol by name, only
5599
+ * about the calls each one declares (see `protocols.ts`).
5600
+ *
5601
+ * This is the half both services share. Reading a wallet's positions and listing
5602
+ * the supply catalogue ask the same question of a market once it is identified,
5603
+ * so asking it lives here rather than in either service.
5604
+ *
5605
+ * Everything is batched per chain: twenty markets across four protocols still
5606
+ * cost one multicall for their sizes and live rates, plus at most one follow-up
5607
+ * round for the rates that are a function of it.
5608
+ */
5609
+
5610
+ /** A receipt-token balance awaiting conversion to its underlying. */
5611
+ interface HeldBalance {
5612
+ market: LendingMarket;
5613
+ /** Receipt-token balance (shares for a vault, underlying for aToken/Comet). */
5614
+ rawBalance: bigint;
5615
+ /** Receipt-token `decimals()`, null when the call failed. */
5616
+ tokenDecimals: number | null;
5617
+ }
5618
+ /**
5619
+ * Describes markets on one chain, sharing an APY concurrency budget across every
5620
+ * call it makes. One instance per service, so a whole-catalogue scan and a
5621
+ * wallet read never together exceed the cap.
5622
+ */
5623
+ declare class MarketDescriber {
5624
+ private readonly endpoints;
5519
5625
  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
5626
  /**
5526
- * Every curated USDC lending market on a chain. Empty when the chain has none
5527
- * or the API is unreachable — never throws.
5627
+ * Token metadata source for the underlying's ICON — the one thing about the
5628
+ * asset that is not on chain. Cosmetic only: every failure path here leaves
5629
+ * `logo: null` and changes nothing else about the description.
5528
5630
  */
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): {
5631
+ private readonly pantograph;
5632
+ constructor(endpoints: ApyEndpoints);
5633
+ /**
5634
+ * Attach market size and the APY series to each market — one batched on-chain
5635
+ * read plus one API call per market. Order is preserved, so callers can zip
5636
+ * the result with their own per-market data. Never throws.
5637
+ *
5638
+ * Asset resolution comes FIRST and is awaited on its own: both the state read
5639
+ * (which reserve to quote, which decimals to scale by) and the APY fetch
5640
+ * (which reserve's history to ask for) are parameterised by it, so they cannot
5641
+ * be started until it lands. That is one extra round-trip per chain, batched
5642
+ * across every market — the price of describing a market in its own asset
5643
+ * rather than assuming the chain's USDC.
5644
+ */
5645
+ describe(chain: string, info: LendingChainInfo, markets: LendingMarket[]): Promise<LendingMarketOverview[]>;
5646
+ /**
5647
+ * Every market's receipt-token balance + decimals in one batch, narrowed to the
5648
+ * markets the wallet actually holds something in — the step that decides how
5649
+ * much further work the rest of the flow has to do.
5650
+ */
5651
+ readBalances(chain: string, address: string, markets: LendingMarket[]): Promise<HeldBalance[]>;
5652
+ /**
5653
+ * Each held balance in its market's own underlying, aligned with `held`. A
5654
+ * protocol whose receipt token is an ERC-4626 share declares a
5655
+ * `convertToAssets` call; one whose balance is already underlying declares
5656
+ * none. As with {@link readMarketState}, every conversion across every protocol
5657
+ * shares ONE multicall.
5658
+ *
5659
+ * A vault whose conversion reverts falls back to the raw balance in the share
5660
+ * token's own decimals — an approximation that beats dropping the position
5661
+ * outright.
5662
+ *
5663
+ * `assets[i]` carries the decimals to scale by; a market whose asset could not
5664
+ * be resolved has NaN decimals and yields 0, so an unscalable balance is
5665
+ * dropped as dust rather than reported at the wrong magnitude.
5666
+ */
5667
+ convertToUnderlying(chain: string, held: HeldBalance[], assets: Array<LendingMarketOverview['asset']>): Promise<number[]>;
5668
+ /**
5669
+ * The asset each market lends, aligned with `markets`, in three batched rounds:
5670
+ * ask every market for its underlying, then ask every distinct underlying for
5671
+ * its `decimals()` and `symbol()`, then ask Pantograph for those same
5672
+ * underlyings' ICONS — the only part of the asset that is not on chain, and the
5673
+ * only round that is allowed to fail without consequence.
5674
+ *
5675
+ * The market is the ONLY source consulted. There used to be a per-chain USDC
5676
+ * fallback for a market whose accessor was missing or reverted, and it was
5677
+ * wrong in exactly the cases it fired: a market that fails to name its asset is
5678
+ * not thereby a USDC market, and calling it one attributes a WETH or DAI size
5679
+ * to the wrong token with the wrong decimals. An unresolvable asset is now
5680
+ * reported unresolved (NaN decimals), which suppresses the size instead of
5681
+ * misstating it — the same treatment a chain with no curated USDC always got.
5682
+ *
5683
+ * This is also what lets a market lend anything at all: nothing here knows or
5684
+ * cares which asset a chain's "real" stablecoin is.
5685
+ */
5686
+ private resolveAssets;
5687
+ /** `decimals()` + `symbol()` for each distinct asset address, in one multicall. */
5688
+ private readAssetMetadata;
5689
+ /**
5690
+ * Icon URL for each distinct asset address, from Pantograph's token metadata —
5691
+ * one request for the whole set.
5692
+ *
5693
+ * Purely cosmetic, and treated as such throughout: an unknown token, a chain
5694
+ * Pantograph does not index, or an outright failure all yield an EMPTY map, so
5695
+ * the assets come back with `logo: null` and every number in the description is
5696
+ * exactly what it would have been without this call. `getTokensMetadata`
5697
+ * already swallows its own errors; the catch is for the unexpected.
5698
+ */
5699
+ private fetchAssetLogos;
5700
+ /**
5701
+ * On-chain state of each market, aligned with `markets`: its size and its live
5702
+ * supply rate.
5703
+ *
5704
+ * This is where the batching lives. Each market's protocol only DECLARES the
5705
+ * calls it wants (`sizeCall`, `liveRateCall`); they are pooled here into a
5706
+ * single multicall, and each protocol then decodes its own slice of the result.
5707
+ *
5708
+ * Compound and Spark need a SECOND call that depends on the first's answer
5709
+ * (`getSupplyRate` of the utilization just read; `getAPR` on the rate provider
5710
+ * just named), so a second round follows when any market asks for one. Those
5711
+ * follow-ups are batched together too — two round-trips per chain at worst,
5712
+ * never two per market.
5713
+ *
5714
+ * Either field is null when its call failed or decoded implausibly.
5715
+ */
5716
+ private readMarketState;
5717
+ /**
5718
+ * Historical supply-APY samples for one market, from whichever upstream its
5719
+ * protocol queries, plus that source's own live rate where it reports one.
5720
+ *
5721
+ * Unlike the on-chain reads there is nothing to batch here — each protocol
5722
+ * talks to a different API, one request per market — so the protocol performs
5723
+ * the fetch itself. Never throws: an unreachable source yields no samples, so
5724
+ * the market is still listed, just without APY.
5725
+ */
5726
+ private fetchApy;
5727
+ }
5728
+
5729
+ /**
5730
+ * Reading lending markets — **every asset, every chain**, and every protocol the
5731
+ * probes can recognise (see the caveat under "What this does NOT cover").
5732
+ *
5733
+ * This is the half the Keyring app consumes. The app already knows what a wallet
5734
+ * holds: its token API returns each row with `yieldProtocol` / `yieldAsset`
5735
+ * tags, and {@link file://./yieldTokenValue.ts} converts vault shares to
5736
+ * underlying for the USD figure. What the app cannot get from a token list is
5737
+ * everything ABOUT the market behind a receipt token — its name, its protocol,
5738
+ * the rate it pays, how large it is. That is what this service supplies.
5739
+ *
5740
+ * ## Why this is separate from supplying
5741
+ *
5742
+ * Supplying is narrow on purpose: only the markets CoinPool curates, and only the
5743
+ * protocol families the FE can encode a deposit for. Those limits come from the
5744
+ * write path and have nothing to do with reading.
5745
+ *
5746
+ * A wallet, meanwhile, can hold any receipt token at all — aWETH on Base, an
5747
+ * uncurated Morpho vault, a receipt from a chain `/supply/v2` does not cover.
5748
+ * Each of those describes its own market on chain, so each is readable. Gating a
5749
+ * read on the supply catalogue would make a position the user genuinely holds
5750
+ * vanish from the app for a reason that belongs to a different feature, so this
5751
+ * service applies NO catalogue restriction and NO chain restriction.
5752
+ *
5753
+ * ## What this does NOT cover
5754
+ *
5755
+ * The one real limit is the SHAPE of the receipt token, and it is worth stating
5756
+ * plainly because "reads everything" is the easy thing to assume here.
5757
+ *
5758
+ * {@link file://./discovery.ts} identifies a token by the accessor only its
5759
+ * family implements, and it probes three: Aave v3's `POOL()` +
5760
+ * `UNDERLYING_ASSET_ADDRESS()`, Compound v3's `baseToken()`, and ERC-4626's
5761
+ * `asset()`. A token answering none of them returns null — so Aave **v2**
5762
+ * (`LENDING_POOL()`), Compound **v2** (cToken `underlying()`), and any other
5763
+ * non-4626 design are NOT seen. Verified: `aUSDC` (v2) and `cDAI` (v2) both
5764
+ * resolve to null, while `sDAI` (a genuine 4626) resolves.
5765
+ *
5766
+ * That null is indistinguishable from "this is a plain ERC-20", so an unseen
5767
+ * protocol fails INVISIBLY rather than loudly — no error, the position simply
5768
+ * does not appear. Widening coverage means adding a probe in `discovery.ts`, not
5769
+ * adding a class in `protocols.ts`.
5770
+ *
5771
+ * Note the asymmetry with the catalogue path: a market that arrives from
5772
+ * `/supply/v2` with an unrecognised `type` still gets described, because
5773
+ * `protocolFor` falls back to generic ERC-4626 handling. Only the probe path
5774
+ * drops what it cannot identify.
5775
+ *
5776
+ * ## Chain first, catalogue second
5777
+ *
5778
+ * Identification happens ON CHAIN: a receipt token answers the accessor only its
5779
+ * family implements, so the market behind it is derivable without asking anyone.
5780
+ * That puts curated and uncurated markets on the SAME path. Under catalogue-first,
5781
+ * Base USDC was resolved by an endpoint while Base WETH was resolved by a probe,
5782
+ * so the two could disagree and only one was exercised in testing.
5783
+ *
5784
+ * `/supply/v2` is therefore NOT consulted on this path at all: it defines which
5785
+ * markets can be supplied to, and reading has no business paying for it. The
5786
+ * catalogue would only have contributed cosmetics anyway — a curated display
5787
+ * name, a platform score, a market deep link — so a market read here carries the
5788
+ * name and protocol chain reports. Every number is identical either way.
5789
+ *
5790
+ * (The supply-POSITIONS path below is different, and still catalogue-driven: it
5791
+ * answers "what did the user supply to a curated market", which is a question
5792
+ * about the catalogue by definition.)
5793
+ *
5794
+ * APY history is unaffected — Compound and generic 4626 markets read theirs from
5795
+ * `/supply/rates/history`, a different endpoint, queried per market.
5796
+ *
5797
+ * See {@link file://./LendingSupplyService.ts} for the write path, and
5798
+ * {@link file://./describe.ts} for the pipeline both share.
5799
+ */
5800
+
5801
+ declare class LendingReadService {
5802
+ private readonly coinPoolBaseUrl;
5803
+ private readonly endpoints;
5804
+ private readonly describer;
5805
+ constructor(coinPoolBaseUrl: string, endpoints: ApyEndpoints, describer: MarketDescriber);
5806
+ /**
5807
+ * Describe the markets behind a wallet's RECEIPT TOKENS — the app's entry
5808
+ * point. Given the yield-bearing token addresses the app already has, returns
5809
+ * each one's market with its asset, size, live APY and weekly average.
5810
+ *
5811
+ * Keyed by the LOWERCASED token address, with an entry only for tokens that
5812
+ * resolved: a token that identifies itself as no lending receipt is simply
5813
+ * absent, which is the honest answer rather than a null the caller must filter.
5814
+ *
5815
+ * Batched end to end, which is the point of taking a list rather than one
5816
+ * token: identifying five vault shares costs the same two multicalls as
5817
+ * identifying one, and describing them shares a third. Calling
5818
+ * {@link findMarketByReceiptToken} five times instead would cost roughly five
5819
+ * times as much.
5820
+ *
5821
+ * Works on any chain the RPC layer serves, curated or not. Never throws.
5822
+ *
5823
+ * @param rpcUrl Optional endpoint for `chain`, installed as this core's
5824
+ * override before the read — see {@link registerRpcUrl}. Pass it for any chain
5825
+ * this core carries no definition for; omit it to use the resolved defaults.
5826
+ */
5827
+ describeReceiptTokens(chain: string, tokens: readonly string[], rpcUrl?: string): Promise<Map<string, LendingMarketOverview>>;
5828
+ /**
5829
+ * The market ONE receipt token belongs to — "the user holds this aToken /
5830
+ * Comet / vault share; which market is it?" — described with its size and APY.
5831
+ *
5832
+ * A thin wrapper over {@link describeReceiptTokens}; prefer that one whenever
5833
+ * you have more than a single token, since it batches. Null when the token
5834
+ * identifies itself as no lending receipt, or its market could not be
5835
+ * described. Never throws.
5836
+ *
5837
+ * @param rpcUrl Optional endpoint for `chain` — see {@link describeReceiptTokens}.
5838
+ */
5839
+ findMarketByReceiptToken(chain: string, receiptToken: string, rpcUrl?: string): Promise<LendingMarketOverview | null>;
5840
+ /**
5841
+ * Every market on `chains` the wallet currently supplies to, highest supplied
5842
+ * amount first.
5843
+ *
5844
+ * Scoped to the CURATED catalogue — this walks `/supply/v2`'s markets and
5845
+ * checks the wallet's balance in each, so it reports what the CoinPool product
5846
+ * covers, on whichever chains it covers them (asked, never assumed). A wallet
5847
+ * holding a receipt token from outside that set is not found here;
5848
+ * {@link describeReceiptTokens} is the entry point for those, since it starts
5849
+ * from tokens the caller already knows about rather than from a catalogue to
5850
+ * scan.
5851
+ *
5852
+ * Any asset, not just USDC: each market's own underlying decides what its
5853
+ * balance is denominated in, and {@link LendingSupplyPosition.asset} reports it.
5854
+ *
5855
+ * Chains are queried in parallel and contribute independently: a chain whose
5856
+ * API or RPC fails yields nothing rather than failing the whole call.
5857
+ * Positions worth less than {@link DUST_USDC} are dropped as withdrawal residue.
5858
+ */
5859
+ getSupplyPositions(params: {
5532
5860
  address: string;
5533
- decimals: number;
5534
- } | null;
5861
+ chains: readonly string[];
5862
+ }): Promise<LendingSupplyPosition[]>;
5863
+ /** Size + APY for markets already resolved elsewhere, in the order given. */
5864
+ describeResolvedMarkets(chain: string, markets: LendingMarket[]): Promise<LendingMarketOverview[]>;
5865
+ /** Supply positions on ONE chain: market list → balances → supplied amount + overview. */
5866
+ private positionsForChain;
5867
+ }
5868
+
5869
+ /**
5870
+ * Supplying — the WRITE path, and the narrower of the two.
5871
+ *
5872
+ * TWO limits define it, and both are stated here rather than scattered across
5873
+ * the tools that enforce them:
5874
+ *
5875
+ * 1. **Curated markets only.** `/supply/v2` is what says a market exists to
5876
+ * deposit into. A market discovered on chain is readable but not suppliable:
5877
+ * nobody curated it, nobody scored it, and it was never checked.
5878
+ * 2. **Encodable protocols only** — {@link SUPPLIABLE_TYPES}. The deposit call
5879
+ * differs per family, so a market outside this set has no correct calldata
5880
+ * and would fail at signing, AFTER the user had already approved the asset
5881
+ * to it. That is the worst possible failure point, which is why the check
5882
+ * lives in the service rather than at the edge.
5883
+ *
5884
+ * There is no third limit any more. Supplying used to be pinned to five hardcoded
5885
+ * chains and to USDC; both are now consequences of limit 1 rather than rules of
5886
+ * their own — the chains are whichever ones the catalogue answers for
5887
+ * ({@link listChains}), and the asset is whatever each market's own underlying
5888
+ * turns out to be. Neither is declared in this repository, so CoinPool adding a
5889
+ * chain or a non-USDC market needs no code change here.
5890
+ *
5891
+ * Those limits belong to supplying alone. Reading is wider still — no catalogue
5892
+ * and no chain set at all — see {@link file://./LendingReadService.ts}.
5893
+ *
5894
+ * As with everything in this core, no transaction is built or signed here: this
5895
+ * resolves and validates a market, and the FE owns the allowance check, the
5896
+ * per-protocol encoding and the signing.
5897
+ */
5898
+
5899
+ /**
5900
+ * The protocol families the FE can encode a deposit for. A market whose `type`
5901
+ * falls outside this set is refused rather than sent to the form.
5902
+ *
5903
+ * NOTE this is narrower than the set of types the READ path handles: reading
5904
+ * falls back to generic ERC-4626 for an unrecognised type, which is right for
5905
+ * describing a market and wrong for depositing into one, where a guess costs the
5906
+ * user their approval.
5907
+ */
5908
+ declare const SUPPLIABLE_TYPES: readonly SupplyProtocolType[];
5909
+ /** A market that passed every supply check — {@link LendingSupplyService.canSupply}. */
5910
+ interface SuppliableMarket extends LendingMarket {
5911
+ type: SupplyProtocolType;
5912
+ }
5913
+ declare class LendingSupplyService {
5914
+ private readonly coinPoolBaseUrl;
5915
+ constructor(coinPoolBaseUrl: string);
5916
+ /**
5917
+ * Hex chain ids a supply can target — the chains the catalogue actually
5918
+ * answers for, asked at call time rather than read from a table.
5919
+ */
5920
+ listChains(): Promise<string[]>;
5921
+ /** True when a chain (any alias / hex / decimal form) can be supplied on. */
5922
+ isSupported(chain?: string | null): Promise<boolean>;
5923
+ /** Every curated market on a chain. Empty when the chain has none. */
5924
+ getMarkets(chain: string): Promise<LendingMarket[]>;
5925
+ /**
5926
+ * Resolve ONE market on a chain from a free-text reference — the market name,
5927
+ * the protocol, or the contract address.
5928
+ *
5929
+ * Returns every close match rather than guessing when the reference is
5930
+ * ambiguous ("Morpho" on a chain with several Morpho vaults): depositing into
5931
+ * the wrong vault is not reversible, so the caller asks instead of picking.
5932
+ */
5933
+ findMarket(chain: string, reference: string): Promise<LendingMarket[]>;
5934
+ /**
5935
+ * Whether a deposit into this market can actually be encoded — the last gate
5936
+ * before a form opens. Narrows the type as it answers, so a caller that passes
5937
+ * this has a {@link SuppliableMarket} rather than a market with a string type.
5938
+ */
5939
+ canSupply(market: LendingMarket): market is SuppliableMarket;
5535
5940
  /**
5536
5941
  * The receipt token a supply into `market` credits — its own ERC-20 symbol and
5537
5942
  * decimals, read on chain in one multicall.
@@ -5554,26 +5959,232 @@ declare class LendingService {
5554
5959
  decimals: number | null;
5555
5960
  isUnderlying: boolean;
5556
5961
  }>;
5962
+ }
5963
+
5964
+ /**
5965
+ * Chain-id arithmetic for the lending module — a LEAF, importing nothing from
5966
+ * the rest of it.
5967
+ *
5968
+ * `chains.ts` is where "which chains can be supplied on?" is answered, and that
5969
+ * answer now comes from the catalogue, so `chains.ts` imports `catalog.ts`. The
5970
+ * catalogue in turn needs to parse a chain id before it can request one. These
5971
+ * two functions are what it needs and they depend on nothing, so they live here
5972
+ * rather than completing an import cycle.
5973
+ *
5974
+ * `chains.ts` re-exports both, so callers keep importing them from there.
5975
+ */
5976
+
5977
+ /**
5978
+ * Stands in for "this market's asset could not be established" — a sentinel,
5979
+ * never an address to read or approve.
5980
+ *
5981
+ * A market that cannot name its own underlying used to be attributed to the
5982
+ * chain's USDC. That was a guess, and a costly one on the supply path: the user
5983
+ * would approve and spend USDC against a market lending something else. There is
5984
+ * no chain-level asset to fall back to any more, so the resolver reports this
5985
+ * address with NaN decimals instead, which suppresses the market's size on the
5986
+ * read path and blocks the form on the write path.
5987
+ */
5988
+ declare const UNRESOLVED_ASSET = "0x0000000000000000000000000000000000000000";
5989
+
5990
+ /**
5991
+ * Which chains lending works on — and the distinction that runs through this
5992
+ * whole module: **reading is wider than supplying**.
5993
+ *
5994
+ * The two are not the same set and must never be conflated:
5995
+ *
5996
+ * - **Supply chains** — wherever CoinPool actually returns curated markets, asked
5997
+ * at runtime rather than declared here. `/supply/v2` is what says a market
5998
+ * exists; this module's job is to ASK it, not to predict its answer.
5999
+ * - **Read chains** — anywhere at all. A receipt token identifies its own market
6000
+ * on chain (see `discovery.ts`), so describing an aWETH position on a chain
6001
+ * CoinPool never heard of is perfectly possible. Reading is gated by what the
6002
+ * RPC layer supports, not by the supply catalogue.
6003
+ *
6004
+ * Gating a READ on the supply set is the bug this split exists to prevent: it
6005
+ * makes a position the user genuinely holds disappear from the app, for the
6006
+ * unrelated reason that nobody can deposit there through us.
6007
+ *
6008
+ * ## Why there is no chain table here any more
6009
+ *
6010
+ * There used to be a five-entry `SUPPLY_CHAINS` map, each with a hardcoded USDC
6011
+ * address. It was wrong in both directions: CoinPool adding a chain did nothing
6012
+ * until someone edited this file, and a market that lends something other than
6013
+ * USDC had no way to say so. Both facts already exist upstream — the chain list
6014
+ * is whatever `/supply/v2` answers for, and the asset is whatever the market's
6015
+ * own `underlyingCall` returns on chain — so both are read from there now.
6016
+ *
6017
+ * The candidate chains to ASK are the RPC layer's own active set
6018
+ * ({@link listCandidateChains}); a chain the core cannot reach has nothing to
6019
+ * offer a supply flow even if CoinPool lists it.
6020
+ *
6021
+ * Every function that consults the catalogue takes the CoinPool base URL, since
6022
+ * a host may point the core at its own deployment — there is no global default
6023
+ * hiding in here for the same reason there is no chain table.
6024
+ */
6025
+
6026
+ /**
6027
+ * The chains worth ASKING `/supply/v2` about — the RPC layer's active set.
6028
+ *
6029
+ * Not a claim that any of them has markets; that is what {@link listSupplyChains}
6030
+ * resolves. A chain the core has no RPC for is excluded because every downstream
6031
+ * step (market size, balances, receipt-token metadata) needs one.
6032
+ */
6033
+ declare function listCandidateChains(): string[];
6034
+ /**
6035
+ * Hex chain ids that currently have curated supply markets, discovered by asking
6036
+ * `/supply/v2` for every candidate chain in parallel.
6037
+ *
6038
+ * Live, not declared: a chain CoinPool adds shows up here with no code change,
6039
+ * and one it drops disappears. `catalog.ts` caches each chain's answer briefly,
6040
+ * so the repeated calls one turn makes cost a single round of requests.
6041
+ */
6042
+ declare function listSupplyChains(baseUrl: string): Promise<string[]>;
6043
+ /**
6044
+ * True when a chain (any alias / hex / decimal form) has curated supply markets
6045
+ * right now — asked, not assumed.
6046
+ */
6047
+ declare function isSupplyChain(baseUrl: string, chain?: string | null): Promise<boolean>;
6048
+
6049
+ /**
6050
+ * The lending domain, in one object — a facade over two services split by what
6051
+ * they are FOR.
6052
+ *
6053
+ * ## The split, and why it exists
6054
+ *
6055
+ * Reading and supplying want different things, and an earlier single class made
6056
+ * them share limits that belong to only one of them:
6057
+ *
6058
+ * - **{@link read} — {@link LendingReadService}. Every asset, every chain.**
6059
+ * What the Keyring app consumes. A wallet can hold any receipt token at all:
6060
+ * aWETH on Base, an uncurated Morpho vault, a receipt from a chain
6061
+ * `/supply/v2` never covered. Each of those describes its own market on chain,
6062
+ * so each is describable — provided its receipt token is one of the three
6063
+ * shapes the probes recognise (Aave v3 aToken, Comet, ERC-4626); Aave v2 and
6064
+ * Compound v2 are NOT among them. See that service's "What this does NOT
6065
+ * cover". The app already knows WHICH tokens a wallet
6066
+ * holds (its token API tags them `yieldProtocol` / `yieldAsset`, and
6067
+ * {@link file://./lending/yieldTokenValue.ts} values them); what it cannot get
6068
+ * from a token list is the market behind the token, which is what
6069
+ * {@link LendingReadService.describeReceiptTokens} answers — in one batch.
6070
+ *
6071
+ * - **{@link supply} — {@link LendingSupplyService}. Curated and encodable.**
6072
+ * Narrower on purpose, but along two axes only: `/supply/v2` decides a market
6073
+ * exists, and only the protocol families the FE can encode a deposit for may be
6074
+ * targeted. That second limit comes from the write path — a market with no
6075
+ * correct calldata fails at signing, after the user already approved the asset
6076
+ * to it. Neither the CHAIN nor the ASSET is limited here: the chains are
6077
+ * whichever ones the catalogue answers for, and each market's asset is read
6078
+ * from the market itself, so a non-USDC market supplies its own asset.
6079
+ *
6080
+ * Gating a READ on the supply set is the specific bug this split prevents — it
6081
+ * makes a position the user genuinely holds disappear from the app, for the
6082
+ * unrelated reason that nobody can deposit there through us.
6083
+ *
6084
+ * Both halves share one pipeline ({@link file://./lending/describe.ts}) and one
6085
+ * APY concurrency budget, so a wide scan stays polite to every upstream.
6086
+ *
6087
+ * ## Where the numbers come from
6088
+ *
6089
+ * A wallet's supplied balance is NOT read from an indexer: the receipt token
6090
+ * (aToken / Comet / ERC-4626 vault share) is read straight from chain through
6091
+ * Multicall3, so the number always matches what the app shows. Everything else
6092
+ * comes from the same sources the CoinPool web app itself uses — its
6093
+ * `useUsdcLendingData` hook, in the SEPARATE `coinpool-v2` repository
6094
+ * (`src/hooks/useUsdcLendingData.ts`), is the reference this service was checked
6095
+ * against protocol by protocol:
6096
+ *
6097
+ * - market list ................. CoinPool `GET /supply/v2?chainId=…`
6098
+ * - supply-APY history ......... Aave v3 GraphQL (`aave-v3`),
6099
+ * Morpho GraphQL (`morpho-v2`),
6100
+ * CoinPool `GET /supply/rates/history` (rest)
6101
+ * - supplied amount / market size on-chain via Multicall3
6102
+ *
6103
+ * Reported APY is the AVERAGE of the daily supply-APY samples of the last
6104
+ * `APY_HISTORY_DAYS` days plus the live rate — a spot rate swings with borrow
6105
+ * demand, so an average is what a supplier actually earns.
6106
+ *
6107
+ * ## Protocols differ; the pipeline does not
6108
+ *
6109
+ * The market kinds disagree on every input: where the market size lives, whether
6110
+ * the receipt token is 1:1 with USDC or an ERC-4626 share, which API knows the
6111
+ * rate history, and whether a live rate has to come off-chain. Each kind is a
6112
+ * class in {@link file://./lending/protocols.ts}; the pipeline drives them and
6113
+ * knows about no protocol by name.
6114
+ *
6115
+ * | | market size | balance | APY history | live APY |
6116
+ * |--------------|----------------|-------------|-------------|------------|
6117
+ * | aave-v3 | aToken supply | underlying | Aave API | on-chain |
6118
+ * | compound-v3 | Comet supply | underlying | CoinPool | newest row |
6119
+ * | spark* | totalAssets() | ERC-4626 | CoinPool | newest row |
6120
+ * | morpho-v2 | totalAssets() | ERC-4626 | Morpho API | from API |
6121
+ *
6122
+ * Two entries in that last column are worth stating outright, because the app
6123
+ * looks like it disagrees. The app derives EVERY protocol's live rate on-chain,
6124
+ * each with its own formula; here only Aave does. That is not a shortcut taken
6125
+ * blindly — CoinPool's history endpoint refreshes intraday and its newest row
6126
+ * was checked against chain to six decimals for all three protocols that use it.
6127
+ * Aave is the one case where the API and the on-chain figure genuinely differ,
6128
+ * so it is the one case that pays for the extra call.
6129
+ *
6130
+ * Protocols DECLARE their on-chain calls rather than making them, so every
6131
+ * market on a chain still resolves in ONE Multicall3 round-trip regardless of
6132
+ * how many protocols are involved — see the protocols module for why.
6133
+ *
6134
+ * Independent of {@link file://./MoralisService.ts}: these markets are curated
6135
+ * by the CoinPool platform and an indexer neither knows the curated set nor the
6136
+ * vault share → USDC conversion.
6137
+ */
6138
+ declare class LendingService {
6139
+ /** Reading: every asset, every chain; Aave v3 / Comet / ERC-4626 receipt shapes. */
6140
+ readonly read: LendingReadService;
6141
+ /** Supplying: curated markets and encodable protocols only — any chain, any asset. */
6142
+ readonly supply: LendingSupplyService;
6143
+ constructor(config?: LendingServiceConfig);
6144
+ /** Hex chain ids with curated supply markets, as the catalogue reports them now. */
6145
+ listSupportedChains(): Promise<string[]>;
6146
+ /** True when the given chain (any alias / hex / decimal form) can be supplied on. */
6147
+ isSupported(chain?: string | null): Promise<boolean>;
6148
+ /** Every curated market on a chain. Empty when it has none; never throws. */
6149
+ getMarkets(chain: string): Promise<LendingMarket[]>;
6150
+ /** Resolve markets on a chain from a name, protocol or contract address. */
6151
+ findMarket(chain: string, reference: string): Promise<LendingMarket[]>;
6152
+ /** Whether a deposit into this market can be encoded by the FE. */
6153
+ canSupply(market: LendingMarket): boolean;
6154
+ /** ERC-20 symbol + decimals of the receipt token a supply credits. */
6155
+ readReceiptToken(chain: string, market: Pick<LendingMarket, 'token' | 'type'>): Promise<{
6156
+ symbol: string | null;
6157
+ decimals: number | null;
6158
+ isUnderlying: boolean;
6159
+ }>;
5557
6160
  /**
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.
6161
+ * Describe the markets behind a wallet's receipt tokens, batched. The app's
6162
+ * entry point for showing assets other than USDC — see
6163
+ * {@link LendingReadService.describeReceiptTokens}.
5561
6164
  *
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.
6165
+ * @param rpcUrl Optional endpoint for `chain`, installed as this core's RPC
6166
+ * override before the read. Pass the host's own endpoint for any chain this
6167
+ * core carries no definition for — without one the read comes back empty as
6168
+ * though the token were a plain ERC-20.
5566
6169
  */
5567
- findMarket(chain: string, reference: string): Promise<LendingMarket[]>;
6170
+ describeReceiptTokens(chain: string, tokens: readonly string[], rpcUrl?: string): Promise<Map<string, LendingMarketOverview>>;
5568
6171
  /**
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.
6172
+ * The market ONE receipt token belongs to. Prefer {@link describeReceiptTokens} for several.
6173
+ *
6174
+ * @param rpcUrl Optional endpoint for `chain` — see {@link describeReceiptTokens}.
5572
6175
  */
6176
+ findMarketByReceiptToken(chain: string, receiptToken: string, rpcUrl?: string): Promise<LendingMarketOverview | null>;
6177
+ /** Size + APY for markets already resolved by {@link findMarket}, in the order given. */
5573
6178
  describeResolvedMarkets(chain: string, markets: LendingMarket[]): Promise<LendingMarketOverview[]>;
5574
6179
  /**
5575
6180
  * 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.
6181
+ * can I supply?" view. Highest average APY first, unrated markets last.
6182
+ *
6183
+ * No chain is filtered out in advance: a chain with no markets contributes an
6184
+ * empty catalogue and therefore nothing, which is the same outcome an
6185
+ * allowlist would produce and costs one request instead of a stale assumption.
6186
+ * Each market reports its own {@link LendingMarketOverview.asset}, so a
6187
+ * non-USDC market is listed as itself rather than dropped.
5577
6188
  *
5578
6189
  * Chains are queried in parallel and contribute independently: a chain whose
5579
6190
  * API or RPC fails yields nothing rather than failing the whole call.
@@ -5582,69 +6193,14 @@ declare class LendingService {
5582
6193
  chains: readonly string[];
5583
6194
  }): Promise<LendingMarketOverview[]>;
5584
6195
  /**
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.
6196
+ * Every curated lending market the wallet currently supplies to, across
6197
+ * `chains`, highest supplied amount first — see
6198
+ * {@link LendingReadService.getSupplyPositions}.
5589
6199
  */
5590
6200
  getSupplyPositions(params: {
5591
6201
  address: string;
5592
6202
  chains: readonly string[];
5593
6203
  }): 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
6204
  }
5649
6205
 
5650
6206
  type LendingMarketsToolConfig = LendingServiceConfig;
@@ -5653,7 +6209,7 @@ type SortKey = 'apy' | 'score' | 'size';
5653
6209
  /**
5654
6210
  * Tool: get-lending-markets
5655
6211
  *
5656
- * The USDC lending markets a user CAN supply to — the catalogue side of the
6212
+ * The lending markets a user CAN supply to — the catalogue side of the
5657
6213
  * lending domain, as opposed to `get-wallet-lending-positions` which reports
5658
6214
  * what a wallet already supplies. Each market carries its size, the protocol's
5659
6215
  * live supply APY — the rate the list is ranked on, and the one a depositor is
@@ -5707,6 +6263,12 @@ declare class LendingMarketsTool extends BaseTool {
5707
6263
  currentApyPercent: number | null;
5708
6264
  apyChangePercent: number | null;
5709
6265
  totalSuppliedUsdc: number | null;
6266
+ /**
6267
+ * What `totalSuppliedUsdc` is denominated in. Almost always USDC, but a
6268
+ * market on another asset reports its own — so the formatting rule below
6269
+ * can say "dollars" only when this actually is a dollar stablecoin.
6270
+ */
6271
+ suppliedAssetSymbol: string | null;
5710
6272
  platformScore: number | null;
5711
6273
  }[];
5712
6274
  protocolFilter?: string | undefined;
@@ -5780,6 +6342,16 @@ declare class WalletLendingPositionsTool extends BaseTool {
5780
6342
  chainsQueried: string[];
5781
6343
  positionCount: number;
5782
6344
  totals: {
6345
+ mixedAssets: boolean;
6346
+ suppliedUsdc: null;
6347
+ estimatedAnnualYieldUsdc: null;
6348
+ weightedAvgApyPercent: null;
6349
+ /** Denominated in the single asset every position shares. */
6350
+ assetSymbol?: undefined;
6351
+ } | {
6352
+ mixedAssets: boolean;
6353
+ /** Denominated in the single asset every position shares. */
6354
+ assetSymbol: string | null;
5783
6355
  suppliedUsdc: number;
5784
6356
  estimatedAnnualYieldUsdc: number;
5785
6357
  weightedAvgApyPercent: number | null;
@@ -5790,6 +6362,8 @@ declare class WalletLendingPositionsTool extends BaseTool {
5790
6362
  protocolUrl: string | null;
5791
6363
  chain: string;
5792
6364
  suppliedUsdc: number;
6365
+ /** What `suppliedUsdc` and `estimatedAnnualYieldUsdc` are denominated in. */
6366
+ suppliedAssetSymbol: string | null;
5793
6367
  avgApyPercent: number | null;
5794
6368
  currentApyPercent: number | null;
5795
6369
  apyChangePercent: number | null;
@@ -5806,16 +6380,22 @@ declare class WalletLendingPositionsTool extends BaseTool {
5806
6380
  }
5807
6381
 
5808
6382
  interface OpenSupplyFormToolConfig extends LendingServiceConfig {
5809
- /** Moralis config for the USDC balance shown on the form. */
6383
+ /** Moralis config for the asset balance shown on the form. */
5810
6384
  moralis?: MoralisServiceConfig;
5811
6385
  }
5812
6386
  /**
5813
6387
  * Tool: open-supply-usdc-form
5814
6388
  *
5815
- * Opens the form that deposits USDC into ONE lending market. The counterpart to
6389
+ * Opens the form that deposits into ONE lending market. The counterpart to
5816
6390
  * `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.
6391
+ * market the user picked, reads the asset THAT market lends, checks the wallet's
6392
+ * balance of it, and hands the FE everything it needs to run the approve →
6393
+ * supply sequence itself.
6394
+ *
6395
+ * The asset is never assumed to be USDC. `/supply/v2` decides which markets
6396
+ * exist and `LendingService` resolves each one's underlying on chain, so a
6397
+ * market on WETH is supplied in WETH; USDC is only the fallback for a market
6398
+ * whose asset could not be read. See {@link supplyAsset}.
5819
6399
  *
5820
6400
  * Like every wallet action in this core, the tool does NOT build or sign a
5821
6401
  * transaction — it resolves and validates, then emits a `SupplyUsdcForm` payload.
@@ -5839,7 +6419,8 @@ declare class OpenSupplyFormTool extends BaseTool {
5839
6419
  candidates?: undefined;
5840
6420
  marketName?: undefined;
5841
6421
  protocol?: undefined;
5842
- usdcBalance?: undefined;
6422
+ assetSymbol?: undefined;
6423
+ assetBalance?: undefined;
5843
6424
  requestedAmount?: undefined;
5844
6425
  ui?: undefined;
5845
6426
  apyPercent?: undefined;
@@ -5852,7 +6433,8 @@ declare class OpenSupplyFormTool extends BaseTool {
5852
6433
  candidates?: undefined;
5853
6434
  marketName?: undefined;
5854
6435
  protocol?: undefined;
5855
- usdcBalance?: undefined;
6436
+ assetSymbol?: undefined;
6437
+ assetBalance?: undefined;
5856
6438
  requestedAmount?: undefined;
5857
6439
  ui?: undefined;
5858
6440
  apyPercent?: undefined;
@@ -5865,7 +6447,8 @@ declare class OpenSupplyFormTool extends BaseTool {
5865
6447
  candidates?: undefined;
5866
6448
  marketName?: undefined;
5867
6449
  protocol?: undefined;
5868
- usdcBalance?: undefined;
6450
+ assetSymbol?: undefined;
6451
+ assetBalance?: undefined;
5869
6452
  requestedAmount?: undefined;
5870
6453
  ui?: undefined;
5871
6454
  apyPercent?: undefined;
@@ -5881,7 +6464,8 @@ declare class OpenSupplyFormTool extends BaseTool {
5881
6464
  chainsWithLendingMarkets?: undefined;
5882
6465
  marketName?: undefined;
5883
6466
  protocol?: undefined;
5884
- usdcBalance?: undefined;
6467
+ assetSymbol?: undefined;
6468
+ assetBalance?: undefined;
5885
6469
  requestedAmount?: undefined;
5886
6470
  ui?: undefined;
5887
6471
  apyPercent?: undefined;
@@ -5894,20 +6478,22 @@ declare class OpenSupplyFormTool extends BaseTool {
5894
6478
  chainsWithLendingMarkets?: undefined;
5895
6479
  market?: undefined;
5896
6480
  candidates?: undefined;
5897
- usdcBalance?: undefined;
6481
+ assetSymbol?: undefined;
6482
+ assetBalance?: undefined;
5898
6483
  requestedAmount?: undefined;
5899
6484
  ui?: undefined;
5900
6485
  apyPercent?: undefined;
5901
6486
  } | {
5902
6487
  error: string;
6488
+ marketName: string;
5903
6489
  chain: string;
5904
6490
  _instructions: string;
5905
6491
  chainsWithLendingMarkets?: undefined;
5906
6492
  market?: undefined;
5907
6493
  candidates?: undefined;
5908
- marketName?: undefined;
5909
6494
  protocol?: undefined;
5910
- usdcBalance?: undefined;
6495
+ assetSymbol?: undefined;
6496
+ assetBalance?: undefined;
5911
6497
  requestedAmount?: undefined;
5912
6498
  ui?: undefined;
5913
6499
  apyPercent?: undefined;
@@ -5915,7 +6501,8 @@ declare class OpenSupplyFormTool extends BaseTool {
5915
6501
  error: string;
5916
6502
  marketName: string;
5917
6503
  chain: string;
5918
- usdcBalance: string;
6504
+ assetSymbol: string;
6505
+ assetBalance: string;
5919
6506
  _instructions: string;
5920
6507
  chainsWithLendingMarkets?: undefined;
5921
6508
  market?: undefined;
@@ -5928,8 +6515,9 @@ declare class OpenSupplyFormTool extends BaseTool {
5928
6515
  error: string;
5929
6516
  marketName: string;
5930
6517
  chain: string;
6518
+ assetSymbol: string;
5931
6519
  requestedAmount: string | null;
5932
- usdcBalance: string;
6520
+ assetBalance: string;
5933
6521
  _instructions: string;
5934
6522
  chainsWithLendingMarkets?: undefined;
5935
6523
  market?: undefined;
@@ -5943,7 +6531,8 @@ declare class OpenSupplyFormTool extends BaseTool {
5943
6531
  protocol: string;
5944
6532
  chain: string;
5945
6533
  apyPercent: number | null;
5946
- usdcBalance: string | null;
6534
+ assetSymbol: string;
6535
+ assetBalance: string | null;
5947
6536
  _instructions: string;
5948
6537
  error?: undefined;
5949
6538
  chainsWithLendingMarkets?: undefined;
@@ -5954,24 +6543,24 @@ declare class OpenSupplyFormTool extends BaseTool {
5954
6543
  /** Size + live APY for the one resolved market. Null when it can't be priced. */
5955
6544
  private describeOne;
5956
6545
  /**
5957
- * The wallet's USDC on this chain, for the form's spendable line and the
5958
- * balance checks above.
6546
+ * The wallet's balance of the market's asset on this chain, for the form's
6547
+ * spendable line and the balance checks above.
5959
6548
  *
5960
6549
  * The distinction that matters here is "the call FAILED" vs "the call
5961
6550
  * succeeded and reported nothing", which a bare null cannot express:
5962
6551
  *
5963
6552
  * - `null` — the balance is genuinely UNREADABLE (request failed or threw).
5964
6553
  * 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.
6554
+ * - `{ amount: '0' }` — the request SUCCEEDED and returned no row for it.
5966
6555
  *
5967
6556
  * The second case is the one that was being missed. `getWalletTokenBalances`
5968
6557
  * serves portfolio LISTS, so it drops zero rows and anything worth under a
5969
6558
  * cent; we asked it for this one token, so a successful call with no row means
5970
6559
  * 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.
6560
+ * it as '0' is what lets the `no_asset_balance` branch fire instead of opening
6561
+ * a form the user cannot submit.
5973
6562
  */
5974
- private usdcBalance;
6563
+ private assetBalance;
5975
6564
  /**
5976
6565
  * Presentation contract for the synthesizer. Only reached once the supply is
5977
6566
  * actually possible — an empty or short balance returns earlier with its own
@@ -8483,6 +9072,18 @@ interface ClientBatchConfig {
8483
9072
  batchSize?: number;
8484
9073
  /** Extra ms to keep collecting before sending (default 0 — same tick). */
8485
9074
  wait?: number;
9075
+ /**
9076
+ * On a chain with NO Multicall3, batches degrade to individual
9077
+ * `eth_call`s — this bounds how many are in flight (default 8). Raise it
9078
+ * for a private node, lower it for an endpoint that rate-limits hard.
9079
+ */
9080
+ fallbackConcurrency?: number;
9081
+ /**
9082
+ * Skip the one-off `eth_getCode` that verifies Multicall3 exists, and
9083
+ * assume it does. For hosts that only ever touch chains they know carry
9084
+ * the deployment and want to save the probe. Default `false`.
9085
+ */
9086
+ assumeMulticall3?: boolean;
8486
9087
  };
8487
9088
  }
8488
9089
  interface Client {
@@ -8533,9 +9134,11 @@ type MulticallResult<TResult = unknown> = {
8533
9134
  * Chain lookup + RPC-endpoint resolution — the single source of truth for
8534
9135
  * "which node do we talk to for chain X".
8535
9136
  *
8536
- * Resolution order, unchanged from before the client rewrite:
9137
+ * Resolution order:
8537
9138
  * 1. a caller-supplied override (`AgentConfig.rpcUrls` → {@link setRpcOverrides}),
8538
- * 2. the chain definition's default public RPC.
9139
+ * 2. the remote Pantograph catalogue ({@link file://./remote.ts}), once loaded —
9140
+ * which also supplies endpoints for chains carrying no definition here,
9141
+ * 3. the chain definition's default public RPC, as the floor beneath both.
8539
9142
  *
8540
9143
  * An override changes only which endpoint is PREFERRED — the chain's built-in
8541
9144
  * endpoints stay behind it as backups, so a host that configures its own node
@@ -8565,12 +9168,30 @@ declare function setRpcOverrides(overrides?: Record<string, string>): void;
8565
9168
  /** The currently installed overrides (read-only copy). */
8566
9169
  declare function getRpcOverrides(): Readonly<Record<string, string>>;
8567
9170
  /**
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
9171
+ * Every endpoint for a chain, most-preferred first, from three layers:
9172
+ *
9173
+ * 1. the caller-supplied override (`AgentConfig.rpcUrls`),
9174
+ * 2. the remote Pantograph catalogue, when {@link loadRemoteChains} has run,
9175
+ * 3. the chain definition's built-in list.
9176
+ *
9177
+ * Duplicates are dropped, so an override naming an endpoint already present
8571
9178
  * simply promotes it rather than making it appear twice.
8572
9179
  *
8573
- * Empty only when the chain is neither overridden nor known.
9180
+ * The catalogue sits AHEAD of the built-ins: it is the same table the wallet
9181
+ * itself dials, maintained live, so an endpoint that has degraded since this
9182
+ * package was published is corrected there without a release. The built-ins
9183
+ * become the floor beneath it — still present, still ordered, and still the
9184
+ * whole answer whenever the catalogue has not loaded (startup, offline host,
9185
+ * API down) or does not carry the chain.
9186
+ *
9187
+ * The trade-off this accepts: the endpoint normally dialled for a known chain is
9188
+ * now chosen upstream rather than pinned in this repo, so a bad head entry in
9189
+ * the catalogue is felt on the first call rather than only as a backup. The
9190
+ * `fallback` transport covers that — it walks to the next endpoint on a
9191
+ * timeout/5xx/rate-limit — but latency is paid before it does.
9192
+ *
9193
+ * Empty only when the chain is overridden by nothing, absent from the
9194
+ * catalogue, and known to no definition.
8574
9195
  */
8575
9196
  declare function resolveRpcUrls(chainId: string | number): string[];
8576
9197
  /**
@@ -9154,6 +9775,15 @@ type StateOverride = Record<Address, StateOverrideAccount>;
9154
9775
  interface CallParameters extends TransactionRequest, BlockParameters {
9155
9776
  /** Temporary state (balances, code, storage) the call is simulated against. */
9156
9777
  stateOverride?: StateOverride;
9778
+ /**
9779
+ * Send this call on its own, never folded into the client's shared
9780
+ * `aggregate3`.
9781
+ *
9782
+ * Set by the no-Multicall3 fallback: those calls exist PRECISELY because the
9783
+ * chain has no Multicall3, so re-batching them would route them straight back
9784
+ * into the contract that isn't there.
9785
+ */
9786
+ skipBatch?: boolean;
9157
9787
  }
9158
9788
  interface CallReturnType {
9159
9789
  /** Return data, or `undefined` when the call returned nothing (`0x`). */
@@ -9234,11 +9864,16 @@ interface MulticallParameters extends BlockParameters {
9234
9864
  allowFailure?: boolean;
9235
9865
  /** Max calldata bytes per aggregated call; `0` disables splitting. */
9236
9866
  batchSize?: number;
9237
- /** Multicall3 address override — required on a chain the registry doesn't know. */
9867
+ /** Multicall3 address override — trusted as-is, skipping the deployment probe. */
9238
9868
  multicallAddress?: Address;
9239
9869
  /** Sender each read is simulated as. */
9240
9870
  account?: Address;
9241
9871
  stateOverride?: StateOverride;
9872
+ /**
9873
+ * Max `eth_call`s in flight on the no-Multicall3 fallback (default 8, or the
9874
+ * client's `batch.multicall.fallbackConcurrency`).
9875
+ */
9876
+ fallbackConcurrency?: number;
9242
9877
  }
9243
9878
  declare function multicall(client: Client, parameters: MulticallParameters & {
9244
9879
  allowFailure?: true;
@@ -9265,6 +9900,10 @@ declare function multicall(client: Client, parameters: MulticallParameters): Pro
9265
9900
  * batch. viem's `batchSize` bounds the REQUEST (calldata bytes); `maxCalls`
9266
9901
  * bounds the RESPONSE, which is what matters for reads whose returns are large
9267
9902
  * and unpredictable — on-chain `data:` token URIs being the case this core hits.
9903
+ *
9904
+ * On a chain with NO Multicall3 deployment it falls back to individual
9905
+ * `eth_call`s at bounded concurrency — see {@link file://./multicallFallback.ts}.
9906
+ * The result contract is identical either way, so callers never branch on it.
9268
9907
  */
9269
9908
 
9270
9909
  /** One pre-encoded call. */
@@ -9286,9 +9925,17 @@ interface MulticallRawParameters extends BlockParameters {
9286
9925
  multicallAddress?: Address;
9287
9926
  account?: Address;
9288
9927
  stateOverride?: StateOverride;
9928
+ /**
9929
+ * Max `eth_call`s in flight on the no-Multicall3 fallback (default 8, or the
9930
+ * client's `batch.multicall.fallbackConcurrency`). Ignored when the chain has
9931
+ * the deployment, where the whole batch is one request anyway.
9932
+ */
9933
+ fallbackConcurrency?: number;
9289
9934
  }
9290
9935
  /**
9291
- * Run pre-encoded calls through `aggregate3`, chunked and in parallel.
9936
+ * Run pre-encoded calls through `aggregate3`, chunked and in parallel — or, on a
9937
+ * chain with no Multicall3 deployment, as individual `eth_call`s at bounded
9938
+ * concurrency. Both routes return the same thing, so callers never branch.
9292
9939
  *
9293
9940
  * NEVER throws for a partial failure: a chunk whose RPC round-trip fails marks
9294
9941
  * only ITS OWN entries `success: false`, so one bad batch can't sink the rest.
@@ -9501,6 +10148,17 @@ interface GetPublicClientOptions {
9501
10148
  pinRpcUrl?: boolean;
9502
10149
  /** Fold parallel reads into one aggregate3 (default `true` — see below). */
9503
10150
  batch?: boolean;
10151
+ /**
10152
+ * How many `eth_call`s run at once when the chain turns out to have no
10153
+ * Multicall3 and a batch degrades to individual calls (default 8).
10154
+ */
10155
+ fallbackConcurrency?: number;
10156
+ /**
10157
+ * Trust the canonical Multicall3 address without the one-off `eth_getCode`
10158
+ * that verifies it. Saves a request per chain; only safe when every chain this
10159
+ * client touches is known to carry the deployment.
10160
+ */
10161
+ assumeMulticall3?: boolean;
9504
10162
  }
9505
10163
  /**
9506
10164
  * The shared client for a chain, created on first use.
@@ -10105,6 +10763,13 @@ declare function createX402SignatureProvider(opts: {
10105
10763
  * underlying (their decimals match it) and yield arrives as a growing
10106
10764
  * `balanceOf`. Converting these would be a bug, so they are left untouched.
10107
10765
  *
10766
+ * - **Oracle-priced shares** (`spark-l2-susds`) — share-based like the first
10767
+ * group, but with no `convertToAssets` to ask: bridged sUSDS is a plain ERC-20
10768
+ * on its chain (the vault stays on Ethereum), so the conversion reads the SSR
10769
+ * oracle's ray-scaled rate and multiplies. Still ONE call per token, decoded
10770
+ * differently — see {@link YieldConversionPlan.rateKeys}. Needs
10771
+ * {@link YieldTokenInput.chain}, since the oracle is per chain.
10772
+ *
10108
10773
  * Which side a token falls on is decided by an explicit allow-list of
10109
10774
  * share-based protocols, mirroring the wallet app's own `LENDING_PLATFORMS`.
10110
10775
  * The protocol classes encode the same split as `balanceIsUnderlying`, but that
@@ -10162,6 +10827,16 @@ interface YieldTokenInput {
10162
10827
  address?: string;
10163
10828
  decimals?: number;
10164
10829
  } | null;
10830
+ /**
10831
+ * Chain id — hex (`'0x2105'`) or decimal (`8453`), both accepted. Needed ONLY
10832
+ * by `spark-l2-susds`, whose conversion goes to that chain's SSR oracle rather
10833
+ * than to the token, and whose oracle address is per chain.
10834
+ *
10835
+ * Optional so existing callers are unaffected: every ERC-4626 type converts
10836
+ * against the token itself and never reads this. A sUSDS row without it is
10837
+ * passed through unconverted rather than converted against a guessed oracle.
10838
+ */
10839
+ chain?: string | number | null;
10165
10840
  }
10166
10841
  /** One declared `convertToAssets` read, tagged with the token it belongs to. */
10167
10842
  interface YieldConversionCall extends MulticallRequest {
@@ -10172,6 +10847,17 @@ interface YieldConversionCall extends MulticallRequest {
10172
10847
  interface YieldConversionPlan {
10173
10848
  /** Reads to perform, in order. Empty when nothing needs converting. */
10174
10849
  calls: YieldConversionCall[];
10850
+ /**
10851
+ * Keys in {@link calls} whose read returns a ray-scaled RATE rather than an
10852
+ * amount — cross-chain sUSDS, which has no `convertToAssets` and is valued
10853
+ * against its chain's SSR oracle instead.
10854
+ *
10855
+ * Exposed so {@link applyYieldConversions} can tell the two apart: decoding a
10856
+ * ray as though it were assets would report a ~10^27 balance. Callers execute
10857
+ * the plan exactly as before and need not consult this — it stays a single
10858
+ * round-trip, and there is no second phase to forget.
10859
+ */
10860
+ rateKeys: string[];
10175
10861
  }
10176
10862
  /** A token's corrected valuation. */
10177
10863
  interface YieldTokenValue {
@@ -10237,6 +10923,210 @@ declare function planYieldTokenConversions(tokens: YieldTokenInput[]): YieldConv
10237
10923
  */
10238
10924
  declare function applyYieldConversions(tokens: YieldTokenInput[], plan: YieldConversionPlan, returns: Array<string | null>): Map<string, YieldTokenValue>;
10239
10925
 
10926
+ /**
10927
+ * Executing half of the yield-token valuation — the transport `yieldTokenValue`
10928
+ * deliberately leaves to its caller, supplied once here so every consumer stops
10929
+ * writing its own.
10930
+ *
10931
+ * {@link file://./yieldTokenValue.ts} stays what it is: two pure, synchronous
10932
+ * functions that declare reads and fold answers back. That split earns its keep —
10933
+ * it is what makes the arithmetic testable without a node. What it did NOT earn
10934
+ * is a copy of the batching, chunking and error-swallowing in every app that
10935
+ * calls it, which is what actually happened: the wallet grew its own `aggregate3`
10936
+ * encoder and its own sequential fallback, duplicating `multicallRead` almost
10937
+ * line for line.
10938
+ *
10939
+ * So this module supplies the missing half against the core's own chain stack:
10940
+ *
10941
+ * - {@link valueYieldTokens} tokens the caller ALREADY described → values
10942
+ * - {@link getTokenPriceUSD} an address → the price of one unit, metadata
10943
+ * fetched here
10944
+ *
10945
+ * ## Why two entry points rather than one
10946
+ *
10947
+ * They differ in who owns the token's yield IDENTITY, and that is not a detail.
10948
+ *
10949
+ * A wallet's token list resolves `yieldProtocol` / `yieldAsset` from several
10950
+ * sources it alone can see — the live API response, the field persisted on the
10951
+ * token, a by-address re-ask, and its own stored snapshot — because no single one
10952
+ * is complete: the chain-wide discovery list omits the tag for real vaults, and a
10953
+ * vault recovered from a snapshot has no live entry at all. A token arriving with
10954
+ * an identity already resolved that way must be valued AS DESCRIBED;
10955
+ * re-fetching it here would see only the first of those sources and would
10956
+ * silently drop the tag, which understates the position by exactly the yield
10957
+ * accrued — the failure this whole area exists to prevent.
10958
+ *
10959
+ * {@link valueYieldTokens} is therefore the honest shape for a list: the caller
10960
+ * describes, this executes. It is also the only shape that is one batch rather
10961
+ * than N requests.
10962
+ *
10963
+ * {@link getTokenPriceUSD} is for the opposite case — a screen holding nothing
10964
+ * but an address (a token detail, a swap target, a search row). There is no
10965
+ * richer identity to respect, so fetching it here is not a loss, and it removes
10966
+ * the fetch-then-convert dance every such caller was repeating.
10967
+ */
10968
+
10969
+ /** Shared options for the calls in this module. */
10970
+ interface YieldPricingOptions {
10971
+ /**
10972
+ * Preferred RPC endpoint. PREFERS rather than replaces: the chain's other
10973
+ * known endpoints stay behind it as backups, so a caller passing its paid
10974
+ * provider keeps a fallback rather than losing one.
10975
+ */
10976
+ rpcUrl?: string;
10977
+ /**
10978
+ * Token API base URL. Defaults to the same Pantograph host the rest of the
10979
+ * core dials.
10980
+ */
10981
+ apiBaseUrl?: string;
10982
+ }
10983
+ /**
10984
+ * Value a set of ALREADY-DESCRIBED tokens, running their conversions in one
10985
+ * batch.
10986
+ *
10987
+ * Exactly {@link planYieldTokenConversions} → execute → {@link
10988
+ * applyYieldConversions}, which is the sequence every caller was writing by
10989
+ * hand. The contract of the two pure halves is preserved unchanged:
10990
+ *
10991
+ * - the returned map has an entry for EVERY input token, converted or not, so
10992
+ * the caller applies it uniformly;
10993
+ * - a failed read is never destructive — that token falls back to
10994
+ * `balance × price` with `converted: false`, so a flaky RPC understates a
10995
+ * position at worst instead of zeroing it;
10996
+ * - nothing convertible plans no calls and costs no RPC.
10997
+ *
10998
+ * `chainId` is also what reaches each input's `chain` field when the caller left
10999
+ * it unset — needed by cross-chain sUSDS, whose conversion goes to that chain's
11000
+ * SSR oracle rather than to the token. An input that names its own `chain` keeps
11001
+ * it, so a caller mixing chains in one array is not silently re-pointed.
11002
+ */
11003
+ declare function valueYieldTokens(chainId: string | number, tokens: YieldTokenInput[], options?: YieldPricingOptions): Promise<Map<string, YieldTokenValue>>;
11004
+ /**
11005
+ * The USD price of ONE unit of a token, in the unit its balance is actually
11006
+ * denominated in.
11007
+ *
11008
+ * The problem this solves is that the token API quotes a share-based vault at
11009
+ * its UNDERLYING asset's price, while the holder's balance is in SHARES — worth
11010
+ * more, and drifting further up as yield accrues. A screen showing the raw API
11011
+ * price therefore disagrees with the same wallet's token list, which converts.
11012
+ *
11013
+ * Conversion runs against a synthetic ONE-share balance, so the answer needs no
11014
+ * wallet balance and is equally right for a vault the user does not hold — the
11015
+ * token they are swapping INTO, say.
11016
+ *
11017
+ * Returns:
11018
+ * - the API price unchanged, and NO RPC, for every plain token and every
11019
+ * rebasing receipt (`aave-v3`, `compound-v3`), whose balance is already the
11020
+ * underlying;
11021
+ * - the per-SHARE price for a share-based vault that converted;
11022
+ * - `null` when there is no usable price, INCLUDING when a share-based vault's
11023
+ * read fails. That last case is deliberate: the API price is known to be in
11024
+ * the wrong unit there, so no price is better than a wrong one, and the
11025
+ * caller falls back to whatever it already had.
11026
+ */
11027
+ declare function getTokenPriceUSD(chainId: string | number, address: string, options?: YieldPricingOptions): Promise<number | null>;
11028
+ /**
11029
+ * The per-unit price of a token the caller has ALREADY fetched.
11030
+ *
11031
+ * Same answer as {@link getTokenPriceUSD} without the request, for callers that
11032
+ * hold an API row already — a search screen listing many tokens, or a wallet
11033
+ * pricing a vault whose zero balance left it nothing to convert.
11034
+ */
11035
+ declare function resolveTokenPriceUSD(chainId: string | number, token: YieldPricingToken, options?: YieldPricingOptions): Promise<number | null>;
11036
+ /** The fields {@link resolveTokenPriceUSD} reads off a token API row. */
11037
+ interface YieldPricingToken {
11038
+ address?: string | null;
11039
+ decimals?: number | string | null;
11040
+ /** The API's quote — for a share-based vault, the UNDERLYING's price. */
11041
+ price?: number | string | null;
11042
+ yieldProtocol?: string | null;
11043
+ yieldAsset?: {
11044
+ address?: string;
11045
+ decimals?: number;
11046
+ } | null;
11047
+ }
11048
+
11049
+ /**
11050
+ * Spark's PSM3 — the one hard-coded address per chain that makes cross-chain
11051
+ * sUSDS describable, and the reason nothing ELSE about it has to be hard-coded.
11052
+ *
11053
+ * ## Why a constant exists here at all
11054
+ *
11055
+ * Every other family in {@link file://./discovery.ts} is identified by probing
11056
+ * the receipt token: an aToken answers `POOL()`, a Comet answers `baseToken()`,
11057
+ * a 4626 vault answers `asset()`. Cross-chain sUSDS answers NONE of them, and
11058
+ * that is by design rather than by omission — Spark's docs are explicit:
11059
+ *
11060
+ * > The crosschain sUSDS token does not contain any ERC4626 functionality -
11061
+ * > this is only available on Ethereum mainnet.
11062
+ *
11063
+ * The reason is where the assets live. Mainnet sUSDS is a real vault holding
11064
+ * USDS; bridging via SkyLink moves only the SHARE token, leaving the USDS on
11065
+ * Ethereum. The token on Base therefore has no assets to report and nothing to
11066
+ * convert against, so `asset()`, `totalAssets()`, `convertToAssets()` and
11067
+ * `rateProvider()` all revert (verified on Base). It is, on chain, a plain
11068
+ * ERC-20 that happens to appreciate.
11069
+ *
11070
+ * With nothing on the token to probe, identification has to come from somewhere
11071
+ * that KNOWS the token, and PSM3 is that somewhere: it is the contract L2 swaps
11072
+ * route through, and it names all three assets plus the rate oracle.
11073
+ *
11074
+ * ## Why the address cannot be derived
11075
+ *
11076
+ * Checked, in order, before settling for a constant:
11077
+ *
11078
+ * - **CREATE2 / deterministic deploy** — no. `spark-psm/deploy/PSM3Deploy.sol`
11079
+ * is a plain `new PSM3(owner, usdc, usds, susds, rateProvider)`, so the
11080
+ * address falls out of the deployer's nonce. The four live deployments below
11081
+ * share no prefix, which is the same fact observed from outside.
11082
+ * - **An on-chain registry** — no. `sparkdotfi/spark-address-registry` is the
11083
+ * canonical source, but it is a Solidity `library` of `constant`s consumed at
11084
+ * COMPILE time; it is not deployed and cannot be called. No npm package
11085
+ * mirrors it either.
11086
+ * - **Sky's Chainlog** (`0xdA0Ab1e0…740F`) — genuinely on-chain and genuinely a
11087
+ * registry, but the wrong one: it lists Sky's MAINNET contracts (`MCD_PSM_*`,
11088
+ * `MCD_LITE_PSM_*`), holds no `PSM3` key, and is deployed only on Ethereum,
11089
+ * so a Base read cannot reach it.
11090
+ * - **A backlink from the token** — no. sUSDS exposes no `psm()`, `oracle()`,
11091
+ * `usds()` or any other pointer (probed; all revert). The relationship runs
11092
+ * one way, PSM3 → token.
11093
+ *
11094
+ * So one anchor per chain is the floor, not a shortcut.
11095
+ *
11096
+ * ## Why THIS constant rather than the obvious three
11097
+ *
11098
+ * The alternative is hard-coding USDS, sUSDS and the SSR oracle per chain.
11099
+ * PSM3 replaces all three because it names them at runtime, which is better on
11100
+ * two counts beyond arithmetic:
11101
+ *
11102
+ * - It is **self-checking**. A wrong PSM3 address makes `susds()` revert or
11103
+ * return a token that matches no holding, and the position simply stays
11104
+ * undiscovered — exactly today's behaviour, no worse. A wrong hard-coded
11105
+ * USDS, by contrast, yields a market that looks correct while describing the
11106
+ * wrong asset, which is the failure `protocols.ts` refuses to make anywhere
11107
+ * else.
11108
+ * - It **tracks upstream**. Spark governance can repoint the rate oracle;
11109
+ * `rateProvider()` follows it with no code change.
11110
+ *
11111
+ * Addresses come from Spark's own registry, quoted with the version comment it
11112
+ * carries so a future reader can diff against it:
11113
+ * https://github.com/sparkdotfi/spark-address-registry/blob/master/src/Base.sol
11114
+ */
11115
+
11116
+ /**
11117
+ * PSM3 on `chain`, or null where Spark has deployed none.
11118
+ *
11119
+ * Accepts hex (`'0x2105'`) or decimal (`8453`) — the lending paths use hex, the
11120
+ * wallet's token list carries numbers, and keying on the raw value would
11121
+ * silently miss one of them.
11122
+ *
11123
+ * Exported from the package because the app needs it too: exiting a cross-chain
11124
+ * sUSDS position is a PSM3 swap, and the app would otherwise keep its own copy
11125
+ * of this table, which is exactly the pair that drifts. This module is the one
11126
+ * place the addresses are recorded and justified.
11127
+ */
11128
+ declare function psm3For(chain: string | number | null | undefined): string | null;
11129
+
10240
11130
  /**
10241
11131
  * PantographService — Pantograph API client.
10242
11132
  *
@@ -10258,6 +11148,28 @@ declare const HEX_TO_PANTOGRAPH: Record<string, string>;
10258
11148
  */
10259
11149
  declare const TRENDING_DEFAULT_BY_HEX_CHAIN: Record<string, string[]>;
10260
11150
  declare function toPantographChain(hexChain: string): string;
11151
+ /** Raw token shape returned by Pantograph list endpoints (pre-normalization). */
11152
+ interface PantographRawToken {
11153
+ address?: string;
11154
+ token_address?: string;
11155
+ price?: number | string;
11156
+ icon_image?: string;
11157
+ decimals?: number | string;
11158
+ /**
11159
+ * Yield identity, carried through verbatim rather than normalised.
11160
+ *
11161
+ * These decide whether a balance is vault SHARES (which must be converted
11162
+ * on-chain before it can be valued) or already the underlying, so the
11163
+ * distinction between an ABSENT tag and a tag of `null` matters to callers:
11164
+ * absent means the question was never answered and should be re-asked, null
11165
+ * means answered "not a vault". Defaulting either one here would erase that.
11166
+ */
11167
+ yieldProtocol?: string | null;
11168
+ yieldAsset?: {
11169
+ address?: string;
11170
+ decimals?: number;
11171
+ } | null;
11172
+ }
10261
11173
  declare class PantographService {
10262
11174
  private baseUrl;
10263
11175
  constructor(config?: PantographServiceConfig);
@@ -10273,6 +11185,25 @@ declare class PantographService {
10273
11185
  * Mutates the array in-place. Non-fatal: silently skips on failure.
10274
11186
  */
10275
11187
  enrichTokenPrices(tokens: TokenBalance[], moralisChain: string): Promise<void>;
11188
+ /**
11189
+ * Raw pricing rows for specific contracts, with their yield identity intact.
11190
+ *
11191
+ * Separate from {@link enrichTokenPrices} because that one answers a different
11192
+ * question: it folds a price and a logo onto balances it was handed, dropping
11193
+ * everything else. Yield valuation needs the fields it drops — `decimals`, and
11194
+ * the `yieldProtocol` / `yieldAsset` pair that decides whether the quoted price
11195
+ * even belongs to the unit the balance is in.
11196
+ *
11197
+ * Rows are returned VERBATIM rather than normalised: `decimals` arrives as a
11198
+ * string on some tokens and an absent `yieldProtocol` must stay absent (see
11199
+ * {@link PantographRawToken}), so coercing here would destroy the very
11200
+ * distinctions the caller reads.
11201
+ *
11202
+ * Accepts a decimal or hex chain id — this route is keyed by the decimal id and
11203
+ * serves every EVM chain, so no per-chain slug is involved. Never throws: a
11204
+ * failed request yields an empty array, and the caller degrades per token.
11205
+ */
11206
+ getYieldPricingTokens(chainId: string | number, addresses: string[]): Promise<Array<PantographRawToken>>;
10276
11207
  /**
10277
11208
  * Fetch metadata + price for a single token from Pantograph.
10278
11209
  * Returns null if the token is not found or the request fails.
@@ -10636,4 +11567,4 @@ declare class AbortError extends Error {
10636
11567
  */
10637
11568
  declare function isAbortError(err: unknown): boolean;
10638
11569
 
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 };
11570
+ 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, convertSusdsShares, 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 };