Indexer oracle /api/v1/oracle/price returns LUNC/USD exactly 100x too high #515

Closed
opened 2026-08-10 16:08:24 +00:00 by leonardocolucci · 47 comments
leonardocolucci commented 2026-08-10 16:08:24 +00:00 (Migrated from gitlab.com)

Summary

/api/v1/oracle/price on the production indexer returns LUNC/USD scaled exactly 100× too high, while attributing the values to KuCoin/MEXC — whose real same-minute prices are 100× lower.

Evidence (fetched within the same minute, 2026-08-10 ~16:06 UTC)

Source LUNC/USD
indexer oracle (price_usd) 0.005039
— oracle's claimed "kucoin" source 0.00502
— oracle's claimed "mexc" source 0.00511 (earlier fetch)
KuCoin actual (/api/v1/market/orderbook/level1?symbol=LUNC-USDT) 0.00005009
MEXC actual (/api/v3/ticker/price?symbol=LUNCUSDT) 0.00005024
Binance actual 0.00005024
CoinGecko 0.00004996

The oracle's per-source values are precisely the real exchange prices × 100, so this looks like a unit/scaling bug in the fetcher (e.g. parsing a 1000LUNC or cents-denominated field, or a stray ×100), not a stale price.

Impact

Anything consuming this endpoint — dApp USD displays, charts, integrators valuing cLUNC inventory — overstates USD values by 100×. We caught it because our bot's portfolio meter suddenly claimed a ~$380 wallet was worth ~$38,000; a treasury or listing decision made off this feed would be off by the same factor.

Happy to retest once fixed.

## Summary `/api/v1/oracle/price` on the production indexer returns LUNC/USD scaled **exactly 100× too high**, while attributing the values to KuCoin/MEXC — whose real same-minute prices are 100× lower. ## Evidence (fetched within the same minute, 2026-08-10 ~16:06 UTC) | Source | LUNC/USD | |---|---| | indexer oracle (`price_usd`) | **0.005039** | | — oracle's claimed "kucoin" source | 0.00502 | | — oracle's claimed "mexc" source | 0.00511 (earlier fetch) | | KuCoin actual (`/api/v1/market/orderbook/level1?symbol=LUNC-USDT`) | 0.00005009 | | MEXC actual (`/api/v3/ticker/price?symbol=LUNCUSDT`) | 0.00005024 | | Binance actual | 0.00005024 | | CoinGecko | 0.00004996 | The oracle's per-source values are precisely the real exchange prices × 100, so this looks like a unit/scaling bug in the fetcher (e.g. parsing a 1000LUNC or cents-denominated field, or a stray ×100), not a stale price. ## Impact Anything consuming this endpoint — dApp USD displays, charts, integrators valuing cLUNC inventory — overstates USD values by 100×. We caught it because our bot's portfolio meter suddenly claimed a ~$380 wallet was worth ~$38,000; a treasury or listing decision made off this feed would be off by the same factor. Happy to retest once fixed.
PlasticDigits commented 2026-08-11 00:36:26 +00:00 (Migrated from gitlab.com)

