keyring-agent-core 0.3.13 → 0.3.15

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
@@ -1883,7 +1883,7 @@ interface VectorKBConfig {
1883
1883
  provider?: KnowledgeBaseProvider;
1884
1884
  }
1885
1885
  interface LLMProviderConfig {
1886
- /** Model name, e.g. "gemini-2.5-flash-lite" */
1886
+ /** Model name, e.g. "gemini-2.5-flash" */
1887
1887
  model?: string;
1888
1888
  /** Max tokens for generation */
1889
1889
  maxTokens?: number;
@@ -1903,6 +1903,17 @@ interface LLMProviderConfig {
1903
1903
  * "https://generativelanguage.googleapis.com" when {@link apiKey} is set.
1904
1904
  */
1905
1905
  baseUrl?: string;
1906
+ /**
1907
+ * Provider-wide default Gemini thinking budget, used by every call that does
1908
+ * not pass its own {@link ChatOptions.thinkingBudget}. Defaults to `0`
1909
+ * (thinking OFF): on `gemini-2.5-flash` thinking is otherwise dynamic and its
1910
+ * reasoning tokens are generated sequentially before any visible output — the
1911
+ * single biggest per-call latency cost. The agent's prompts are tuned for
1912
+ * no-thinking (the Flash-Lite default). `null` omits `thinkingConfig` entirely
1913
+ * (the model's native default); a positive number sets a fixed budget. Models
1914
+ * whose thinking cannot be disabled (e.g. 2.5 Pro, floor 128) need a value here.
1915
+ */
1916
+ thinkingBudget?: number | null;
1906
1917
  }
1907
1918
  interface AgentConfig {
1908
1919
  /**
@@ -2182,6 +2193,10 @@ interface LLMResponse {
2182
2193
  promptTokens: number;
2183
2194
  completionTokens: number;
2184
2195
  totalTokens: number;
2196
+ /** Reasoning tokens spent before the visible output (Gemini 2.5 thinking). */
2197
+ thoughtsTokens?: number;
2198
+ /** Prompt tokens served from Gemini's (implicit) context cache. */
2199
+ cachedTokens?: number;
2185
2200
  };
2186
2201
  }
2187
2202
  /** Optional flags for an LLM call */
