controlling search depth for reliable token pricing

Mobula's pricing engine could not establish a valid USD price for AI (a shitty pumpfun token at a $20k market cap). the most direct references were too thin, but usable pools existed further along the graph. the problem was deciding how far to search to reach them while bounding computation costs and preserving independent references. AI was quoted against NVDA. the engine therefore needed a USD reference for NVDA, including through NVDA/SOL. those pools had less than $1,000 of usable liquidity depth and failed our validation threshold. an NVDA/BTC pool had sufficient depth. but the intermediate token, Big Titty Coin, did not have a reference USD price calculated by our pricing cron that the fallback could use as a quote to value NVDA. the fallback stopped at that branch, even though a BTC/SOL pool provided a path to an approved USD anchor. the usable path was: AI/NVDA -> NVDA/BTC -> BTC/SOL -> USD we extended the fallback to resolve these intermediate references on demand. the engine can start from SOL's USD price, calculate BTC's price, then use BTC as the quote for NVDA, and finally NVDA as the quote for AI. search depth determines how far the engine explores the graph. liquidity depth determines whether each reference can be accepted. a search that stops too early can miss a valid reference. a search that goes too far multiplies storage accesses and can introduce more dependencies without improving price quality. with r1 measured in NVDA per AI, r2 in BTC per NVDA and r3 in SOL per BTC: AI price in USD = r1 * r2 * r3 * SOL price in USD reliability depends on the references that make up this product. adding steps does not automatically make the price more accurate. the purpose is to reach sufficiently liquid pools when nearby references are unusable. each step must satisfy the depth threshold and fee checks. the path must reach an approved anchor without cycles or circular dependencies. to establish NVDA's USD reference, the search specifically excludes the AI/NVDA pool. otherwise, the engine could derive NVDA from an AI valuation, then reuse NVDA to price AI. the result would be numerically computable but lack an independent reference. exploration also has to remain compatible with the engine's workload. with b branches per token and depth d, a naive search can examine on the order of b^d paths. each branch can require additional pool and metadata reads. increasing depth without controlling breadth can therefore increase costs rapidly. the fallback only runs after the usual references fail. a valid direct reference retains priority. depth is bounded, and each search has a budget of eight expansions. when a frontier contains more candidates than the remaining budget, only a subset is explored, following the order provided by storage. already-loaded anchors remain usable: an oversized branch must not invalidate a reference already found. this budget counts graph expansions, not a maximum number of Redis commands. loading a branch can require multiple operations. we also cap concurrent distinct searches at four per pricer instance. requests beyond that capacity are not queued. identical calls share a search while it is in progress. once it finishes, its result is not retained in a price cache, allowing subsequent calls to use updated references. the target path now resolves in staging. tests cover insufficient liquidity depth, cycles, exclusions and exploration limits. full pipeline validation remains pending. the objective is to explore far enough to find usable references without accepting a fragile route or turning every missing price into an unbounded search.

More in Tech

Sacha Delhoux