Review: Factory pair-creation BankMsg::Send to treasury (GitLab #276) #313
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#313
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?
Current codebase
GitLab #276 introduced pair-creation fee collection in
smartcontracts/contracts/factory/src/contract.rs:This was the first in-repo use of
BankMsg::Sendto treasury (previously fees were CW20-only flows). Treasury contract itself is external (ustr-cmmgit dep).Integration test:
create_pair_charges_fee_to_treasury_and_gov_can_set_itinsmartcontracts/tests/src/lib.rs.Why this is needed
Bank sends differ from Wasm executes: native denom routing, blocked addresses, clawback, and failure modes. A careful review ensures:
UnexpectedPairCreationFunds)Constraints / guardrails
SetPairCreationFee/ treasury update must remain sole mutators.docs/security-model.mdand factory invariants.Relevant files
smartcontracts/contracts/factory/src/contract.rs(~lines 220–248)smartcontracts/contracts/factory/src/error.rssmartcontracts/contracts/factory/src/state.rssmartcontracts/tests/src/lib.rs(create_pair_charges_fee_to_treasury…)ustr-cmmtreasury cratedocs/security-model.mdRecommended direction
docs/audits/factory-treasury-bank-send.md:CreatePairOnePairCreationPerBlockAcceptance criteria
Test plan (all paths)
InsufficientPairCreationFeeUnexpectedPairCreationFundsAttack / abuse / hack vectors
UpdateConfigOnePairCreationPerBlockVerification criteria
make test-contractsgreen.marked as related to #276
mentioned in commit
ce26e061f1mentioned in merge request !789
Implementation complete (review + tests)
MR: https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/merge_requests/71
Review outcome
Factory
execute_create_pairbank-send logic (#276) is sound — no contract changes required. Checklist and sign-off:docs/audits/factory-treasury-bank-send.md.Acceptance criteria
create_pair_fee_bank_send_adversarial_pathsmake test-contracts(363 integration tests)Commands
Indexer
Pair creation indexing does not depend on bank send events (no factory fee parser in indexer).
Issue left open until MR !789 merges.
mentioned in commit
0d3c4eeacfVerification complete — GitLab #313
Issue: https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/313
Implementation MR: !789 (merged)
Independent verify pass on branch
cursor/gitlab-issue-verification-4a81(2026-06-05).Acceptance criteria
docs/audits/factory-treasury-bank-send.md— 11 checklist rows + attack-vector tablecreate_pair_fee_bank_send_adversarial_paths(stray denom, mixed funds, overpay refund, treasury rotation)make test-contracts— 374 integration tests greenTest plan
create_pair_charges_fee_to_treasury_and_gov_can_set_itInsufficientPairCreationFeecreate_pair_fee_bank_send_adversarial_pathsUnexpectedPairCreationFundscreate_pair_refunds_uluna_when_fee_disabledAttack vectors
UpdateConfig/ instantiateBankMsg::Send; noreplyhandlerpaid < feerejected before pair creationOnePairCreationPerBlock+ fee when > 0Indexer
PASS — no
create_pair/ pair-creation fee parser inindexer/; pair indexing does not depend on bank send events.Commands run
Contract review (manual)
Reviewed
execute_create_pairfee handling (contract.rs~L236–267): uluna-only funds, underpay guard, fee to treasury, overpay refund,OnePairCreationPerBlockgate beforeResponse. Cross-checkeddocs/security-model.mdand invariant F2 indocs/contracts-security-audit.md.Sign-off: Factory
BankMsg::Sendpair-creation fee path is sound; no further contract changes required.mentioned in issue #376