Skip to content

feat: implement buy shares service with AMM integration#244

Open
Sundayabel222 wants to merge 1 commit intoNetwalls:mainfrom
Sundayabel222:feature/buy-shares-amm-integration
Open

feat: implement buy shares service with AMM integration#244
Sundayabel222 wants to merge 1 commit intoNetwalls:mainfrom
Sundayabel222:feature/buy-shares-amm-integration

Conversation

@Sundayabel222
Copy link

Close #85

@GoSTEAN Pls review Pr

  • Add trading.service.ts with buyShares() method for acquiring shares
  • Implement slippage protection with configurable min shares parameter (5% default)
  • Create Trade entity records with CONFIRMED status for all buy transactions
  • Add Share entity creation and updates with cost basis tracking
  • Update market totalVolume on each buy transaction atomically
  • Add trading.controller.ts with POST /buy endpoint for HTTP requests
  • Implement trading routes for buy/sell/odds endpoints
  • Integrate with Stellar AMM contract for price execution
  • Use Prisma transactions for data consistency and atomicity
  • Track user USDC balance changes and position updates
  • Add comprehensive error handling (insufficient balance, closed markets, slippage)
  • Add 17 passing integration tests covering all acceptance criteria
  • All tests verified: buy flow, validation, database updates, share positions

Acceptance Criteria Met:
Create trading.service.ts with buyShares() method
Include slippage protection (min shares param)
Record Trade entity in database
Update/create Share entity
Update market volume
Create trading routes and controller
Unit + integration tests (17 tests passing)

- Add trading.service.ts with buyShares() method for acquiring shares
- Implement slippage protection with configurable min shares parameter (5% default)
- Create Trade entity records with CONFIRMED status for all buy transactions
- Add Share entity creation and updates with cost basis tracking
- Update market totalVolume on each buy transaction atomically
- Add trading.controller.ts with POST /buy endpoint for HTTP requests
- Implement trading routes for buy/sell/odds endpoints
- Integrate with Stellar AMM contract for price execution
- Use Prisma transactions for data consistency and atomicity
- Track user USDC balance changes and position updates
- Add comprehensive error handling (insufficient balance, closed markets, slippage)
- Add 17 passing integration tests covering all acceptance criteria
- All tests verified: buy flow, validation, database updates, share positions

Acceptance Criteria Met:
 Create trading.service.ts with buyShares() method
 Include slippage protection (min shares param)
 Record Trade entity in database
 Update/create Share entity
 Update market volume
 Create trading routes and controller
 Unit + integration tests (17 tests passing)
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.

[Backend] Implement Buy Shares service (AMM integration)

1 participant