Ladder escrow amount produces oversized Uint128 — increase_allowance fails with "number too large to fit in target type" #233
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#233
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?
Issue Summary
When placing a ladder order, the CW20
increase_allowancecall is sent with an escrowamountvalue that is too large to fit in a Uint128. The error string (02000000020000000200000002000000020000000) is 41 digits long — far exceeding the Uint128 maximum of 39 digits (340282366920938463463374607431768211455). The value appears to be the per-rung escrow amounts (20000000each) concatenated as strings rather than summed as integers, producing a nonsensical composite number.Reproduction Steps
/trade, select EMBER/CORAL, and click the LADDER tab0.95, End price1.05, Rung count5, Total escrow100CORAL20000000raw escrowExpected Behavior
The
increase_allowanceamount should equal the total raw escrow across all rungs summed as an integer — for 5 rungs of20000000each, the correct value is100000000. The value should be a valid Uint128 integer string.Actual Behavior
The amount sent in
increase_allowanceis02000000020000000200000002000000020000000— 41 characters, consistent with the 5 per-rung amounts (20000000) concatenated as strings rather than added as integers. The transaction is rejected with:Console Logs
Root Cause (suspected)
The rung escrow amounts are being aggregated using string concatenation (e.g.
Array.join('')or+=on a string variable) rather than numeric addition (reduce((sum, n) => sum + n, BigInt(0))). The leading0prefix and the 5 repetitions of20000000in the resulting string match this pattern exactly. The fix is to ensure the total allowance amount is computed as a numeric sum before serialisation to a Uint128 string.Likely location: ladder escrow aggregation in
LimitOrderLadderPanel.tsxor the batch placement utility inpair.ts.Environment Details
localterra(local Docker)VITE_NETWORK=local npm run devmake indexer-dev)make deploy-localWallet / Device Details
http://localhost:26657Severity / Impact
High — blocks all ladder placements independently of issue https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/232 . Even if the
place_limit_order_batchvariant were supported by the contract, the malformed Uint128 inincrease_allowancecauses the sequence to fail before the batch message is ever reached. Both bugs combine to make the ladder feature entirely non-functional. The fix is low-effort: change the allowance amount aggregation from string concatenation to integer summation. Was discovered during verification of https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/231 .cc: @PlasticDigits
mentioned in commit
9f46fec22cFix landed on
main(9f46fec)Root cause:
sumLadderAmountsRawinlimitOrderLadder.tsusedreducewith a string accumulator ('0'), so each step did string concatenation instead ofBigIntaddition. Five rungs of20000000became02000000020000000200000002000000020000000, which fails CW20increase_allowanceUint128 parsing.Code fix: Already on
mainin515fba3— accumulator is now0nand the reduce addsBigIntvalues; final.toString()once at the end.This follow-up commit (
9f46fec): Regression test (5 ×20000000→100000000, explicit anti-concat assertion), JSDoc onsumLadderAmountsRaw, and docs/skill crosslinks (#233).Automated verification (agent)
npm test -- limitOrderLadder(includes #233 regression case)place 5-rung ladder in one tx (batch hook)— allowance + ladder tx succeeds; LCD showsplace_limit_order_batch/place_limit_orderwasm actionsManual verification checklist (@totdking)
Please confirm on localterra with indexer + contracts deployed:
/limits→ select pair (e.g. EMBER/CORAL) → Ladder tab (wallet connected)0.95, End1.05, rungs5, total escrow100CORAL — preview shows five rows with20000000raw eachincrease_allowance) amount is100000000(not a 41-digit concat string)invalid Uint128/number too large to fit in target typein wallet or broadcast errorDocs:
docs/limit-orders.md(ladder escrow aggregation invariant),skills/AGENTS_LIMIT_ORDER_BATCH_LADDER.mdinvariant §3.Leaving issue open for your sign-off.
/cc @totdking
Manual qa not requried, agent can conduct all 5 verifications
Verification complete (agent, worktree
verify/issue-233)Verified fix commits
515fba3(BigInt sum) and9f46fec(regression test + docs/skill crosslinks) on localterra with indexer + deployed contracts. No code changes required — fix already onmain.Automated checks
npm test -- limitOrderLadder— 2/2 pass, including GitLab #233 regression (5 × 20000000→100000000, anti-concat assertion)place 5-rung ladder in one tx (batch hook)(e2e/limit-orders-tx.spec.ts,e2e-txproject) — passed (~28s)On-chain / indexer checks (issue checklist)
expandLimitLadderwith start0.95, end1.05, 5 rungs, total100000000raw → five rows of20000000each (Vitest + E2E fill100human @ 6 decimals)increase_allowanceamount =100000000— LCD (docker exec fallback) shows most recent ladder allowance tx from dev wallet with amount100000000, not the 41-digit concat string100000000; wasm actions includeplace_limit_order_batchandplace_limit_order(E2E LCD poll)/api/v1/pairs/{pair}/limit-placements— 5 new active bid limits (orders 5–9, prices0.95–1.05) from tx7F2BC8…at block 10763invalid Uint128/number too large to fit in target typeerrorsDocs / invariants (already on main)
docs/limit-orders.md— ladder escrow aggregation invariant (#233)skills/AGENTS_LIMIT_ORDER_BATCH_LADDER.md— invariant §3 + regression test commandManual re-check (optional)
/limits→ dual-CW20 pair → Ladder tab0.95, End1.05, rungs5, total escrow100(6-decimal token)20000000raw100000000, placement tx succeedsClosing — all issue criteria and comment checklist items pass.
mentioned in issue #268
mentioned in issue #546