Skip to content

Add locked unit reserve for payment hub withdrawals#3792

Closed
Copilot wants to merge 1 commit into
payment_hub_transferfrom
copilot/sub-pr-3791
Closed

Add locked unit reserve for payment hub withdrawals#3792
Copilot wants to merge 1 commit into
payment_hub_transferfrom
copilot/sub-pr-3791

Conversation

Copilot AI commented Nov 21, 2025

Copy link
Copy Markdown
Contributor

Introduced a per-coin locked unit reserve mechanism that allows withdrawals from PaymentHub even when channels are active, provided sufficient unlocked balance remains.

Changes

  • Global configuration: Added PaymentHubConfig with per-coin locked_unit_per_coin table
  • Unlocked balance calculation: withdraw_from_hub now checks unlocked_balance = total_balance - (locked_unit × active_channel_count) instead of blocking all withdrawals
  • Admin API: set_locked_unit<CoinType> configures reserve per coin type with monotonic non-decreasing enforcement
  • Event emission: LockedUnitConfigUpdatedEvent tracks config changes
  • View helpers: get_unlocked_balance_in_hub, get_required_locked_for_owner, get_locked_unit
  • Code cleanup: Removed unnecessary copy operations and redundant wrapper functions

Behavior

Before: Any active channel blocks all withdrawals
After: Withdrawals allowed up to unlocked balance, maintaining locked_unit × active_channels reserve

// User has 1000 coins, 2 active channels, locked_unit = 100
// Required locked: 100 × 2 = 200
// Unlocked balance: 1000 - 200 = 800
// Can withdraw up to 800 coins

Overflow protection relies on Move's built-in abort; governance expected to set reasonable locked_unit values.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel

vercel Bot commented Nov 21, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rooch-portal-v2.1 Ready Ready Preview Comment Nov 21, 2025 4:39am
test-portal Ready Ready Preview Comment Nov 21, 2025 4:39am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
rooch Ignored Ignored Preview Nov 21, 2025 4:39am

Copilot AI changed the title [WIP] Add locked unit reserve for payment hub withdrawals Add locked unit reserve for payment hub withdrawals Nov 21, 2025
Copilot AI requested a review from jolestar November 21, 2025 04:37
@jolestar jolestar closed this Nov 21, 2025
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.

2 participants