Skip to content

feat: implement Soroban pool ownership contract logic#65

Merged
Obiajulu-gif merged 1 commit into
Chainmove:mainfrom
Chucks1093:feat/pool-ownership-logic-issue-11
Jun 23, 2026
Merged

feat: implement Soroban pool ownership contract logic#65
Obiajulu-gif merged 1 commit into
Chainmove:mainfrom
Chucks1093:feat/pool-ownership-logic-issue-11

Conversation

@Chucks1093

Copy link
Copy Markdown
Contributor

Closes #11

What was implemented

Pool units / shares support

  • Added total_units: u64 field to the Pool struct to represent the total number of ownership shares available in the pool (e.g. 100 units = 100 investable shares).
  • create_pool now accepts total_units as a required parameter and validates it is non-zero.

Oversubscription prevention

  • record_investment now checks whether total_invested + amount would exceed target_amount before accepting the investment.
  • Returns ContractError::Oversubscribed (variant 5) if the investment would push the pool past its funding cap.
  • Added ContractError::PoolInactive (variant 6) — record_investment also rejects investments into a closed pool.

Investor share calculation

  • Added get_investor_share(investor, pool_id) -> u64 which returns the investor's ownership stake in basis points (bps): invested * 10_000 / target_amount. A 25% stake returns 2500.

Pool lifecycle: close

  • Added close_pool(owner, pool_id) which requires owner auth and sets pool.active = false, preventing further investment without deleting pool data.

Tests added (test.rs)

All existing tests were updated to pass total_units to create_pool. New tests added:

Test What it verifies
rejects_oversubscription An investment that would exceed target_amount is rejected; exact-remainder investment succeeds
updates_duplicate_investor_position Two investments by the same investor accumulate correctly on both the position and pool totals
calculates_investor_share_in_bps A 2 500 / 10 000 investment returns exactly 2 500 bps
rejects_investment_into_closed_pool After close_pool, record_investment returns PoolInactive

@Obiajulu-gif Obiajulu-gif merged commit 2f59f37 into Chainmove:main Jun 23, 2026
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.

[P1] Implement Soroban pool ownership contract logic

2 participants