feat: implement Soroban pool ownership contract logic#65
Merged
Obiajulu-gif merged 1 commit intoJun 23, 2026
Merged
Conversation
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11
What was implemented
Pool units / shares support
total_units: u64field to thePoolstruct to represent the total number of ownership shares available in the pool (e.g. 100 units = 100 investable shares).create_poolnow acceptstotal_unitsas a required parameter and validates it is non-zero.Oversubscription prevention
record_investmentnow checks whethertotal_invested + amountwould exceedtarget_amountbefore accepting the investment.ContractError::Oversubscribed(variant 5) if the investment would push the pool past its funding cap.ContractError::PoolInactive(variant 6) —record_investmentalso rejects investments into a closed pool.Investor share calculation
get_investor_share(investor, pool_id) -> u64which returns the investor's ownership stake in basis points (bps):invested * 10_000 / target_amount. A 25% stake returns2500.Pool lifecycle: close
close_pool(owner, pool_id)which requires owner auth and setspool.active = false, preventing further investment without deleting pool data.Tests added (
test.rs)All existing tests were updated to pass
total_unitstocreate_pool. New tests added:rejects_oversubscriptiontarget_amountis rejected; exact-remainder investment succeedsupdates_duplicate_investor_positioncalculates_investor_share_in_bpsrejects_investment_into_closed_poolclose_pool,record_investmentreturnsPoolInactive