deploy-local: attach factory pair_creation_fee_uluna on every create_pair #318
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#318
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?
Summary
make deploy-local/scripts/deploy-dex-local.shfails at Phase 4 when creating the first factory pair: the factory rejectscreate_pairbecause noulunais attached for the governance-set pair creation fee introduced in GitLab #276. Local QA, E2E, indexer bootstrap, and agent verification flows that depend on a full deploy are blocked unless operators manually add--amount 100000000ulunaper pair.Current codebase
On-chain (GitLab #276)
100_000_000uluna (100 LUNC) —DEFAULT_PAIR_CREATION_FEE_ULUNAinsmartcontracts/packages/dex-common/src/factory.rs.create_pair(smartcontracts/contracts/factory/src/contract.rs):config.pair_creation_fee_uluna(instantiate default or governanceSetPairCreationFee).info.fundsto include at least that amount of nativeulunaonly (UnexpectedPairCreationFundsif other denoms are attached).config.treasury; refunds overpay to sender.CreatePairper block (OnePairCreationPerBlock).InsufficientPairCreationFee,UnexpectedPairCreationFunds,OnePairCreationPerBlockinsmartcontracts/contracts/factory/src/error.rs.create_pair_charges_fee_to_treasury_and_gov_can_set_itinsmartcontracts/tests/src/lib.rs(no fee → reject; exact fee → treasury credited; gov can update fee).Local deploy script (broken)
scripts/deploy-dex-local.shinstantiates the factory without overridingpair_creation_fee_uluna→ on-chain fee is 100M uluna (serde default).terrad_txhelper (lines ~100–111) does not pass--amounton wasm executes.create_pairloops call the factory without attached uluna:${#PAIR_CONFIGS[@]}main pairs (~20)Pair creation requires 100000000 uluna attached.Related scripts (same gap)
scripts/e2e-seed-wrap-pairs.sh—create_pairviaterrad_tx wasm executewith no--amount(will fail once factory fee is non-zero on the target chain).What still works
pair_creation_fee_uluna: zeroor attach coins in multitest.--amount 100000000ulunasucceeds on LocalTerra.Why this is needed
make deploy-localis the documented path for LocalTerra +frontend-dapp/.env.local+indexer/.env(docs/local-development.md,docs/qa-onboarding.md,AGENTS.md, CIe2ejob).make start-qachainsmake deploy-local→make qa-verify-deploy; deploy abort means QA stack never completes.Constraints and guardrails
pair_creation_fee_ulunafrom factoryQueryMsg::Configat deploy time so script stays correct if governance changes the fee on a long-lived local chain.ulunamay be attached for the fee; do not attach CW20 or other denoms.OnePairCreationPerBlock— existingsleepbetween txs may be sufficient; if batching is added, keep one create per block.test1/terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v) must have enough uluna for ~25 pairs × fee (+ gas); document or assert balance early with a clear error.pair_creation_fee_uluna: "0"in factory instantiate JSON is acceptable only if documented and isolated to local deploy; default recommendation is attach the real fee so local behavior matches mainnet economics.make check-fee-discount-tier-docsand deploy script drift rules unchanged unless this issue explicitly extends them.Relevant files
scripts/deploy-dex-local.sh(terrad_tx, Phase 4 / 4b / 4ccreate_pair)scripts/e2e-seed-wrap-pairs.shscripts/lib/e2e-terrad-tx.sh(if shared wrapper is introduced)smartcontracts/packages/dex-common/src/factory.rssmartcontracts/contracts/factory/src/contract.rs(execute_create_pair)smartcontracts/tests/src/lib.rs(create_pair_charges_fee_to_treasury_and_gov_can_set_it)scripts/qa/start-qa.sh,scripts/qa/verify-deploy.sh,Makefile(deploy-local,qa-verify-deploy)docs/local-development.md,docs/qa-onboarding.md,AGENTS.mdRecommended direction
deploy-dex-local.sh(orscripts/lib/) e.g.factory_create_pair():configonce after instantiate →PAIR_CREATION_FEE_ULUNAvariable.terrad_tx wasm execute "$FACTORY" "$CREATE_MSG" --amount "${PAIR_CREATION_FEE_ULUNA}uluna".create_paircall sites to use the helper.test1uluna balance; fail fast if< (num_pairs_to_create × fee) + gas_buffer.e2e-seed-wrap-pairs.shthe same way (query fee or source from env written by deploy).docs/local-development.md/ QA onboarding that pair creation consumes uluna per pair (treasury on local = test address).create_pair+--amount(or runsscripts/qa/test-deploy-local-pair-fee.shagainst a running localterra) — see test plan.Acceptance criteria
make deploy-local(orbash scripts/deploy-dex-local.sh) completes Phase 4–4c withoutInsufficientPairCreationFeeon a fresh LocalTerra volume.create_pairindeploy-dex-local.shattaches ≥ on-chainpair_creation_fee_uluna(prefer exact amount).e2e-seed-wrap-pairs.shsucceeds on a chain deployed with non-zero pair creation fee.config.treasury, same as test address on local) balance increases byfee × pairs_created(modulo any pre-existing balance).SetPairCreationFeeon a dev chain does not require script edits (re-deploy or re-query).test1uluna balance is insufficient before Phase 4.Test plan — functional paths
make deploy-local.env.local/indexer/.envwritten;make qa-verify-deploypassesPairAlreadyExists— out of scope unless idempotency is required)pair_creation_fee_uluna == 0(if local instantiate override added)create_pairwith no--amountstill works100000000(default)e2e-seed-wrap-pairs.shafter deployTest plan — attack / abuse / edge vectors
create_pairUnexpectedPairCreationFunds; deploy must never send CW20/native other than uluna for fee--amount)InsufficientPairCreationFee; caught by deploy failure or automated grep testcreate_pairin same blockOnePairCreationPerBlock; deploy spacing must remain safeVerification criteria
make start && make wait-healthy && make build-optimized && make deploy-localexit 0 on clean VM.make qa-verify-deploypass after deploy.config→pair_creation_fee_uluna; count pairs in registry; treasury uluna delta ≈fee × count.scripts/e2e-seed-wrap-pairs.sh(with.env.localfrom deploy) exit 0.cargo test -p cl8y-dex-tests create_pair_charges_fee_to_treasury_and_gov_can_set_it.Related
--amount 100000000uluna)marked as related to #276
mentioned in merge request !772
Took this one. The local deploy was dodging the #276 fee by instantiating the factory with pair_creation_fee_uluna=0 — that was my earlier convenience, but it hides the fee path from local/E2E, which is exactly what you flagged here.
Reworked deploy-dex-local.sh to match mainnet economics instead:
e2e-seed-wrap-pairs.sh already had the query+attach pattern, so it lines up. verify-issue-276.sh now guards that the deploy actually attaches the fee, and the docs that claimed "local uses fee 0" are corrected.
Proven on a fresh post-#276 factory:
One thing worth knowing: the currently deployed contracts predate #276 (built before the fee field landed), so the live factory doesn't have the field at all — needs a redeploy to pick up #276. make deploy-local rebuilds optimized artifacts first, so the documented path is fine.
Branch qa/318-315-deploy-fee-gas, commit
f5747ed, MR !772 (bundled with #315). Still want a full fresh-volume make deploy-local run through Phase 4-4c to sign it off end to end — folding that into the next chain refresh. @PlasticDigitsmentioned in issue #315
mentioned in commit
019ded61e2mentioned in issue #325
mentioned in merge request !783
mentioned in commit
9ec5c0db10mentioned in merge request !769
mentioned in issue #320
mentioned in issue #329
mentioned in commit
e924ac1e0fmentioned in merge request !813
mentioned in commit
71016dae1b