fix(community-tax): AutoLP pair must be factory-listed with the tax token + skim floor (M-2, M-3) #610
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#610
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?
Parent / related
Audit
INTERNAL_KIMIK3_1787468843M-2 / M-3. Template #592 T592-10. Bind / SKU init #605 (H-1 — AutoLP is paid and never bound; do not re-do bind here). PoC:poc_autolp_manager_can_skim_to_fake_pair. M-2 has no PoC yet.Gated on #605: no factory check or skim floor matters until a token has
cfg.autolpset. Implement against the AutoLP crate now; ship migrate of 11613 when bind exists.Product decision (2026-08-23):
pairmust be factory-listed and have the tax token as one side.Current codebase
community-tax-autolp:UpdateConfig { pair }onlyaddr_validates. No factoryPairlookup. No check thatasset_infoscontainscfg.token.SkimToLpis permissionless (T592-10). Sends half the tax-token balance tocfg.pairwithCw20HookMsg::Swap { max_spread: None, min_return: None, hybrid: pool_only }.UpdateConfigmerges omittedOptionfields (does not wipe). Manager-only.apply_autolp_settingserrors ifcfg.autolpis None. Launchercreate_tokenbuildsAutolpInitthenlet _ = (code_id, autolp_init)— bind is #605.Anyone can sandwich a permissionless no-floor skim. A manager (or stolen manager key) can point
pairat a contract that accepts the hook and keeps the tokens.Why this is needed
AutoLP is sold as “optional skim into a CL8Y pair.” Without a factory+token-side check, skim is an arbitrary Send to a manager-chosen address. Without a floor, permissionless skim is a sandwich. Both waste tax that was supposed to deepen the book.
Constraints / guardrails
SkimToLpstays permissionless and is never called from tokenTransfer/Sendor pairAfterSwap.pairset (instantiate orUpdateConfig) must:factory.Pair { asset_infos }(or equivalent factory query the pair itself reports) for a CL8Y factory pair, andcfg.tokenas one of the twoasset_infos.min_returnand/ormax_spread). Do not leave bothNoneon the swap hook.SKIMMINGstays. Do not call skim from the pair hook.Relevant files
smartcontracts/contracts/community-tax-autolp/src/contract.rs(execute_update,execute_skim, reply provide)smartcontracts/contracts/community-tax-autolp/src/msg.rssmartcontracts/contracts/community-tax-token/src/invoice.rs(apply_autolp_settings)smartcontracts/contracts/community-token-launcher/src/contract.rs(when #605 instantiates AutoLP)smartcontracts/contracts/community-token-launcher/tests/audit_poc.rsskills/AGENTS_COMMUNITY_TAX_CW20.md(T592-10)Factory / pair types:
dex_common::factory::PairResponse,PairInfo.asset_infos.Recommended direction
factory(from token/launcher config) if not already present — needed for the lookup. If the crate has no factory field today, add it on instantiate /UpdateConfig(manager cannot point factory at a fake registry without also passing a real Pair query; prefer immutable factory from launcher).Pairfor the two asset infos (token + quote). Quote may be CW20 or native; one side must becfg.token. Store only the returnedcontract_addr.min_returnfrom a manager-set basis (new config field, default conservative) ormax_spreadwith a documented cap (e.g. 50–200 bps). Permissionless caller cannot override the floor downward.poc_autolp_manager_can_skim_to_fake_pair. Add a skim-below-floor revert test.Acceptance criteria
UpdateConfig { pair: fake }(mock that is not factory-listed, or listed but neither asset is the tax token) reverts.UpdateConfig { pair }of a factory pair whose assets are[tax_token, quote]succeeds.Nonemin_returnand/ormax_spread.UpdateConfigfields still merge (existing sanity).poc_autolp_manager_can_skim_to_fake_pairfails or is inverted.Test plan — all paths
pair = None— skim skips / errors as today until pair set.SKIMMINGcleared.UpdateConfig→ Unauthorized.SkimToLpstill allowed for a valid pair.Test plan — attack / abuse
SkimToLpagain —SKIMMING/ lock still holds; do not unlock before messages are queued in a way that allows a second skim in the same tx against a malicious pair (document residual if reply unlocks before provide).Transfer(T592-10).Verification
cargo test -p cl8y-community-tax-autolp+ inverted audit PoC.pair.marked as related to #592
marked as related to #605
mentioned in merge request !1122
mentioned in issue #605
mentioned in issue #611
mentioned in merge request !1130
Implemented on
issue/610-autolp-factory-pair-skim-floor— MR !1130.Completed:
UpdateConfig { pair: fake }/ wrong-token listed pair reverts[tax_token, quote]succeeds (asset 0 or 1)max_spread(default 100 bps, cap 200); optionalmin_returnSKIMMINGrolls backUpdateConfigfields still mergepoc_autolp_manager_can_skim_to_fake_pairinvertedskills/AGENTS_COMMUNITY_TAX_AUTOLP.md; Manage Token copyNot in this MR:
mentioned in commit
77d57d20eamentioned in commit
574793b4efmentioned in issue #616
marked as related to #616
Merge sanity (!1130 landed on
main; CI not waited).Conflicts with !1127 were docs/Makefile only (kept M610 + option-2 wording + #613 verify target).
Automated:
make verify-issue-6108/8 (AutoLP crate, invertedpoc_autolp_manager_can_skim_to_fake_pair, launcher factory pin, Manage Token / SKU copy).Acceptance leftover (ops, not reopen)
Post-merge store/skim: #616. Bind/store remains on #611.
mentioned in issue #620
marked as related to #620
marked as related to #623
mentioned in issue #624
mentioned in issue #633
mentioned in merge request !1137
mentioned in issue #635
marked as related to #635