fix(indexer): CG/CMC orderbook timestamps (CG milliseconds, CMC seconds) #222
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#222
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
Normalize orderbook
timestampformats on listing endpoints: CoinGecko (/cg/orderbook) → Unix time in milliseconds (numeric); CoinMarketCap (/cmc/orderbook/*) → Unix time in seconds (numeric), matching exchange-integration conventions and fixing drift vsdocs/CG_CMC_COMPLIANCE.md.Related: #210. References: Kujira FIN Coingecko API (ms), Openware CMC orderbook (ms in example array element — confirm seconds for CMC with listing team; this issue implements seconds for CMC per product request).
Current codebase
GET /cg/orderbooktimestampString—Utc::now().to_rfc3339()incg.rsGET /cmc/orderbook/:market_pairtimestampString— RFC3339 incmc.rsGET /cg/historical_tradestrade_timestampi64secondsGET /cmc/trades/:market_pairtimestampi64secondsProblem: Orderbook handlers are inconsistent with (a) their own compliance doc examples, (b) Kujira CG reference (
"timestamp": 1667742512184), (c) CMC trades on the same/cmc/surface (seconds).Why this is needed
/cmc/*: trades already use seconds; orderbook should match.Constraints and guardrails
cmc/trades)chronosafe conversion; no float timestampsCgOrderbookResponse/CmcOrderbookResponsefield typeshistorical_tradestimestamps (already seconds)Relevant files
indexer/src/api/cg.rsCgOrderbookResponse.timestampindexer/src/api/cmc.rsCmcOrderbookResponse.timestampindexer/tests/api_orderbook_lcd_mock.rsdocs/CG_CMC_COMPLIANCE.mdskills/AGENTS_INDEXER_AMM_ORDERBOOK_SIM.mdRecommended direction
timestamp: Utc::now().timestamp_millis()(oras_millis()on offset) → serialize as i64/u64.timestamp: Utc::now().timestamp()→ i64 seconds.body["timestamp"].is_number()and magnitude sanity.Acceptance criteria
/cg/orderbookreturns numerictimestampin milliseconds./cmc/orderbook/*returns numerictimestampin seconds.Test plan — functional paths
timestampis number;timestamp > 1_700_000_000_000(ms sanity)timestampis number;timestamp > 1_700_000_000(s sanity)cg_ms / 1000 == cmc_s(±1s skew)Test plan — attack vectors / abuse
Verification criteria
curl/ integration tests assert JSON types./cgor/cmcroutes.marked as related to #210
mentioned in issue #210
@brouie — #222 recovery / verification (issue stays open until you sign off)
Summary
/cg/orderbooktimestamp→ numeric Unix milliseconds/cmc/orderbook/*timestamp→ numeric Unix seconds (aligned with/cmc/trades)indexer/src/api/listing_timestamps.rs; CG/CMC handlers + compliance docs cross-linked (#224)Landed on
mainImplementation/docs merged via #224 commit
862d7ddonorigin/main(worktreecl8y-dex-terraclassic-fix-222/ branchfix/222-orderbook-timestampswere already absent locally).Verification checklist
cd indexer && cargo test --lib listing_timestamps -- --test-threads=1(2 unit tests)cargo test --test api_orderbook_lcd_mock -- --test-threads=1with Postgresdex_indexer_test127.0.0.1:5432hits sqlx connect timeout, run tests on Docker network, e.g.TEST_DATABASE_URL=postgres://cl8y_legal:cl8y_legal@cl8y-dex-terraclassic-postgres-1:5432/dex_indexer_testinsidecl8y-dex-terraclassic_default(10/10 passed in recovery run)docs/CG_CMC_COMPLIANCE.mdRecovery agent notes
#222commit with the draft message — content is in862d7dd.#222 verification complete (agent, worktree
verify/issue-222)Verified implementation already on
main(9f78dcd); no code changes required from this run.Summary
GET /cg/orderbook—timestampis JSON number, Unix milliseconds (i64)GET /cmc/orderbook/*— root Openware array; innertimestampis JSON number, Unix seconds (i64)indexer/src/api/listing_timestamps.rs; handlers incg.rs/cmc.rsdocs/CG_CMC_COMPLIANCE.md,docs/indexer-invariants.md,skills/AGENTS_INDEXER_AMM_ORDERBOOK_SIM.mdAcceptance criteria
/cg/orderbooknumeric ms timestamp/cmc/orderbook/*numeric seconds timestampCgOrderbookResponse.timestamp/CmcOrderbookResponse.timestamp→integer/int64Tests run (worktree
../cl8y-dex-terraclassic-verify-222)cargo test --lib listing_timestamps -- --test-threads=1— 2/2 passedcargo test --test api_orderbook_lcd_mock -- --test-threads=1— 10/10 passed (includes ms/s type + skew assertions)EMBER_CORALon:3001): CG ms>1.7e12, CMC s>1.7e9&<1.7e12,cg_ms/1000 == cmc_s(±0)/api-docs/openapi.jsonconfirms numeric types/cg/historical_tradestrade_timestampint;/cmc/tradestimestampint;/cg/pairs,/cmc/summaryHTTP 200Note:
api_cg/api_cmcfull suites can flake when multiple agents sharedex_indexer_testconcurrently (404 / empty body from TRUNCATE races). Re-run with--test-threads=1when no othercargo testis active.Manual QA checklist (listing team)
docs/CG_CMC_COMPLIANCE.md§ orderbook examplescurllive/cg/orderbook?ticker_id=<PAIR>&depth=5— confirm numeric mscurllive/cmc/orderbook/<PAIR>?depth=5— confirm[{...}]wrapper + numeric secondsAll issue-body verification criteria and functional test-plan scenarios passed on this run. Closing.
mentioned in issue #224
mentioned in issue #223
mentioned in issue #337