Contracts: unify hook commission_amount for pool-only and hybrid swaps #196
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#196
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?
Problem statement
Post-swap hooks receive
AfterSwap.commission_amountreflecting the pool leg only on hybrid txs (invariant L7). Integrators and fee hooks mis-account total fees when a book leg charged commission separately.Evidence / context
docs/contracts-security-audit.md— L7.smartcontracts/contracts/hooks/; backlog #80 / DEX-P2-005.Proposed solution
Define and implement a single commission_total (or extend
commission_amount) that includes pool + book fee components consistent with on-chain treasury transfers. Update hook README and breaking-change note.Acceptance criteria
docs/integrators.md+ hook README document semantics.Priority
P2 (security / integrator correctness)
mentioned in commit
4a6d3618cdImplementation summary (GitLab #196)
Merged to
mainin commitf31fa82.What changed
Breaking change (hook integrators):
AfterSwap.commission_amountnow reports total protocol commission in the ask asset (pool treasury transfer + book taker fees). Previously hybrid swaps sent pool-leg-only commission to hooks (invariant L7).execute_swap: tracksbook_commission_totalfrom orderbook matching; hooks receivepool_commission + book_commission; swap wasm attrs keep Terraport-baseline pool-onlycommission_amountand addbook_commission_amountwhen the book leg runs.HybridSimulation/HybridReverseSimulation:commission_amountis the same total as hooks; new fieldspool_commission_amountandbook_commission_amountexpose leg breakdown (max_spread / #197 uses pool leg only).BookMatchResult/BookSimulateResultstructs carrycommission_total.docs/contracts-security-audit.md,docs/integrators.md,docs/limit-orders.md,docs/terraport.md,smartcontracts/contracts/hooks/README.md.skills/AGENTS_HOOK_COMMISSION.mdfor third-party integrators.Verification checklist
HybridSimulation.commission_amount==pool_commission_amount+book_commission_amountcommission_amount(pool only) +book_commission_amount== hook totalcommission_amountunchanged; nobook_commission_amountattrcargo test -p cl8y-dex-tests hook_commission hybrid_max_spreadpassescommission_amounton swap eventsTests added
limit_order_tests::hybrid_hook_commission_includes_pool_and_booklimit_order_tests::pool_only_hook_commission_unchanged@brouie — please verify on your side when you have a moment. Leaving this issue open until confirmed.
/cc @PlasticDigits
Verification complete (GitLab #196)
Verified on
main@049a979— no additional code changes required; L7 hook commission fix fromf31fa82is correct.Acceptance criteria
HybridSimulation.commission_amount==pool_commission_amount+book_commission_amount(on-chain LCD query on pairterra10y4…with resting bids: 11367 = 6427 + 4940).book_commission_amount=0,commission_amount==pool_commission_amount(LCD +pool_only_hook_commission_unchangedtest).docs/integrators.md,smartcontracts/contracts/hooks/README.md,skills/AGENTS_HOOK_COMMISSION.mddocument total hook commission + Terraport baseline attrs.Verification checklist
AF66A294…: wasm attrscommission_amount=6394(pool) +book_commission_amount=4940= 11334 hook total; transfers to local treasury (test1).book_commission_amountattr (unit test + LCD).pool_commission + book_commissiontoAfterSwap(contract.rs+ unit tests).return_asset(not commission); third-party integrators readingcommission_amountnow get the full total — documented breaking change.cargo test -p cl8y-dex-tests hybrid_hook_commission_includes_pool_and_book pool_only_hook_commission_unchanged hybrid_max_spread— all pass.commission_amountremains pool-leg-only;book_commission_amountextension present on hybrid txs.Infra / UI
Closing as verified.
mentioned in issue #216
mentioned in issue #586
mentioned in issue #710