Skip to content

feat: secondary market for pool positions and co-funding shares (#1025) - #1030

Merged
sanmipaul merged 2 commits into
astera-hq:mainfrom
financialcrackerjack-max:any/secondary-market-pool-positions
Jul 30, 2026
Merged

feat: secondary market for pool positions and co-funding shares (#1025)#1030
sanmipaul merged 2 commits into
astera-hq:mainfrom
financialcrackerjack-max:any/secondary-market-pool-positions

Conversation

@financialcrackerjack-max

Copy link
Copy Markdown
Contributor

Summary

Closes #1025

Adds an opt-in secondary market so investors can exit deployed positions before invoice repayment, without relying on the low-liquidity withdrawal queue.

Changes

contracts/pool/src/lib.rs

  • New types: Listing, ListingStatus (Open/Filled/Cancelled), ListingKind (CoFunding/SingleFunded)
  • New PoolError variants: ListingNotFound, ListingNotOpen, ListingNotSeller, InsufficientListingBalance, TooManyListings
  • New Symbol storage keys (DataKey is at Soroban 50-variant ceiling): LISTING_DATA, LISTING_IDS_INV, LISTING_IDS_SELLER, LISTING_COUNTER
  • list_position — seller lists a CoFundShare bps slice or a SingleFunded deployed-principal slice; compliance gate + per-invoice cap (50) enforced
  • cancel_listing — seller-only cancellation of open listings
  • buy_listing — atomic claim transfer + price settlement; compliance, KYC, and max_single_investor_bps concentration cap enforced on buyer
  • get_listing, list_listings_for_invoice, list_listings_for_investor — read-only views
  • Events: lst_open, lst_cncl, lst_buy under the existing pool EVT topic

contracts/pool/tests/secondary_market_tests.rs

  • Full lifecycle: list → buy, list → cancel
  • Error paths: zero amount, zero price, exceeds share, non-seller cancel, double-cancel, buy cancelled listing, self-buy, insufficient buyer balance
  • Index queries: list_listings_for_invoice, list_listings_for_investor, get_listing for nonexistent ID

packages/sdk/src/types.ts + packages/sdk/src/clients/pool.ts + sdk/src/client.ts

  • Listing, ListingStatus, ListingKind TypeScript types
  • listPosition, cancelListing, buyListing, getListing, listListingsForInvoice, listListingsForInvestor methods on PoolClient

indexer/src/parser.ts

  • Registers lst_open, lst_cncl, lst_buy event types
  • Actor extraction for all three events

docs/interacting-with-contracts.md

  • Full secondary market flow documentation with CLI examples, SDK usage, event table, and repayment/default-after-transfer behaviour

…ra-hq#1025)

- Add Listing, ListingStatus, ListingKind types to pool contract
- Add PoolError variants: ListingNotFound, ListingNotOpen, ListingNotSeller,
  InsufficientListingBalance, TooManyListings
- Add Symbol storage keys: LISTING_DATA, LISTING_IDS_INV, LISTING_IDS_SELLER,
  LISTING_COUNTER (DataKey is at Soroban 50-variant ceiling)
- Implement list_position: validates CoFundShare/deployed balance, enforces
  compliance gate, per-invoice cap (50), allocates listing ID
- Implement cancel_listing: seller-only, open listings only
- Implement buy_listing: compliance + KYC + concentration-cap checks on buyer,
  atomically transfers CoFundShare bps or deployed principal slice, debits
  buyer available and credits seller available
- Implement get_listing, list_listings_for_invoice, list_listings_for_investor
- Emit lst_open / lst_cncl / lst_buy events under pool EVT topic
- Add secondary_market_tests.rs: list, cancel, buy, index query, error paths
- SDK: add Listing/ListingStatus/ListingKind types; add listPosition,
  cancelListing, buyListing, getListing, listListingsForInvoice,
  listListingsForInvestor to PoolClient
- Indexer: register lst_open/lst_cncl/lst_buy event types; extract actor
- Docs: add interacting-with-contracts.md documenting the full flow
@sanmipaul

Copy link
Copy Markdown
Contributor

Great work @financialcrackerjack-max

@sanmipaul
sanmipaul merged commit 0db0a56 into astera-hq:main Jul 30, 2026
1 of 4 checks 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.

feat: secondary market for pool positions and co-funding shares

2 participants