Skip to content

Price CATs that trade on Forge when Dexie has no price for them - #892

Closed
awizardxch wants to merge 1 commit into
xch-dev:mainfrom
awizardxch:forge-price-source
Closed

awizardxch wants to merge 1 commit into
xch-dev:mainfrom
awizardxch:forge-price-source

Conversation

@awizardxch

Copy link
Copy Markdown
Contributor

Problem

Sage prices CATs from Dexie's v3/prices/tickers, which Dexie builds from offers completed on Dexie. A token that trades only through Forge's AMM pools never appears in that list, so Sage shows it with no value however actively it trades. On testnet today Dexie's list holds 4 tokens.

Change

Forge serves its own ticker list in Dexie's exact shape at /api/v1/prices/tickers:

  • One ticker per CAT that sits in an XCH pool. last_price is XCH per whole token, the mid price of the token's deepest XCH pool, with weighted pools priced by their weights.
  • A pool below a depth floor never prices anything: 1 XCH on mainnet, 0.01 TXCH on testnet. A near-empty pool can be pushed to any price for a few mojos, and a wallet would show that as a balance's value.
  • Extra fields say where a price came from: source: "forge", pool_id, depth_xch, state_as_of. The endpoint is public, read-only and answers any origin.

PriceContext fetches Dexie and Forge in parallel with Promise.allSettled:

  • Dexie stays primary. Forge only fills a token Dexie has no last_price (or ask) for.
  • Either source failing leaves the other in place. Before this change a Dexie outage cleared every CAT price.
  • forgeApiUrl(path, isTestnet) is added to src/lib/urls.ts beside the Dexie and MintGarden helpers.

Merge behavior, checked in a browser engine:

Case Result
Both up Dexie's price where it has one; Forge fills tokens Dexie has no last price for
Dexie down Forge prices its tokens
Forge down Identical to today

tsc -p tsconfig.app.json, eslint and prettier pass on the touched files.

Draft until the Forge endpoint is live on both networks. The hosts are Forge's routers (forge-ui-production.up.railway.app for mainnet, forge-responder.up.railway.app for testnet), kept in one function so a custom domain is a one-line change.

🤖 Generated with Claude Code

Sage prices CATs from Dexie's v3/prices/tickers, which Dexie builds from
offers completed on Dexie. A token that trades only through Forge's pools
never appears there, so Sage shows it with no value.

Forge now serves its own ticker list in Dexie's shape
(/api/v1/prices/tickers): one ticker per CAT, the mid price of its deepest
XCH pool, and none from a pool below a depth floor (1 XCH on mainnet, 0.01
on testnet) so a near-empty pool cannot set a displayed value. Sage fetches
both lists in parallel. Dexie stays primary: Forge only fills tokens Dexie
has no last price for, and either source failing leaves the other in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@awizardxch

Copy link
Copy Markdown
Contributor Author

Closing for now: we need to settle the hosting for a price feed (caching, stable domain) before proposing it. Will reopen or replace it when that's in place.

@awizardxch awizardxch closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant