Skip to content

PriceLevelsRpcSource ​

Fetch-on-demand source for pAMM price levels: one titan_getPammBooks call per getPriceLevels. Also exposes the quote helpers directly. Simplest for sporadic use.

ts
new PriceLevelsRpcSource(options?: PriceLevelsRpcSourceOptions)

Usage ​

ts
import { PriceLevels, PriceLevelsRpcSource } from "propamm/prices";

// custom endpoint — snapshot and quotes both use it
const prices = new PriceLevels({
  source: new PriceLevelsRpcSource({ url: "https://us.data.titanbuilder.xyz/data" }),
});

Methods ​

getPriceLevels() ​

ts
getPriceLevels(): Promise<PriceLevelsSnapshot>

Returns Promise<PriceLevelsSnapshot> — a fresh snapshot. Throws on HTTP or JSON-RPC error.

getQuote() ​

ts
getQuote(tokenIn: Address, tokenOut: Address, amountIn: bigint): Promise<TitanQuote>

Returns Promise<TitanQuote>. Throws on error.

getQuoteVenue() ​

ts
getQuoteVenue(venue: Address, tokenIn: Address, tokenOut: Address, amountIn: bigint): Promise<TitanQuote>

Returns Promise<TitanQuote>. Throws on error.

Options ​

url (optional) ​

  • Type: string
  • Default: https://eu.data.titanbuilder.xyz/data

Titan JSON-RPC endpoint. Served from regional hosts (eu., ap., us.); pick the nearest.

fetch (optional) ​

  • Type: typeof fetch

Custom fetch implementation.

decimals (optional) ​

  • Type: Record<string, number>

Decimals of tokens missing from TOKEN_DECIMALS, by token address (an entry also overrides the built-in value). Titan's v2 feed sends amounts in human units, so a book quoting a token without known decimals is skipped. Each value must be an integer from 0 to 255, or the constructor throws.