keyring-agent-core 0.3.3 → 0.3.5

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
@@ -1614,8 +1614,8 @@ interface AgentConfig {
1614
1614
  /**
1615
1615
  * Base URL for the token/pool search gateway (default:
1616
1616
  * https://entry-gateway.backend-prod.api.uniswap.org). Separate from
1617
- * `baseUrl`: Uniswap moved SearchTokens to this host while ExploreStats
1618
- * and GraphQL stayed on the interface gateway.
1617
+ * `baseUrl`: Uniswap moved SearchTokens and the pool leaderboard to this
1618
+ * host while GraphQL stayed on the interface gateway.
1619
1619
  */
1620
1620
  searchBaseUrl?: string;
1621
1621
  /** Minimum USD value the user must supply to add liquidity. Default 10. */
@@ -1845,6 +1845,22 @@ declare class Subagent {
1845
1845
  interface RewriteResult {
1846
1846
  /** True if the user message depends on prior turns (pronoun, ellipsis, confirmation, continuation). */
1847
1847
  isFollowUp: boolean;
1848
+ /**
1849
+ * The model's SEMANTIC judgement of the latest message read in isolation:
1850
+ * does it state both an action and what that action applies to, so a reader
1851
+ * with zero access to prior turns understands it?
1852
+ *
1853
+ * This is the primitive `isFollowUp` and `topicChanged` are derived from.
1854
+ * Asking for it separately is what makes the pair reliable: the model used to
1855
+ * answer "is this a follow-up?" by pattern-matching topical similarity to the
1856
+ * previous turn, so a self-contained new intent that reused a token from the
1857
+ * previous turn ("buy usdc" during an add-liquidity flow) came back as a
1858
+ * follow-up and inherited context it never asked for. "Does this sentence
1859
+ * stand alone?" is a question about the sentence only, which the model
1860
+ * answers far more consistently — and it cannot be approximated with a word
1861
+ * list, since the same short reply is elliptical or not depending on meaning.
1862
+ */
1863
+ selfContained: boolean;
1848
1864
  /**
1849
1865
  * The fully-resolved, self-contained version of the user query in the user's
1850
1866
  * language. Equal to the original message when `isFollowUp` is false.
@@ -5337,7 +5353,7 @@ declare class TransactionByHashTool extends BaseTool {
5337
5353
  * them.
5338
5354
  */
5339
5355
  /** Market kinds `/supply/v2` returns; see {@link PROTOCOLS}. */
5340
- type LendingProtocolType = 'aave-v3' | 'compound-v3' | 'spark' | 'spark-ethereum' | 'spark-l2-susds' | 'morpho-v2';
5356
+ type LendingProtocolType = 'aave-v3' | 'compound-v3' | 'spark' | 'spark-ethereum' | 'spark-l2-susds' | 'morpho-v2' | 'maple';
5341
5357
  /**
5342
5358
  * The per-chain facts a protocol needs — the numeric chain id, and nothing else.
5343
5359
  *
@@ -7397,13 +7413,12 @@ declare class PoolFallbackAiTool extends BaseTool {
7397
7413
  * UniswapService — Uniswap Explore API.
7398
7414
  *
7399
7415
  * Wraps the public endpoints that power https://app.uniswap.org/explore. These
7400
- * are Connect-RPC services: ExploreStats JSON-encodes its request into a
7401
- * `message` query parameter, search POSTs a JSON body; both answer plain JSON.
7416
+ * are Connect-RPC services that POST a JSON body and answer plain JSON.
7402
7417
  *
7403
- * Two gateways, deliberately: ExploreStats + GraphQL stay on
7404
- * `interface.gateway.uniswap.org`, while token/pool search moved to
7405
- * `entry-gateway.backend-prod.api.uniswap.org` — see
7406
- * {@link DEFAULT_SEARCH_BASE_URL}.
7418
+ * Two gateways, deliberately: pool leaderboards (ListPools) and token/pool
7419
+ * search live on `entry-gateway.backend-prod.api.uniswap.org`, while the
7420
+ * per-pool GraphQL detail queries remain on `interface.gateway.uniswap.org` —
7421
+ * see {@link DEFAULT_SEARCH_BASE_URL}.
7407
7422
  *
7408
7423
  * No SDK dependencies — uses native `fetch`.
7409
7424
  */
@@ -7414,12 +7429,19 @@ interface UniswapServiceConfig {
7414
7429
  * Base URL for the token/pool SEARCH gateway (default:
7415
7430
  * https://entry-gateway.backend-prod.api.uniswap.org).
7416
7431
  *
7417
- * Deliberately separate from {@link baseUrl}: Uniswap moved SearchTokens to
7418
- * this host while ExploreStats and GraphQL stayed on the interface gateway,
7419
- * so the two cannot share one origin. Kept configurable so the rest of the
7432
+ * Deliberately separate from {@link baseUrl}: Uniswap moved SearchTokens and
7433
+ * the pool leaderboard here while GraphQL stayed on the interface gateway, so
7434
+ * the two cannot share one origin. Kept configurable so the rest of the
7420
7435
  * migration can be followed without a code change.
7421
7436
  */
7422
7437
  searchBaseUrl?: string;
7438
+ /**
7439
+ * Base URL for the per-pool LIQUIDITY gateway (default:
7440
+ * https://liquidity.backend-prod.api.uniswap.org), which serves
7441
+ * version-agnostic pool detail. A third origin for the same reason
7442
+ * {@link searchBaseUrl} is a second one — see {@link DEFAULT_LIQUIDITY_BASE_URL}.
7443
+ */
7444
+ liquidityBaseUrl?: string;
7423
7445
  }
7424
7446
  type UniswapProtocolVersion = 'V2' | 'V3' | 'V4';
7425
7447
 
@@ -7458,10 +7480,10 @@ type TopPoolsToolConfig = UniswapServiceConfig & {
7458
7480
  /**
7459
7481
  * Tool: get-top-pools
7460
7482
  *
7461
- * Wraps Uniswap's ExploreStats endpoint
7462
- * (`uniswap.explore.v1.ExploreStatsService/ExploreStats`) to surface the
7463
- * top liquidity pools for a given EVM chain. Returns pools ranked by TVL by
7464
- * default; sorting can be switched to volume or transaction count.
7483
+ * Wraps Uniswap's ListPools endpoint (`data.v2.DataApiService/ListPools`) — the
7484
+ * source app.uniswap.org/explore reads — to surface the top liquidity pools for
7485
+ * a given EVM chain. Returns pools ranked by TVL by default; sorting can be
7486
+ * switched to 1d/30d volume or APR, all of which the endpoint ranks server-side.
7465
7487
  */
7466
7488
  declare class TopPoolsTool extends BaseTool {
7467
7489
  name: string;
@@ -7470,11 +7492,12 @@ declare class TopPoolsTool extends BaseTool {
7470
7492
  parameters: ToolParameter[];
7471
7493
  private service;
7472
7494
  /**
7473
- * The Graph subgraph client, used ONLY as a data fallback when Uniswap's
7474
- * ExploreStats has no V3 pools for a chain (e.g. Optimism / Polygon, which are
7475
- * V4-populated in Explore but still have rich V3 pools on the subgraph). This
7476
- * is a tool-layer data fallback — the pool agent's tool surface stays
7477
- * Uniswap-only; it never sees a subgraph tool.
7495
+ * The Graph subgraph client, used ONLY as a data fallback when Uniswap returns
7496
+ * no V3 pools for a chain. ListPools closed the old ExploreStats gap on
7497
+ * Optimism / Polygon, but thin chains still come back near-empty (Linea served
7498
+ * a single V3 pool at the time of writing), so the fallback stays. This is a
7499
+ * tool-layer data fallback — the pool agent's tool surface stays Uniswap-only;
7500
+ * it never sees a subgraph tool.
7478
7501
  */
7479
7502
  private subgraphFallback;
7480
7503
  /** Used ONLY to check add-liquidity (gateway) support per chain — see {@link PoolService.isAddLiquiditySupported}. */
@@ -7486,6 +7509,9 @@ declare class TopPoolsTool extends BaseTool {
7486
7509
  * numbers rather than the LLM's arithmetic. `volumeToTvlRatio` (24h volume ÷
7487
7510
  * TVL) is the single most informative LP-quality signal — capital efficiency /
7488
7511
  * how hard each dollar of liquidity is working.
7512
+ *
7513
+ * ListPools reports the ratio itself, so an upstream value is used as-is;
7514
+ * the local division only covers sources that don't (the subgraph fallback).
7489
7515
  */
7490
7516
  private withExpertSignals;
7491
7517
  /**
@@ -7528,8 +7554,7 @@ type PoolDetailToolConfig = UniswapServiceConfig & {
7528
7554
  * Always-search-then-detail flow for a single Uniswap V3 pool:
7529
7555
  * 1) call SearchTokens upstream to enumerate pools matching the user's input,
7530
7556
  * 2) filter the search result by token symbols and (optionally) fee tier,
7531
- * 3) if the filter narrows to exactly one pool, fetch its full detail via
7532
- * the V3Pool GraphQL operation,
7557
+ * 3) if the filter narrows to exactly one pool, fetch its full detail,
7533
7558
  * 4) otherwise return the candidates so the LLM can ask the user to pick one.
7534
7559
  *
7535
7560
  * The LLM never passes pool addresses — every address that reaches the detail
@@ -7577,15 +7602,6 @@ declare class PoolDetailTool extends BaseTool {
7577
7602
  * Never throws — returns `[]` on any miss so the detail view is unaffected.
7578
7603
  */
7579
7604
  private fetchPriceRanges;
7580
- /**
7581
- * Trim and enrich the GraphQL payload with derived metrics.
7582
- *
7583
- * `lpFeeShare` is the fraction of swap fees left to LPs after the pool's
7584
- * on-chain protocol fee; pass it so fees/APR are the LP-net figures rather
7585
- * than the gross `feeTier × volume` headline.
7586
- */
7587
- private formatPool;
7588
- private formatHistorical;
7589
7605
  }
7590
7606
 
7591
7607
  type PoolSearchToolConfig = UniswapServiceConfig & {
@@ -7614,6 +7630,12 @@ declare class PoolSearchTool extends BaseTool {
7614
7630
  private formatPool;
7615
7631
  }
7616
7632
 
7633
+ /** One point of the weekly volume series, in the shape the analyst reads. */
7634
+ interface PoolHistoricalVolumePoint {
7635
+ timestamp?: number;
7636
+ volumeUsd?: number;
7637
+ }
7638
+
7617
7639
  type PoolByAddressToolConfig = UniswapServiceConfig & {
7618
7640
  /** Hit production addresses endpoints (for add-liquidity gateway lookup). Default true. */
7619
7641
  isProduction?: boolean;
@@ -7627,7 +7649,9 @@ type PoolByAddressToolConfig = UniswapServiceConfig & {
7627
7649
  * with `searchType: "TOKEN"` — and dispatches based on which side returns
7628
7650
  * data:
7629
7651
  *
7630
- * - POOL hit → fetch the pool's full detail (V3Pool GraphQL).
7652
+ * - POOL hit → fetch the pool's full detail. One version-agnostic lookup
7653
+ * covers V2, V3 and V4, so a pasted address never has to be routed by a
7654
+ * version guessed before the pool was read.
7631
7655
  * - TOKEN hit → list pools that contain that token, ranked by 24h volume.
7632
7656
  * - Neither → return an error so the caller can ask the user to clarify.
7633
7657
  */
@@ -7664,12 +7688,10 @@ declare class PoolByAddressTool extends BaseTool {
7664
7688
  fees24hUsd: number | undefined;
7665
7689
  lpFeeShare: number;
7666
7690
  aprPercent: number | undefined;
7691
+ totalAprPercent: number | undefined;
7667
7692
  volumeToTvlRatio: number | undefined;
7668
7693
  txCount: number | undefined;
7669
- historicalVolumeWeek: {
7670
- timestamp: number | undefined;
7671
- volumeUsd: number | undefined;
7672
- }[] | undefined;
7694
+ historicalVolumeWeek: PoolHistoricalVolumePoint[] | undefined;
7673
7695
  token0: {
7674
7696
  address: string | undefined;
7675
7697
  symbol: string | undefined;
@@ -7679,6 +7701,8 @@ declare class PoolByAddressTool extends BaseTool {
7679
7701
  reserve: number | undefined;
7680
7702
  isSpam: boolean | undefined;
7681
7703
  safetyLevel: string | undefined;
7704
+ transferFeeBps: number | undefined;
7705
+ isUnrecognizedToken: true | undefined;
7682
7706
  } | undefined;
7683
7707
  token1: {
7684
7708
  address: string | undefined;
@@ -7689,6 +7713,8 @@ declare class PoolByAddressTool extends BaseTool {
7689
7713
  reserve: number | undefined;
7690
7714
  isSpam: boolean | undefined;
7691
7715
  safetyLevel: string | undefined;
7716
+ transferFeeBps: number | undefined;
7717
+ isUnrecognizedToken: true | undefined;
7692
7718
  } | undefined;
7693
7719
  };
7694
7720
  error?: undefined;
@@ -7735,9 +7761,6 @@ declare class PoolByAddressTool extends BaseTool {
7735
7761
  private findTokenByAddress;
7736
7762
  private formatToken;
7737
7763
  private formatPoolCandidate;
7738
- /** `lpFeeShare` is the fraction of swap fees LPs keep after the protocol fee. */
7739
- private formatPoolDetail;
7740
- private formatHistorical;
7741
7764
  }
7742
7765
 
7743
7766
  interface OpenAddLiquidityFormToolConfig extends UniswapServiceConfig {
@@ -7802,6 +7825,25 @@ declare class OpenAddLiquidityFormTool extends BaseTool {
7802
7825
  * than risk showing an inverted (misleading) range.
7803
7826
  */
7804
7827
  private orientRangesToForm;
7828
+ /**
7829
+ * The "this pool exists, but it's a version we can't add liquidity to yet"
7830
+ * result. Distinct from `pool_not_found` on purpose: telling a user their pool
7831
+ * doesn't exist when it plainly does on Uniswap reads as a bug, so name the
7832
+ * version and point them at V3 instead.
7833
+ */
7834
+ private unsupportedVersionResult;
7835
+ /**
7836
+ * Look for the pool the user meant among the protocol versions this flow does
7837
+ * NOT support (V2 / V4), used only after the V3 search came back empty.
7838
+ *
7839
+ * Purpose is purely diagnostic: it lets the caller say "this is a V4 pool and
7840
+ * adding liquidity only supports V3" instead of the misleading "no pool found".
7841
+ * A pinned `poolAddress` wins when present — that address IS the pool the user
7842
+ * tapped; otherwise the pair (and fee tier, when given) identifies it. Returns
7843
+ * `undefined` on any error or miss, so the caller falls back to `pool_not_found`
7844
+ * exactly as it did before.
7845
+ */
7846
+ private findUnsupportedVersionPool;
7805
7847
  private matchesPairExact;
7806
7848
  private matchesPair;
7807
7849
  private symMatch;