keyring-agent-core 0.3.2 → 0.3.4
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 +82 -34
- package/dist/index.js +81 -76
- package/dist/index.native.js +194 -189
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1611,6 +1611,13 @@ interface AgentConfig {
|
|
|
1611
1611
|
uniswap?: {
|
|
1612
1612
|
/** Base URL for the Uniswap interface gateway (default: https://interface.gateway.uniswap.org) */
|
|
1613
1613
|
baseUrl?: string;
|
|
1614
|
+
/**
|
|
1615
|
+
* Base URL for the token/pool search gateway (default:
|
|
1616
|
+
* https://entry-gateway.backend-prod.api.uniswap.org). Separate from
|
|
1617
|
+
* `baseUrl`: Uniswap moved SearchTokens and the pool leaderboard to this
|
|
1618
|
+
* host while GraphQL stayed on the interface gateway.
|
|
1619
|
+
*/
|
|
1620
|
+
searchBaseUrl?: string;
|
|
1614
1621
|
/** Minimum USD value the user must supply to add liquidity. Default 10. */
|
|
1615
1622
|
minProvideUsd?: number;
|
|
1616
1623
|
/**
|
|
@@ -5330,7 +5337,7 @@ declare class TransactionByHashTool extends BaseTool {
|
|
|
5330
5337
|
* them.
|
|
5331
5338
|
*/
|
|
5332
5339
|
/** Market kinds `/supply/v2` returns; see {@link PROTOCOLS}. */
|
|
5333
|
-
type LendingProtocolType = 'aave-v3' | 'compound-v3' | 'spark' | 'spark-ethereum' | 'spark-l2-susds' | 'morpho-v2';
|
|
5340
|
+
type LendingProtocolType = 'aave-v3' | 'compound-v3' | 'spark' | 'spark-ethereum' | 'spark-l2-susds' | 'morpho-v2' | 'maple';
|
|
5334
5341
|
/**
|
|
5335
5342
|
* The per-chain facts a protocol needs — the numeric chain id, and nothing else.
|
|
5336
5343
|
*
|
|
@@ -7387,17 +7394,38 @@ declare class PoolFallbackAiTool extends BaseTool {
|
|
|
7387
7394
|
}
|
|
7388
7395
|
|
|
7389
7396
|
/**
|
|
7390
|
-
* UniswapService — Uniswap Explore API
|
|
7397
|
+
* UniswapService — Uniswap Explore API.
|
|
7398
|
+
*
|
|
7399
|
+
* Wraps the public endpoints that power https://app.uniswap.org/explore. These
|
|
7400
|
+
* are Connect-RPC services that POST a JSON body and answer plain JSON.
|
|
7391
7401
|
*
|
|
7392
|
-
*
|
|
7393
|
-
*
|
|
7394
|
-
*
|
|
7402
|
+
* Two gateways, deliberately: pool leaderboards (ListPools) and token/pool
|
|
7403
|
+
* search live on `entry-gateway.backend-prod.api.uniswap.org`, while the
|
|
7404
|
+
* per-pool GraphQL detail queries remain on `interface.gateway.uniswap.org` —
|
|
7405
|
+
* see {@link DEFAULT_SEARCH_BASE_URL}.
|
|
7395
7406
|
*
|
|
7396
7407
|
* No SDK dependencies — uses native `fetch`.
|
|
7397
7408
|
*/
|
|
7398
7409
|
interface UniswapServiceConfig {
|
|
7399
7410
|
/** Base URL for the Uniswap interface gateway (default: https://interface.gateway.uniswap.org) */
|
|
7400
7411
|
baseUrl?: string;
|
|
7412
|
+
/**
|
|
7413
|
+
* Base URL for the token/pool SEARCH gateway (default:
|
|
7414
|
+
* https://entry-gateway.backend-prod.api.uniswap.org).
|
|
7415
|
+
*
|
|
7416
|
+
* Deliberately separate from {@link baseUrl}: Uniswap moved SearchTokens and
|
|
7417
|
+
* the pool leaderboard here while GraphQL stayed on the interface gateway, so
|
|
7418
|
+
* the two cannot share one origin. Kept configurable so the rest of the
|
|
7419
|
+
* migration can be followed without a code change.
|
|
7420
|
+
*/
|
|
7421
|
+
searchBaseUrl?: string;
|
|
7422
|
+
/**
|
|
7423
|
+
* Base URL for the per-pool LIQUIDITY gateway (default:
|
|
7424
|
+
* https://liquidity.backend-prod.api.uniswap.org), which serves
|
|
7425
|
+
* version-agnostic pool detail. A third origin for the same reason
|
|
7426
|
+
* {@link searchBaseUrl} is a second one — see {@link DEFAULT_LIQUIDITY_BASE_URL}.
|
|
7427
|
+
*/
|
|
7428
|
+
liquidityBaseUrl?: string;
|
|
7401
7429
|
}
|
|
7402
7430
|
type UniswapProtocolVersion = 'V2' | 'V3' | 'V4';
|
|
7403
7431
|
|
|
@@ -7436,10 +7464,10 @@ type TopPoolsToolConfig = UniswapServiceConfig & {
|
|
|
7436
7464
|
/**
|
|
7437
7465
|
* Tool: get-top-pools
|
|
7438
7466
|
*
|
|
7439
|
-
* Wraps Uniswap's
|
|
7440
|
-
*
|
|
7441
|
-
*
|
|
7442
|
-
*
|
|
7467
|
+
* Wraps Uniswap's ListPools endpoint (`data.v2.DataApiService/ListPools`) — the
|
|
7468
|
+
* source app.uniswap.org/explore reads — to surface the top liquidity pools for
|
|
7469
|
+
* a given EVM chain. Returns pools ranked by TVL by default; sorting can be
|
|
7470
|
+
* switched to 1d/30d volume or APR, all of which the endpoint ranks server-side.
|
|
7443
7471
|
*/
|
|
7444
7472
|
declare class TopPoolsTool extends BaseTool {
|
|
7445
7473
|
name: string;
|
|
@@ -7448,11 +7476,12 @@ declare class TopPoolsTool extends BaseTool {
|
|
|
7448
7476
|
parameters: ToolParameter[];
|
|
7449
7477
|
private service;
|
|
7450
7478
|
/**
|
|
7451
|
-
* The Graph subgraph client, used ONLY as a data fallback when Uniswap
|
|
7452
|
-
*
|
|
7453
|
-
*
|
|
7454
|
-
*
|
|
7455
|
-
*
|
|
7479
|
+
* The Graph subgraph client, used ONLY as a data fallback when Uniswap returns
|
|
7480
|
+
* no V3 pools for a chain. ListPools closed the old ExploreStats gap on
|
|
7481
|
+
* Optimism / Polygon, but thin chains still come back near-empty (Linea served
|
|
7482
|
+
* a single V3 pool at the time of writing), so the fallback stays. This is a
|
|
7483
|
+
* tool-layer data fallback — the pool agent's tool surface stays Uniswap-only;
|
|
7484
|
+
* it never sees a subgraph tool.
|
|
7456
7485
|
*/
|
|
7457
7486
|
private subgraphFallback;
|
|
7458
7487
|
/** Used ONLY to check add-liquidity (gateway) support per chain — see {@link PoolService.isAddLiquiditySupported}. */
|
|
@@ -7464,6 +7493,9 @@ declare class TopPoolsTool extends BaseTool {
|
|
|
7464
7493
|
* numbers rather than the LLM's arithmetic. `volumeToTvlRatio` (24h volume ÷
|
|
7465
7494
|
* TVL) is the single most informative LP-quality signal — capital efficiency /
|
|
7466
7495
|
* how hard each dollar of liquidity is working.
|
|
7496
|
+
*
|
|
7497
|
+
* ListPools reports the ratio itself, so an upstream value is used as-is;
|
|
7498
|
+
* the local division only covers sources that don't (the subgraph fallback).
|
|
7467
7499
|
*/
|
|
7468
7500
|
private withExpertSignals;
|
|
7469
7501
|
/**
|
|
@@ -7506,8 +7538,7 @@ type PoolDetailToolConfig = UniswapServiceConfig & {
|
|
|
7506
7538
|
* Always-search-then-detail flow for a single Uniswap V3 pool:
|
|
7507
7539
|
* 1) call SearchTokens upstream to enumerate pools matching the user's input,
|
|
7508
7540
|
* 2) filter the search result by token symbols and (optionally) fee tier,
|
|
7509
|
-
* 3) if the filter narrows to exactly one pool, fetch its full detail
|
|
7510
|
-
* the V3Pool GraphQL operation,
|
|
7541
|
+
* 3) if the filter narrows to exactly one pool, fetch its full detail,
|
|
7511
7542
|
* 4) otherwise return the candidates so the LLM can ask the user to pick one.
|
|
7512
7543
|
*
|
|
7513
7544
|
* The LLM never passes pool addresses — every address that reaches the detail
|
|
@@ -7555,15 +7586,6 @@ declare class PoolDetailTool extends BaseTool {
|
|
|
7555
7586
|
* Never throws — returns `[]` on any miss so the detail view is unaffected.
|
|
7556
7587
|
*/
|
|
7557
7588
|
private fetchPriceRanges;
|
|
7558
|
-
/**
|
|
7559
|
-
* Trim and enrich the GraphQL payload with derived metrics.
|
|
7560
|
-
*
|
|
7561
|
-
* `lpFeeShare` is the fraction of swap fees left to LPs after the pool's
|
|
7562
|
-
* on-chain protocol fee; pass it so fees/APR are the LP-net figures rather
|
|
7563
|
-
* than the gross `feeTier × volume` headline.
|
|
7564
|
-
*/
|
|
7565
|
-
private formatPool;
|
|
7566
|
-
private formatHistorical;
|
|
7567
7589
|
}
|
|
7568
7590
|
|
|
7569
7591
|
type PoolSearchToolConfig = UniswapServiceConfig & {
|
|
@@ -7573,7 +7595,7 @@ type PoolSearchToolConfig = UniswapServiceConfig & {
|
|
|
7573
7595
|
/**
|
|
7574
7596
|
* Tool: search-pools
|
|
7575
7597
|
*
|
|
7576
|
-
* Wraps the Uniswap `
|
|
7598
|
+
* Wraps the Uniswap `data.v1.SearchService/SearchTokens` endpoint with
|
|
7577
7599
|
* `searchType: "POOL"`. Lets users discover pools by free-text query
|
|
7578
7600
|
* (token symbol like "WBTC" or "USDC", token name, or pool address) on a
|
|
7579
7601
|
* specific chain. Paginated.
|
|
@@ -7592,6 +7614,12 @@ declare class PoolSearchTool extends BaseTool {
|
|
|
7592
7614
|
private formatPool;
|
|
7593
7615
|
}
|
|
7594
7616
|
|
|
7617
|
+
/** One point of the weekly volume series, in the shape the analyst reads. */
|
|
7618
|
+
interface PoolHistoricalVolumePoint {
|
|
7619
|
+
timestamp?: number;
|
|
7620
|
+
volumeUsd?: number;
|
|
7621
|
+
}
|
|
7622
|
+
|
|
7595
7623
|
type PoolByAddressToolConfig = UniswapServiceConfig & {
|
|
7596
7624
|
/** Hit production addresses endpoints (for add-liquidity gateway lookup). Default true. */
|
|
7597
7625
|
isProduction?: boolean;
|
|
@@ -7605,7 +7633,9 @@ type PoolByAddressToolConfig = UniswapServiceConfig & {
|
|
|
7605
7633
|
* with `searchType: "TOKEN"` — and dispatches based on which side returns
|
|
7606
7634
|
* data:
|
|
7607
7635
|
*
|
|
7608
|
-
* - POOL hit → fetch the pool's full detail
|
|
7636
|
+
* - POOL hit → fetch the pool's full detail. One version-agnostic lookup
|
|
7637
|
+
* covers V2, V3 and V4, so a pasted address never has to be routed by a
|
|
7638
|
+
* version guessed before the pool was read.
|
|
7609
7639
|
* - TOKEN hit → list pools that contain that token, ranked by 24h volume.
|
|
7610
7640
|
* - Neither → return an error so the caller can ask the user to clarify.
|
|
7611
7641
|
*/
|
|
@@ -7642,12 +7672,10 @@ declare class PoolByAddressTool extends BaseTool {
|
|
|
7642
7672
|
fees24hUsd: number | undefined;
|
|
7643
7673
|
lpFeeShare: number;
|
|
7644
7674
|
aprPercent: number | undefined;
|
|
7675
|
+
totalAprPercent: number | undefined;
|
|
7645
7676
|
volumeToTvlRatio: number | undefined;
|
|
7646
7677
|
txCount: number | undefined;
|
|
7647
|
-
historicalVolumeWeek:
|
|
7648
|
-
timestamp: number | undefined;
|
|
7649
|
-
volumeUsd: number | undefined;
|
|
7650
|
-
}[] | undefined;
|
|
7678
|
+
historicalVolumeWeek: PoolHistoricalVolumePoint[] | undefined;
|
|
7651
7679
|
token0: {
|
|
7652
7680
|
address: string | undefined;
|
|
7653
7681
|
symbol: string | undefined;
|
|
@@ -7657,6 +7685,8 @@ declare class PoolByAddressTool extends BaseTool {
|
|
|
7657
7685
|
reserve: number | undefined;
|
|
7658
7686
|
isSpam: boolean | undefined;
|
|
7659
7687
|
safetyLevel: string | undefined;
|
|
7688
|
+
transferFeeBps: number | undefined;
|
|
7689
|
+
isUnrecognizedToken: true | undefined;
|
|
7660
7690
|
} | undefined;
|
|
7661
7691
|
token1: {
|
|
7662
7692
|
address: string | undefined;
|
|
@@ -7667,6 +7697,8 @@ declare class PoolByAddressTool extends BaseTool {
|
|
|
7667
7697
|
reserve: number | undefined;
|
|
7668
7698
|
isSpam: boolean | undefined;
|
|
7669
7699
|
safetyLevel: string | undefined;
|
|
7700
|
+
transferFeeBps: number | undefined;
|
|
7701
|
+
isUnrecognizedToken: true | undefined;
|
|
7670
7702
|
} | undefined;
|
|
7671
7703
|
};
|
|
7672
7704
|
error?: undefined;
|
|
@@ -7713,9 +7745,6 @@ declare class PoolByAddressTool extends BaseTool {
|
|
|
7713
7745
|
private findTokenByAddress;
|
|
7714
7746
|
private formatToken;
|
|
7715
7747
|
private formatPoolCandidate;
|
|
7716
|
-
/** `lpFeeShare` is the fraction of swap fees LPs keep after the protocol fee. */
|
|
7717
|
-
private formatPoolDetail;
|
|
7718
|
-
private formatHistorical;
|
|
7719
7748
|
}
|
|
7720
7749
|
|
|
7721
7750
|
interface OpenAddLiquidityFormToolConfig extends UniswapServiceConfig {
|
|
@@ -7780,6 +7809,25 @@ declare class OpenAddLiquidityFormTool extends BaseTool {
|
|
|
7780
7809
|
* than risk showing an inverted (misleading) range.
|
|
7781
7810
|
*/
|
|
7782
7811
|
private orientRangesToForm;
|
|
7812
|
+
/**
|
|
7813
|
+
* The "this pool exists, but it's a version we can't add liquidity to yet"
|
|
7814
|
+
* result. Distinct from `pool_not_found` on purpose: telling a user their pool
|
|
7815
|
+
* doesn't exist when it plainly does on Uniswap reads as a bug, so name the
|
|
7816
|
+
* version and point them at V3 instead.
|
|
7817
|
+
*/
|
|
7818
|
+
private unsupportedVersionResult;
|
|
7819
|
+
/**
|
|
7820
|
+
* Look for the pool the user meant among the protocol versions this flow does
|
|
7821
|
+
* NOT support (V2 / V4), used only after the V3 search came back empty.
|
|
7822
|
+
*
|
|
7823
|
+
* Purpose is purely diagnostic: it lets the caller say "this is a V4 pool and
|
|
7824
|
+
* adding liquidity only supports V3" instead of the misleading "no pool found".
|
|
7825
|
+
* A pinned `poolAddress` wins when present — that address IS the pool the user
|
|
7826
|
+
* tapped; otherwise the pair (and fee tier, when given) identifies it. Returns
|
|
7827
|
+
* `undefined` on any error or miss, so the caller falls back to `pool_not_found`
|
|
7828
|
+
* exactly as it did before.
|
|
7829
|
+
*/
|
|
7830
|
+
private findUnsupportedVersionPool;
|
|
7783
7831
|
private matchesPairExact;
|
|
7784
7832
|
private matchesPair;
|
|
7785
7833
|
private symMatch;
|