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!1323
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/oracle-cumulative-u256"
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
price × dtand both running cumulatives areUint256. A storedu128decimal string loads as the same integer (zero-extend). Sums past2^128stay that integer.u128, or when the cumulative add would have. Observe returns everyseconds_agopoint in that case.#465/#1231still skip an unrepresentable ratio. Pair cw2 is 1.18.0. Migrate does not rewriteOBSERVATIONS.Founder direction on #1224 (256-bit) and #1322 (zero-extend
u128intou256) replaces the earlier wrapping-add note.Invariants O1322-1–O1322-8:
skills/AGENTS_TWAP_CUMULATIVE_U256.md,docs/twap-oracle.md,docs/contracts-security-audit.md. Ratio skip staysskills/AGENTS_TWAP_OBSERVE_RATIO.md.Issue criteria
#1224
price_times_dtreturns the full product. ADecimal×u64fits in 192 bits, so execute does not abort.u128,oracle_updatereturns Ok and stores that product. Swap, provide, and withdraw stay live once the cumulative add is also wide.#465skip remains.extreme_ratio_degrades_gracefully_instead_of_panickingis green.normal_ratio_still_records_observation).cargo testinsmartcontractspassed, including the oracle modules.#1322
price_aandprice_bplus a delta that fits inu128but whose sum does not:oracle_updatestores the fullUint256sum and advances the ring. The exact live cumulative340144359629112943994362291128760055446is that unit fixture.Observewithseconds_ago[0, historical]returns every offset. The "now" value is the wide sum. Storage is unchanged by the query.u128::MAXmove reserves (multitest).2^128returns(end − start) / elapsedfromcompute_twap_priceandcomputeTwapPriceDecimalString.2^128matches that integral.#465and#1231tests stay green. JSON keys stayprice_a_cumulatives/price_b_cumulatives.Not in this PR
2^128. The later comment asked for zero-extend instead.end < startstays a corrupt window.OBSERVATIONSin place.u128::MAX − 500rather than the live cumulative string. Block time is nanoseconds in au64, so a ~1:1 pool cannot accrue the ~1.38e35 headroom under that seed. The live string is covered by the directoracle_updatetest, which is the function swap / provide / withdraw call.Test plan
make verify-issue-1322(alsomake verify-issue-1224) — 17/17, including the retest passcd smartcontracts && cargo testcargo fmt --checkandcargo clippy -- -D warnings -A clippy::uninlined_format_argsOBSERVATIONS, thenObserveand a small swap on the previously bricked pair