Two-tx limit order sequence burns first gas fee when second tx fails #132
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#132
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
Placing a limit order sends two sequential transactions:
increase_allowance(CW20 approval, ~5.665 LUNC gas) followed byplace_limit_order(~26.90875 LUNC gas). If the second tx fails for any reason, insufficient LUNC, user rejection, or on-chain error, the first tx has already gone through and burned its gas. The user loses ~5.665 LUNC with no order placed. The issue #130 fix guards against zero escrow token balance but does not validate that the wallet holds enough LUNC to cover both fees before starting the sequence.Reproduction Steps
/limits, select a pair, enter a valid amount, click Place Limitincrease_allowance, ~5.665 LUNC fee)place_limit_order, ~26.90875 LUNC fee) — fails or is rejected due to insufficient LUNCExpected Behavior
The frontend should validate that the wallet holds enough LUNC to cover both tx fees before sending the first transaction, not just that the escrow token balance is sufficient. If total LUNC balance is below the combined fee estimate, the Place Limit button should be disabled with a clear message.
Actual Behavior
The first tx (
increase_allowance) is broadcast and burns ~5.665 LUNC even when the second tx cannot complete, leaving the user with no order placed and a reduced gas balance.place_limit_orderRoot Cause
The two-tx sequence in
LimitOrdersPage.tsx:122has no total LUNC pre-flight check. The issue #130 fix added an escrow token balance gate but the same validation gap exists for native gas , the frontend does not check whetherwalletLuncBalance >= fee1 + fee2before broadcasting the first tx.Relevant files:
frontend-dapp/src/pages/LimitOrdersPage.tsx:122, two-tx sequence with no total LUNC pre-flight checkEnvironment Details
localterra(local Docker)VITE_NETWORK=local npm run devmake indexer-dev)make deploy-localWallet / Device Details
http://localhost:26657Severity / Impact
Medium. Users lose real LUNC to gas fees on a two-tx sequence that was never going to complete. The fix is low-effort: sum both estimated fees and compare against the wallet's native LUNC balance before broadcasting the first tx, mirroring the escrow token gate added in issue #130
CC: @PlasticDigits
mentioned in issue #133
mentioned in commit
b4ebc07ba5Implemented native LUNC preflight for the two-transaction CW20 limit place path (
increase_allowancethenplace_limit_order), so tx1 is not broadcast when the wallet cannot pay both fee envelopes.What changed
LimitOrdersPageandTradeOrderTicketrequire bank uluna ≥estimateLimitOrderPlaceSequenceUlunaFeesTotal()(same gas limits andeffectiveGasPriceUluna()asexecuteTerraContract) before enabling Place limit or broadcasting.limitOrderNativeGasBalanceGate.ts,useNativeUlunaBalance(React Query key['tokenBalance', address, 'uluna']),estimateLimitOrderPlaceSequenceUlunaFeesTotalintransactions.ts.docs/limit-orders.md,docs/frontend.md,skills/AGENTS_TERRACLASSIC_GAS.md,skills/AGENTS_LOCALNET_TRADING_SWARM.md; crosslinks from escrow gate +LimitOrderEscrowPlaceGuardMessage.Verification checklist
28.325gas price) → Place limit disabled with clear inline copy (two txs / gas)./limitsand/tradelimit panel.cd frontend-dapp && npx vitest run(297 tests).@totdking Please re-run your repro and confirm; leaving the issue open until you verify.
mentioned in issue #115
Verification checklist
28.325gas price) → Place limit disabled with clear inline copy (two txs / gas)./limitsand/tradelimit panel.cd frontend-dapp && npx vitest run(297 tests).Good to close on dev side
cc : @PlasticDigits
mentioned in issue #147
mentioned in issue #206
mentioned in issue #213
mentioned in issue #587
mentioned in commit
05451b201fmentioned in issue #629