hoodkit
    Preparing search index...

    Interface HoodCache

    A read-through cache over the hoodchain SDK reads, with request coalescing: N concurrent identical reads collapse into ONE upstream call, and results are cached per-datatype TTL. Wrap the hot read paths (quotes, portfolios) to cut RPC load by orders of magnitude under load.

    interface HoodCache {
        stats: CacheStats;
        ttls: CacheTtls;
        clear(): Promise<void>;
        getMultiplier(symbol: string): Promise<bigint | null>;
        getPortfolio(
            owner: `0x${string}`,
            options?: GetQuoteOptions,
        ): Promise<Portfolio>;
        getPosition(
            owner: `0x${string}`,
            symbol: string,
            options?: GetQuoteOptions,
        ): Promise<StockPosition>;
        getQuote(symbol: string, options?: GetQuoteOptions): Promise<StockQuote>;
        getUsdgBalance(owner: `0x${string}`): Promise<bigint>;
        invalidate(key: string): Promise<void>;
        read<T>(key: string, fetcher: () => Promise<T>, ttlMs: number): Promise<T>;
    }
    Index
    stats: CacheStats

    Live hit/miss/coalesce counters.

    ttls: CacheTtls

    Effective TTLs after option merge.

    • Cached, coalesced getMultiplier.

      Parameters

      • symbol: string

      Returns Promise<bigint | null>

    • Cached, coalesced getPortfolio.

      Parameters

      • owner: `0x${string}`
      • Optionaloptions: GetQuoteOptions

      Returns Promise<Portfolio>

    • Cached, coalesced single-position read.

      Parameters

      • owner: `0x${string}`
      • symbol: string
      • Optionaloptions: GetQuoteOptions

      Returns Promise<StockPosition>

    • Cached, coalesced getQuote.

      Parameters

      • symbol: string
      • Optionaloptions: GetQuoteOptions

      Returns Promise<StockQuote>

    • Cached, coalesced USDG balance.

      Parameters

      • owner: `0x${string}`

      Returns Promise<bigint>

    • Drop a cached key (e.g. after a write you know invalidates it).

      Parameters

      • key: string

      Returns Promise<void>

    • Generic read-through primitive: coalesce + cache any async fetch under key. Reuse this to cache your own chain reads with the same guarantees.

      Type Parameters

      • T

      Parameters

      • key: string
      • fetcher: () => Promise<T>
      • ttlMs: number

      Returns Promise<T>