harden(factory): refund/reject attached uluna even when pair fee is disabled (#276) #763
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!763
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "qa/276-fee-fund-hardening"
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?
Follow-up hardening on #276 — the original MR (!754) merged before this landed, so it's a fresh MR against the now-merged code.
Self-review of the
BankMsgfund handling (the one part with no in-repo precedent) caught a stuck-funds edge that's now on main: the whole fee block was gated onif fee != 0, so if governance disables the fee (sets it 0) and a caller mistakenly attaches uluna, it was neither forwarded nor refunded — stuck in the factory. A stray denom while the fee's off had the same hole.Fix: the denom check, the
paid >= feeguard, and the excess refund now run regardless of the fee value; only the treasury send stays conditional onfee > 0. So with the fee disabled, any attached uluna is fully refunded, and nothing can get stuck in any path.Test
create_pair_refunds_uluna_when_fee_disabled(fee=0 + attach uluna -> treasury 0, factory 0, full refund). Contract suite green. No closing keyword.Security review
Commit reviewed:
c117428b7a48179eb348c7524fab830217c91357Scope:
execute_create_pairfund handling insmartcontracts/contracts/factory/src/contract.rs(+ regression test insmartcontracts/tests/src/lib.rs). MR hardensBankMsgpaths whenpair_creation_fee_uluna == 0.Method: Traced attacker-controlled
info.funds/info.senderthrough denom checks,paid >= fee, treasury send, and refundBankMsgs; compared behavior forfee > 0vsfee == 0; checked rollback on failed pair instantiate (SubMsg::reply_on_success); reviewed existing fee tests and prior MR discussion threads (none).Outcome:
FINDINGS: 0medium+No inline threads — nothing to anchor on the diff.
Notes (informational, not findings)
main: when the fee was zero, attacheduluna(or stray denoms) skipped the oldif !fee.is_zero()block and could remain in the factory.paid >= fee, andrefund = paid - feerun for all fee values; only the treasurySendis gated onfee > 0. Refunds go only toinfo.senderand cannot exceed coins attached in the sameCreatePaircall (paidis derived frominfo.funds, not the factory’s historical balance).fee > 0remains blocked byInsufficientPairCreationFee; atomic rollback on failed instantiation is unchanged.Security review: no medium+ findings on this diff.
mentioned in commit
4ab91ed936mentioned in issue #303