Approved to fix. Likely cause is api confusing - the price api should be delivering ustc price. Breaking change to v1 approved (as we are still in non-economic phase) to change the api routes to /api/v1/oracle/price/ustc and /api/v1/oracle/price/lunc, with /api/v1/oracle/price listing available tickers such as {metadata: "... explain how to use the api here...", tickers:["ustc","lunc"]

Approved to fix. Likely cause is api confusing - the price api should be delivering ustc price. Breaking change to v1 approved (as we are still in non-economic phase) to change the api routes to /api/v1/oracle/price/ustc and /api/v1/oracle/price/lunc, with /api/v1/oracle/price listing available tickers such as {metadata: "... explain how to use the api here...", tickers:["ustc","lunc"]
PlasticDigits commented 2026-08-11 00:50:30 +00:00 (Migrated from gitlab.com)

mentioned in commit aa59731ea0

mentioned in commit aa59731ea0848b6d00c3392a2dcf7da8ed22a694
PlasticDigits commented 2026-08-11 00:50:43 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1050

mentioned in merge request !1050
PlasticDigits commented 2026-08-11 00:50:50 +00:00 (Migrated from gitlab.com)

Fix implemented in !1050 (fix/515-oracle-price-tickers).

Breaking v1 change (as approved):

  • GET /api/v1/oracle/price → catalog { metadata, tickers: ["ustc","lunc"] }
  • GET /api/v1/oracle/price/ustc / /lunc → ticker snapshots
  • Matching history catalog + /history/{ticker}
  • Regression: make verify-issue-515

Please retest LUNC path against KuCoin/MEXC after indexer deploy.

Fix implemented in !1050 (`fix/515-oracle-price-tickers`). Breaking v1 change (as approved): - `GET /api/v1/oracle/price` → catalog `{ metadata, tickers: ["ustc","lunc"] }` - `GET /api/v1/oracle/price/ustc` / `/lunc` → ticker snapshots - Matching history catalog + `/history/{ticker}` - Regression: `make verify-issue-515` Please retest LUNC path against KuCoin/MEXC after indexer deploy.
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-08-11 01:07:07 +00:00
PlasticDigits commented 2026-08-11 01:07:08 +00:00 (Migrated from gitlab.com)

mentioned in commit 92d5e3a105

mentioned in commit 92d5e3a1053c029fe04c64304761d90435da0e66
PlasticDigits commented 2026-08-11 01:07:21 +00:00 (Migrated from gitlab.com)

Merge sanity check (!1050 → main)

Merged via glab mr merge 332 after resolving a post-!1049 conflict in Makefile .PHONY (kept both verify-issue-512 and verify-issue-515). No automerge; CI was ci_quota_exceeded, not waited on.

Local checks on the MR branch: cargo test --lib oracle (11/11), cargo test --test api_oracle (10/10), Protocol/Trade frontend tests (33) — all passed. make verify-issue-515 needs frontend node_modules on a fresh checkout.

Acceptance vs #515

Criterion Result
Bare /api/v1/oracle/price + /history → ticker catalog Met
Snapshots at /price/{ustc|lunc} and /history/{ticker} Met
Poller fetches both tickers with distinct CEX/CoinGecko symbols Met
Volume USD / overview still USTC-only Met
Protocol page default getOraclePrice() → USTC/USD Met
Docs/invariants X1–X6 + verify target Met

Remaining gaps / follow-ups (ops, not code blockers)

  1. Deploy checklist — Run migration 20260811000000_oracle_prices_multi_ticker.sql (indexer auto-migrate on start), deploy indexer + frontend together, and notify integrators: bare GET /api/v1/oracle/price is now a catalog, not a numeric price (use /price/ustc or /price/lunc).
  2. verify-issue-515 bootstrap — Script bootstraps Postgres but not frontend deps; fresh checkouts fail the frontend step with vitest: not found until npm install in frontend-dapp.
  3. Live CEX smoke — Symbol wiring is unit-tested; compare /price/lunc vs live KuCoin/MEXC LUNCUSDT after deploy (MR test plan).

Please retest LUNC vs USTC scale on staging/prod after indexer deploy.

## Merge sanity check (!1050 → main) Merged via `glab mr merge 332` after resolving a post-!1049 conflict in `Makefile` `.PHONY` (kept both `verify-issue-512` and `verify-issue-515`). No automerge; CI was `ci_quota_exceeded`, not waited on. Local checks on the MR branch: `cargo test --lib oracle` (11/11), `cargo test --test api_oracle` (10/10), Protocol/Trade frontend tests (33) — all passed. `make verify-issue-515` needs frontend `node_modules` on a fresh checkout. ### Acceptance vs #515 | Criterion | Result | |---|---| | Bare `/api/v1/oracle/price` + `/history` → ticker catalog | Met | | Snapshots at `/price/{ustc\|lunc}` and `/history/{ticker}` | Met | | Poller fetches both tickers with distinct CEX/CoinGecko symbols | Met | | Volume USD / overview still USTC-only | Met | | Protocol page default `getOraclePrice()` → USTC/USD | Met | | Docs/invariants X1–X6 + verify target | Met | ### Remaining gaps / follow-ups (ops, not code blockers) 1. **Deploy checklist** — Run migration `20260811000000_oracle_prices_multi_ticker.sql` (indexer auto-migrate on start), deploy indexer + frontend together, and notify integrators: bare `GET /api/v1/oracle/price` is now a **catalog**, not a numeric price (use `/price/ustc` or `/price/lunc`). 2. **`verify-issue-515` bootstrap** — Script bootstraps Postgres but not frontend deps; fresh checkouts fail the frontend step with `vitest: not found` until `npm install` in `frontend-dapp`. 3. **Live CEX smoke** — Symbol wiring is unit-tested; compare `/price/lunc` vs live KuCoin/MEXC LUNCUSDT after deploy (MR test plan). Please retest LUNC vs USTC scale on staging/prod after indexer deploy.
leonardocolucci commented 2026-08-11 09:30:24 +00:00 (Migrated from gitlab.com)

Retested — confirmed fixed, and thanks for the fast turnaround (filed → fixed in under a day).

Verification, same-minute against external references:

Ticker Oracle External (KuCoin)
/api/v1/oracle/price/lunc 0.00005005 0.00004982 ✓
/api/v1/oracle/price/ustc 0.0050235 0.00503 ✓

Also happy to correct my own diagnosis: this was never a 100× scaling bug — the old unlabeled endpoint was serving USTC/USD, and consumers (us included) read it as LUNC/USD. The "exactly 100×" in my title was just the coincidental USTC:LUNC price ratio. Your fix — ticker in the path, both assets served explicitly — is the right structural cure, and having the bare /price endpoint return metadata instead of a number is a nice touch: any stale consumer breaks loudly instead of silently misreading forever.

We've migrated our tooling to /price/lunc and keep independent exchange cross-checks as standard practice. Fine to close from our side.

Retested — **confirmed fixed**, and thanks for the fast turnaround (filed → fixed in under a day). Verification, same-minute against external references: | Ticker | Oracle | External (KuCoin) | | |---|---|---|---| | `/api/v1/oracle/price/lunc` | 0.00005005 | 0.00004982 | ✓ | | `/api/v1/oracle/price/ustc` | 0.0050235 | 0.00503 | ✓ | Also happy to correct my own diagnosis: this was never a 100× *scaling* bug — the old unlabeled endpoint was serving USTC/USD, and consumers (us included) read it as LUNC/USD. The "exactly 100×" in my title was just the coincidental USTC:LUNC price ratio. Your fix — ticker in the path, both assets served explicitly — is the right structural cure, and having the bare `/price` endpoint return metadata instead of a number is a nice touch: any stale consumer breaks loudly instead of silently misreading forever. We've migrated our tooling to `/price/lunc` and keep independent exchange cross-checks as standard practice. Fine to close from our side.
PlasticDigits commented 2026-08-15 09:36:29 +00:00 (Migrated from gitlab.com)

marked as related to #520

marked as related to #520
PlasticDigits commented 2026-08-15 09:36:29 +00:00 (Migrated from gitlab.com)

mentioned in issue #520

mentioned in issue #520
PlasticDigits commented 2026-08-15 11:39:17 +00:00 (Migrated from gitlab.com)

mentioned in issue #522

mentioned in issue #522
PlasticDigits commented 2026-08-15 11:39:19 +00:00 (Migrated from gitlab.com)

marked as related to #522

marked as related to #522
PlasticDigits commented 2026-08-15 11:52:33 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1055

mentioned in merge request !1055
PlasticDigits commented 2026-08-15 12:19:49 +00:00 (Migrated from gitlab.com)

mentioned in issue #524

mentioned in issue #524
PlasticDigits commented 2026-08-17 03:51:35 +00:00 (Migrated from gitlab.com)

mentioned in issue #543

mentioned in issue #543
PlasticDigits commented 2026-08-17 03:52:29 +00:00 (Migrated from gitlab.com)

mentioned in issue #544

mentioned in issue #544
PlasticDigits commented 2026-08-17 03:52:31 +00:00 (Migrated from gitlab.com)

marked as related to #544

marked as related to #544
PlasticDigits commented 2026-08-17 10:29:11 +00:00 (Migrated from gitlab.com)

mentioned in issue #548

mentioned in issue #548
PlasticDigits commented 2026-08-17 10:29:13 +00:00 (Migrated from gitlab.com)

marked as related to #548

marked as related to #548
PlasticDigits commented 2026-08-17 10:35:57 +00:00 (Migrated from gitlab.com)

mentioned in issue #550

mentioned in issue #550
PlasticDigits commented 2026-08-17 10:35:57 +00:00 (Migrated from gitlab.com)

marked as related to #550

marked as related to #550
PlasticDigits commented 2026-08-18 00:28:53 +00:00 (Migrated from gitlab.com)

mentioned in issue #556

mentioned in issue #556
PlasticDigits commented 2026-08-19 00:57:40 +00:00 (Migrated from gitlab.com)

mentioned in issue #568

mentioned in issue #568
PlasticDigits commented 2026-08-19 00:57:43 +00:00 (Migrated from gitlab.com)

marked as related to #568

marked as related to #568
PlasticDigits commented 2026-08-19 01:02:31 +00:00 (Migrated from gitlab.com)

mentioned in issue #569

mentioned in issue #569
PlasticDigits commented 2026-08-19 01:03:03 +00:00 (Migrated from gitlab.com)

mentioned in issue #570

mentioned in issue #570
PlasticDigits commented 2026-08-19 01:03:04 +00:00 (Migrated from gitlab.com)

marked as related to #570

marked as related to #570
PlasticDigits commented 2026-08-19 01:04:57 +00:00 (Migrated from gitlab.com)

mentioned in issue #571

mentioned in issue #571
PlasticDigits commented 2026-08-19 01:04:58 +00:00 (Migrated from gitlab.com)

marked as related to #571

marked as related to #571
PlasticDigits commented 2026-08-19 01:05:02 +00:00 (Migrated from gitlab.com)

mentioned in issue #572

mentioned in issue #572
PlasticDigits commented 2026-08-19 01:05:03 +00:00 (Migrated from gitlab.com)

marked as related to #572

marked as related to #572
PlasticDigits commented 2026-08-19 11:49:49 +00:00 (Migrated from gitlab.com)

mentioned in issue #574

mentioned in issue #574
PlasticDigits commented 2026-08-19 11:49:53 +00:00 (Migrated from gitlab.com)

marked as related to #574

marked as related to #574
PlasticDigits commented 2026-08-19 11:49:57 +00:00 (Migrated from gitlab.com)

mentioned in issue #575

mentioned in issue #575
PlasticDigits commented 2026-08-19 11:49:59 +00:00 (Migrated from gitlab.com)

marked as related to #575

marked as related to #575
PlasticDigits commented 2026-08-19 12:11:17 +00:00 (Migrated from gitlab.com)

mentioned in issue #579

mentioned in issue #579
PlasticDigits commented 2026-08-19 12:11:17 +00:00 (Migrated from gitlab.com)

marked as related to #579

marked as related to #579
PlasticDigits commented 2026-08-19 12:11:28 +00:00 (Migrated from gitlab.com)

mentioned in issue #580

mentioned in issue #580
PlasticDigits commented 2026-08-19 12:11:30 +00:00 (Migrated from gitlab.com)

marked as related to #580

marked as related to #580
PlasticDigits commented 2026-08-20 03:03:44 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1106

mentioned in merge request !1106
PlasticDigits commented 2026-08-21 00:21:03 +00:00 (Migrated from gitlab.com)

mentioned in issue #586

mentioned in issue #586
PlasticDigits commented 2026-08-22 03:10:04 +00:00 (Migrated from gitlab.com)

mentioned in issue #589

mentioned in issue #589
PlasticDigits commented 2026-08-22 12:26:37 +00:00 (Migrated from gitlab.com)

mentioned in issue #597

mentioned in issue #597
PlasticDigits commented 2026-08-24 00:30:20 +00:00 (Migrated from gitlab.com)

mentioned in issue #614

mentioned in issue #614
PlasticDigits commented 2026-08-24 03:15:46 +00:00 (Migrated from gitlab.com)

mentioned in issue #619

mentioned in issue #619
PlasticDigits commented 2026-08-26 01:11:06 +00:00 (Migrated from gitlab.com)

mentioned in issue #653

mentioned in issue #653
PlasticDigits commented 2026-08-27 11:52:20 +00:00 (Migrated from gitlab.com)

mentioned in issue #690

mentioned in issue #690
PlasticDigits commented 2026-08-27 11:52:44 +00:00 (Migrated from gitlab.com)

mentioned in issue #691

mentioned in issue #691
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic#515
No description provided.