Skip to content

Add Pool Close Function After Disbursement (#16)#48

Merged
martinvibes merged 1 commit intoWeb3Novalabs:mainfrom
vestor-dev:impl-close-pool-func
Jan 28, 2026
Merged

Add Pool Close Function After Disbursement (#16)#48
martinvibes merged 1 commit intoWeb3Novalabs:mainfrom
vestor-dev:impl-close-pool-func

Conversation

@vestor-dev
Copy link
Contributor

Add Pool Close Function After Disbursement (#16)

Summary

Implements an admin/creator function to mark pools as closed after full disbursement or cancellation, with optional storage cleanup for resource efficiency on Stellar.

closes #16

Changes

Core Implementation

  • New Pool State: Added Closed state to PoolState enum
  • New Functions:
    • close_pool(pool_id, caller): Marks a pool as closed (admin-only)
    • is_closed(pool_id): View function to check if a pool is closed
  • New Event: pool_closed event emitted when a pool is closed
  • New Errors:
    • PoolAlreadyClosed: Prevents closing an already closed pool
    • PoolNotDisbursedOrRefunded: Ensures pools can only be closed after disbursement or cancellation

Business Logic

  • Pools can only be closed when in Disbursed or Cancelled state
  • Only admin can close pools (authorization required)
  • Closing is optional and non-forced - no automatic cleanup
  • Once closed, pools cannot be reopened

Testing

Added comprehensive test suite (close_pool_test.rs) with 16 tests covering:

  • ✅ Successful closure after disbursement
  • ✅ Successful closure after cancellation
  • ✅ Prevention of double-closing
  • ✅ State transition validation
  • ✅ Authorization checks
  • ✅ Error handling for invalid states
  • ✅ View function behavior across all states
  • ✅ Event emission verification
  • ✅ Multiple pool scenarios
Screenshot 2026-01-28 at 4 12 22 pm

…ll disbursement or cancellation, with optional storage cleanup for resource efficiency on Stellar.
@martinvibes martinvibes self-requested a review January 28, 2026 15:13
Copy link
Contributor

@martinvibes martinvibes left a comment

Choose a reason for hiding this comment

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

Nice Implementation @vestor-dev
LGTM!

@martinvibes martinvibes merged commit 91586ba into Web3Novalabs:main Jan 28, 2026
1 check passed
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.

Add pool close function after disbursement

2 participants