Fix swap price orientation for CG/CMC OHLC (#466) #1008
No reviewers
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!1008
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/466-swap-price-orientation"
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
Fixes GitLab #466: the indexer stored
swap_events.priceas rawreturn_amount / offer_amountwith no base/quote orientation. Two-sided trading mixed P and 1/P in the same column, corrupting 24h high/low,last_price, bid/ask, candles, and CG/CMC feeds.Changes:
swap_orientation::orient_swap_leg— canonical quote per base (asset_1/asset_0) at index time inprocess_swapand candle builder volume buckets.get_24h_stats_for_pair,get_24h_stats_all_pairs),pair_volume_24hrefresh, andrebuild_candles_from_swapsbucket volumes by asset id, not raw offer/return.20260707000000_*backfills historicalswap_events.priceand truncatescandlesfor rebuild.docs/indexer-invariants.md,docs/CG_CMC_COMPLIANCE.md.Acceptance checklist
orient_swap_legunit tests + parser uses moduleoriented_two_sided_swaps_high_low_are_not_reciprocalsMAX/MINon oriented prices)oriented_volume_aggregation_sums_base_and_quote_legscargo test --test api_aggregator_batchcargo test --test indexer_pair_volume_pagination20260707000000_normalize_swap_price_orientation.sqlTRUNCATE candlesin migration; rebuild viaseed-qa --cleanorrebuild_candles_from_swaps/cg/tickerslow ≠ 1/highVerification for third parties
After deploy + migration on an indexer with bidirectional history:
cargo run -- seed-qa --cleanon QA, or per-pairrebuild_candles_from_swaps.curl -s $INDEXER/cg/tickers | jq '.[] | select(.low != null) | {id: .ticker_id, last: .last_price, high: .high, low: .low}'— confirmlowis not≈ 1/high.Follow-ups
seed-qadocs).Bugbot is not enabled for your account, so this pull request was not reviewed.
Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.
Security review — MR !1008
Commit reviewed:
ff28fbba19d3fdf38b8d3300331f6589c2d2cb98Scope: Swap price/volume orientation fix for CG/CMC OHLC (#466) —
swap_orientation::orient_swap_leg, indexer parser/candle path, 24h stats & volume rollup SQL, migration20260707000000_normalize_swap_price_orientation.sql, docs/tests.Method
Outcome: FINDINGS: 0 (no medium+)
No inline review threads — nothing met the medium+ bar with a plausible exploit path on this diff.
Notes (informational, below reporting threshold)
$1…); candle interval string is allowlisted beforeformat!— no injection surface added.asset_resolver; orientation is deterministic math on amounts already indexed — no new unauthenticated write API.TRUNCATE candles: One-time deploy availability concern (empty candles until rebuild); not attacker-triggerable without DB/migration control.Automated security review (Cursor Cloud Agent). Label
block:securitynot applied.mentioned in commit
a5bbd55e16