-
Notifications
You must be signed in to change notification settings - Fork 0
Decimal normalization for production-scale deposits #42
Copy link
Copy link
Open
Labels
P1-highCore feature, important for MVPCore feature, important for MVPctx:orbital-coreAMM 수학 엔진 (Sphere invariant, Tick, Swap)AMM 수학 엔진 (Sphere invariant, Tick, Swap)layer:mathFixed-point arithmetic, invariant computationFixed-point arithmetic, invariant computationlayer:smart-contractAnchor/Rust on-chain programAnchor/Rust on-chain programtype:featureNew functionality implementationNew functionality implementation
Milestone
Description
Metadata
Metadata
Assignees
Labels
P1-highCore feature, important for MVPCore feature, important for MVPctx:orbital-coreAMM 수학 엔진 (Sphere invariant, Tick, Swap)AMM 수학 엔진 (Sphere invariant, Tick, Swap)layer:mathFixed-point arithmetic, invariant computationFixed-point arithmetic, invariant computationlayer:smart-contractAnchor/Rust on-chain programAnchor/Rust on-chain programtype:featureNew functionality implementationNew functionality implementation
Summary
Q64.64
checked_muloverflow로 인해 현재 asset당 최대 ~740 토큰만 예치 가능.Instruction handler 경계에서 decimal 정규화를 적용해 ~17.5억 토큰/asset 까지 확장.
Problem
initialize_pool에서w_norm_squared()→r² = radius.checked_mul(radius)호출D에 대해r ≈ D × 2.366(n=3),r²가 Q64.64 i128 범위 초과Solution: Decimal Normalization
온체인 instruction handler 진입/퇴출 경계에서 변환:
진입 (raw → normalized)
퇴출 (normalized → raw)
영향 받는 instruction handlers (4곳)
initialize_pool—initial_deposit_per_asset정규화add_liquidity— deposit amount 정규화swap— input amount 정규화, output amount 역정규화remove_liquidity— withdrawal amount 역정규화내부 수학 변경 없음
fixed_point.rs,sphere.rs,torus.rs등 수학 모듈은 그대로 유지Capacity After Fix
Acceptance Criteria
initialize_pool성공Context
🤖 Generated with Claude Code