Fix pair Price (USD) / chart / tape: scale decimals and convert to USD #522
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#522
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Trade/Charts Price (USD) headline, candle OHLC, pair stats, and other USD surfaces treat indexer
swap_events.priceas dollars. That field is raw quote-per-base (return/offerintegers) with no decimal scaling and no oracle conversion, so mixed-decimal pairs (USTR 18 vs UST1 6) show79.7181Tand same-decimal UST1/cUSTC shows~206instead of ~$1.Environment
dex.cl8y.com)orient_swap_leg/ candles / pair stats) + frontend (tapeLastPriceUsd/PriceChart)Steps to reproduce
/charts) for UST1/cUSTC.Pairs (columbus-5):
terra1ceprjsxp86ggftf5e38wwt34l83e5gq7penkdnv4wsatkwcs8v6qccw55fterra16vxrhpvpcucu05y0nr862vf9hnqeh274uaff4s7hz4n0ea74006qf5hgqyExample last prints (hybrid pool-only,
cl8ydeploy):FA9582AB…→ 24.102109 cUSTCDD50849A…→ 0.116651 UST11748D35D…→ 9.297 USTRExpected behavior
Price (USD) (headline, chart, pair Open/Close, and any other USD label) is the USD price of 1 human unit of pair base (
asset_0).10^(decimals_quote − decimals_base)so the tape is human quote per base.For the seeded pools (USTC ~$0.004928 at seed):
Trades table / limit-order price may stay human quote-per-base, but any control labeled USD (headline, chart, escrow USD notional) must use the converted value.
Actual behavior
24.102109 / 0.116651= 206.62 cUSTC per UST1 (6/6, no USD)9297047794755092035 / 116624≈ 7.97e13 raw (×10^12 vs human ~79.72 USTR/UST1)Pool mids are ~202.92 cUSTC/UST1 and ~81.17 USTR/UST1. Compact format turns
7.97e13into79.7181T.Root cause
#466 orientation (quote per base, independent of offer leg) is correct, but
orient_swap_legdivides raw on-chain amounts and never appliesassets.decimals:Candles copy that price (
candle_builder.rs). The UI then treats the newest tapepriceas USD:TradePage.tsx/ChartsPage.tsx:tapeLastPriceUsd={trades[0].price}PriceChart.tsx/chartHeadlinePrice.ts: headline + seriesLimitOrdersPage.tsx/limitOrderPriceReference.ts:tapeHeadlineUsdfor escrow USD notionallast_priceare the same unscaled seriesassets.decimalsis already stored (UST1/cUSTC = 6, USTR = 18).Fix (suggested)
Indexer (source of truth)
orient_swap_leg(or insert path) by10^(decimals_1 − decimals_0).swap_events.price+ candles for the two #508 pairs (and any other mixed-decimal pair).Frontend (do not pass raw
trades[].priceas USD)tapeLastPriceUsd/tapeHeadlineUsdmust be the USD field (or client-side: human scale × quote USD).T.Mode
Severity
Live charts currently imply UST1 is $206 or $79 trillion.
Evidence
indexer/src/indexer/swap_orientation.rs,indexer/src/indexer/parser.rs,indexer/src/indexer/candle_builder.rs,frontend-dapp/src/pages/TradePage.tsx,frontend-dapp/src/pages/ChartsPage.tsx,frontend-dapp/src/components/charts/PriceChart.tsx,frontend-dapp/src/components/charts/chartHeadlinePrice.ts,frontend-dapp/src/utils/limitOrderPriceReference.tsAcceptance
T-scaledmarked as related to #466
marked as related to #508
marked as related to #515
mentioned in commit
7edc70d4cdmentioned in merge request !1055
Merge review (!1055) — residual gaps
Local sanity:
make verify-issue-5225/5 PASS (docs, indexer lib pair_price/swap_orientation, integration human+USD + #466, frontend tape/headline/formatPairPrice). GitLab CI on !1055 did not run tests — all jobs failed withci_quota_exceeded(no runner).Code review vs acceptance: PASS_WITH_GAPS (code complete; live/ops still open).
Acceptance still open (ops / live)
price_usdis NULL iforacle_pricesis empty at migrate time. Confirm USTC oracle is populated before migrate.resolveTapeLastPriceUsdhelper; not live-verified on columbus-5.Non-blocking
10^(decimals_quote − decimals_base)is inverted; MR correctly uses10^(decimals_base − decimals_quote).AGENTS.mdon the MR branch has a duplicatedverify-issue-522line / skill bullet (docs-only). Will clean after merge if still present.Merging !1055 without waiting for CI per review request.
mentioned in commit
8ff700ee20mentioned in commit
1d5360e031Live check (columbus-5 Coolify) — 2026-08-15T12:19Z
Indexer
https://indexer.dex.cl8y.comand frontendhttps://dex.cl8y.comare already on the #522 build. No further Coolify rebuild needed for this issue.Indexer
/healthok. USTC oracle fresh (0.0049405, sources kucoin/mexc/average @ 12:18Z).price_usd. Stats expose*_usd. Candles OHLC are USD of 1 UST1 (not raw / notT).price(quote/base)price_usdFrontend
Last-Modified: Sat, 15 Aug 2026 12:10:06 GMTpairPriceUsd-BiLCzYSz.jspresent; Trade / Charts / Limits wiretapeLastPriceUsd/open_price_usd/close_price_usd/tapeHeadlineUsd.Manual eyeball on
/tradeand/chartsstill useful; API + bundle already match ~$1.mentioned in issue #524
marked as related to #524
mentioned in issue PlasticDigits2/ustr-cmm#13
Ops complete on columbus-5. Issue already closed by !1055.
Coolify indexer + frontend serve #522 (
price_usd~$1 on UST1/cUSTC and UST1/USTR). Live check: https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/522#note_3690136730mentioned in issue #530
mentioned in issue #543
marked as related to #543
mentioned in issue #544
marked as related to #544
mentioned in issue #548
marked as related to #548
mentioned in issue #550
marked as related to #550
mentioned in issue #551
mentioned in issue #556
mentioned in issue #557
mentioned in issue #564
mentioned in issue #565
mentioned in issue #568
marked as related to #568
mentioned in issue #569
mentioned in issue #580
marked as related to #580
mentioned in issue #586
mentioned in issue #597
mentioned in issue #682
mentioned in issue #683
mentioned in issue #692