Skip to content

docs: specify fee calculation at settlement, not close - #49

Merged
thiras merged 2 commits into
mainfrom
docs/specify-fee-on-disputed-closes
Mar 30, 2026
Merged

thiras merged 2 commits into
mainfrom
docs/specify-fee-on-disputed-closes

Conversation

@thiras

@thiras thiras commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Specifies that the protocol fee is calculated at final settlement (after dispute window expires), not at closeChannel time — closes ADR 003: Fee calculation on disputed channel closes is unspecified #20
  • Adds settleChannel(bytes32 channelId) to the IStablePaymentChannel interface and ChannelSettled event
  • Adds claimedNonce field to Channel struct for dispute nonce comparison
  • Updates ADR 004 gas cost table and amortization math for the three-step lifecycle (open + close + settle)
  • Adds ChannelSettled event to ADR 007 watchtower monitoring events with cross-reference to ADR 003

Test plan

  • Verify cross-references render correctly on GitHub (003-payments.md#fee-calculation-on-disputed-closes)
  • Verify mermaid pie chart in ADR 004 renders with updated title
  • Review fund distribution formula: provider = claimedAmount - fee, treasury = fee, client = deposit - claimedAmount
  • Confirm no remaining "at channel close" phrasing in ADR 003/004/007

🤖 Generated with Claude Code

Protocol fee is computed at final settlement (after dispute window expires)
based on the highest valid voucher, not at closeChannel time. Adds
settleChannel to the contract interface, ChannelSettled event, claimedNonce
to Channel struct, and updates gas cost table for the three-step lifecycle.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings March 30, 2026 19:45

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refines the payment channel mechanism by introducing a three-step lifecycle consisting of initiation, a dispute window, and final settlement. Key changes include the addition of a settleChannel function, a claimedNonce field for tracking the latest valid state, and new events for better observability across the system. The review feedback focused on maintaining a high-level architectural perspective in the ADR documentation by abstracting away low-level implementation details and ensuring consistency across the various documents.

Comment thread adr/003-payments.md Resolved
Comment thread adr/003-payments.md Resolved
Comment thread adr/007-watchtower.md Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the ADR documentation to clarify that protocol fees are computed at final settlement (after the dispute window), and documents the resulting 3-step channel lifecycle (close → dispute → settle).

Changes:

  • Clarifies fee timing and fund distribution mechanics in ADR 003, including documenting settleChannel and ChannelSettled.
  • Updates watchtower monitoring events/behavior to include ChannelSettled (ADR 007) with a cross-reference to ADR 003.
  • Updates tokenomics fee wording and the gas/amortization table to include settleChannel (ADR 004).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
adr/003-payments.md Documents settlement-time fee calculation, adds settleChannel/ChannelSettled, and introduces claimedNonce in the channel state spec.
adr/004-tokenomics.md Updates fee allocation wording to “at settlement” and extends the gas/amortization section for the 3-step lifecycle.
adr/007-watchtower.md Adds ChannelSettled to the watchtower event set and explains how watchtowers use it to stop monitoring.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread adr/003-payments.md Resolved
Comment thread adr/007-watchtower.md Resolved
Comment thread adr/007-watchtower.md Resolved
Comment thread adr/003-payments.md Resolved
Comment thread adr/003-payments.md Resolved
- disputeChannel step now explicitly mentions claimedNonce update
- Client→node bullet reflects 3-step close/settle flow
- British spelling consistency (finalised)
- PoC action items include ChannelSettled event

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@thiras
thiras merged commit a0a9022 into main Mar 30, 2026
@thiras
thiras deleted the docs/specify-fee-on-disputed-closes branch March 30, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ADR 003: Fee calculation on disputed channel closes is unspecified

2 participants