@@ -2203,17 +2218,16 @@ interface ChatOptions {
2203
2218
  maxOutputTokens?: number;
2204
2219
  /**
2205
2220
  * Gemini 2.5 thinking budget, in tokens. These models spend reasoning
2206
- * ("thinking") tokens that count AGAINST `maxOutputTokens` before any visible
2207
- * output — so a tight `maxOutputTokens` cap on a thinking model can be consumed
2208
- * entirely by reasoning, cutting the turn off with `MAX_TOKENS` before a single
2209
- * JSON byte is emitted. For the short, schema-bound JSON calls that carry a
2210
- * `maxOutputTokens` cap, thinking adds no value, so it is disabled by default
2211
- * (budget 0) whenever a cap is set — making the cap apply fully to real output.
2212
- * Pass an explicit value to override: `0` forces thinking off, `-1` restores the
2213
- * model's dynamic budget, a positive number sets a fixed budget. Leave unset to
2214
- * use the cap-driven default.
2215
- */
2216
- thinkingBudget?: number;
2221
+ * ("thinking") tokens that count AGAINST `maxOutputTokens` and are generated
2222
+ * before any visible output — so thinking is pure added latency on calls that
2223
+ * don't need it, and a tight cap can be consumed entirely by reasoning
2224
+ * (`MAX_TOKENS` with no output). Thinking is therefore OFF by default for every
2225
+ * call (see {@link LLMProviderConfig.thinkingBudget}). Override per call: `0`
2226
+ * forces it off, `-1` dynamic, a positive number a fixed budget, and `null`
2227
+ * omits `thinkingConfig` so the model's native default applies. Leave unset to
2228
+ * use the provider default.
2229
+ */
2230
+ thinkingBudget?: number | null;
2217
2231
  /**
2218
2232
  * Force the model to call one of the supplied `tools` instead of answering in
2219
2233
  * text (Gemini `functionCallingConfig.mode = "ANY"`). Used by action subagents
@@ -3033,8 +3047,8 @@ declare class WebsiteTrustKeyringAgent {
3033
3047
  * without ever truncating a valid reply. Omit to fall back to the provider
3034
3048
  * default (4096).
3035
3049
  * - `thinkingBudget` controls the Gemini 2.5 reasoning budget (tokens count
3036
- * AGAINST `maxOutputTokens`). The provider defaults it to 0 whenever a
3037
- * `maxOutputTokens` cap is set, so a formatting/extraction call spends its
3050
+ * AGAINST `maxOutputTokens`). The provider defaults it to 0 (off), so a
3051
+ * formatting/extraction call spends its
3038
3052
  * whole budget on real output. The one call that needs real reasoning —
3039
3053
  * {@link investigate}, which must correctly judge official vs. look-alike —
3040
3054
  * passes an explicit positive budget AND a cap wide enough to hold thinking +
@@ -3251,6 +3265,8 @@ declare class GeminiProvider implements LLMProvider {
3251
3265
  private model;
3252
3266
  private maxTokens;
3253
3267
  private temperature;
3268
+ /** Default thinking budget for calls that don't set one. `null` = model default. */
3269
+ private thinkingBudget;
3254
3270
  private baseUrl;
3255
3271
  /** Caller's own Gemini key. Empty when running through the proxy. */
3256
3272
  private apiKey;
@@ -3312,188 +3328,558 @@ declare function registerMaybeNoForm(registry: {
3312
3328
  }, tool: Tool, messages?: NoFormToolMessages): void;
3313
3329
 
3314
3330
  /**
3315
- * MoralisService — Moralis Web3 API + Cortex AI proxy.
3331
+ * Shared ABI / hex types for the codec layer.
3316
3332
  *
3317
- * Adapted from keyring-chatbot-agent-sdk moralis service.
3318
- * Uses native fetch — no SDK dependencies.
3333
+ * Deliberately STRUCTURAL and loose (every field but `type` optional) rather
3334
+ * than viem's fully-inferred `Abi` generics: this core hand-writes its ABIs as
3335
+ * plain object literals — some without `as const` — and a strict type would
3336
+ * reject them at every call site for no runtime benefit. Validation happens
3337
+ * where it matters, at runtime, in {@link file://./signature.ts}.
3319
3338
  */
3320
- interface MoralisServiceConfig {
3321
- /** Base URL for Moralis proxy (default: https://nft.keyring.app) */
3322
- baseUrl?: string;
3323
- /** Base URL for DeFi APIs — uses /api/moralis-v1/proxy route (default: https://nft.keyring.app) */
3324
- v1BaseUrl?: string;
3325
- /** Pantograph API base URL for price enrichment */
3326
- pantographUrl?: string;
3339
+ /** A 0x-prefixed hex string. */
3340
+ type Hex = `0x${string}`;
3341
+ /** A 0x-prefixed 20-byte address. */
3342
+ type Address = `0x${string}`;
3343
+ /** One ABI input/output parameter; `components` is present for tuples. */
3344
+ interface AbiParameter {
3345
+ readonly name?: string;
3346
+ readonly type: string;
3347
+ readonly internalType?: string;
3348
+ readonly components?: readonly AbiParameter[];
3349
+ /** Events only — whether the parameter is a topic. */
3350
+ readonly indexed?: boolean;
3327
3351
  }
3328
- interface TokenBalance {
3329
- token_address: string;
3330
- symbol: string;
3331
- name: string;
3332
- logo?: string;
3333
- thumbnail?: string;
3334
- decimals: number;
3335
- balance: string;
3336
- possible_spam: boolean;
3337
- verified_contract: boolean;
3338
- total_supply?: string;
3339
- total_supply_formatted?: string;
3340
- percentage_relative_to_total_supply?: number;
3341
- balance_formatted: string;
3342
- usd_price?: number;
3343
- usd_price_24hr_percent_change?: number;
3344
- usd_price_24hr_usd_change?: number;
3345
- usd_value?: number;
3346
- usd_value_24hr_usd_change?: number;
3347
- native_token: boolean;
3348
- portfolio_percentage?: number;
3352
+ /** One ABI entry: function, event, error, constructor, fallback or receive. */
3353
+ interface AbiItem {
3354
+ readonly type?: string;
3355
+ readonly name?: string;
3356
+ readonly inputs?: readonly AbiParameter[];
3357
+ readonly outputs?: readonly AbiParameter[];
3358
+ readonly stateMutability?: string;
3359
+ readonly anonymous?: boolean;
3349
3360
  }
3350
- interface TokenMetadata {
3351
- token_address: string;
3352
- address?: string;
3361
+ /** A contract ABI. */
3362
+ type Abi = readonly AbiItem[];
3363
+
3364
+ /**
3365
+ * Chain shape — viem's `Chain`, plus a `hexId` because this core identifies
3366
+ * chains by hex id (`0x2105`) everywhere: in tool arguments, in `UserContext`,
3367
+ * and in the wallet payloads it hands the app.
3368
+ */
3369
+
3370
+ /** A contract deployed at a known address on a chain. */
3371
+ interface ChainContract {
3372
+ address: Address;
3373
+ /** Block the contract was deployed at, when known — reads before it can't work. */
3374
+ blockCreated?: number;
3375
+ }
3376
+ /** The chain's one native coin (everything else on it is a token). */
3377
+ interface ChainNativeCurrency {
3353
3378
  name: string;
3354
3379
  symbol: string;
3355
3380
  decimals: number;
3356
- logo?: string;
3357
- thumbnail?: string;
3358
- icon_image?: string;
3359
- logoURI?: string;
3360
- usd_price?: number;
3361
- usd_price_24hr_percent_change?: number;
3362
- usd_price_24hr_usd_change?: number;
3363
- /**
3364
- * The token's `symbol()` as READ FROM THE CONTRACT, when the upstream index
3365
- * has it. Distinct from `symbol`, which is the index's own editorial label and
3366
- * is frequently lower-cased ("usdc") or otherwise diverges from the chain.
3367
- *
3368
- * `null` when the index never resolved it — a token whose symbol therefore
3369
- * still has to be read on-chain by the caller. Absent on endpoints that don't
3370
- * report it at all (e.g. top-gainers), which is the same situation.
3371
- *
3372
- * Consumers should not have to reach for this: `normalizePantographToken`
3373
- * already promotes it over `symbol`, so the canonical field is on-chain-true
3374
- * wherever Pantograph knew the answer. It stays exposed for callers that need
3375
- * to know WHICH source a symbol came from — see `confirmTokenIdentities`,
3376
- * which skips its RPC round-trip when the symbol is already on-chain-sourced.
3377
- */
3378
- symbolOnchain?: string | null;
3379
- /** The token's on-chain `name()`, same contract as {@link symbolOnchain}. */
3380
- nameOnchain?: string | null;
3381
- auditGoplus?: Record<string, unknown>;
3382
- holder_count?: string;
3383
- holders?: unknown[];
3384
- coinGeckoId?: string;
3385
- position?: number;
3386
- isActive?: boolean;
3387
- updatedAt?: string;
3388
- price_change_24h?: number;
3389
- telegram_channel_identifier?: string;
3390
- subreddit_url?: string;
3391
- facebook_username?: string;
3392
- twitter_screen_name?: string;
3393
- homepage?: string[];
3394
- announcement_url?: string[];
3395
- categories?: string[];
3396
- chat_url?: string[];
3397
- market_cap_rank?: number;
3398
- max_supply?: number | null;
3399
- total_supply?: number | string;
3400
- circulating_supply?: number;
3401
- fully_diluted_valuation?: number;
3402
- market_cap?: number;
3403
- total_volume?: number;
3404
3381
  }
3405
- interface NFTItem {
3406
- token_address: string;
3407
- token_id: string;
3408
- amount: string;
3409
- owner_of: string;
3410
- token_hash: string;
3411
- block_number_minted: string;
3412
- block_number: string;
3413
- contract_type: 'ERC721' | 'ERC1155';
3382
+ interface Chain {
3383
+ /** Decimal chain id (`8453`). */
3384
+ id: number;
3385
+ /** Canonical hex chain id (`0x2105`) — this core's primary key for a chain. */
3386
+ hexId: Hex;
3387
+ /** Display name, as shown to users. */
3414
3388
  name: string;
3415
- symbol: string;
3416
- token_uri?: string;
3417
- metadata?: string;
3418
- normalized_metadata?: {
3419
- name?: string;
3420
- description?: string;
3421
- image?: string;
3422
- animation_url?: string;
3423
- attributes?: Array<{
3424
- trait_type: string;
3425
- value: string;
3426
- }>;
3389
+ nativeCurrency: ChainNativeCurrency;
3390
+ rpcUrls: {
3391
+ default: {
3392
+ http: readonly string[];
3393
+ };
3427
3394
  };
3428
- possible_spam: boolean;
3429
- verified_collection: boolean;
3430
- media?: {
3431
- mimetype?: string;
3432
- parent_hash?: string;
3433
- status?: string;
3434
- updated_at?: string;
3435
- media_collection?: {
3436
- low?: {
3437
- url: string;
3438
- width: number;
3439
- height: number;
3440
- };
3441
- medium?: {
3442
- url: string;
3443
- width: number;
3444
- height: number;
3445
- };
3446
- high?: {
3447
- url: string;
3448
- width: number;
3449
- height: number;
3450
- };
3395
+ blockExplorers?: {
3396
+ default: {
3397
+ name: string;
3398
+ url: string;
3451
3399
  };
3452
- original_media_url?: string;
3453
3400
  };
3454
- collection_logo?: string;
3455
- collection_banner_image?: string;
3401
+ /** Well-known contracts; `multicall3` is what the batching layer needs. */
3402
+ contracts?: {
3403
+ multicall3?: ChainContract;
3404
+ };
3405
+ testnet?: boolean;
3456
3406
  }
3407
+
3457
3408
  /**
3458
- * One row of `GET /{address}/nft/collections` — an NFT collection the wallet
3459
- * holds, rather than an individual token.
3409
+ * The 12 EVM chains this core supports, as viem-shaped {@link Chain} objects.
3410
+ *
3411
+ * One definition per chain carries everything the stack needs — decimal id, hex
3412
+ * id, display name, native coin, default public RPC and the Multicall3
3413
+ * deployment — so nothing has to be threaded through call sites or duplicated in
3414
+ * a second table.
3415
+ *
3416
+ * Multicall3 sits at the SAME deterministic address on every one of them
3417
+ * (verified on-chain via `eth_getCode`), but each chain still spells it out: a
3418
+ * chain that ever ships it elsewhere is then a one-line change here.
3419
+ *
3420
+ * `blockCreated` is advisory metadata — it only gates reads pinned to a
3421
+ * HISTORICAL block (a read at `latest`, the default, never consults it) — and is
3422
+ * left out where the deployment block isn't confirmed.
3423
+ *
3424
+ * `rpcUrls.default.http` is an ORDERED PREFERENCE LIST, not a single endpoint:
3425
+ * the first entry is the one normally used, and the rest are fixed backups the
3426
+ * {@link file://../transports/fallback.ts} transport walks down when a request
3427
+ * fails transiently (rate limit, 5xx, timeout). A public endpoint rejecting the
3428
+ * odd method — eth.llamarpc.com answering `eth_gasPrice` with HTTP 525, say —
3429
+ * therefore degrades to a slower answer rather than no answer.
3460
3430
  */
3461
- interface NFTCollectionItem {
3462
- token_address: string;
3463
- contract_type: 'ERC721' | 'ERC1155' | string;
3464
- name?: string;
3465
- symbol?: string;
3466
- /** How many tokens of this collection the wallet holds. */
3467
- count?: number;
3468
- possible_spam?: boolean;
3469
- verified_collection?: boolean;
3470
- collection_logo?: string;
3471
- collection_banner_image?: string;
3472
- }
3473
- type NFTContractMetadata = {
3474
- token_address: string;
3475
- name: string;
3476
- symbol: string;
3477
- contract_type: 'ERC721' | 'ERC1155' | string;
3478
- possible_spam: 'true' | 'false';
3479
- verified_collection: 'true' | 'false';
3480
- synced_at: string | null;
3481
- collection_logo: string;
3482
- collection_banner_image: string;
3483
- collection_category: string;
3484
- project_url: string;
3485
- wiki_url: string;
3486
- discord_url: string;
3487
- telegram_url: string;
3488
- twitter_username: string;
3489
- instagram_username: string;
3490
- floor_price: string;
3491
- floor_price_usd: string;
3492
- floor_price_currency: string;
3493
- last_sale: NFTLastSale | null;
3494
- };
3495
- type NFTLastSale = {
3496
- transaction_hash: string;
3431
+
3432
+ /** Canonical Multicall3 address, identical on every supported chain. */
3433
+ declare const MULTICALL3_ADDRESS: "0xcA11bde05977b3631167028862bE2a173976CA11";
3434
+ /** Every supported chain, in the core's canonical order. */
3435
+ declare const chains: readonly Chain[];
3436
+
3437
+ /**
3438
+ * Domain-level batched reads, on top of the chain stack
3439
+ * ({@link file://../chain/index.ts}).
3440
+ *
3441
+ * The Multicall3 plumbing this file used to carry — the hand-written
3442
+ * `aggregate3` encoder, the `(bool,bytes)[]` reader, the chunking loop — now
3443
+ * lives in `chain/actions/multicall.ts` and `chain/actions/multicallRaw.ts`,
3444
+ * where it is ABI-driven and reusable. What remains here are the three helpers
3445
+ * the core's services actually ask for, with their signatures and their
3446
+ * never-throws, positionally-aligned contracts unchanged:
3447
+ *
3448
+ * - {@link multicallRead} raw calldata in, raw return data out
3449
+ * - {@link multicallErc20Metadata} symbol + decimals, incl. legacy bytes32 tokens
3450
+ * - {@link multicallTokenUris} ERC-721 `tokenURI` for many NFTs
3451
+ *
3452
+ * For anything new, prefer the client directly — `getPublicClient(chainId)` then
3453
+ * `.multicall({ contracts })` — which decodes results and reports typed
3454
+ * per-entry errors instead of `null`.
3455
+ */
3456
+
3457
+ /** One read in a {@link multicallRead} batch: a target contract + full calldata. */
3458
+ interface MulticallRequest {
3459
+ /** Contract to call. A malformed address yields a `null` result. */
3460
+ target: string;
3461
+ /** Encoded calldata — selector + ABI-encoded args, 0x-prefixed. */
3462
+ callData: string;
3463
+ }
3464
+
3465
+ /**
3466
+ * USD valuation for yield-bearing wallet tokens.
3467
+ *
3468
+ * A wallet's token list shows a balance and a price, and normally the USD value
3469
+ * is just the product of the two. For yield-bearing tokens that is wrong often
3470
+ * enough to matter, and the reason splits the tagged tokens into two kinds:
3471
+ *
3472
+ * - **Share-based vaults** (`spark`, `spark-ethereum`, `morpho-v2`) — `balanceOf`
3473
+ * returns ERC-4626 SHARES, while the price the token API quotes belongs to the
3474
+ * vault's UNDERLYING asset. A share is worth more than one unit of underlying
3475
+ * and drifts further up as yield accrues (measured live: 1 steakUSDC = 1.0354
3476
+ * USDC, 1 Spark sUSDC = 1.1051 USDC). The two are not even in the same unit —
3477
+ * shares carry the vault's own decimals, usually 18, against the underlying's
3478
+ * 6 for USDC. `convertToAssets(shares)` answers both problems at once: it
3479
+ * returns the position denominated in exactly what the price describes.
3480
+ *
3481
+ * - **Rebasing tokens** (`aave-v3`, `compound-v3`) — the balance is ALREADY the
3482
+ * underlying (their decimals match it) and yield arrives as a growing
3483
+ * `balanceOf`. Converting these would be a bug, so they are left untouched.
3484
+ *
3485
+ * - **Oracle-priced shares** (`spark-l2-susds`) — share-based like the first
3486
+ * group, but with no `convertToAssets` to ask: bridged sUSDS is a plain ERC-20
3487
+ * on its chain (the vault stays on Ethereum), so the conversion reads the SSR
3488
+ * oracle's ray-scaled rate and multiplies. Still ONE call per token, decoded
3489
+ * differently — see {@link YieldConversionPlan.rateKeys}. Needs
3490
+ * {@link YieldTokenInput.chain}, since the oracle is per chain.
3491
+ *
3492
+ * Which side a token falls on is decided by an explicit allow-list of
3493
+ * share-based protocols, mirroring the wallet app's own `LENDING_PLATFORMS`.
3494
+ * The protocol classes encode the same split as `balanceIsUnderlying`, but that
3495
+ * flag is reached through `protocolFor`, which falls back to an ERC-4626
3496
+ * protocol for types it doesn't recognise — a safe default for listing lending
3497
+ * markets, and the wrong one here, where a mistaken conversion silently
3498
+ * corrupts a balance. An allow-list fails closed instead.
3499
+ *
3500
+ * ## Why this returns calls instead of making them
3501
+ *
3502
+ * Same reasoning as {@link LendingProtocol}: the caller owns the transport. The
3503
+ * wallet app already has its own RPC stack — ranked endpoints, failover, a
3504
+ * Multicall3 batcher, and rate-limit-aware pacing for chains without Multicall3 —
3505
+ * and duplicating it here would mean a second, worse copy. So
3506
+ * {@link planYieldTokenConversions} declares the reads, the caller executes them
3507
+ * however it likes, and {@link applyYieldConversions} folds the answers back in.
3508
+ * Both halves are pure and synchronous, which also makes them trivial to test.
3509
+ */
3510
+
3511
+ /**
3512
+ * Whether a `yieldProtocol` denominates balances in vault SHARES rather than the
3513
+ * underlying asset.
3514
+ *
3515
+ * Exported so callers can explain a decision — logging why a tagged token was
3516
+ * skipped, say — without keeping their own copy of the list, which would drift.
3517
+ * This answers only the protocol question: use {@link isShareBasedYieldToken}
3518
+ * for whether a specific token is actually convertible, since that also needs a
3519
+ * price and the underlying's decimals.
3520
+ */
3521
+ declare function isShareBasedProtocol(yieldProtocol?: string | null): yieldProtocol is string;
3522
+ /**
3523
+ * The price ONE unit of a token's underlying is valued at.
3524
+ *
3525
+ * Two sources, in order:
3526
+ *
3527
+ * 1. `yieldAsset.fixedPrice` — the API stating that this underlying is valued
3528
+ * at a fixed rate rather than at its market print. It sends `1` for USDC
3529
+ * vaults (verified live on Base for both `spark` sUSDC and `compound-v3`
3530
+ * cUSDCv3), which is the redemption rate a holder actually gets.
3531
+ * 2. `priceUSD` — the market quote, for everything else.
3532
+ *
3533
+ * ## Why a fixed price is the better number when the API sends one
3534
+ *
3535
+ * `convertToAssets` returns an amount of the UNDERLYING, and for a dollar
3536
+ * stablecoin that amount IS the dollar figure: redemption is 1:1 by
3537
+ * construction. The market quote for the same asset is a live print — 0.99993
3538
+ * one refresh, 1.00007 the next — and because it multiplies the whole position,
3539
+ * that noise lands on the total: a $50,000 holding drifts by several dollars
3540
+ * between refreshes with nothing having happened on chain. Two screens
3541
+ * refreshing seconds apart then disagree, which reads as a bug in the balance
3542
+ * rather than as noise in a feed.
3543
+ *
3544
+ * ## Why the API owns this decision
3545
+ *
3546
+ * Which assets are fixed-price is a question about the ASSET, and the API is
3547
+ * already the authority on every other fact about it (`address`, `decimals`).
3548
+ * Deciding it here would mean a hard-coded address table per chain — one that
3549
+ * must be extended for every new stablecoin and every bridged variant, that
3550
+ * silently does nothing when an address is missed, and that no test can catch
3551
+ * drifting from the API's own view. Reading the field instead means a new
3552
+ * fixed-price asset needs no client release at all.
3553
+ *
3554
+ * ## Scope
3555
+ *
3556
+ * This applies to any token whose `yieldAsset` carries the field, share-based
3557
+ * or rebasing alike — a `compound-v3` receipt is already denominated in its
3558
+ * underlying, so valuing that underlying at par is the same statement about the
3559
+ * same dollars. A plain wallet token has no `yieldAsset` and is unaffected: it
3560
+ * keeps its market quote, which is the honest number for something the user can
3561
+ * sell right now.
3562
+ *
3563
+ * One consequence is deliberate: a fixed price makes a vault valuable even when
3564
+ * the API returns NO market quote, because the price no longer depends on one.
3565
+ * Such a token used to be skipped entirely and shown at `balance × 0`.
3566
+ */
3567
+ declare function effectivePriceUSD(token: YieldTokenInput): number;
3568
+ /**
3569
+ * A wallet token as the caller already knows it. Field names mirror what the
3570
+ * Keyring/Pantograph token API returns, so a caller can pass its rows nearly
3571
+ * as-is.
3572
+ */
3573
+ interface YieldTokenInput {
3574
+ /** Caller's own identifier, echoed back untouched so results can be re-joined. */
3575
+ key: string;
3576
+ /** The token contract — the vault itself for a share-based position. */
3577
+ address: string;
3578
+ /** Raw on-chain balance, unscaled. */
3579
+ rawBalance: bigint;
3580
+ /** The token's own decimals (vault share decimals, usually 18). */
3581
+ decimals: number;
3582
+ /**
3583
+ * Price quoted by the token API — for a vault, the UNDERLYING's price.
3584
+ * Missing, zero or non-finite disables conversion for this token; see
3585
+ * {@link isShareBasedYieldToken}.
3586
+ */
3587
+ priceUSD: number;
3588
+ /** `yieldProtocol` from the token API; anything untagged is left alone. */
3589
+ yieldProtocol?: string | null;
3590
+ /**
3591
+ * `yieldAsset` from the token API — the underlying this token is denominated
3592
+ * in once converted.
3593
+ *
3594
+ * `fixedPrice` is the API declaring that this underlying is valued at a fixed
3595
+ * rate rather than at its market quote (it sends `1` for USDC). When present
3596
+ * it takes precedence over {@link priceUSD}; see {@link effectivePriceUSD}.
3597
+ */
3598
+ yieldAsset?: {
3599
+ address?: string;
3600
+ decimals?: number;
3601
+ fixedPrice?: number | string | null;
3602
+ } | null;
3603
+ /**
3604
+ * Chain id — hex (`'0x2105'`) or decimal (`8453`), both accepted. Needed ONLY
3605
+ * by `spark-l2-susds`, whose conversion goes to that chain's SSR oracle rather
3606
+ * than to the token, and whose oracle address is per chain.
3607
+ *
3608
+ * Optional so existing callers are unaffected: every ERC-4626 type converts
3609
+ * against the token itself and never reads this. A sUSDS row without it is
3610
+ * passed through unconverted rather than converted against a guessed oracle.
3611
+ */
3612
+ chain?: string | number | null;
3613
+ }
3614
+ /** One declared `convertToAssets` read, tagged with the token it belongs to. */
3615
+ interface YieldConversionCall extends MulticallRequest {
3616
+ /** {@link YieldTokenInput.key} of the token this call resolves. */
3617
+ key: string;
3618
+ }
3619
+ /** What {@link planYieldTokenConversions} worked out, ready to execute. */
3620
+ interface YieldConversionPlan {
3621
+ /** Reads to perform, in order. Empty when nothing needs converting. */
3622
+ calls: YieldConversionCall[];
3623
+ /**
3624
+ * Keys in {@link calls} whose read returns a ray-scaled RATE rather than an
3625
+ * amount — cross-chain sUSDS, which has no `convertToAssets` and is valued
3626
+ * against its chain's SSR oracle instead.
3627
+ *
3628
+ * Exposed so {@link applyYieldConversions} can tell the two apart: decoding a
3629
+ * ray as though it were assets would report a ~10^27 balance. Callers execute
3630
+ * the plan exactly as before and need not consult this — it stays a single
3631
+ * round-trip, and there is no second phase to forget.
3632
+ */
3633
+ rateKeys: string[];
3634
+ }
3635
+ /** A token's corrected valuation. */
3636
+ interface YieldTokenValue {
3637
+ /** Position size in UNDERLYING units (e.g. USDC), not shares. */
3638
+ underlyingAmount: number;
3639
+ /** `underlyingAmount × priceUSD`. */
3640
+ valueUSD: number;
3641
+ /**
3642
+ * Value per SHARE — `valueUSD / balanceFormatted`.
3643
+ *
3644
+ * Worth storing alongside the total: it keeps a row's displayed unit price
3645
+ * consistent with its total, and lets a later balance-only refresh recompute
3646
+ * `balance × price` correctly without re-reading the chain.
3647
+ */
3648
+ pricePerTokenUSD: number;
3649
+ /** True when an on-chain conversion produced this. See {@link applyYieldConversions}. */
3650
+ converted: boolean;
3651
+ }
3652
+ /**
3653
+ * True when a token's balance is ERC-4626 shares that must be converted.
3654
+ *
3655
+ * These are the same three conditions the wallet app (`coinpool-v2`) gates its
3656
+ * own portfolio conversion on, in the same order:
3657
+ *
3658
+ * 1. a known share-based protocol — its `LENDING_PLATFORMS` allow-list. Note
3659
+ * this is deliberately stricter than {@link protocolFor} alone, which falls
3660
+ * back to an ERC-4626 protocol for unrecognised types: the right default when
3661
+ * listing lending markets, but not here, where guessing wrong silently
3662
+ * corrupts a balance. Rebasing receipts (`aave-v3`, `compound-v3`) are
3663
+ * already underlying and are excluded by the list, exactly as they are there.
3664
+ * 2. `yieldAsset.decimals`, the scale the returned assets must be read at —
3665
+ * without it the result is an unscaled integer, not an amount;
3666
+ * 3. a usable `priceUSD` (finite and > 0). The conversion's whole purpose is to
3667
+ * produce a USD value, and with no price there is none to produce — the
3668
+ * read would cost an RPC call to compute `x × 0`. Worse, reporting a
3669
+ * converted price of 0 would overwrite the caller's own last-known-price
3670
+ * fallback, turning a priced row into a valueless one that dust filters then
3671
+ * hide. Leaving it untouched keeps whatever the caller already had.
3672
+ *
3673
+ * Anything failing these — rebasing, untagged, unpriced, or incompletely
3674
+ * described — is passed through on its existing `balance × price`.
3675
+ */
3676
+ declare function isShareBasedYieldToken(token: YieldTokenInput): boolean;
3677
+ /**
3678
+ * Declare the `convertToAssets` reads needed to value `tokens` correctly.
3679
+ *
3680
+ * Only share-based holdings with a non-zero balance produce a call, so a wallet
3681
+ * holding no vault tokens plans nothing and costs no RPC.
3682
+ */
3683
+ declare function planYieldTokenConversions(tokens: YieldTokenInput[]): YieldConversionPlan;
3684
+ /**
3685
+ * Fold executed conversion results back into per-token valuations.
3686
+ *
3687
+ * `returns` must align with {@link YieldConversionPlan.calls} — entry `i` is the
3688
+ * raw return data of call `i`, or `null` if that read failed. The returned map is
3689
+ * keyed by {@link YieldTokenInput.key} and contains an entry for every input
3690
+ * token, converted or not, so the caller can apply it uniformly.
3691
+ *
3692
+ * A failed or undecodable read is never destructive: that token falls back to
3693
+ * `balance × price` — the value it would have had anyway — and is reported with
3694
+ * `converted: false`, so a flaky RPC understates a position at worst instead of
3695
+ * zeroing it.
3696
+ */
3697
+ declare function applyYieldConversions(tokens: YieldTokenInput[], plan: YieldConversionPlan, returns: Array<string | null>): Map<string, YieldTokenValue>;
3698
+
3699
+ /**
3700
+ * MoralisService — Moralis Web3 API + Cortex AI proxy.
3701
+ *
3702
+ * Adapted from keyring-chatbot-agent-sdk moralis service.
3703
+ * Uses native fetch — no SDK dependencies.
3704
+ */
3705
+
3706
+ interface MoralisServiceConfig {
3707
+ /** Base URL for Moralis proxy (default: https://nft.keyring.app) */
3708
+ baseUrl?: string;
3709
+ /** Base URL for DeFi APIs — uses /api/moralis-v1/proxy route (default: https://nft.keyring.app) */
3710
+ v1BaseUrl?: string;
3711
+ /** Pantograph API base URL for price enrichment */
3712
+ pantographUrl?: string;
3713
+ }
3714
+ interface TokenBalance {
3715
+ token_address: string;
3716
+ symbol: string;
3717
+ name: string;
3718
+ logo?: string;
3719
+ thumbnail?: string;
3720
+ decimals: number;
3721
+ balance: string;
3722
+ possible_spam: boolean;
3723
+ verified_contract: boolean;
3724
+ total_supply?: string;
3725
+ total_supply_formatted?: string;
3726
+ percentage_relative_to_total_supply?: number;
3727
+ balance_formatted: string;
3728
+ usd_price?: number;
3729
+ usd_price_24hr_percent_change?: number;
3730
+ usd_price_24hr_usd_change?: number;
3731
+ usd_value?: number;
3732
+ usd_value_24hr_usd_change?: number;
3733
+ native_token: boolean;
3734
+ portfolio_percentage?: number;
3735
+ }
3736
+ interface TokenMetadata {
3737
+ token_address: string;
3738
+ address?: string;
3739
+ name: string;
3740
+ symbol: string;
3741
+ decimals: number;
3742
+ logo?: string;
3743
+ thumbnail?: string;
3744
+ icon_image?: string;
3745
+ logoURI?: string;
3746
+ usd_price?: number;
3747
+ usd_price_24hr_percent_change?: number;
3748
+ usd_price_24hr_usd_change?: number;
3749
+ /**
3750
+ * The token's `symbol()` as READ FROM THE CONTRACT, when the upstream index
3751
+ * has it. Distinct from `symbol`, which is the index's own editorial label and
3752
+ * is frequently lower-cased ("usdc") or otherwise diverges from the chain.
3753
+ *
3754
+ * `null` when the index never resolved it — a token whose symbol therefore
3755
+ * still has to be read on-chain by the caller. Absent on endpoints that don't
3756
+ * report it at all (e.g. top-gainers), which is the same situation.
3757
+ *
3758
+ * Consumers should not have to reach for this: `normalizePantographToken`
3759
+ * already promotes it over `symbol`, so the canonical field is on-chain-true
3760
+ * wherever Pantograph knew the answer. It stays exposed for callers that need
3761
+ * to know WHICH source a symbol came from — see `confirmTokenIdentities`,
3762
+ * which skips its RPC round-trip when the symbol is already on-chain-sourced.
3763
+ */
3764
+ symbolOnchain?: string | null;
3765
+ /** The token's on-chain `name()`, same contract as {@link symbolOnchain}. */
3766
+ nameOnchain?: string | null;
3767
+ auditGoplus?: Record<string, unknown>;
3768
+ holder_count?: string;
3769
+ holders?: unknown[];
3770
+ coinGeckoId?: string;
3771
+ position?: number;
3772
+ isActive?: boolean;
3773
+ updatedAt?: string;
3774
+ price_change_24h?: number;
3775
+ telegram_channel_identifier?: string;
3776
+ subreddit_url?: string;
3777
+ facebook_username?: string;
3778
+ twitter_screen_name?: string;
3779
+ homepage?: string[];
3780
+ announcement_url?: string[];
3781
+ categories?: string[];
3782
+ chat_url?: string[];
3783
+ market_cap_rank?: number;
3784
+ max_supply?: number | null;
3785
+ total_supply?: number | string;
3786
+ circulating_supply?: number;
3787
+ fully_diluted_valuation?: number;
3788
+ market_cap?: number;
3789
+ total_volume?: number;
3790
+ }
3791
+ interface NFTItem {
3792
+ token_address: string;
3793
+ token_id: string;
3794
+ amount: string;
3795
+ owner_of: string;
3796
+ token_hash: string;
3797
+ block_number_minted: string;
3798
+ block_number: string;
3799
+ contract_type: 'ERC721' | 'ERC1155';
3800
+ name: string;
3801
+ symbol: string;
3802
+ token_uri?: string;
3803
+ metadata?: string;
3804
+ normalized_metadata?: {
3805
+ name?: string;
3806
+ description?: string;
3807
+ image?: string;
3808
+ animation_url?: string;
3809
+ attributes?: Array<{
3810
+ trait_type: string;
3811
+ value: string;
3812
+ }>;
3813
+ };
3814
+ possible_spam: boolean;
3815
+ verified_collection: boolean;
3816
+ media?: {
3817
+ mimetype?: string;
3818
+ parent_hash?: string;
3819
+ status?: string;
3820
+ updated_at?: string;
3821
+ media_collection?: {
3822
+ low?: {
3823
+ url: string;
3824
+ width: number;
3825
+ height: number;
3826
+ };
3827
+ medium?: {
3828
+ url: string;
3829
+ width: number;
3830
+ height: number;
3831
+ };
3832
+ high?: {
3833
+ url: string;
3834
+ width: number;
3835
+ height: number;
3836
+ };
3837
+ };
3838
+ original_media_url?: string;
3839
+ };
3840
+ collection_logo?: string;
3841
+ collection_banner_image?: string;
3842
+ }
3843
+ /**
3844
+ * One row of `GET /{address}/nft/collections` — an NFT collection the wallet
3845
+ * holds, rather than an individual token.
3846
+ */
3847
+ interface NFTCollectionItem {
3848
+ token_address: string;
3849
+ contract_type: 'ERC721' | 'ERC1155' | string;
3850
+ name?: string;
3851
+ symbol?: string;
3852
+ /** How many tokens of this collection the wallet holds. */
3853
+ count?: number;
3854
+ possible_spam?: boolean;
3855
+ verified_collection?: boolean;
3856
+ collection_logo?: string;
3857
+ collection_banner_image?: string;
3858
+ }
3859
+ type NFTContractMetadata = {
3860
+ token_address: string;
3861
+ name: string;
3862
+ symbol: string;
3863
+ contract_type: 'ERC721' | 'ERC1155' | string;
3864
+ possible_spam: 'true' | 'false';
3865
+ verified_collection: 'true' | 'false';
3866
+ synced_at: string | null;
3867
+ collection_logo: string;
3868
+ collection_banner_image: string;
3869
+ collection_category: string;
3870
+ project_url: string;
3871
+ wiki_url: string;
3872
+ discord_url: string;
3873
+ telegram_url: string;
3874
+ twitter_username: string;
3875
+ instagram_username: string;
3876
+ floor_price: string;
3877
+ floor_price_usd: string;
3878
+ floor_price_currency: string;
3879
+ last_sale: NFTLastSale | null;
3880
+ };
3881
+ type NFTLastSale = {
3882
+ transaction_hash: string;
3497
3883
  block_timestamp: string;
3498
3884
  buyer_address: string;
3499
3885
  seller_address: string;
@@ -4704,6 +5090,13 @@ declare class MoralisService {
4704
5090
  minMarketCap?: number;
4705
5091
  securityScore?: number;
4706
5092
  }): Promise<MoralisApiResponse<TopGainerToken[]>>;
5093
+ /**
5094
+ * USD price of each yield token's UNDERLYING, from this service's own
5095
+ * Pantograph host — see {@link fetchUnderlyingPricesUSD}. Public so the
5096
+ * single-token price reader (`readTokenUsdPrice`) values a vault against the
5097
+ * same host the balance path does.
5098
+ */
5099
+ getUnderlyingPricesUSD(chain: string | undefined, yieldAssets: YieldTokenInput['yieldAsset'][]): Promise<Map<string, number>>;
4707
5100
  /** Enrich token balances with price/logo data. Delegates to PantographService. */
4708
5101
  private enrichTokenPrices;
4709
5102
  /**
@@ -5924,141 +6317,6 @@ interface ApyEndpoints {
5924
6317
  morphoApiUrl: string;
5925
6318
  }
5926
6319
 
5927
- /**
5928
- * Shared ABI / hex types for the codec layer.
5929
- *
5930
- * Deliberately STRUCTURAL and loose (every field but `type` optional) rather
5931
- * than viem's fully-inferred `Abi` generics: this core hand-writes its ABIs as
5932
- * plain object literals — some without `as const` — and a strict type would
5933
- * reject them at every call site for no runtime benefit. Validation happens
5934
- * where it matters, at runtime, in {@link file://./signature.ts}.
5935
- */
5936
- /** A 0x-prefixed hex string. */
5937
- type Hex = `0x${string}`;
5938
- /** A 0x-prefixed 20-byte address. */
5939
- type Address = `0x${string}`;
5940
- /** One ABI input/output parameter; `components` is present for tuples. */
5941
- interface AbiParameter {
5942
- readonly name?: string;
5943
- readonly type: string;
5944
- readonly internalType?: string;
5945
- readonly components?: readonly AbiParameter[];
5946
- /** Events only — whether the parameter is a topic. */
5947
- readonly indexed?: boolean;
5948
- }
5949
- /** One ABI entry: function, event, error, constructor, fallback or receive. */
5950
- interface AbiItem {
5951
- readonly type?: string;
5952
- readonly name?: string;
5953
- readonly inputs?: readonly AbiParameter[];
5954
- readonly outputs?: readonly AbiParameter[];
5955
- readonly stateMutability?: string;
5956
- readonly anonymous?: boolean;
5957
- }
5958
- /** A contract ABI. */
5959
- type Abi = readonly AbiItem[];
5960
-
5961
- /**
5962
- * Chain shape — viem's `Chain`, plus a `hexId` because this core identifies
5963
- * chains by hex id (`0x2105`) everywhere: in tool arguments, in `UserContext`,
5964
- * and in the wallet payloads it hands the app.
5965
- */
5966
-
5967
- /** A contract deployed at a known address on a chain. */
5968
- interface ChainContract {
5969
- address: Address;
5970
- /** Block the contract was deployed at, when known — reads before it can't work. */
5971
- blockCreated?: number;
5972
- }
5973
- /** The chain's one native coin (everything else on it is a token). */
5974
- interface ChainNativeCurrency {
5975
- name: string;
5976
- symbol: string;
5977
- decimals: number;
5978
- }
5979
- interface Chain {
5980
- /** Decimal chain id (`8453`). */
5981
- id: number;
5982
- /** Canonical hex chain id (`0x2105`) — this core's primary key for a chain. */
5983
- hexId: Hex;
5984
- /** Display name, as shown to users. */
5985
- name: string;
5986
- nativeCurrency: ChainNativeCurrency;
5987
- rpcUrls: {
5988
- default: {
5989
- http: readonly string[];
5990
- };
5991
- };
5992
- blockExplorers?: {
5993
- default: {
5994
- name: string;
5995
- url: string;
5996
- };
5997
- };
5998
- /** Well-known contracts; `multicall3` is what the batching layer needs. */
5999
- contracts?: {
6000
- multicall3?: ChainContract;
6001
- };
6002
- testnet?: boolean;
6003
- }
6004
-
6005
- /**
6006
- * The 12 EVM chains this core supports, as viem-shaped {@link Chain} objects.
6007
- *
6008
- * One definition per chain carries everything the stack needs — decimal id, hex
6009
- * id, display name, native coin, default public RPC and the Multicall3
6010
- * deployment — so nothing has to be threaded through call sites or duplicated in
6011
- * a second table.
6012
- *
6013
- * Multicall3 sits at the SAME deterministic address on every one of them
6014
- * (verified on-chain via `eth_getCode`), but each chain still spells it out: a
6015
- * chain that ever ships it elsewhere is then a one-line change here.
6016
- *
6017
- * `blockCreated` is advisory metadata — it only gates reads pinned to a
6018
- * HISTORICAL block (a read at `latest`, the default, never consults it) — and is
6019
- * left out where the deployment block isn't confirmed.
6020
- *
6021
- * `rpcUrls.default.http` is an ORDERED PREFERENCE LIST, not a single endpoint:
6022
- * the first entry is the one normally used, and the rest are fixed backups the
6023
- * {@link file://../transports/fallback.ts} transport walks down when a request
6024
- * fails transiently (rate limit, 5xx, timeout). A public endpoint rejecting the
6025
- * odd method — eth.llamarpc.com answering `eth_gasPrice` with HTTP 525, say —
6026
- * therefore degrades to a slower answer rather than no answer.
6027
- */
6028
-
6029
- /** Canonical Multicall3 address, identical on every supported chain. */
6030
- declare const MULTICALL3_ADDRESS: "0xcA11bde05977b3631167028862bE2a173976CA11";
6031
- /** Every supported chain, in the core's canonical order. */
6032
- declare const chains: readonly Chain[];
6033
-
6034
- /**
6035
- * Domain-level batched reads, on top of the chain stack
6036
- * ({@link file://../chain/index.ts}).
6037
- *
6038
- * The Multicall3 plumbing this file used to carry — the hand-written
6039
- * `aggregate3` encoder, the `(bool,bytes)[]` reader, the chunking loop — now
6040
- * lives in `chain/actions/multicall.ts` and `chain/actions/multicallRaw.ts`,
6041
- * where it is ABI-driven and reusable. What remains here are the three helpers
6042
- * the core's services actually ask for, with their signatures and their
6043
- * never-throws, positionally-aligned contracts unchanged:
6044
- *
6045
- * - {@link multicallRead} raw calldata in, raw return data out
6046
- * - {@link multicallErc20Metadata} symbol + decimals, incl. legacy bytes32 tokens
6047
- * - {@link multicallTokenUris} ERC-721 `tokenURI` for many NFTs
6048
- *
6049
- * For anything new, prefer the client directly — `getPublicClient(chainId)` then
6050
- * `.multicall({ contracts })` — which decodes results and reports typed
6051
- * per-entry errors instead of `null`.
6052
- */
6053
-
6054
- /** One read in a {@link multicallRead} batch: a target contract + full calldata. */
6055
- interface MulticallRequest {
6056
- /** Contract to call. A malformed address yields a `null` result. */
6057
- target: string;
6058
- /** Encoded calldata — selector + ABI-encoded args, 0x-prefixed. */
6059
- callData: string;
6060
- }
6061
-
6062
6320
  /**
6063
6321
  * Address helpers — EIP-55 checksumming and validation, matching viem's
6064
6322
  * `isAddress` / `getAddress` / `isAddressEqual`.
@@ -10985,6 +11243,17 @@ interface SpendableBalance {
10985
11243
  *
10986
11244
  * `null` on every failure, and for a price of zero: see {@link usablePrice} for
10987
11245
  * why an unpriced token must not be reported as a worthless one.
11246
+ *
11247
+ * A yield token is priced in the unit its balance is in, as the wallet's token
11248
+ * list and its own balance rows (`getWalletTokenBalances`) price it:
11249
+ * - share-based vault → the price of ONE SHARE, converted on-chain. The API's
11250
+ * `usd_price` for a vault is its UNDERLYING's, so reading it raw undervalues
11251
+ * each share by the accrued yield — "swap $100 of a vault" then sold ~5%
11252
+ * (Morpho USDC) to ~18% (syrupUSDC) more shares than $100. `null` when the
11253
+ * read fails: the raw price is in the wrong unit, so none beats it.
11254
+ * - rebasing receipt → the underlying's unit price (`fixedPrice` when sent).
11255
+ * The identity rides on the metadata row already fetched, so a plain token
11256
+ * costs nothing extra, and a vault one multicall.
10988
11257
  */
10989
11258
  declare function readTokenUsdPrice(input: {
10990
11259
  moralis?: MoralisService;
@@ -12553,238 +12822,258 @@ declare function createX402SignatureProvider(opts: {
12553
12822
  }): X402RetryHandler;
12554
12823
 
12555
12824
  /**
12556
- * USD valuation for yield-bearing wallet tokens.
12557
- *
12558
- * A wallet's token list shows a balance and a price, and normally the USD value
12559
- * is just the product of the two. For yield-bearing tokens that is wrong often
12560
- * enough to matter, and the reason splits the tagged tokens into two kinds:
12561
- *
12562
- * - **Share-based vaults** (`spark`, `spark-ethereum`, `morpho-v2`) — `balanceOf`
12563
- * returns ERC-4626 SHARES, while the price the token API quotes belongs to the
12564
- * vault's UNDERLYING asset. A share is worth more than one unit of underlying
12565
- * and drifts further up as yield accrues (measured live: 1 steakUSDC = 1.0354
12566
- * USDC, 1 Spark sUSDC = 1.1051 USDC). The two are not even in the same unit —
12567
- * shares carry the vault's own decimals, usually 18, against the underlying's
12568
- * 6 for USDC. `convertToAssets(shares)` answers both problems at once: it
12569
- * returns the position denominated in exactly what the price describes.
12570
- *
12571
- * - **Rebasing tokens** (`aave-v3`, `compound-v3`) — the balance is ALREADY the
12572
- * underlying (their decimals match it) and yield arrives as a growing
12573
- * `balanceOf`. Converting these would be a bug, so they are left untouched.
12574
- *
12575
- * - **Oracle-priced shares** (`spark-l2-susds`) — share-based like the first
12576
- * group, but with no `convertToAssets` to ask: bridged sUSDS is a plain ERC-20
12577
- * on its chain (the vault stays on Ethereum), so the conversion reads the SSR
12578
- * oracle's ray-scaled rate and multiplies. Still ONE call per token, decoded
12579
- * differently — see {@link YieldConversionPlan.rateKeys}. Needs
12580
- * {@link YieldTokenInput.chain}, since the oracle is per chain.
12581
- *
12582
- * Which side a token falls on is decided by an explicit allow-list of
12583
- * share-based protocols, mirroring the wallet app's own `LENDING_PLATFORMS`.
12584
- * The protocol classes encode the same split as `balanceIsUnderlying`, but that
12585
- * flag is reached through `protocolFor`, which falls back to an ERC-4626
12586
- * protocol for types it doesn't recognise — a safe default for listing lending
12587
- * markets, and the wrong one here, where a mistaken conversion silently
12588
- * corrupts a balance. An allow-list fails closed instead.
12589
- *
12590
- * ## Why this returns calls instead of making them
12591
- *
12592
- * Same reasoning as {@link LendingProtocol}: the caller owns the transport. The
12593
- * wallet app already has its own RPC stack — ranked endpoints, failover, a
12594
- * Multicall3 batcher, and rate-limit-aware pacing for chains without Multicall3 —
12595
- * and duplicating it here would mean a second, worse copy. So
12596
- * {@link planYieldTokenConversions} declares the reads, the caller executes them
12597
- * however it likes, and {@link applyYieldConversions} folds the answers back in.
12598
- * Both halves are pure and synchronous, which also makes them trivial to test.
12599
- */
12600
-
12601
- /**
12602
- * Whether a `yieldProtocol` denominates balances in vault SHARES rather than the
12603
- * underlying asset.
12604
- *
12605
- * Exported so callers can explain a decision — logging why a tagged token was
12606
- * skipped, say — without keeping their own copy of the list, which would drift.
12607
- * This answers only the protocol question: use {@link isShareBasedYieldToken}
12608
- * for whether a specific token is actually convertible, since that also needs a
12609
- * price and the underlying's decimals.
12610
- */
12611
- declare function isShareBasedProtocol(yieldProtocol?: string | null): yieldProtocol is string;
12612
- /**
12613
- * The price ONE unit of a token's underlying is valued at.
12614
- *
12615
- * Two sources, in order:
12616
- *
12617
- * 1. `yieldAsset.fixedPrice` — the API stating that this underlying is valued
12618
- * at a fixed rate rather than at its market print. It sends `1` for USDC
12619
- * vaults (verified live on Base for both `spark` sUSDC and `compound-v3`
12620
- * cUSDCv3), which is the redemption rate a holder actually gets.
12621
- * 2. `priceUSD` — the market quote, for everything else.
12622
- *
12623
- * ## Why a fixed price is the better number when the API sends one
12624
- *
12625
- * `convertToAssets` returns an amount of the UNDERLYING, and for a dollar
12626
- * stablecoin that amount IS the dollar figure: redemption is 1:1 by
12627
- * construction. The market quote for the same asset is a live print — 0.99993
12628
- * one refresh, 1.00007 the next — and because it multiplies the whole position,
12629
- * that noise lands on the total: a $50,000 holding drifts by several dollars
12630
- * between refreshes with nothing having happened on chain. Two screens
12631
- * refreshing seconds apart then disagree, which reads as a bug in the balance
12632
- * rather than as noise in a feed.
12825
+ * The yield identity of a RAW token API row — `yieldProtocol` + `yieldAsset` —
12826
+ * out of the two shapes the API can send each field in.
12633
12827
  *
12634
- * ## Why the API owns this decision
12828
+ * The token API is migrating both fields:
12635
12829
  *
12636
- * Which assets are fixed-price is a question about the ASSET, and the API is
12637
- * already the authority on every other fact about it (`address`, `decimals`).
12638
- * Deciding it here would mean a hard-coded address table per chain — one that
12639
- * must be extended for every new stablecoin and every bridged variant, that
12640
- * silently does nothing when an address is missed, and that no test can catch
12641
- * drifting from the API's own view. Reading the field instead means a new
12642
- * fixed-price asset needs no client release at all.
12830
+ * - protocol: `yieldProtocolV2` (new) → `yieldProtocol` (legacy)
12831
+ * - asset: `newConfig.yieldInfo` `{ assetToken, assetDecimals, assetFixedPrice }`
12832
+ * (new) → `yieldAsset` `{ address, decimals, fixedPrice }` (legacy)
12643
12833
  *
12644
- * ## Scope
12834
+ * Today both are sent side by side, so reading only the legacy field happens to
12835
+ * work. The day the backend drops one, a reader that knows only the other stops
12836
+ * seeing the vault at all: its balance is then valued as if it were the
12837
+ * underlying, understating it by exactly the yield accrued.
12645
12838
  *
12646
- * This applies to any token whose `yieldAsset` carries the field, share-based
12647
- * or rebasing alike — a `compound-v3` receipt is already denominated in its
12648
- * underlying, so valuing that underlying at par is the same statement about the
12649
- * same dollars. A plain wallet token has no `yieldAsset` and is unaffected: it
12650
- * keeps its market quote, which is the honest number for something the user can
12651
- * sell right now.
12839
+ * This is the same precedence the wallet applies (`resolveApiYieldProtocol` /
12840
+ * `resolveApiYieldAsset` in the app's `constants/lending`). Both must stay in
12841
+ * step, or the in-chat agent and the wallet screens value one vault differently.
12652
12842
  *
12653
- * One consequence is deliberate: a fixed price makes a vault valuable even when
12654
- * the API returns NO market quote, because the price no longer depends on one.
12655
- * Such a token used to be skipped entirely and shown at `balance × 0`.
12843
+ * The three-state protocol answer is preserved rather than collapsed:
12844
+ * - `undefined` — neither field present: never answered, ask again later;
12845
+ * - `null` — answered "not a vault";
12846
+ * - a string — the tag.
12656
12847
  */
12657
- declare function effectivePriceUSD(token: YieldTokenInput): number;
12848
+ /** The underlying a yield token is denominated in — the shape valuation reads. */
12849
+ interface YieldAssetInfo {
12850
+ address?: string;
12851
+ decimals?: number;
12852
+ fixedPrice?: number | string | null;
12853
+ }
12854
+ /** A token API row, as far as its yield identity is concerned. */
12855
+ interface RawYieldIdentityRow {
12856
+ yieldProtocol?: string | null;
12857
+ yieldProtocolV2?: string | null;
12858
+ yieldAsset?: YieldAssetInfo | null;
12859
+ newConfig?: {
12860
+ yieldInfo?: {
12861
+ assetToken?: string | null;
12862
+ assetDecimals?: number | string | null;
12863
+ assetFixedPrice?: number | string | null;
12864
+ } | null;
12865
+ } | null;
12866
+ }
12867
+ /** The protocol tag of a raw row — `yieldProtocolV2` first, then `yieldProtocol`. */
12868
+ declare function resolveRawYieldProtocol(row: RawYieldIdentityRow | null | undefined): string | null | undefined;
12869
+ /** The underlying of a raw row — `newConfig.yieldInfo` first, then `yieldAsset`. */
12870
+ declare function resolveRawYieldAsset(row: RawYieldIdentityRow | null | undefined): YieldAssetInfo | null | undefined;
12658
12871
  /**
12659
- * A wallet token as the caller already knows it. Field names mirror what the
12660
- * Keyring/Pantograph token API returns, so a caller can pass its rows nearly
12661
- * as-is.
12872
+ * Both halves at once, or `null` when the row says nothing about yield at all —
12873
+ * so a caller keeping a map of identities records only rows that answered.
12662
12874
  */
12663
- interface YieldTokenInput {
12664
- /** Caller's own identifier, echoed back untouched so results can be re-joined. */
12665
- key: string;
12666
- /** The token contract — the vault itself for a share-based position. */
12667
- address: string;
12668
- /** Raw on-chain balance, unscaled. */
12669
- rawBalance: bigint;
12670
- /** The token's own decimals (vault share decimals, usually 18). */
12671
- decimals: number;
12875
+ declare function resolveRawYieldIdentity(row: RawYieldIdentityRow | null | undefined): {
12876
+ yieldProtocol: string | null | undefined;
12877
+ yieldAsset: YieldAssetInfo | null | undefined;
12878
+ } | null;
12879
+
12880
+ /**
12881
+ * PantographService — Pantograph API client.
12882
+ *
12883
+ * Handles token price/logo enrichment, token search, and token metadata
12884
+ * lookups via the Pantograph wallet API.
12885
+ */
12886
+
12887
+ interface PantographServiceConfig {
12888
+ /** Pantograph API base URL (default: https://wallet-api.pantograph.app) */
12889
+ baseUrl?: string;
12890
+ }
12891
+ /** Maps hex chain ID → Pantograph chain name */
12892
+ declare const HEX_TO_PANTOGRAPH: Record<string, string>;
12893
+ /**
12894
+ * Default tokens to always surface in the trending list per chain (keyed by hex
12895
+ * chain ID). Mirrors the SDK's `tokenTrendingDefault`: these are prepended to
12896
+ * the top-gainers feed so staple assets (WETH/WBTC/…) appear even when they are
12897
+ * not currently "gaining". Addresses are lowercased for matching.
12898
+ */
12899
+ declare const TRENDING_DEFAULT_BY_HEX_CHAIN: Record<string, string[]>;
12900
+ declare function toPantographChain(hexChain: string): string;
12901
+ /** Raw token shape returned by Pantograph list endpoints (pre-normalization). */
12902
+ interface PantographRawToken extends RawYieldIdentityRow {
12903
+ address?: string;
12904
+ token_address?: string;
12905
+ price?: number | string;
12906
+ icon_image?: string;
12907
+ decimals?: number | string;
12672
12908
  /**
12673
- * Price quoted by the token API — for a vault, the UNDERLYING's price.
12674
- * Missing, zero or non-finite disables conversion for this token; see
12675
- * {@link isShareBasedYieldToken}.
12909
+ * Yield identity, carried through verbatim rather than normalised.
12910
+ *
12911
+ * These decide whether a balance is vault SHARES (which must be converted
12912
+ * on-chain before it can be valued) or already the underlying, so the
12913
+ * distinction between an ABSENT tag and a tag of `null` matters to callers:
12914
+ * absent means the question was never answered and should be re-asked, null
12915
+ * means answered "not a vault". Defaulting either one here would erase that.
12916
+ *
12917
+ * Each also has a newer field (`yieldProtocolV2`, `newConfig.yieldInfo`,
12918
+ * declared on {@link RawYieldIdentityRow}); read the pair through
12919
+ * `resolveRawYieldIdentity`, never field by field.
12676
12920
  */
12677
- priceUSD: number;
12678
- /** `yieldProtocol` from the token API; anything untagged is left alone. */
12679
12921
  yieldProtocol?: string | null;
12922
+ yieldAsset?: {
12923
+ address?: string;
12924
+ decimals?: number;
12925
+ fixedPrice?: number | string | null;
12926
+ } | null;
12680
12927
  /**
12681
- * `yieldAsset` from the token API — the underlying this token is denominated
12682
- * in once converted.
12683
- *
12684
- * `fixedPrice` is the API declaring that this underlying is valued at a fixed
12685
- * rate rather than at its market quote (it sends `1` for USDC). When present
12686
- * it takes precedence over {@link priceUSD}; see {@link effectivePriceUSD}.
12928
+ * The contract's own `symbol()`, as the index read it. `null` (or absent) when
12929
+ * the index never resolved one — see {@link TokenMetadata.symbolOnchain}.
12687
12930
  */
12931
+ symbolOnchain?: string | null;
12932
+ }
12933
+ /**
12934
+ * The yield half of a token API row — what decides whether a quoted price
12935
+ * belongs to the unit a balance is denominated in.
12936
+ *
12937
+ * Split out of {@link PantographRawToken} so {@link
12938
+ * PantographService.enrichTokenPrices} can hand it back without exposing the
12939
+ * rest of that private wire shape.
12940
+ */
12941
+ interface PantographYieldIdentity {
12942
+ yieldProtocol?: string | null;
12688
12943
  yieldAsset?: {
12689
12944
  address?: string;
12690
12945
  decimals?: number;
12691
12946
  fixedPrice?: number | string | null;
12692
12947
  } | null;
12948
+ }
12949
+ declare class PantographService {
12950
+ private baseUrl;
12951
+ constructor(config?: PantographServiceConfig);
12693
12952
  /**
12694
- * Chain id — hex (`'0x2105'`) or decimal (`8453`), both accepted. Needed ONLY
12695
- * by `spark-l2-susds`, whose conversion goes to that chain's SSR oracle rather
12696
- * than to the token, and whose oracle address is per chain.
12953
+ * Build the unified token metadata + price endpoint for a chain:
12954
+ * `/keyrings/tokens/all/{chainId}?addresses=…`, where `{chainId}` is the
12955
+ * DECIMAL chain id (hex → number). One route serves every chain — no per-chain
12956
+ * slug — so token lookups work the same on Ethereum, Gnosis, or any other EVM.
12957
+ */
12958
+ private tokensUrl;
12959
+ /**
12960
+ * Fetch token metadata + price rows for any number of contracts on one chain,
12961
+ * split across as many `/keyrings/tokens/all/{chainId}` requests as needed.
12697
12962
  *
12698
- * Optional so existing callers are unaffected: every ERC-4626 type converts
12699
- * against the token itself and never reads this. A sUSDS row without it is
12700
- * passed through unconverted rather than converted against a guessed oracle.
12963
+ * Batches run in parallel and their rows are concatenated, so the caller sees
12964
+ * one flat list and cannot tell how many requests produced it. A batch that
12965
+ * fails contributes nothing rather than failing the whole call: every caller
12966
+ * here degrades per token (a missing row means no price, not an error), so
12967
+ * losing one chunk of a large wallet is strictly better than losing all of it.
12968
+ *
12969
+ * `chainId` is the DECIMAL id this route is keyed by; callers holding a hex
12970
+ * chain convert before calling.
12701
12971
  */
12702
- chain?: string | number | null;
12703
- }
12704
- /** One declared `convertToAssets` read, tagged with the token it belongs to. */
12705
- interface YieldConversionCall extends MulticallRequest {
12706
- /** {@link YieldTokenInput.key} of the token this call resolves. */
12707
- key: string;
12708
- }
12709
- /** What {@link planYieldTokenConversions} worked out, ready to execute. */
12710
- interface YieldConversionPlan {
12711
- /** Reads to perform, in order. Empty when nothing needs converting. */
12712
- calls: YieldConversionCall[];
12972
+ private fetchTokensAll;
12713
12973
  /**
12714
- * Keys in {@link calls} whose read returns a ray-scaled RATE rather than an
12715
- * amount — cross-chain sUSDS, which has no `convertToAssets` and is valued
12716
- * against its chain's SSR oracle instead.
12974
+ * Enrich token balances with price and logo data from Pantograph.
12975
+ * Mutates the array in-place. Non-fatal: silently skips on failure.
12717
12976
  *
12718
- * Exposed so {@link applyYieldConversions} can tell the two apart: decoding a
12719
- * ray as though it were assets would report a ~10^27 balance. Callers execute
12720
- * the plan exactly as before and need not consult this — it stays a single
12721
- * round-trip, and there is no second phase to forget.
12977
+ * Also RETURNS the yield identity of each row it saw, keyed by lower-cased
12978
+ * address. The `usd_value` written here is `balance × price`, which is the
12979
+ * wrong arithmetic for a share-based vault: the balance is ERC-4626 SHARES
12980
+ * while the price quotes the UNDERLYING. Correcting that needs an on-chain
12981
+ * `convertToAssets`, which this method cannot do — it is the price-and-logo
12982
+ * pass, not an RPC one — so it hands the caller what the fix requires instead.
12983
+ *
12984
+ * Returned rather than folded onto the tokens because {@link TokenBalance} is
12985
+ * the Moralis wire shape and these are Pantograph's fields; and returned
12986
+ * rather than re-fetched by the caller because a second request to the same
12987
+ * endpoint would cost a round-trip to learn what this one already parsed.
12722
12988
  */
12723
- rateKeys: string[];
12724
- }
12725
- /** A token's corrected valuation. */
12726
- interface YieldTokenValue {
12727
- /** Position size in UNDERLYING units (e.g. USDC), not shares. */
12728
- underlyingAmount: number;
12729
- /** `underlyingAmount × priceUSD`. */
12730
- valueUSD: number;
12989
+ enrichTokenPrices(tokens: TokenBalance[], moralisChain: string): Promise<Map<string, PantographYieldIdentity>>;
12731
12990
  /**
12732
- * Value per SHARE — `valueUSD / balanceFormatted`.
12991
+ * Raw pricing rows for specific contracts, with their yield identity intact.
12733
12992
  *
12734
- * Worth storing alongside the total: it keeps a row's displayed unit price
12735
- * consistent with its total, and lets a later balance-only refresh recompute
12736
- * `balance × price` correctly without re-reading the chain.
12993
+ * Separate from {@link enrichTokenPrices} because that one answers a different
12994
+ * question: it folds a price and a logo onto balances it was handed, dropping
12995
+ * everything else. Yield valuation needs the fields it drops — `decimals`, and
12996
+ * the `yieldProtocol` / `yieldAsset` pair that decides whether the quoted price
12997
+ * even belongs to the unit the balance is in.
12998
+ *
12999
+ * Rows are returned VERBATIM rather than normalised: `decimals` arrives as a
13000
+ * string on some tokens and an absent `yieldProtocol` must stay absent (see
13001
+ * {@link PantographRawToken}), so coercing here would destroy the very
13002
+ * distinctions the caller reads.
13003
+ *
13004
+ * Accepts a decimal or hex chain id — this route is keyed by the decimal id and
13005
+ * serves every EVM chain, so no per-chain slug is involved. Never throws: a
13006
+ * failed request yields an empty array, and the caller degrades per token.
12737
13007
  */
12738
- pricePerTokenUSD: number;
12739
- /** True when an on-chain conversion produced this. See {@link applyYieldConversions}. */
12740
- converted: boolean;
13008
+ getYieldPricingTokens(chainId: string | number, addresses: string[]): Promise<Array<PantographRawToken>>;
13009
+ /**
13010
+ * Fetch metadata + price for a single token from Pantograph.
13011
+ * Returns null if the token is not found or the request fails.
13012
+ */
13013
+ getTokenMetadata(address: string, moralisChain: string): Promise<TokenMetadata | null>;
13014
+ getTokensMetadata(addresses: string[], moralisChain: string): Promise<Record<string, TokenMetadata>>;
13015
+ /**
13016
+ * Search for tokens by symbol or name keyword on a specific chain.
13017
+ * Uses the Pantograph /token-list/all endpoint.
13018
+ */
13019
+ searchTokensByKey(params: {
13020
+ key: string;
13021
+ chain?: string;
13022
+ }): Promise<MoralisApiResponse<TokenMetadata[]>>;
13023
+ /**
13024
+ * List trending tokens on a chain via Pantograph's top-gainers endpoint:
13025
+ * `GET /token-list/all/top-gainers?chainId={chainId}&duration=24h&limit=N`.
13026
+ *
13027
+ * Mirrors the SDK's trending view: the chain's staple tokens
13028
+ * ({@link TRENDING_DEFAULT_BY_HEX_CHAIN}, e.g. WETH/WBTC) are fetched in
13029
+ * parallel and prepended to the top-gainers feed, then the merged list is
13030
+ * de-duplicated by address. This guarantees the default tokens always show
13031
+ * up even when they are not currently "gaining".
13032
+ *
13033
+ * `limit` behaviour:
13034
+ * - omitted → ALL default tokens + 5 top gainers (no cap).
13035
+ * - given N → exactly N tokens TOTAL (defaults + gainers, capped to N).
13036
+ *
13037
+ * Returns the canonical {@link TrendingToken} shape so it is a drop-in
13038
+ * replacement for `MoralisService.getTrendingTokens` — consumers reading
13039
+ * `symbol`, `name`, `usdPrice`, `pricePercentChange['24h']` and
13040
+ * `tokenAddress` work unchanged.
13041
+ *
13042
+ * Pantograph scopes results to a single chain (it has no cross-chain feed),
13043
+ * so when no `chain` is given we fall back to {@link DEFAULT_CHAIN} (Ethereum).
13044
+ */
13045
+ getTrendingTokens(params?: {
13046
+ chain?: string;
13047
+ limit?: number;
13048
+ }): Promise<MoralisApiResponse<TrendingToken[]>>;
13049
+ /**
13050
+ * Fill missing `marketCap` / `totalVolume` on trending tokens via a single
13051
+ * `/keyrings/tokens/{chain}/v2` batch. Non-fatal: leaves fields null on error.
13052
+ */
13053
+ private enrichTrendingMarketData;
13054
+ /** Fetch and normalize the raw top-gainers feed for a hex chain. */
13055
+ private fetchTopGainers;
13056
+ /**
13057
+ * List the top-gaining tokens on a chain via Pantograph's top-gainers feed:
13058
+ * `GET /token-list/all/top-gainers?chainId={chainId}&duration={duration}&limit=N`.
13059
+ *
13060
+ * Unlike {@link getTrendingTokens}, this does NOT prepend the chain's staple
13061
+ * tokens — it returns the raw gainers ranking only, so it answers "biggest
13062
+ * pumps" questions directly. Results are enriched with market cap / 24h volume
13063
+ * via a batched metadata call (the gainers feed omits those fields), then
13064
+ * returned in the canonical {@link TrendingToken} shape.
13065
+ *
13066
+ * Pantograph scopes results to a single chain (no cross-chain feed), so when
13067
+ * no `chain` is given we fall back to {@link DEFAULT_CHAIN} (Ethereum).
13068
+ *
13069
+ * `duration` accepts Pantograph windows: "1h", "24h", "7d", "30d".
13070
+ */
13071
+ getTopGainers(params?: {
13072
+ chain?: string;
13073
+ limit?: number;
13074
+ duration?: string;
13075
+ }): Promise<MoralisApiResponse<TrendingToken[]>>;
12741
13076
  }
12742
- /**
12743
- * True when a token's balance is ERC-4626 shares that must be converted.
12744
- *
12745
- * These are the same three conditions the wallet app (`coinpool-v2`) gates its
12746
- * own portfolio conversion on, in the same order:
12747
- *
12748
- * 1. a known share-based protocol — its `LENDING_PLATFORMS` allow-list. Note
12749
- * this is deliberately stricter than {@link protocolFor} alone, which falls
12750
- * back to an ERC-4626 protocol for unrecognised types: the right default when
12751
- * listing lending markets, but not here, where guessing wrong silently
12752
- * corrupts a balance. Rebasing receipts (`aave-v3`, `compound-v3`) are
12753
- * already underlying and are excluded by the list, exactly as they are there.
12754
- * 2. `yieldAsset.decimals`, the scale the returned assets must be read at —
12755
- * without it the result is an unscaled integer, not an amount;
12756
- * 3. a usable `priceUSD` (finite and > 0). The conversion's whole purpose is to
12757
- * produce a USD value, and with no price there is none to produce — the
12758
- * read would cost an RPC call to compute `x × 0`. Worse, reporting a
12759
- * converted price of 0 would overwrite the caller's own last-known-price
12760
- * fallback, turning a priced row into a valueless one that dust filters then
12761
- * hide. Leaving it untouched keeps whatever the caller already had.
12762
- *
12763
- * Anything failing these — rebasing, untagged, unpriced, or incompletely
12764
- * described — is passed through on its existing `balance × price`.
12765
- */
12766
- declare function isShareBasedYieldToken(token: YieldTokenInput): boolean;
12767
- /**
12768
- * Declare the `convertToAssets` reads needed to value `tokens` correctly.
12769
- *
12770
- * Only share-based holdings with a non-zero balance produce a call, so a wallet
12771
- * holding no vault tokens plans nothing and costs no RPC.
12772
- */
12773
- declare function planYieldTokenConversions(tokens: YieldTokenInput[]): YieldConversionPlan;
12774
- /**
12775
- * Fold executed conversion results back into per-token valuations.
12776
- *
12777
- * `returns` must align with {@link YieldConversionPlan.calls} — entry `i` is the
12778
- * raw return data of call `i`, or `null` if that read failed. The returned map is
12779
- * keyed by {@link YieldTokenInput.key} and contains an entry for every input
12780
- * token, converted or not, so the caller can apply it uniformly.
12781
- *
12782
- * A failed or undecodable read is never destructive: that token falls back to
12783
- * `balance × price` — the value it would have had anyway — and is reported with
12784
- * `converted: false`, so a flaky RPC understates a position at worst instead of
12785
- * zeroing it.
12786
- */
12787
- declare function applyYieldConversions(tokens: YieldTokenInput[], plan: YieldConversionPlan, returns: Array<string | null>): Map<string, YieldTokenValue>;
12788
13077
 
12789
13078
  /**
12790
13079
  * Executing half of the yield-token valuation — the transport `yieldTokenValue`
@@ -12864,6 +13153,37 @@ interface YieldPricingOptions {
12864
13153
  * it, so a caller mixing chains in one array is not silently re-pointed.
12865
13154
  */
12866
13155
  declare function valueYieldTokens(chainId: string | number, tokens: YieldTokenInput[], options?: YieldPricingOptions): Promise<Map<string, YieldTokenValue>>;
13156
+ type YieldAsset = YieldTokenInput['yieldAsset'];
13157
+ /**
13158
+ * USD price of each UNDERLYING (`yieldAsset.address`), keyed by lowercased
13159
+ * address — ONE batched token-API lookup per chain.
13160
+ *
13161
+ * Needed because the vault's OWN quote is not a usable unit price. The API
13162
+ * prices vaults inconsistently: most at the underlying's price, but some
13163
+ * already at the per-SHARE price (measured on Ethereum: syrupUSDT +14%, sUSDS
13164
+ * +11%, spETH +2.9% over their underlying) and at least one below it (aEthsDAI
13165
+ * $0.9998 against sDAI's $1.18). Multiplying `convertToAssets` by a per-share
13166
+ * quote counts the yield twice; valuing a rebasing receipt at a wrong quote
13167
+ * misprices the whole balance. The underlying's own row has neither problem.
13168
+ *
13169
+ * A fixed-price asset needs no lookup and is skipped. Best-effort: a failed
13170
+ * lookup yields an empty map and {@link unitPriceUSD} falls back to the vault's
13171
+ * quote, which is what every token was valued at before this existed.
13172
+ *
13173
+ * Same rule as the wallet's `fetchAssetPrices` / `unitPriceOf` — both must stay
13174
+ * in step, or the agent and the wallet screens value one vault differently.
13175
+ */
13176
+ declare function fetchUnderlyingPricesUSD(chainId: string | number, yieldAssets: YieldAsset[], pantograph?: PantographService): Promise<Map<string, number>>;
13177
+ /**
13178
+ * Price of ONE unit of a yield token's underlying, in the order the wallet
13179
+ * uses: `yieldAsset.fixedPrice` → the underlying's own API price (from
13180
+ * {@link fetchUnderlyingPricesUSD}) → `fallback`, the vault's own quote.
13181
+ *
13182
+ * This is what a {@link YieldTokenInput.priceUSD} must be set to. `fixedPrice`
13183
+ * still outranks it downstream through {@link effectivePriceUSD}, so the two
13184
+ * never disagree.
13185
+ */
13186
+ declare function unitPriceUSD(yieldAsset: YieldAsset, underlyingPrices: Map<string, number>, fallback: number | string | null | undefined): number;
12867
13187
  /**
12868
13188
  * The USD price of ONE unit of a token, in the unit its balance is actually
12869
13189
  * denominated in.
@@ -12878,9 +13198,11 @@ declare function valueYieldTokens(chainId: string | number, tokens: YieldTokenIn
12878
13198
  * token they are swapping INTO, say.
12879
13199
  *
12880
13200
  * Returns:
12881
- * - the API price unchanged, and NO RPC, for every plain token and every
12882
- * rebasing receipt (`aave-v3`, `compound-v3`), whose balance is already the
12883
- * underlying;
13201
+ * - the API price unchanged, and NO RPC, for every plain token;
13202
+ * - the underlying's unit price (`yieldAsset.fixedPrice` when sent, the API
13203
+ * price otherwise), and NO RPC, for a rebasing receipt (`aave-v3`,
13204
+ * `compound-v3`), whose balance is already the underlying — the same price
13205
+ * the balance path values it at;
12884
13206
  * - the per-SHARE price for a share-based vault that converted;
12885
13207
  * - `null` when there is no usable price, INCLUDING when a share-based vault's
12886
13208
  * read fails. That last case is deliberate: the API price is known to be in
@@ -12900,7 +13222,12 @@ declare function resolveTokenPriceUSD(chainId: string | number, token: YieldPric
12900
13222
  interface YieldPricingToken {
12901
13223
  address?: string | null;
12902
13224
  decimals?: number | string | null;
12903
- /** The API's quote — for a share-based vault, the UNDERLYING's price. */
13225
+ /**
13226
+ * For a plain token, the API's quote. For a yield token, the price of ONE
13227
+ * unit of the UNDERLYING — {@link unitPriceUSD}, not the vault's own quote,
13228
+ * which the API sometimes already states per share (valuing on it would
13229
+ * count the yield twice). `yieldAsset.fixedPrice`, when sent, outranks it.
13230
+ */
12904
13231
  price?: number | string | null;
12905
13232
  yieldProtocol?: string | null;
12906
13233
  /** See {@link YieldTokenInput.yieldAsset}: `fixedPrice` outranks `price`. */
@@ -12992,200 +13319,6 @@ interface YieldPricingToken {
12992
13319
  */
12993
13320
  declare function psm3For(chain: string | number | null | undefined): string | null;
12994
13321
 
12995
- /**
12996
- * PantographService — Pantograph API client.
12997
- *
12998
- * Handles token price/logo enrichment, token search, and token metadata
12999
- * lookups via the Pantograph wallet API.
13000
- */
13001
-
13002
- interface PantographServiceConfig {
13003
- /** Pantograph API base URL (default: https://wallet-api.pantograph.app) */
13004
- baseUrl?: string;
13005
- }
13006
- /** Maps hex chain ID → Pantograph chain name */
13007
- declare const HEX_TO_PANTOGRAPH: Record<string, string>;
13008
- /**
13009
- * Default tokens to always surface in the trending list per chain (keyed by hex
13010
- * chain ID). Mirrors the SDK's `tokenTrendingDefault`: these are prepended to
13011
- * the top-gainers feed so staple assets (WETH/WBTC/…) appear even when they are
13012
- * not currently "gaining". Addresses are lowercased for matching.
13013
- */
13014
- declare const TRENDING_DEFAULT_BY_HEX_CHAIN: Record<string, string[]>;
13015
- declare function toPantographChain(hexChain: string): string;
13016
- /** Raw token shape returned by Pantograph list endpoints (pre-normalization). */
13017
- interface PantographRawToken {
13018
- address?: string;
13019
- token_address?: string;
13020
- price?: number | string;
13021
- icon_image?: string;
13022
- decimals?: number | string;
13023
- /**
13024
- * Yield identity, carried through verbatim rather than normalised.
13025
- *
13026
- * These decide whether a balance is vault SHARES (which must be converted
13027
- * on-chain before it can be valued) or already the underlying, so the
13028
- * distinction between an ABSENT tag and a tag of `null` matters to callers:
13029
- * absent means the question was never answered and should be re-asked, null
13030
- * means answered "not a vault". Defaulting either one here would erase that.
13031
- */
13032
- yieldProtocol?: string | null;
13033
- yieldAsset?: {
13034
- address?: string;
13035
- decimals?: number;
13036
- fixedPrice?: number | string | null;
13037
- } | null;
13038
- /**
13039
- * The contract's own `symbol()`, as the index read it. `null` (or absent) when
13040
- * the index never resolved one — see {@link TokenMetadata.symbolOnchain}.
13041
- */
13042
- symbolOnchain?: string | null;
13043
- }
13044
- /**
13045
- * The yield half of a token API row — what decides whether a quoted price
13046
- * belongs to the unit a balance is denominated in.
13047
- *
13048
- * Split out of {@link PantographRawToken} so {@link
13049
- * PantographService.enrichTokenPrices} can hand it back without exposing the
13050
- * rest of that private wire shape.
13051
- */
13052
- interface PantographYieldIdentity {
13053
- yieldProtocol?: string | null;
13054
- yieldAsset?: {
13055
- address?: string;
13056
- decimals?: number;
13057
- fixedPrice?: number | string | null;
13058
- } | null;
13059
- }
13060
- declare class PantographService {
13061
- private baseUrl;
13062
- constructor(config?: PantographServiceConfig);
13063
- /**
13064
- * Build the unified token metadata + price endpoint for a chain:
13065
- * `/keyrings/tokens/all/{chainId}?addresses=…`, where `{chainId}` is the
13066
- * DECIMAL chain id (hex → number). One route serves every chain — no per-chain
13067
- * slug — so token lookups work the same on Ethereum, Gnosis, or any other EVM.
13068
- */
13069
- private tokensUrl;
13070
- /**
13071
- * Fetch token metadata + price rows for any number of contracts on one chain,
13072
- * split across as many `/keyrings/tokens/all/{chainId}` requests as needed.
13073
- *
13074
- * Batches run in parallel and their rows are concatenated, so the caller sees
13075
- * one flat list and cannot tell how many requests produced it. A batch that
13076
- * fails contributes nothing rather than failing the whole call: every caller
13077
- * here degrades per token (a missing row means no price, not an error), so
13078
- * losing one chunk of a large wallet is strictly better than losing all of it.
13079
- *
13080
- * `chainId` is the DECIMAL id this route is keyed by; callers holding a hex
13081
- * chain convert before calling.
13082
- */
13083
- private fetchTokensAll;
13084
- /**
13085
- * Enrich token balances with price and logo data from Pantograph.
13086
- * Mutates the array in-place. Non-fatal: silently skips on failure.
13087
- *
13088
- * Also RETURNS the yield identity of each row it saw, keyed by lower-cased
13089
- * address. The `usd_value` written here is `balance × price`, which is the
13090
- * wrong arithmetic for a share-based vault: the balance is ERC-4626 SHARES
13091
- * while the price quotes the UNDERLYING. Correcting that needs an on-chain
13092
- * `convertToAssets`, which this method cannot do — it is the price-and-logo
13093
- * pass, not an RPC one — so it hands the caller what the fix requires instead.
13094
- *
13095
- * Returned rather than folded onto the tokens because {@link TokenBalance} is
13096
- * the Moralis wire shape and these are Pantograph's fields; and returned
13097
- * rather than re-fetched by the caller because a second request to the same
13098
- * endpoint would cost a round-trip to learn what this one already parsed.
13099
- */
13100
- enrichTokenPrices(tokens: TokenBalance[], moralisChain: string): Promise<Map<string, PantographYieldIdentity>>;
13101
- /**
13102
- * Raw pricing rows for specific contracts, with their yield identity intact.
13103
- *
13104
- * Separate from {@link enrichTokenPrices} because that one answers a different
13105
- * question: it folds a price and a logo onto balances it was handed, dropping
13106
- * everything else. Yield valuation needs the fields it drops — `decimals`, and
13107
- * the `yieldProtocol` / `yieldAsset` pair that decides whether the quoted price
13108
- * even belongs to the unit the balance is in.
13109
- *
13110
- * Rows are returned VERBATIM rather than normalised: `decimals` arrives as a
13111
- * string on some tokens and an absent `yieldProtocol` must stay absent (see
13112
- * {@link PantographRawToken}), so coercing here would destroy the very
13113
- * distinctions the caller reads.
13114
- *
13115
- * Accepts a decimal or hex chain id — this route is keyed by the decimal id and
13116
- * serves every EVM chain, so no per-chain slug is involved. Never throws: a
13117
- * failed request yields an empty array, and the caller degrades per token.
13118
- */
13119
- getYieldPricingTokens(chainId: string | number, addresses: string[]): Promise<Array<PantographRawToken>>;
13120
- /**
13121
- * Fetch metadata + price for a single token from Pantograph.
13122
- * Returns null if the token is not found or the request fails.
13123
- */
13124
- getTokenMetadata(address: string, moralisChain: string): Promise<TokenMetadata | null>;
13125
- getTokensMetadata(addresses: string[], moralisChain: string): Promise<Record<string, TokenMetadata>>;
13126
- /**
13127
- * Search for tokens by symbol or name keyword on a specific chain.
13128
- * Uses the Pantograph /token-list/all endpoint.
13129
- */
13130
- searchTokensByKey(params: {
13131
- key: string;
13132
- chain?: string;
13133
- }): Promise<MoralisApiResponse<TokenMetadata[]>>;
13134
- /**
13135
- * List trending tokens on a chain via Pantograph's top-gainers endpoint:
13136
- * `GET /token-list/all/top-gainers?chainId={chainId}&duration=24h&limit=N`.
13137
- *
13138
- * Mirrors the SDK's trending view: the chain's staple tokens
13139
- * ({@link TRENDING_DEFAULT_BY_HEX_CHAIN}, e.g. WETH/WBTC) are fetched in
13140
- * parallel and prepended to the top-gainers feed, then the merged list is
13141
- * de-duplicated by address. This guarantees the default tokens always show
13142
- * up even when they are not currently "gaining".
13143
- *
13144
- * `limit` behaviour:
13145
- * - omitted → ALL default tokens + 5 top gainers (no cap).
13146
- * - given N → exactly N tokens TOTAL (defaults + gainers, capped to N).
13147
- *
13148
- * Returns the canonical {@link TrendingToken} shape so it is a drop-in
13149
- * replacement for `MoralisService.getTrendingTokens` — consumers reading
13150
- * `symbol`, `name`, `usdPrice`, `pricePercentChange['24h']` and
13151
- * `tokenAddress` work unchanged.
13152
- *
13153
- * Pantograph scopes results to a single chain (it has no cross-chain feed),
13154
- * so when no `chain` is given we fall back to {@link DEFAULT_CHAIN} (Ethereum).
13155
- */
13156
- getTrendingTokens(params?: {
13157
- chain?: string;
13158
- limit?: number;
13159
- }): Promise<MoralisApiResponse<TrendingToken[]>>;
13160
- /**
13161
- * Fill missing `marketCap` / `totalVolume` on trending tokens via a single
13162
- * `/keyrings/tokens/{chain}/v2` batch. Non-fatal: leaves fields null on error.
13163
- */
13164
- private enrichTrendingMarketData;
13165
- /** Fetch and normalize the raw top-gainers feed for a hex chain. */
13166
- private fetchTopGainers;
13167
- /**
13168
- * List the top-gaining tokens on a chain via Pantograph's top-gainers feed:
13169
- * `GET /token-list/all/top-gainers?chainId={chainId}&duration={duration}&limit=N`.
13170
- *
13171
- * Unlike {@link getTrendingTokens}, this does NOT prepend the chain's staple
13172
- * tokens — it returns the raw gainers ranking only, so it answers "biggest
13173
- * pumps" questions directly. Results are enriched with market cap / 24h volume
13174
- * via a batched metadata call (the gainers feed omits those fields), then
13175
- * returned in the canonical {@link TrendingToken} shape.
13176
- *
13177
- * Pantograph scopes results to a single chain (no cross-chain feed), so when
13178
- * no `chain` is given we fall back to {@link DEFAULT_CHAIN} (Ethereum).
13179
- *
13180
- * `duration` accepts Pantograph windows: "1h", "24h", "7d", "30d".
13181
- */
13182
- getTopGainers(params?: {
13183
- chain?: string;
13184
- limit?: number;
13185
- duration?: string;
13186
- }): Promise<MoralisApiResponse<TrendingToken[]>>;
13187
- }
13188
-
13189
13322
  /**
13190
13323
  * Deterministic Uniswap V3 pool-address derivation (CREATE2).
13191
13324
  *
@@ -13520,4 +13653,4 @@ declare class AbortError extends Error {
13520
13653
  */
13521
13654
  declare function isAbortError(err: unknown): boolean;
13522
13655
 
13523
- 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, type ApprovalTx, ApproveTokenTool, type ApyPoint, BaseNftAiTool, BaseSwapProvider, BaseTool, BaseWalletActionTool, type BlockParameters, type BlockTag, type BuildApprovalsParams, type BuyTokenSide, BuyTokenTool, CachedResource, 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, CoinpoolConfigApi, type ConfirmAddLiquidityTxProps, type ContractFunctionParameters, type CortexResponse, DEFAULT_CHAIN, DEFAULT_PROVIDER, DEFAULT_RPC_BY_CHAIN, DEFILLAMA_EXTRA_SIGNALS, DEFILLAMA_POOL_CHAIN_HEXES, DEFILLAMA_POOL_CHAIN_PARAM_DESCRIPTION, DebridgeProvider, type DecodedCall, type DecodedEvent, type DecodedParam, type DefaultSubagentName, DefiLlamaEstimatePoolYieldTool, type DefiLlamaEstimatePoolYieldToolConfig, type DefiLlamaPool, DefiLlamaPoolByAddressTool, type DefiLlamaPoolByAddressToolConfig, DefiLlamaPoolCandidateResolver, DefiLlamaPoolDetailTool, type DefiLlamaPoolDetailToolConfig, DefiLlamaPoolSearchTool, type DefiLlamaPoolSearchToolConfig, DefiLlamaPoolService, type DefiLlamaPoolServiceConfig, type DefiLlamaProtocolVersion, type DefiLlamaServiceResponse, type DefiLlamaSortBy, DefiLlamaTopPoolsTool, type DefiLlamaTopPoolsToolConfig, type DefiPosition, type DefiPositionDetails, type DefiPositionToken, type DefiProtocolSummary, type EIP1193RequestFn, EstimatePoolYieldTool, type EstimatePoolYieldToolConfig, type FeeContext, type FormattedDefiLlamaPool, GeminiProvider, GeminiSearchAiTool, type GeminiSearchAiToolConfig, HEX_TO_PANTOGRAPH, type Hex, type HolderChangePeriod, type HolderSupplyTier, type HttpMethod, type IngestKnowledgeBaseInput, type IngestKnowledgeBaseResult, type InputTokenInfo, type KBSearchResult, KeyringSettingApi, KnowledgeBase, type KnowledgeBaseEntry, type KnowledgeBaseProvider, type LLMProvider, type LLMProviderConfig, type LLMResponse, type LLMToolCall, type LendingMarket, type LendingMarketCardProps, LendingMarketDetailTool, type LendingMarketDetailToolConfig, type LendingMarketListProps, 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, NATIVE_GAS_LIMIT, 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 NativeActionKind, type NativeGasGap, type NativeTokenInfo, NfcBuyTool, NfcInfoTool, type NftTransferLastSale, NoFormTool, type NoFormToolMessages, OpenAddLiquidityFormTool, type OpenAddLiquidityFormToolConfig, OpenSupplyFormTool, type OpenSupplyFormToolConfig, POOL_UNISWAP_AGENT_TOOL_NAMES, PantographService, type PantographServiceConfig, type PantographYieldIdentity, type PaymentToken, PoolByAddressTool, type PoolByAddressToolConfig, PoolDetailTool, type PoolDetailToolConfig, type PoolDisplayInfo, PoolFallbackAiTool, type PoolFallbackAiToolConfig, type PoolOnchainInfo, PoolPriceRangesTool, type PoolPriceRangesToolConfig, PoolSearchTool, type PoolSearchToolConfig, PoolService, type PoolServiceConfig, PoolSwapRouter, type PresetInputs, PreviewAddLiquidityTool, type PreviewAddLiquidityToolConfig, type PriceBounds, type PriceRangePrefill, type ProviderName, PublicClient, type PublicClientConfig, type QuickRate, type QuoteGas, type RangePreset, type ReActPhase, type ReActStep, type ReActTrace, type ReadContractParameters, RelayProvider, type ResolvedRange, Router, type RouterAssignment, type RouterDecision, SUPPLIABLE_TYPES, SUPPORTED_CHAINS, SUPPORTED_CHAINS_LABEL, SWAP_PROVIDER_CONFIG, SendNativeTool, SendNftTool, SendTokenTool, type SpendableBalance, 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 SwapProviderConfig, type SwapProviderConfigMap, SwapProviderFactory, type SwapQuoteParams, type SwapQuoteResult, type SwapRoute, type SwapRouteRequest, SwapRouter, SwapRouterRegistry, type SwapTokenFormProps, 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, UserSwapRouter, 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, buildApprovals, buildChallenge, buildRangePresets, buildUniswapPoolUrl, call, canDeriveV3PoolAddress, chains, checkNativeGasAffordable, checksumAddress, clampTick, clearPublicClientCache, coinpoolConfigApi, compareDecimal, completeX402, configureSupportedChains, configureSwapProvider, convertSusdsShares, createAiAgent, createDefaultSubagents, createNfcAgent, createNftAgent, createPoolUniswapAgent, createPublicClient, createTokenAgent, createTransport, createWalletActionAgent, createWalletAgent, createX402SignatureProvider, decodeAbiParameters, decodeErrorResult, decodeFunctionData, decodeFunctionResult, defiLlamaPoolInfoScope, defiLlamaPoolSupportsLabel, deriveV3PoolAddress, displayFromChallenge, effectivePriceUSD, encodeAbiParameters, encodeApprove, encodeErrorResult, encodeFunctionData, encodeSignedHeader, erc1155Abi, erc20Abi, erc20Abi_bytes32, erc721Abi, estimateGas, estimateNativeGasReserveWei, estimateTransactionFeeWei, ethCallAt, ethCallByChain, exactAmountString, extractOutRaw, extractQuoteError, fallback, feeWeiToNative, fetchTopMarketplaces, floorToDecimals, formatDefiLlamaPool, getAbiItem, getAddress, getBalance, getBlock, getBlockNumber, getChain, getChainContractAddress, getChainId, getChainMeta, getCode, getDefaultRpcUrl, getGasPrice, getNativeTokenInfo, getPublicClient, getRevertReason, getRpcOverrides, getStorageAt, getTokenPriceUSD, getTransactionCount, http, humanToWei, ingestKnowledgeBase, isAbortError, isAddress, isAddressEqual, isPaymentRequired, isShareBasedProtocol, isShareBasedYieldToken, isSupplyChain, keyringSettingApi, listCandidateChains, listSupplyChains, mulDivFloor, multicall, multicall3Abi, multicallRaw, nativeGasShortfall, nfcAmazonSearchUrl, normaliseCountry, normalizeDecimal, normalizePriceRangeToPool, parseAbi, parseAbiItem, parseAbiParameters, pickLogo, planYieldTokenConversions, priceToTick, protocolLabelFor, psm3For, readContract, readPaymentError, readPaymentRequired, readProtocolFeeWei, readReceipt, readSpendableBalance, readTokenUsdPrice, registerMaybeNoForm, requestWithX402, resolveGasLimit, resolveNfcShopLinks, resolveRpcUrl, resolveRpcUrls, resolveTokenPriceUSD, roundTickToSpacing, rpcCall, setRpcOverrides, spendableNative, swapProviderFactory, swapRouterRegistry, tickToPrice, toEventSelector, toFunctionSelector, toPantographChain, toPlainDecimal, valueYieldTokens, weiToHuman };
13656
+ 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, type ApprovalTx, ApproveTokenTool, type ApyPoint, BaseNftAiTool, BaseSwapProvider, BaseTool, BaseWalletActionTool, type BlockParameters, type BlockTag, type BuildApprovalsParams, type BuyTokenSide, BuyTokenTool, CachedResource, 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, CoinpoolConfigApi, type ConfirmAddLiquidityTxProps, type ContractFunctionParameters, type CortexResponse, DEFAULT_CHAIN, DEFAULT_PROVIDER, DEFAULT_RPC_BY_CHAIN, DEFILLAMA_EXTRA_SIGNALS, DEFILLAMA_POOL_CHAIN_HEXES, DEFILLAMA_POOL_CHAIN_PARAM_DESCRIPTION, DebridgeProvider, type DecodedCall, type DecodedEvent, type DecodedParam, type DefaultSubagentName, DefiLlamaEstimatePoolYieldTool, type DefiLlamaEstimatePoolYieldToolConfig, type DefiLlamaPool, DefiLlamaPoolByAddressTool, type DefiLlamaPoolByAddressToolConfig, DefiLlamaPoolCandidateResolver, DefiLlamaPoolDetailTool, type DefiLlamaPoolDetailToolConfig, DefiLlamaPoolSearchTool, type DefiLlamaPoolSearchToolConfig, DefiLlamaPoolService, type DefiLlamaPoolServiceConfig, type DefiLlamaProtocolVersion, type DefiLlamaServiceResponse, type DefiLlamaSortBy, DefiLlamaTopPoolsTool, type DefiLlamaTopPoolsToolConfig, type DefiPosition, type DefiPositionDetails, type DefiPositionToken, type DefiProtocolSummary, type EIP1193RequestFn, EstimatePoolYieldTool, type EstimatePoolYieldToolConfig, type FeeContext, type FormattedDefiLlamaPool, GeminiProvider, GeminiSearchAiTool, type GeminiSearchAiToolConfig, HEX_TO_PANTOGRAPH, type Hex, type HolderChangePeriod, type HolderSupplyTier, type HttpMethod, type IngestKnowledgeBaseInput, type IngestKnowledgeBaseResult, type InputTokenInfo, type KBSearchResult, KeyringSettingApi, KnowledgeBase, type KnowledgeBaseEntry, type KnowledgeBaseProvider, type LLMProvider, type LLMProviderConfig, type LLMResponse, type LLMToolCall, type LendingMarket, type LendingMarketCardProps, LendingMarketDetailTool, type LendingMarketDetailToolConfig, type LendingMarketListProps, 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, NATIVE_GAS_LIMIT, 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 NativeActionKind, type NativeGasGap, type NativeTokenInfo, NfcBuyTool, NfcInfoTool, type NftTransferLastSale, NoFormTool, type NoFormToolMessages, OpenAddLiquidityFormTool, type OpenAddLiquidityFormToolConfig, OpenSupplyFormTool, type OpenSupplyFormToolConfig, POOL_UNISWAP_AGENT_TOOL_NAMES, PantographService, type PantographServiceConfig, type PantographYieldIdentity, type PaymentToken, PoolByAddressTool, type PoolByAddressToolConfig, PoolDetailTool, type PoolDetailToolConfig, type PoolDisplayInfo, PoolFallbackAiTool, type PoolFallbackAiToolConfig, type PoolOnchainInfo, PoolPriceRangesTool, type PoolPriceRangesToolConfig, PoolSearchTool, type PoolSearchToolConfig, PoolService, type PoolServiceConfig, PoolSwapRouter, type PresetInputs, PreviewAddLiquidityTool, type PreviewAddLiquidityToolConfig, type PriceBounds, type PriceRangePrefill, type ProviderName, PublicClient, type PublicClientConfig, type QuickRate, type QuoteGas, type RangePreset, type RawYieldIdentityRow, type ReActPhase, type ReActStep, type ReActTrace, type ReadContractParameters, RelayProvider, type ResolvedRange, Router, type RouterAssignment, type RouterDecision, SUPPLIABLE_TYPES, SUPPORTED_CHAINS, SUPPORTED_CHAINS_LABEL, SWAP_PROVIDER_CONFIG, SendNativeTool, SendNftTool, SendTokenTool, type SpendableBalance, 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 SwapProviderConfig, type SwapProviderConfigMap, SwapProviderFactory, type SwapQuoteParams, type SwapQuoteResult, type SwapRoute, type SwapRouteRequest, SwapRouter, SwapRouterRegistry, type SwapTokenFormProps, 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, UserSwapRouter, 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 YieldAssetInfo, type YieldConversionCall, type YieldConversionPlan, type YieldPricingOptions, type YieldPricingToken, type YieldTokenInput, type YieldTokenValue, ZERO_ADDRESS, amazonDomainForLanguage, apiClient, applyYieldConversions, buildApprovals, buildChallenge, buildRangePresets, buildUniswapPoolUrl, call, canDeriveV3PoolAddress, chains, checkNativeGasAffordable, checksumAddress, clampTick, clearPublicClientCache, coinpoolConfigApi, compareDecimal, completeX402, configureSupportedChains, configureSwapProvider, convertSusdsShares, createAiAgent, createDefaultSubagents, createNfcAgent, createNftAgent, createPoolUniswapAgent, createPublicClient, createTokenAgent, createTransport, createWalletActionAgent, createWalletAgent, createX402SignatureProvider, decodeAbiParameters, decodeErrorResult, decodeFunctionData, decodeFunctionResult, defiLlamaPoolInfoScope, defiLlamaPoolSupportsLabel, deriveV3PoolAddress, displayFromChallenge, effectivePriceUSD, encodeAbiParameters, encodeApprove, encodeErrorResult, encodeFunctionData, encodeSignedHeader, erc1155Abi, erc20Abi, erc20Abi_bytes32, erc721Abi, estimateGas, estimateNativeGasReserveWei, estimateTransactionFeeWei, ethCallAt, ethCallByChain, exactAmountString, extractOutRaw, extractQuoteError, fallback, feeWeiToNative, fetchTopMarketplaces, fetchUnderlyingPricesUSD, floorToDecimals, formatDefiLlamaPool, getAbiItem, getAddress, getBalance, getBlock, getBlockNumber, getChain, getChainContractAddress, getChainId, getChainMeta, getCode, getDefaultRpcUrl, getGasPrice, getNativeTokenInfo, getPublicClient, getRevertReason, getRpcOverrides, getStorageAt, getTokenPriceUSD, getTransactionCount, http, humanToWei, ingestKnowledgeBase, isAbortError, isAddress, isAddressEqual, isPaymentRequired, isShareBasedProtocol, isShareBasedYieldToken, isSupplyChain, keyringSettingApi, listCandidateChains, listSupplyChains, mulDivFloor, multicall, multicall3Abi, multicallRaw, nativeGasShortfall, nfcAmazonSearchUrl, normaliseCountry, normalizeDecimal, normalizePriceRangeToPool, parseAbi, parseAbiItem, parseAbiParameters, pickLogo, planYieldTokenConversions, priceToTick, protocolLabelFor, psm3For, readContract, readPaymentError, readPaymentRequired, readProtocolFeeWei, readReceipt, readSpendableBalance, readTokenUsdPrice, registerMaybeNoForm, requestWithX402, resolveGasLimit, resolveNfcShopLinks, resolveRawYieldAsset, resolveRawYieldIdentity, resolveRawYieldProtocol, resolveRpcUrl, resolveRpcUrls, resolveTokenPriceUSD, roundTickToSpacing, rpcCall, setRpcOverrides, spendableNative, swapProviderFactory, swapRouterRegistry, tickToPrice, toEventSelector, toFunctionSelector, toPantographChain, toPlainDecimal, unitPriceUSD, valueYieldTokens, weiToHuman };